Skip to content

Commit 0f544ee

Browse files
carlosmngitster
authored andcommitted
archive: re-allow HEAD:Documentation on a remote invocation
The tightening done in (ee27ca4: archive: don't let remote clients get unreachable commits, 2011-11-17) went too far and disallowed HEAD:Documentation as it would try to find "HEAD:Documentation" as a ref. Only DWIM the "HEAD" part to see if it exists as a ref. Once we're sure that we've been given a valid ref, we follow the normal code path. This still disallows attempts to access commits which are not branch tips. Signed-off-by: Carlos Martín Nieto <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 7b51c33 commit 0f544ee

File tree

1 file changed

+15
-6
lines changed

1 file changed

+15
-6
lines changed

archive.c

Lines changed: 15 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -260,14 +260,23 @@ static void parse_treeish_arg(const char **argv,
260260
/* Remotes are only allowed to fetch actual refs */
261261
if (remote) {
262262
char *ref = NULL;
263-
if (!dwim_ref(name, strlen(name), sha1, &ref))
264-
die("no such ref: %s", name);
263+
const char *refname, *colon = NULL;
264+
265+
colon = strchr(name, ':');
266+
if (colon)
267+
refname = xstrndup(name, colon - name);
268+
else
269+
refname = name;
270+
271+
if (!dwim_ref(refname, strlen(refname), sha1, &ref))
272+
die("no such ref: %s", refname);
273+
if (refname != name)
274+
free((void *)refname);
265275
free(ref);
266276
}
267-
else {
268-
if (get_sha1(name, sha1))
269-
die("Not a valid object name");
270-
}
277+
278+
if (get_sha1(name, sha1))
279+
die("Not a valid object name");
271280

272281
commit = lookup_commit_reference_gently(sha1, 1);
273282
if (commit) {

0 commit comments

Comments
 (0)