archive: re-allow HEAD:Documentation on a remote invocation
The tightening done in (ee27ca4a: 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 <cmn@elego.de> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Carlos Martín Nieto committed
Jan 11, 2012 at 13:12 UTC
0f544ee897ac2cc760f29d3568cc4295ca69fd1f
1 file changed
+15
-6
archive.c
+15
-6
@@ -260,14 +260,23 @@ static void parse_treeish_arg(const char **argv,
260
/* Remotes are only allowed to fetch actual refs */
261
if (remote) {
262
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);
275
free(ref);
276
}
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");
280
281
commit = lookup_commit_reference_gently(sha1, 1);
282
if (commit) {