{"thread":{"id":"44455","subject":"[PATCH] fetch: do not redundantly calculate tag refmap","startedAt":"2016-11-11T00:13:45Z","lastAt":"2016-11-11T02:10:05Z","messageCount":2,"participants":["Jonathan Tan","Jeff King"],"isPatch":true,"patchVersion":1,"patchTotal":null},"messages":[{"id":"305745","messageId":"1478823208-10647-1-git-send-email-jonathantanmy@google.com","threadId":"44455","inReplyTo":null,"subject":"[PATCH] fetch: do not redundantly calculate tag refmap","fromName":"Jonathan Tan","fromEmail":"jonathantanmy@google.com","sentAt":"2016-11-11T00:13:28Z","receivedAt":"2016-11-11T00:13:45Z","isPatch":true,"sender":{"key":"jonathantanmy@fastmail.com","avatar":null},"body":"builtin/fetch.c redundantly calculates refmaps for tags twice. Remove\nthe first calculation.\n\nThis is only a code simplification and slight performance improvement -\nthe result is unchanged, as the redundant refmaps are subsequently\nremoved by the invocation to \"ref_remove_duplicates\" anyway.\n\nThis was introduced in commit c5a84e9 (\"fetch --tags: fetch tags *in\naddition to* other stuff\", 2013-10-29) when modifying the effect of the\n--tags parameter to \"git fetch\". The refmap-for-tag calculation was\ncopied instead of moved.\n\nSigned-off-by: Jonathan Tan <jonathantanmy@google.com>\n---\n\n(I noticed this when working on something in this file.)\n\n builtin/fetch.c | 3 ---\n 1 file changed, 3 deletions(-)\n\ndiff --git a/builtin/fetch.c b/builtin/fetch.c\nindex b6a5597..1d77e58 100644\n--- a/builtin/fetch.c\n+++ b/builtin/fetch.c\n@@ -359,9 +359,6 @@ static struct ref *get_ref_map(struct transport *transport,\n \n \t\tfor (i = 0; i < fetch_refspec_nr; i++)\n \t\t\tget_fetch_map(ref_map, &fetch_refspec[i], &oref_tail, 1);\n-\n-\t\tif (tags == TAGS_SET)\n-\t\t\tget_fetch_map(remote_refs, tag_refspec, &tail, 0);\n \t} else if (refmap_array) {\n \t\tdie(\"--refmap option is only meaningful with command-line refspec(s).\");\n \t} else {\n-- \n2.8.0.rc3.226.g39d4020\n\n"},{"id":"305747","messageId":"20161111020958.ozzbwrvmo5fdf3jj@sigill.intra.peff.net","threadId":"44455","inReplyTo":"1478823208-10647-1-git-send-email-jonathantanmy@google.com","subject":"Re: [PATCH] fetch: do not redundantly calculate tag refmap","fromName":"Jeff King","fromEmail":"peff@peff.net","sentAt":"2016-11-11T02:09:58Z","receivedAt":"2016-11-11T02:10:05Z","isPatch":true,"sender":{"key":"peff@peff.net","avatar":"https://avatars.githubusercontent.com/u/45925?v=4"},"body":"On Thu, Nov 10, 2016 at 04:13:28PM -0800, Jonathan Tan wrote:\n\n> builtin/fetch.c redundantly calculates refmaps for tags twice. Remove\n> the first calculation.\n> \n> This is only a code simplification and slight performance improvement -\n> the result is unchanged, as the redundant refmaps are subsequently\n> removed by the invocation to \"ref_remove_duplicates\" anyway.\n> \n> This was introduced in commit c5a84e9 (\"fetch --tags: fetch tags *in\n> addition to* other stuff\", 2013-10-29) when modifying the effect of the\n> --tags parameter to \"git fetch\". The refmap-for-tag calculation was\n> copied instead of moved.\n> \n> Signed-off-by: Jonathan Tan <jonathantanmy@google.com>\n> ---\n> \n> (I noticed this when working on something in this file.)\n\nCoincidentally I noticed this a few weeks ago, too, while working on\n[1], but didn't follow it up. Mainly I was worried there was something\nhidden or clever going on, but I think it really is just a case of the\ncode growing the two calls over time. So this looks good to me. Thanks\nfor digging it up.\n\n-Peff\n\n[1] http://public-inbox.org/git/20161024132932.i42rqn2vlpocqmkq@sigill.intra.peff.net/\n"}]}