summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--refs.c6
1 files changed, 5 insertions, 1 deletions
diff --git a/refs.c b/refs.c
index d17931a8bc..f8ad1d608c 100644
--- a/refs.c
+++ b/refs.c
@@ -630,7 +630,9 @@ struct ref_entry_cb {
static int do_one_ref(struct ref_entry *entry, void *cb_data)
{
struct ref_entry_cb *data = cb_data;
+ struct ref_entry *old_current_ref;
int retval;
+
if (prefixcmp(entry->name, data->base))
return 0;
@@ -638,10 +640,12 @@ static int do_one_ref(struct ref_entry *entry, void *cb_data)
!ref_resolves_to_object(entry))
return 0;
+ /* Store the old value, in case this is a recursive call: */
+ old_current_ref = current_ref;
current_ref = entry;
retval = data->fn(entry->name + data->trim, entry->u.value.sha1,
entry->flag, data->cb_data);
- current_ref = NULL;
+ current_ref = old_current_ref;
return retval;
}