git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: [PATCH] git fetch one tag only

From
cheng renquan <crquan@gmail.com>
Date
Jun 8, 2012, 21:46 UTC
Message-ID
<CAH5vBdLGHpFCH3mWgNANTw4frzqSz=AO+kB12DSx55wn1hYJag@mail.gmail.com>
In-Reply-To
<7v8vfzjbhi.fsf@alter.siamese.dyndns.org>
On Thu, Jun 7, 2012 at 10:08 AM, Junio C Hamano <gitster@pobox.com> wrote:
Show 15 quoted lines
>  * The auto-follow kicks in whenever you tell "fetch" to update some
>   refs locally.  Maybe if we tweak the rule and auto-follow kick in
>   only when you tell "fetch" to update some refs outside refs/tags
>   locally,
>
>        $ git fetch $over_there tag v1.0.0
>
>   will fetch and store _only_ the v1.0.0 tag.
>
>   Of course, any behaviour change is a regression, and if done
>   without an escape hatch, such a change robs people one useful
>   feature: grab tag v1.0.0 and others older than that tag in one
>   go.
>
> I won't be coding any of the above; just thinking aloud.

Here is the code to implement your 2nd approach, and I don't think this behaviour change is a regression, because if someone is really relying this fetch one tag actually fetch all tags feature he is relying on a broken feature, and should be corrected: if one really need to fetch all tags, that's what explicit "--tags" designed and documented for

diff --git a/builtin/fetch.c b/builtin/fetch.c
index bb9a074..b6d7ef3 100644
--- a/builtin/fetch.c
+++ b/builtin/fetch.c
@@ -158,7 +158,8 @@ static struct ref *get_ref_map(struct transport *transport,
 	if (ref_count || tags == TAGS_SET) {
 		for (i = 0; i < ref_count; i++) {
 			get_fetch_map(remote_refs, &refs[i], &tail, 0);
-			if (refs[i].dst && refs[i].dst[0])
+			if (refs[i].dst && refs[i].dst[0]
+			    && prefixcmp(refs[i].dst, "refs/tags/"))
 				*autotags = 1;
 		}
 		/* Merge everything on the command line, but not --tags */
-- 
cheng renquan (程任全)
Previous: Junio C HamanoNext: Junio C Hamano
Message 8 of 9 in “git fetch one tag only”
  1. git fetch one tag onlycheng renquan, Jun 7, 2012
  2. Junio C HamanoJun 7, 2012
  3. cheng renquanJun 7, 2012
  4. Junio C HamanoJun 7, 2012
  5. cheng renquanJun 7, 2012
  6. cheng renquanJun 7, 2012
  7. Junio C HamanoJun 7, 2012
  8. cheng renquanJun 8, 2012
  9. Junio C HamanoJun 8, 2012

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.