summaryrefslogtreecommitdiff
path: root/archive.c
diff options
context:
space:
mode:
Diffstat (limited to 'archive.c')
-rw-r--r--archive.c21
1 files changed, 15 insertions, 6 deletions
diff --git a/archive.c b/archive.c
index 5f0a3fc6d2..a348480b26 100644
--- a/archive.c
+++ b/archive.c
@@ -260,14 +260,23 @@ static void parse_treeish_arg(const char **argv,
/* Remotes are only allowed to fetch actual refs */
if (remote) {
char *ref = NULL;
- if (!dwim_ref(name, strlen(name), sha1, &ref))
- die("no such ref: %s", name);
+ 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);
free(ref);
}
- else {
- if (get_sha1(name, sha1))
- die("Not a valid object name");
- }
+
+ if (get_sha1(name, sha1))
+ die("Not a valid object name");
commit = lookup_commit_reference_gently(sha1, 1);
if (commit) {