filter_refs(): do not check the same sought_pos twice
authorMichael Haggerty <mhagger@alum.mit.edu>
Sun, 9 Sep 2012 06:19:41 +0000 (08:19 +0200)
committerJunio C Hamano <gitster@pobox.com>
Wed, 12 Sep 2012 18:46:31 +0000 (11:46 -0700)
Once a match has been found at sought_pos, the entry is zeroed and no
future attempts will match that entry.  So increment sought_pos to
avoid checking against the zeroed-out entry during the next iteration.

Signed-off-by: Michael Haggerty <mhagger@alum.mit.edu>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
builtin/fetch-pack.c

index df81995eab3b6e289cff3ebbca64fb493a62dcb9..63d455ffef94a9be7b30ba86d4c4c1b7be60508e 100644 (file)
@@ -565,8 +565,8 @@ static void filter_refs(struct ref **refs, struct string_list *sought)
                                if (cmp < 0) /* definitely do not have it */
                                        break;
                                else if (cmp == 0) { /* definitely have it */
-                                       sought->items[sought_pos].string[0] = '\0';
                                        return_refs[sought_pos] = ref;
+                                       sought->items[sought_pos++].string[0] = '\0';
                                        break;
                                }
                                else /* might have it; keep looking */