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

[PATCH v6 0/3] fetch: advertise fetched refs when backfilling tags

From
Karthik Nayak <karthik.188@gmail.com>
Date
Oct 29, 2026, 12:45 UTC
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 <karthik.188@gmail.com>
---
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 <ps@pks.im>
CC: Justin Tobler <jltobler@gmail.com>
---
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 <karthik.188@gmail.com>
     
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
Previous: Karthik NayakNext: Karthik Nayak
Message 32 of 36 in “fetch: commit references fetched before backfilling tags”
  1. fetch: commit references fetched before backfilling tagsKarthik Nayak, Oct 8, 2026
  2. Patrick SteinhardtOct 9, 2026
  3. Justin ToblerOct 9, 2026
  4. Karthik NayakOct 9, 2026
  5. Karthik NayakOct 9, 2026
  6. fetch: commit references fetched before backfilling tagsKarthik Nayak, Oct 12, 2026
  7. Junio C HamanoOct 12, 2026
  8. Karthik NayakOct 15, 2026
  9. fetch: commit references fetched before backfilling tagsKarthik Nayak, Oct 15, 2026
  10. Justin ToblerOct 20, 2026
  11. Patrick SteinhardtOct 21, 2026
  12. Karthik NayakOct 21, 2026
  13. Justin ToblerOct 21, 2026
  14. Karthik NayakOct 22, 2026
  15. Karthik NayakOct 21, 2026
  16. fetch: advertise fetched refs when backfilling tagsKarthik Nayak, Oct 22, 2026
  17. Patrick SteinhardtOct 23, 2026
  18. Karthik NayakOct 23, 2026
  19. Patrick SteinhardtOct 23, 2026
  20. Karthik NayakOct 23, 2026
  21. Karthik NayakOct 23, 2026
  22. 0/3 fetch: advertise fetched refs when backfilling tagsKarthik Nayak, Oct 28, 2026
  23. 1/3 transport: add `transport_options_release()`Karthik Nayak, Oct 28, 2026
  24. Patrick SteinhardtOct 28, 2026
  25. Karthik NayakOct 28, 2026
  26. Patrick SteinhardtOct 29, 2026
  27. Karthik NayakOct 29, 2026
  28. 2/3 fetch: advertise fetched refs when backfilling tagsKarthik Nayak, Oct 28, 2026
  29. 3/3 t5510: cover upstream info update on fetch failureKarthik Nayak, Oct 28, 2026
  30. Patrick SteinhardtOct 28, 2026
  31. Karthik NayakOct 28, 2026
  32. 0/3 fetch: advertise fetched refs when backfilling tagsKarthik Nayak, Oct 29, 2026
  33. 1/3 t5510: cover upstream info update on fetch failureKarthik Nayak, Oct 29, 2026
  34. 2/3 transport: add `transport_options_release()`Karthik Nayak, Oct 29, 2026
  35. 3/3 fetch: advertise fetched refs when backfilling tagsKarthik Nayak, Oct 29, 2026
  36. Patrick SteinhardtOct 29, 2026

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.