{"thread":{"id":"13162","subject":"[PATCH 5/8] Have a constant extern refspec for \"--tags\"","startedAt":"2008-04-17T23:32:35Z","lastAt":"2008-04-17T23:32:35Z","messageCount":1,"participants":["Daniel Barkalow"],"isPatch":true,"patchVersion":1,"patchTotal":8},"messages":[{"id":"74694","messageId":"alpine.LNX.1.00.0804171931590.19665@iabervon.org","threadId":"13162","inReplyTo":null,"subject":"[PATCH 5/8] Have a constant extern refspec for \"--tags\"","fromName":"Daniel Barkalow","fromEmail":"barkalow@iabervon.org","sentAt":"2008-04-17T23:32:35Z","receivedAt":"2008-04-17T23:32:35Z","isPatch":true,"sender":{"key":"barkalow@iabervon.org","avatar":"https://avatars.githubusercontent.com/u/55364219?v=4"},"body":"The refspec refs/tags/*:refs/tags/* is sufficiently common and generic\nto merit having a constant instead of generating it as needed.\n\nSigned-off-by: Daniel Barkalow <barkalow@iabervon.org>\n---\n builtin-fetch.c |   10 ++--------\n remote.c        |    9 +++++++++\n remote.h        |    2 ++\n 3 files changed, 13 insertions(+), 8 deletions(-)\n\ndiff --git a/builtin-fetch.c b/builtin-fetch.c\nindex 139a6b1..e010fef 100644\n--- a/builtin-fetch.c\n+++ b/builtin-fetch.c\n@@ -127,14 +127,8 @@ static struct ref *get_ref_map(struct transport *transport,\n \t\t/* Merge everything on the command line, but not --tags */\n \t\tfor (rm = ref_map; rm; rm = rm->next)\n \t\t\trm->merge = 1;\n-\t\tif (tags == TAGS_SET) {\n-\t\t\tstruct refspec refspec;\n-\t\t\trefspec.src = \"refs/tags/\";\n-\t\t\trefspec.dst = \"refs/tags/\";\n-\t\t\trefspec.pattern = 1;\n-\t\t\trefspec.force = 0;\n-\t\t\tget_fetch_map(remote_refs, &refspec, &tail, 0);\n-\t\t}\n+\t\tif (tags == TAGS_SET)\n+\t\t\tget_fetch_map(remote_refs, tag_refspec, &tail, 0);\n \t} else {\n \t\t/* Use the defaults */\n \t\tstruct remote *remote = transport->remote;\ndiff --git a/remote.c b/remote.c\nindex 08af7f9..5053b5f 100644\n--- a/remote.c\n+++ b/remote.c\n@@ -2,6 +2,15 @@\n #include \"remote.h\"\n #include \"refs.h\"\n \n+static struct refspec s_tag_refspec = {\n+\t0,\n+\t1,\n+\t\"refs/tags/\",\n+\t\"refs/tags/\"\n+};\n+\n+const struct refspec *tag_refspec = &s_tag_refspec;\n+\n struct counted_string {\n \tsize_t len;\n \tconst char *s;\ndiff --git a/remote.h b/remote.h\nindex 7e9ae79..d9974fa 100644\n--- a/remote.h\n+++ b/remote.h\n@@ -51,6 +51,8 @@ struct refspec {\n \tchar *dst;\n };\n \n+extern const struct refspec *tag_refspec;\n+\n struct ref *alloc_ref(unsigned namelen);\n \n struct ref *copy_ref_list(const struct ref *ref);\n-- \n1.5.4.3.610.gea6cd\n"}]}