From: Karthik Nayak Date: Thu, 29 Oct 2026 12:45:36 GMT Subject: [PATCH v6 0/3] fetch: advertise fetched refs when backfilling tags Message-ID: <20261029-799-shallow-fetch-with-tags-v6-0-e6ddd5201def@gmail.com> In-Reply-To: <20261009-799-shallow-fetch-with-tags-v1-1-379d61504af5@gmail.com> The issue was reported by Mitja Bezenšek on GitLab's Git repo [1]. When fetching, git-fetch(1) performs the reference updates in two steps: 1. Fetches the regular references 2. Backfills any tags With batched updates, both of these operations came under the same reference transaction. Unfortunately, this meant that the initial references fetched were not committed and couldn't be used as 'haves' during the negotiation when backfilling tags. In shallow repositories, this could mean that the server was sending objects the client already possessed. This series fixes this regression. Earlier versions (1-3) tried to fix this by splitting the transaction into two. Which works, but makes the code more complex and is a bit messy overall as we have to deal with errors and also jumps in the codeflow. Justin suggested that we could use the references already available for negotiation instead, that is what v4 onwards does. [1]: https://gitlab.com/gitlab-org/git/-/work_items/799 Signed-off-by: Karthik Nayak --- Changes in v6: - Move the last commit to the front, since it adds a test to exercise existing behavior. - Fix grammar in the commit message and mention how the next commit would catch the leak fixed in 2/3. - Link to v5: https://patch.msgid.link/20261028-799-shallow-fetch-with-tags-v5-0-7c43cc9ae810@gmail.com Changes in v5: - Add a patch fixing a pre-existing leak in the remote-helper transport's cleanup. This allows the patch to drop its manual cleanup. - Move the upstream-info test into its own commit. - Some cleanpus around the commit message and grammar - Link to v4: https://patch.msgid.link/20261022-799-shallow-fetch-with-tags-v4-1-8a1c9ef399ed@gmail.com Changes in v4: - Instead of committing the first transaction and starting a new one, advertise the refs already fetched when backfilling tags. Thanks to Justin for the suggestion. This also fixes the `--atomic` flow. - Link to v3: https://patch.msgid.link/20261015-799-shallow-fetch-with-tags-v3-1-90b6e38b98d2@gmail.com Changes in v3: - Fix the early exit, so a failed transaction_begin() only skips the backfill. - Keep the first commit's result separately, so rejections don't skip the upstream and remote-HEAD setup. - Test that the backfill advertises the fetched tip as a have, instead of checking that the root object isn't fetched, which passed even without the fix. - Add a test for the upstream setup when a main ref is rejected and a tag is backfilled. - Link to v2: https://patch.msgid.link/20261012-799-shallow-fetch-with-tags-v2-1-4211e9a13d3c@gmail.com Changes in v2: - Add benchmarks between master and this branch to show perf regression. - Instead of checking the trace file, simply check that we didn't fetch older objects in the test. - Link to v1: https://patch.msgid.link/20261009-799-shallow-fetch-with-tags-v1-1-379d61504af5@gmail.com CC: Patrick Steinhardt CC: Justin Tobler --- Karthik Nayak (3): t5510: cover upstream info update on fetch failure transport: add `transport_options_release()` fetch: advertise fetched refs when backfilling tags builtin/fetch.c | 33 ++++++++++++++++++++++++++++-- t/t5510-fetch.sh | 59 ++++++++++++++++++++++++++++++++++++++++++++++++++++++ transport-helper.c | 1 + transport.c | 24 +++++++++++++--------- transport.h | 2 ++ 5 files changed, 107 insertions(+), 12 deletions(-) Range-diff versus v5: 3: ed24854913 = 1: 6aafee69c1 t5510: cover upstream info update on fetch failure 1: f15e69e2e6 ! 2: a22b348247 transport: add `transport_options_release()` @@ Commit message the latter misses this. This means when using remote-helpers, data allocated for the structure - leaks. Introduce a new `transport_options_release()`, which acts as a - common path to release memory allocated with the structure and use it in - both files. + leaks. None of the existing tests capture this leak, but the tests + introduced in the next patch do. Fix the leak by introducing + `transport_options_release()`, which acts as a common path to release + memory allocated with the structure and use it in both files. Signed-off-by: Karthik Nayak 2: dc7024fafb = 3: ebe210d2df fetch: advertise fetched refs when backfilling tags --- base-commit: 6de20f6092dcf9bdb1c8efe03db4b70c82b423dd change-id: 20261007-799-shallow-fetch-with-tags-d62b3efb29f0 Thanks - Karthik