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

Re: Tags are no longer fetched when fetching specific commit

From
Junio C Hamano <gitster@pobox.com>
Date
Feb 14, 2025, 18:35 UTC
Message-ID
<xmqqv7tcl6hp.fsf@gitster.g>
In-Reply-To
<Z650WoqFwCSo6svH@nand.local>
Taylor Blau <me@ttaylorr.com> writes:
Show 14 quoted lines
> So I think the right fix would really be something like:
>
> --- 8< ---
> diff --git a/builtin/fetch.c b/builtin/fetch.c
> index fe2b26c74a..0e63621e6c 100644
> --- a/builtin/fetch.c
> +++ b/builtin/fetch.c
> @@ -1770,9 +1770,8 @@ static int do_fetch(struct transport *transport,
>
>  	if (tags == TAGS_SET || tags == TAGS_DEFAULT) {
>  		must_list_refs = 1;
> -		if (transport_ls_refs_options.ref_prefixes.nr)
> -			strvec_push(&transport_ls_refs_options.ref_prefixes,
> -				    "refs/tags/");

I guess the original "if we are giving prefixes already, then make sure we learn about tags" is because the semantics of the ref-prefix is peculiar, in that without _any_, there is no limitation and the remote end would advertise all its refs, but if there is even one, the remote end would advertise only the ones that match any prefix?

> +		strvec_push(&transport_ls_refs_options.ref_prefixes,
> +			    "refs/tags/");

So this change would make sure that, even if somebody else already added a prefix earlier, we would always ask about tags if we come into this block. It also means when nobody has added a prefix before we reach here, we still add prefix to ask about tags. The implication of which may be rather grave. If a later code relied on us _not_ asking for tags here (because nobody is limiting the ls-refs request with prefix), after this change, that code will now see that there is some prefix requested already, and if we wanted to retain what that code does, we would need to adjust that code (and then the need for similar modification cascades X-<).

Show 8 quoted lines
>  	}
>
>  	if (uses_remote_tracking(transport, rs)) {
> --- >8 ---
>
> But I'm unfamiliar enough with this area that I'd appreciate comments
> from the authors of these various commits, all of whom have been CC'd.
> Does this seem right to you, or am I totally down the wrong path?

I have no idea without doing a deep dive myself, for which I have failed to find time for so far.

I have to wonder if the first thing we should do is to update the logic to decide what ref prefixes to use, so that it does not do such an incremental strvec_push(). There are multiple questions in the form "Do we need to know about X?" the code path need to ask before deciding what prefixes to use, and before Bence's "We need to know about HEAD, because we want to know about its symref value", refs/tags hierarchy was one (and only?) thing we needed to ask about. The bug under discussion smells like the result of how brittle the code's assumption about what prefixes other parts would want to ask. This code did not assume there is anybody else, and that is why it broke when we started asking about HEAD. Now we have two possible X's in that question (refs/tags and HEAD). We may want to make sure the code is robust enough when we add the third one.

Thanks.
Previous: Bence FerdinandyNext: Jeff King
Message 4 of 61 in “Tags are no longer fetched when fetching specific commit”
  1. Igor TodorovskiJan 30, 2025
  2. Taylor BlauFeb 13, 2025
  3. Bence FerdinandyFeb 14, 2025
  4. Junio C HamanoFeb 14, 2025
  5. Jeff KingFeb 21, 2025
  6. fetch: fix following tags when fetching specific OIDTaylor Blau, Mar 7, 2025
  7. Taylor BlauMar 7, 2025
  8. Junio C HamanoMar 8, 2025
  9. Bence FerdinandyMar 8, 2025
  10. 0/9 fetch: further ref-prefix cleanups and optimizationsJeff King, Mar 9, 2025
  11. 1/9 t5702: fix typo in test nameJeff King, Mar 9, 2025
  12. Taylor BlauMar 12, 2025
  13. Jeff KingMar 13, 2025
  14. 2/9 t5516: prefer "oid" to "sha1" in some test titlesJeff King, Mar 9, 2025
  15. 3/9 t5516: drop NEEDSWORK about v2 reachability behaviorJeff King, Mar 9, 2025
  16. Taylor BlauMar 12, 2025
  17. 4/9 t5516: beef up exact-oid ref prefixes testJeff King, Mar 9, 2025
  18. 5/9 refspec_ref_prefixes(): clean up refspec_item logicJeff King, Mar 9, 2025
  19. Taylor BlauMar 12, 2025
  20. Jeff KingMar 13, 2025
  21. Junio C HamanoMar 13, 2025
  22. 0/4 refspec: treat 'fetch' as a Boolean valueTaylor Blau, Mar 17, 2025
  23. 1/4 refspec: treat 'fetch' as a Boolean valueTaylor Blau, Mar 17, 2025
  24. Jeff KingMar 18, 2025
  25. Jeff KingMar 18, 2025
  26. Taylor BlauMar 18, 2025
  27. 2/4 refspec: replace `refspec_init()` with fetch/push variantsTaylor Blau, Mar 17, 2025
  28. 3/4 refspec: remove refspec_item_init_or_die()Taylor Blau, Mar 17, 2025
  29. 4/4 refspec: replace `refspec_item_init()` with fetch/push variantsTaylor Blau, Mar 17, 2025
  30. Junio C HamanoMar 17, 2025
  31. Taylor BlauMar 18, 2025
  32. 0/4 refspec: treat 'fetch' as a Boolean valueTaylor Blau, Mar 18, 2025
  33. 1/4 refspec: treat 'fetch' as a Boolean valueTaylor Blau, Mar 18, 2025
  34. 2/4 refspec: replace `refspec_init()` with fetch/push variantsTaylor Blau, Mar 18, 2025
  35. 3/4 refspec: remove refspec_item_init_or_die()Taylor Blau, Mar 18, 2025
  36. 4/4 refspec: replace `refspec_item_init()` with fetch/push variantsTaylor Blau, Mar 18, 2025
  37. Elijah NewrenMar 19, 2025
  38. Taylor BlauMar 17, 2025
  39. Junio C HamanoMar 17, 2025
  40. Taylor BlauMar 18, 2025
  41. 6/9 fetch: ask server to advertise HEAD for config-less fetchJeff King, Mar 9, 2025
  42. Taylor BlauMar 12, 2025
  43. Jeff KingMar 13, 2025
  44. Junio C HamanoMar 13, 2025
  45. Taylor BlauMar 17, 2025
  46. 7/9 fetch: stop protecting additions to ref-prefix listJeff King, Mar 9, 2025
  47. Taylor BlauMar 12, 2025
  48. 8/9 fetch: avoid ls-refs only to ask for HEAD symref updateJeff King, Mar 9, 2025
  49. Junio C HamanoMar 13, 2025
  50. Jeff KingMar 17, 2025
  51. Junio C HamanoMar 17, 2025
  52. 0/2 limiting followRemoteHEAD being usedJeff King, Mar 18, 2025
  53. 1/2 fetch: only respect followRemoteHEAD with configured refspecsJeff King, Mar 18, 2025
  54. Taylor BlauMar 18, 2025
  55. 2/2 fetch: don't ask for remote HEAD if followRemoteHEAD is "never"Jeff King, Mar 18, 2025
  56. Junio C HamanoMar 18, 2025
  57. Taylor BlauMar 18, 2025
  58. 9/9 fetch: use ref prefix list to skip ls-refsJeff King, Mar 9, 2025
  59. Taylor BlauMar 12, 2025
  60. Taylor BlauMar 12, 2025
  61. Jeff KingMar 13, 2025

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.