path: root/walker.c
diff options
authorDaniel Barkalow <>2008-04-26 19:53:09 (GMT)
committerJunio C Hamano <>2008-04-27 00:36:17 (GMT)
commitc13b2633f49e3e61b37973204793a4d9ef981175 (patch)
tree54f173438e506190b6bbc02f574ec0ab6b8339d7 /walker.c
parent36c79d2bf893b9957688a6c8c13cc0bf0589e596 (diff)
Make walker.fetch_ref() take a struct ref.
This simplifies a few things, makes a few things slightly more complicated, but, more importantly, allows that, when struct ref can represent a symref, http_fetch_ref() can return one. Incidentally makes the string that http_fetch_ref() gets include "refs/" (if appropriate), because that's how the name field of struct ref works. As far as I can tell, the usage in walker:interpret_target() wouldn't have worked previously, if it ever would have been used, which it wouldn't (since the fetch process uses the hash instead of the name of the ref there). Signed-off-by: Daniel Barkalow <> Signed-off-by: Junio C Hamano <>
Diffstat (limited to 'walker.c')
1 files changed, 6 insertions, 1 deletions
diff --git a/walker.c b/walker.c
index c10eca8..fa96a7c 100644
--- a/walker.c
+++ b/walker.c
@@ -190,9 +190,14 @@ static int interpret_target(struct walker *walker, char *target, unsigned char *
if (!get_sha1_hex(target, sha1))
return 0;
if (!check_ref_format(target)) {
- if (!walker->fetch_ref(walker, target, sha1)) {
+ struct ref *ref = alloc_ref(strlen(target));
+ strcpy(ref->name, target);
+ if (!walker->fetch_ref(walker, ref)) {
+ hashcpy(sha1, ref->old_sha1);
+ free(ref);
return 0;
+ free(ref);
return -1;