diff options
author | Michael Haggerty <mhagger@alum.mit.edu> | 2012-09-09 08:19:43 +0200 |
---|---|---|
committer | Junio C Hamano <gitster@pobox.com> | 2012-09-12 11:46:31 -0700 |
commit | 4ba159996f6c1b0d6dd0a2a8bd9d6f5b342a4aa5 (patch) | |
tree | f358d131bb86e019d442b92cc1ce683b93461b44 /builtin | |
parent | 4c58f13ba67f9dbe67a351de61703a2db20712cc (diff) | |
download | git-4ba159996f6c1b0d6dd0a2a8bd9d6f5b342a4aa5.tar.gz git-4ba159996f6c1b0d6dd0a2a8bd9d6f5b342a4aa5.tar.xz |
filter_refs(): delete matched refs from sought list
Remove any references that are available from the remote from the
sought list (rather than overwriting their names with NUL characters,
as previously). Mark matching entries by writing a non-NULL pointer
to string_list_item::util during the iteration, then use
filter_string_list() later to filter out the entries that have been
marked.
Document this aspect of fetch_pack() in a comment in the header file.
(More documentation is obviously still needed.)
Signed-off-by: Michael Haggerty <mhagger@alum.mit.edu>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'builtin')
-rw-r--r-- | builtin/fetch-pack.c | 23 |
1 files changed, 15 insertions, 8 deletions
diff --git a/builtin/fetch-pack.c b/builtin/fetch-pack.c index 6cd734a9c..12ba009c1 100644 --- a/builtin/fetch-pack.c +++ b/builtin/fetch-pack.c @@ -525,6 +525,16 @@ static void mark_recent_complete_commits(unsigned long cutoff) } } +static int non_matching_ref(struct string_list_item *item, void *unused) +{ + if (item->util) { + item->util = NULL; + return 0; + } + else + return 1; +} + static void filter_refs(struct ref **refs, struct string_list *sought) { struct ref **return_refs; @@ -566,7 +576,7 @@ static void filter_refs(struct ref **refs, struct string_list *sought) break; else if (cmp == 0) { /* definitely have it */ return_refs[sought_pos] = ref; - sought->items[sought_pos++].string[0] = '\0'; + sought->items[sought_pos++].util = "matched"; break; } else /* might have it; keep looking */ @@ -590,6 +600,7 @@ static void filter_refs(struct ref **refs, struct string_list *sought) } if (return_refs != fastarray) free(return_refs); + filter_string_list(sought, 0, non_matching_ref, NULL); } *refs = newlist; } @@ -1040,13 +1051,9 @@ int cmd_fetch_pack(int argc, const char **argv, const char *prefix) * Otherwise, 'git fetch remote no-such-ref' would * silently succeed without issuing an error. */ - for (i = 0; i < sought.nr; i++) { - char *s = sought.items[i].string; - if (s && s[0]) { - error("no such remote ref %s", s); - ret = 1; - } - } + for (i = 0; i < sought.nr; i++) + error("no such remote ref %s", sought.items[i].string); + ret = 1; } while (ref) { printf("%s %s\n", |