diff options
author | Junio C Hamano <gitster@pobox.com> | 2010-08-18 23:14:38 +0400 |
---|---|---|
committer | Junio C Hamano <gitster@pobox.com> | 2010-08-18 23:14:38 +0400 |
commit | c7e375de4228cdb86e2582e2eda7fa3a6f352fc2 (patch) | |
tree | 31cb1ae05dd6621c740080e6195d16a78e7a215f /builtin/fetch.c | |
parent | d425aa5cac0b4124c6aa5520295e0fd5ed81780b (diff) | |
parent | 8a57c6e9437eeebf849f0def03389078a510312e (diff) |
Merge branch 'ar/string-list-foreach'
* ar/string-list-foreach:
Convert the users of for_each_string_list to for_each_string_list_item macro
Add a for_each_string_list_item macro
Diffstat (limited to 'builtin/fetch.c')
-rw-r--r-- | builtin/fetch.c | 42 |
1 files changed, 13 insertions, 29 deletions
diff --git a/builtin/fetch.c b/builtin/fetch.c index 1b67f5fda5..680a8a97bd 100644 --- a/builtin/fetch.c +++ b/builtin/fetch.c @@ -544,40 +544,14 @@ static int will_fetch(struct ref **head, const unsigned char *sha1) return 0; } -struct tag_data { - struct ref **head; - struct ref ***tail; -}; - -static int add_to_tail(struct string_list_item *item, void *cb_data) -{ - struct tag_data *data = (struct tag_data *)cb_data; - struct ref *rm = NULL; - - /* We have already decided to ignore this item */ - if (!item->util) - return 0; - - rm = alloc_ref(item->string); - rm->peer_ref = alloc_ref(item->string); - hashcpy(rm->old_sha1, item->util); - - **data->tail = rm; - *data->tail = &rm->next; - - return 0; -} - static void find_non_local_tags(struct transport *transport, struct ref **head, struct ref ***tail) { struct string_list existing_refs = { NULL, 0, 0, 0 }; struct string_list remote_refs = { NULL, 0, 0, 0 }; - struct tag_data data; const struct ref *ref; struct string_list_item *item = NULL; - data.head = head; data.tail = tail; for_each_ref(add_existing, &existing_refs); for (ref = transport_get_remote_refs(transport); ref; ref = ref->next) { @@ -631,10 +605,20 @@ static void find_non_local_tags(struct transport *transport, item->util = NULL; /* - * For all the tags in the remote_refs string list, call - * add_to_tail to add them to the list of refs to be fetched + * For all the tags in the remote_refs string list, + * add them to the list of refs to be fetched */ - for_each_string_list(&remote_refs, add_to_tail, &data); + for_each_string_list_item(item, &remote_refs) { + /* Unless we have already decided to ignore this item... */ + if (item->util) + { + struct ref *rm = alloc_ref(item->string); + rm->peer_ref = alloc_ref(item->string); + hashcpy(rm->old_sha1, item->util); + **tail = rm; + *tail = &rm->next; + } + } string_list_clear(&remote_refs, 0); } |