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

Re: Git 2.48. Changed behavior of the git fetch

From
Bence Ferdinandy <bence@ferdinandy.com>
Date
Jan 26, 2025, 23:35 UTC
Message-ID
<D7CEDCJ0KKYL.YS0EWVFCN72X@ferdinandy.com>
In-Reply-To
<CAM6buW4e4c_3BgPo_GU64Fvi7XGcP7tuxdaap1LypyFCOZvZEw@mail.gmail.com>
On Tue Jan 21, 2025 at 18:26, Danila Manturov <danila.manturov@jetbrains.com> wrote:
Show 14 quoted lines
> Hello. I have done some experiments. For some reason, it works
> correctly with JSch. With native ssh/https it doesn't work
>
> On Mon, Jan 13, 2025 at 5:03 PM Bence Ferdinandy <bence@ferdinandy.com> wrote:
>>
>>
>> On Mon Jan 13, 2025 at 15:14, Danila Manturov <danila.manturov@jetbrains.com> wrote:
>> > According to our CI, the first commit where the bug occurs is
>> > 5f212684abb66c9604e745a2296af8c4bb99961c
>>
>> That makes sense, what is more interesting is why the fix Junio wrote later
>> doesn't work in this case ... I didn't have time to dig yet.
>>
>>

I looked up the original thread leading to 6c915c3f85 (fetch: do not ask for HEAD unnecessarily, 2024-12-06) by Junio, which fixed a similar issue (see https://lore.kernel.org/git/444kgiknevb3kwtypjjc2glryaav27t5fafgyzqq5257w7o4pf@4fngcyfmvfcp/T/#u).

Originally Josh there suggested just changing the order of adding tags later to the prefixes should solve the issue. I don't think we ever actually figured out why the order of the prefixes should matter, and Junio's patch solved that particular problem by just not asking for HEAD in that case, but it seems that the current problem can also be solved by swapping the order of tags and HEAD.

This seems like a band-aid again, and I still don't get why the order matters, but I can turn this into a patch if needed:

diff --git a/builtin/fetch.c b/builtin/fetch.c
index fe2b26c74a..7147f06395 100644
--- a/builtin/fetch.c
+++ b/builtin/fetch.c
@@ -1768,6 +1768,11 @@ static int do_fetch(struct transport *transport,
 		}
 	}
 
+	if (uses_remote_tracking(transport, rs)) {
+		must_list_refs = 1;
+		strvec_push(&transport_ls_refs_options.ref_prefixes, "HEAD");
+	}
+
 	if (tags == TAGS_SET || tags == TAGS_DEFAULT) {
 		must_list_refs = 1;
 		if (transport_ls_refs_options.ref_prefixes.nr)
@@ -1775,10 +1780,6 @@ static int do_fetch(struct transport *transport,
 				    "refs/tags/");
 	}
 
-	if (uses_remote_tracking(transport, rs)) {
-		must_list_refs = 1;
-		strvec_push(&transport_ls_refs_options.ref_prefixes, "HEAD");
-	}
 
 	if (must_list_refs) {
 		trace2_region_enter("fetch", "remote_refs", the_repository);
Previous: Danila ManturovNext: Danila Manturov
Message 6 of 8 in “Git 2.48. Changed behavior of the git fetch”
  1. Danila ManturovJan 9, 2025
  2. Bence FerdinandyJan 12, 2025
  3. Danila ManturovJan 13, 2025
  4. Bence FerdinandyJan 13, 2025
  5. Danila ManturovJan 21, 2025
  6. Bence FerdinandyJan 26, 2025
  7. Danila ManturovJan 27, 2025
  8. Bence FerdinandyJan 27, 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.