{"thread":{"id":"12357","subject":"[PATCH 2/4] Allow builtin-fetch's find_non_local_tags to append onto a list","startedAt":"2008-02-28T08:42:34Z","lastAt":"2008-02-28T08:42:34Z","messageCount":1,"participants":["Shawn O. Pearce"],"isPatch":true,"patchVersion":1,"patchTotal":4},"messages":[{"id":"70221","messageId":"20080228084234.GB16870@spearce.org","threadId":"12357","inReplyTo":null,"subject":"[PATCH 2/4] Allow builtin-fetch's find_non_local_tags to append onto a list","fromName":"Shawn O. Pearce","fromEmail":"spearce@spearce.org","sentAt":"2008-02-28T08:42:34Z","receivedAt":"2008-02-28T08:42:34Z","isPatch":true,"sender":{"key":"spearce@spearce.org","avatar":"https://avatars.githubusercontent.com/u/34844?v=4"},"body":"By allowing the function to append onto the end of an existing list\nwe can do more interesting things, like join the list of tags we\nwant to fetch into the first fetch, rather than the second.\n\nSigned-off-by: Shawn O. Pearce <spearce@spearce.org>\n---\n builtin-fetch.c |   16 ++++++++--------\n 1 files changed, 8 insertions(+), 8 deletions(-)\n\ndiff --git a/builtin-fetch.c b/builtin-fetch.c\nindex f8b9542..834fbc6 100644\n--- a/builtin-fetch.c\n+++ b/builtin-fetch.c\n@@ -452,7 +452,9 @@ static int add_existing(const char *refname, const unsigned char *sha1,\n \treturn 0;\n }\n \n-static struct ref *find_non_local_tags(struct transport *transport)\n+static void find_non_local_tags(struct transport *transport,\n+\t\t\tstruct ref **head,\n+\t\t\tstruct ref ***tail)\n {\n \tstatic struct path_list existing_refs = { NULL, 0, 0, 0 };\n \tstruct path_list new_refs = { NULL, 0, 0, 1 };\n@@ -461,8 +463,6 @@ static struct ref *find_non_local_tags(struct transport *transport)\n \tconst unsigned char *ref_sha1;\n \tconst struct ref *tag_ref;\n \tstruct ref *rm = NULL;\n-\tstruct ref *ref_map = NULL;\n-\tstruct ref **tail = &ref_map;\n \tconst struct ref *ref;\n \n \tfor_each_ref(add_existing, &existing_refs);\n@@ -497,13 +497,11 @@ static struct ref *find_non_local_tags(struct transport *transport)\n \t\t\tstrcpy(rm->peer_ref->name, ref_name);\n \t\t\thashcpy(rm->old_sha1, ref_sha1);\n \n-\t\t\t*tail = rm;\n-\t\t\ttail = &rm->next;\n+\t\t\t**tail = rm;\n+\t\t\t*tail = &rm->next;\n \t\t}\n \t\tfree(ref_name);\n \t}\n-\n-\treturn ref_map;\n }\n \n static int do_fetch(struct transport *transport,\n@@ -546,7 +544,9 @@ static int do_fetch(struct transport *transport,\n \t/* if neither --no-tags nor --tags was specified, do automated tag\n \t * following ... */\n \tif (tags == TAGS_DEFAULT && autotags) {\n-\t\tref_map = find_non_local_tags(transport);\n+\t\tstruct ref **tail = &ref_map;\n+\t\tref_map = NULL;\n+\t\tfind_non_local_tags(transport, &ref_map, &tail);\n \t\tif (ref_map) {\n \t\t\ttransport_set_option(transport, TRANS_OPT_DEPTH, \"0\");\n \t\t\tfetch_refs(transport, ref_map);\n-- \n1.5.4.3.393.g5540\n"}]}