From 7748941eaafb44dc1d9fb331fd5e0085a33de8f4 Mon Sep 17 00:00:00 2001 From: Michael Haggerty Date: Wed, 19 Oct 2011 23:44:46 +0200 Subject: [PATCH] do_for_each_ref(): correctly terminate while processesing extra_refs If the user-supplied function returns a nonzero value while processing extra_refs, terminate without processing the rest of the list. This probably has no practical importance, but makes the handling of extra_refs a little bit more consistent with the handling of other refs. Signed-off-by: Michael Haggerty Signed-off-by: Junio C Hamano --- refs.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/refs.c b/refs.c index ae9099300a..7aef76c717 100644 --- a/refs.c +++ b/refs.c @@ -706,8 +706,11 @@ static int do_for_each_ref(const char *submodule, const char *base, each_ref_fn struct ref_array *extra = &extra_refs; - for (i = 0; i < extra->nr; i++) + for (i = 0; i < extra->nr; i++) { retval = do_one_ref(base, fn, trim, flags, cb_data, extra->refs[i]); + if (retval) + goto end_each; + } while (p < packed->nr && l < loose->nr) { struct ref_entry *entry;