Merge branch 'rr/doc-commit' into maint
[gitweb.git] / archive.c
index cd083eaf9aa2f1ae4cfc57d90fb11b8f808fbfe7..a4844330fb4da325aa364640dc80f052dc7b7ad7 100644 (file)
--- a/archive.c
+++ b/archive.c
@@ -254,18 +254,11 @@ static void parse_treeish_arg(const char **argv,
        /* Remotes are only allowed to fetch actual refs */
        if (remote) {
                char *ref = NULL;
-               const char *refname, *colon = NULL;
-
-               colon = strchr(name, ':');
-               if (colon)
-                       refname = xstrndup(name, colon - name);
-               else
-                       refname = name;
-
-               if (!dwim_ref(refname, strlen(refname), sha1, &ref))
-                       die("no such ref: %s", refname);
-               if (refname != name)
-                       free((void *)refname);
+               const char *colon = strchr(name, ':');
+               int refnamelen = colon ? colon - name : strlen(name);
+
+               if (!dwim_ref(name, refnamelen, sha1, &ref))
+                       die("no such ref: %.*s", refnamelen, name);
                free(ref);
        }