@@ -25,9 +25,165 @@ This edition covers what happened during the months of November and December 202
2525### Reviews
2626-->
2727
28- <!-- -
2928### Support
30- -->
29+
30+ * [ git-2.51.0: Fetching tags does not work] ( https://lore.kernel.org/git/CAB9xhmPcHnB2%2Bi6WeA3doAinv7RAeGs04%2Bn0fHLGToJq%3DUKUNw%40mail.gmail.com )
31+
32+ Last September, David Bohman reported a regression in Git 2.51.0
33+ where ` git fetch --tags ` failed to update tags in a bare
34+ repository. He noted that the command output indicated tags would be
35+ updated, but they were not actually added to the
36+ repository. Reverting to version 2.50.1 resolved the issue.
37+
38+ Junio Hamano, the Git maintainer, attempted to reproduce the issue
39+ using a simple bare clone setup but was unsuccessful, suggesting
40+ that David needed to narrow down the specific conditions.
41+
42+ In early November, David returned to the thread reporting that the
43+ issue persisted in Git 2.51.2. He provided a specific reproduction
44+ case involving a bare clone of ` bind9 ` . The output showed that one
45+ tag update was rejected (with a ` would clobber existing tag ` error),
46+ and consequently, all other valid new tags (` v9.18.41 ` , etc.)
47+ failed to appear in the repository, despite being listed as "new
48+ tag" in the output. The command exited with status code 1.
49+
50+ Randall S. Becker suggested using ` git fetch --tags --force ` to
51+ clear the situation. David Bohman replied that while he could
52+ reproduce it locally, the key behavioral change was that prior to
53+ 2.51, Git would fail the conflicting tag but still insert the
54+ non-conflicting ones.
55+
56+ Chris Torek identified the root cause as the new reference
57+ transaction system introduced in recent versions. He noted that the
58+ behavior had shifted to "all or nothing" (either all tags get
59+ updated, or none do) and questioned which behavior was actually
60+ buggy. David Bohman argued that this was a risky change for a mature
61+ tool and noted that the diagnostic messages were misleading because
62+ they reported success for tags that were not actually inserted.
63+
64+ Karthik Nayak confirmed he could reproduce the issue and attributed
65+ it to transaction reference updates.
66+
67+ Karthik submitted
68+ [ version 1] ( https://lore.kernel.org/git/20251103-fix-tags-not-fetching-v1-1-e63caeb6c113%40gmail.com )
69+ of a patch to fix the issue. He explained that commit ` 0e358de64a `
70+ (fetch: use batched reference updates, 2025-05-19) introduced
71+ batched reference updates for ` git fetch ` . When fetching references,
72+ updates are added to a transaction. However, specifically when
73+ fetching tags, if a conflict occurs, the function
74+ ` fetch_and_consume_refs() ` returns an error code immediately. This
75+ caused the code to jump to the cleanup section, skipping the commit
76+ of the transaction entirely, meaning even valid updates were
77+ discarded.
78+
79+ The proposed fix involved extracting the transaction commit logic
80+ into a new function, ` commit_ref_transaction() ` , and ensuring it is
81+ called even when an error code is returned, provided the fetch is
82+ not atomic.
83+
84+ Eric Sunshine reviewed the patch, asking why the test code was
85+ wrapped in subshells and suggesting that ` ! ` should be replaced with
86+ ` test_must_fail ` . Karthik agreed to these changes.
87+
88+ Justin Tobler reviewed the code, agreeing with the logic. He
89+ suggested adding a comment to ` commit_ref_transaction() ` to
90+ distinguish it from ` ref_transaction_commit() ` and asked if the
91+ return value of this new function should be checked.
92+
93+ Karthik submitted
94+ [ version 2] ( https://lore.kernel.org/git/20251106-fix-tags-not-fetching-v2-1-610cb4b0e7c8%40gmail.com )
95+ of the patch. This version added comments, removed subshells from
96+ tests, and extended the fix to the ` backfill_tags() ` function.
97+
98+ Patrick Steinhardt reviewed version 2. He questioned the commit
99+ message's mention of the deprecated "branches/" format in relation
100+ to tag backfilling. Karthik replied, clarifying that after
101+ re-reading the code, he understood that backfilling happens when the
102+ user does not specify ` --tags ` or ` --no-tags ` , confirming Patrick's
103+ understanding.
104+
105+ Patrick noted that the code now had three different callsites
106+ committing the transaction and felt it was "somewhat fragile."
107+ Justin pointed out that the return code of
108+ ` commit_ref_transaction() ` was being ignored in the new
109+ implementation. Karthik agreed to check the return value.
110+
111+ Karthik submitted
112+ [ version 3] ( https://lore.kernel.org/git/20251108-fix-tags-not-fetching-v3-0-a12ab6c4daef%40gmail.com )
113+ of the series. He split the changes into two commits: one for
114+ extracting the logic and one for the fix. He also moved the commit
115+ logic into the cleanup section to avoid calling it at every failure
116+ point.
117+
118+ Patrick reviewed version 3. He suggested using ` goto out ` in
119+ ` commit_ref_transaction() ` for better readability. He also asked for
120+ clarification on why the condition ` retcode > 0 ` was safe in the
121+ cleanup section, specifically regarding ` prune_refs() ` . Karthik
122+ replied, explaining that ` prune_refs() ` creates its own internal
123+ transaction, but later realized he was mistaken about the timing and
124+ promised to verify.
125+
126+ Karthik submitted
127+ [ version 4] ( https://lore.kernel.org/git/20251111-fix-tags-not-fetching-v4-0-185d836ec62a%40gmail.com ) .
128+ This version simplified the code and changed the check from
129+ ` retcode > 0 ` to just ` retcode ` .
130+
131+ Patrick pointed out that the commit message regarding ` prune_refs() `
132+ behavior change seemed incorrect because no transaction exists at
133+ that stage. Karthik verified this and confirmed there is no change
134+ for ` prune_refs() ` .
135+
136+ Karthik submitted
137+ [ version 5] ( https://lore.kernel.org/git/20251113-fix-tags-not-fetching-v5-0-371ea7ec638d%40gmail.com )
138+ with corrected commit messages and better test cleanup.
139+
140+ Junio reviewed version 5 and identified a remaining
141+ issue. He noted that while the patch fixed the transaction commit,
142+ jumping to the cleanup label early meant that subsequent operations
143+ (specifically ` commit_fetch_head() ` , ` set_upstream() ` , and setting
144+ remote HEADs) were still being skipped when errors occurred. He
145+ argued that in non-atomic fetches, these should still run. Karthik
146+ agreed and proposed a fix to only jump to cleanup if ` --atomic ` was
147+ used.
148+
149+ Karthik submitted
150+ [ version 6] ( https://lore.kernel.org/git/20251118-fix-tags-not-fetching-v6-0-2a2f15fc137e%40gmail.com ) ,
151+ adding a third commit to the series to address the skipped
152+ operations regression identified by Junio.
153+
154+ Junio reviewed version 6. He liked the tests but warned
155+ against using ` touch ` to create files due to timestamp issues and
156+ noted a missing test case for ` --set-upstream ` on a successful
157+ fetch. Karthik agreed to fix these.
158+
159+ Karthik submitted
160+ [ version 7] ( https://lore.kernel.org/git/20251119-fix-tags-not-fetching-v7-0-0c8f9fb1f287%40gmail.com ) ,
161+ removing ` touch ` and adjusting the test prerequisites.
162+
163+ Eric reviewed the tests in version 7, asking if ` ! test -f ` should
164+ be ` test_path_is_missing ` . Junio suggested using ` rm -f FETCH_HEAD `
165+ before the test to ensure it is actually created during the run, and
166+ inspecting the file content to verify what was recorded. Karthik
167+ agreed.
168+
169+ Karthik submitted
170+ [ version 8] ( https://lore.kernel.org/git/20251121-fix-tags-not-fetching-v8-0-23b53a8a8334%40gmail.com ) .
171+ This version verified the content of ` FETCH_HEAD ` and used
172+ ` test_path_is_missing ` .
173+
174+ Junio commented that the series looked good. Patrick pointed out a
175+ tiny grammar nit ("eventhough") and asked if the shell syntax
176+ ` >file ` used in the test was compatible with all systems, noting
177+ ` : >file ` is more typical. Karthik replied that existing tests use
178+ the shorter syntax, so it should be fine.
179+
180+ The small patch series was eventually merged, and should be part of
181+ Git 2.53.0 that should be released at the latest towards the
182+ beginning of February 2026. With this not only the transaction logic
183+ will be fixed, but related regressions regarding post-fetch
184+ operations (like updating ` FETCH_HEAD ` ) will also have been
185+ identified and resolved.
186+
31187
32188## Developer Spotlight: Lucas Seiki Oshiro
33189
0 commit comments