summaryrefslogtreecommitdiff
path: root/refs.c
diff options
context:
space:
mode:
authorMichael Haggerty <mhagger@alum.mit.edu>2012-04-10 05:30:14 (GMT)
committerJunio C Hamano <gitster@pobox.com>2012-04-10 22:51:52 (GMT)
commit429213e47039e6c60dd7ffcf4b32bf5bb3515690 (patch)
tree0c595fc05ffcc1de050e301b4794ef068405756b /refs.c
parentbc5fd6d3c29f1a734ebd202573b39c1f66c41744 (diff)
downloadgit-429213e47039e6c60dd7ffcf4b32bf5bb3515690.zip
git-429213e47039e6c60dd7ffcf4b32bf5bb3515690.tar.gz
git-429213e47039e6c60dd7ffcf4b32bf5bb3515690.tar.bz2
refs: manage current_ref within do_one_ref()
Set and clear current_ref within do_one_ref() instead of setting it here and leaving it to somebody else to clear it. Signed-off-by: Michael Haggerty <mhagger@alum.mit.edu> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'refs.c')
-rw-r--r--refs.c13
1 files changed, 7 insertions, 6 deletions
diff --git a/refs.c b/refs.c
index a8f28bd..86e05db 100644
--- a/refs.c
+++ b/refs.c
@@ -250,6 +250,7 @@ static struct ref_entry *current_ref;
static int do_one_ref(const char *base, each_ref_fn fn, int trim,
int flags, void *cb_data, struct ref_entry *entry)
{
+ int retval;
if (prefixcmp(entry->name, base))
return 0;
@@ -262,7 +263,9 @@ static int do_one_ref(const char *base, each_ref_fn fn, int trim,
}
}
current_ref = entry;
- return fn(entry->name + trim, entry->sha1, entry->flag, cb_data);
+ retval = fn(entry->name + trim, entry->sha1, entry->flag, cb_data);
+ current_ref = NULL;
+ return retval;
}
/*
@@ -872,7 +875,7 @@ static int do_for_each_ref(const char *submodule, const char *base, each_ref_fn
}
retval = do_one_ref(base, fn, trim, flags, cb_data, entry);
if (retval)
- goto end_each;
+ return retval;
}
if (l < loose->nr) {
@@ -883,12 +886,10 @@ static int do_for_each_ref(const char *submodule, const char *base, each_ref_fn
for (; p < packed->nr; p++) {
retval = do_one_ref(base, fn, trim, flags, cb_data, packed->refs[p]);
if (retval)
- goto end_each;
+ return retval;
}
-end_each:
- current_ref = NULL;
- return retval;
+ return 0;
}
static int do_head_ref(const char *submodule, each_ref_fn fn, void *cb_data)