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

[PATCH v3 0/2] shallow: handling fetch relative-deepen

From
Samo Pogačnik via GitGitGadget <gitgitgadget@gmail.com>
Date
Jan 10, 2026, 05:13 UTC
Message-ID
<pull.2121.v3.git.git.1768022018.gitgitgadget@gmail.com>
In-Reply-To
<pull.2121.v2.git.git.1767997426.gitgitgadget@gmail.com>

When a shallowed repository gets deepened beyond the beginning of a merged branch, we may endup with some shallows, that are behind the reachable ones. Added test 'fetching deepen beyond merged branch' exposes that behaviour.

On the other hand, it seems that equivalent absolute depth driven fetches result in all the correct shallows. That led to this proposal, which unifies absolute and relative deepening in a way that the same get_shallow_commits() call is used in both cases. The difference is only that depth is adapted for relative deepening by measuring equivalent depth of current local shallow commits in the current remote repo. Thus a new function get_shallows_depth() has been added and the function get_reachable_list() became redundant / removed.

The get_shallows_depth() function also shares the logic of the get_shallow_commits() function, but it focuses on counting depth of each existing shallow commit. The minimum result is stored as 'data->deepen_relative', which is set not to be zero for relative deepening anyway. That way we can allways summ 'data->deepen_relative' and 'depth' values, because 'data->deepen_relative' is always 0 in absolute deepening.

Samo Pogačnik (2):
  shallow: free local object_array allocations
  shallow: handling fetch relative-deepen
 shallow.c             | 45 +++++++++++++++++--------
 shallow.h             |  1 +
 t/t5500-fetch-pack.sh | 23 +++++++++++++
 upload-pack.c         | 76 +++++--------------------------------------
 4 files changed, 64 insertions(+), 81 deletions(-)
base-commit: f0ef5b6d9bcc258e4cbef93839d1b7465d5212b9
Published-As: https://github.com/gitgitgadget/git/releases/tag/pr-git-2121%2Fspog%2Ffix-fetch-deepen-v3
Fetch-It-Via: git fetch https://github.com/gitgitgadget/git pr-git-2121/spog/fix-fetch-deepen-v3
Pull-Request: https://github.com/git/git/pull/2121
Range-diff vs v2:
 1:  f8a8d077cd = 1:  f8a8d077cd shallow: free local object_array allocations
 2:  ba1f80105f ! 2:  e79ab6b740 shallow: handling fetch relative-deepen
     @@ Commit message
      
          An example showing the problem based on added test:
          0. Whole initial git repo to be cloned from
     -    Graph:
     -    *   033585d (HEAD -> main) Merge branch 'branch'
     -    |\
     -    | * 984f8b1 (branch) five
     -    | * ecb578a four
     -    |/
     -    * 0cb5d20 three
     -    * 2b4e70d two
     -    * 61ba98b one
     +       Graph:
     +       *   033585d (HEAD -> main) Merge branch 'branch'
     +       |\
     +       | * 984f8b1 (branch) five
     +       | * ecb578a four
     +       |/
     +       * 0cb5d20 three
     +       * 2b4e70d two
     +       * 61ba98b one
      
          1. Initial shallow clone --depth=3 (all good)
     -    Shallows:
     -    2b4e70da2a10e1d3231a0ae2df396024735601f1
     -    ecb578a3cf37198d122ae5df7efed9abaca17144
     -    Graph:
     -    *   033585d (HEAD -> main) Merge branch 'branch'
     -    |\
     -    | * 984f8b1 five
     -    | * ecb578a (grafted) four
     -    * 0cb5d20 three
     -    * 2b4e70d (grafted) two
     +       Shallows:
     +       2b4e70da2a10e1d3231a0ae2df396024735601f1
     +       ecb578a3cf37198d122ae5df7efed9abaca17144
     +       Graph:
     +       *   033585d (HEAD -> main) Merge branch 'branch'
     +       |\
     +       | * 984f8b1 five
     +       | * ecb578a (grafted) four
     +       * 0cb5d20 three
     +       * 2b4e70d (grafted) two
      
          2. Deepen shallow clone with fetch --deepen=1 (NOT OK)
     -    Shallows:
     -    0cb5d204f4ef96ed241feb0f2088c9f4794ba758
     -    61ba98be443fd51c542eb66585a1f6d7e15fcdae
     -    Graph:
     -    *   033585d (HEAD -> main) Merge branch 'branch'
     -    |\
     -    | * 984f8b1 five
     -    | * ecb578a four
     -    |/
     -    * 0cb5d20 (grafted) three
     -    ---
     -    Note that second shallow commit 61ba98be443fd51c542eb66585a1f6d7e15fcdae
     -    is not reachable.
     +       Shallows:
     +       0cb5d204f4ef96ed241feb0f2088c9f4794ba758
     +       61ba98be443fd51c542eb66585a1f6d7e15fcdae
     +       Graph:
     +       *   033585d (HEAD -> main) Merge branch 'branch'
     +       |\
     +       | * 984f8b1 five
     +       | * ecb578a four
     +       |/
     +       * 0cb5d20 (grafted) three
     +       ---
     +       Note that second shallow commit 61ba98be443fd51c542eb66585a1f6d7e15fcdae
     +       is not reachable.
      
          On the other hand, it seems that equivalent absolute depth driven
          fetches result in all the correct shallows. That led to this proposal,
     @@ Commit message
      
          Same example showing the corrected second step:
          2. Deepen shallow clone with fetch --deepen=1 (all good)
     -    Shallow:
     -    61ba98be443fd51c542eb66585a1f6d7e15fcdae
     -    Graph:
     -    *   033585d (HEAD -> main) Merge branch 'branch'
     -    |\
     -    | * 984f8b1 five
     -    | * ecb578a four
     -    |/
     -    * 0cb5d20 three
     -    * 2b4e70d two
     -    * 61ba98b (grafted) one
     +       Shallow:
     +       61ba98be443fd51c542eb66585a1f6d7e15fcdae
     +       Graph:
     +       *   033585d (HEAD -> main) Merge branch 'branch'
     +       |\
     +       | * 984f8b1 five
     +       | * ecb578a four
     +       |/
     +       * 0cb5d20 three
     +       * 2b4e70d two
     +       * 61ba98b (grafted) one
      
          The get_shallows_depth() function also shares the logic of the
          get_shallow_commits() function, but it focuses on counting depth of
-- 
gitgitgadget
Previous: Junio C HamanoNext: Samo Pogačnik via GitGitGadget
Message 13 of 27 in “shallow: handling fetch relative-deepen”
  1. 0/2 shallow: handling fetch relative-deepenSamo Pogačnik via GitGitGadget, Dec 9, 2025
  2. 1/2 shallow: free local object_array allocationsSamo Pogačnik via GitGitGadget, Dec 9, 2025
  3. Patrick SteinhardtJan 6, 2026
  4. Samo PogačnikJan 9, 2026
  5. Patrick SteinhardtJan 9, 2026
  6. 2/2 shallow: handling fetch relative-deepenSamo Pogačnik via GitGitGadget, Dec 9, 2025
  7. Patrick SteinhardtJan 6, 2026
  8. Samo PogačnikJan 9, 2026
  9. 0/2 shallow: handling fetch relative-deepenSamo Pogačnik via GitGitGadget, Jan 9, 2026
  10. 1/2 shallow: free local object_array allocationsSamo Pogačnik via GitGitGadget, Jan 9, 2026
  11. 2/2 shallow: handling fetch relative-deepenSamo Pogačnik via GitGitGadget, Jan 9, 2026
  12. Junio C HamanoJan 10, 2026
  13. 0/2 shallow: handling fetch relative-deepenSamo Pogačnik via GitGitGadget, Jan 10, 2026
  14. 1/2 shallow: free local object_array allocationsSamo Pogačnik via GitGitGadget, Jan 10, 2026
  15. 2/2 shallow: handling fetch relative-deepenSamo Pogačnik via GitGitGadget, Jan 10, 2026
  16. Kristoffer HaugsbakkJan 15, 2026
  17. 0/2 shallow: handling fetch relative-deepenSamo Pogačnik via GitGitGadget, Jan 16, 2026
  18. 1/2 shallow: free local object_array allocationsSamo Pogačnik via GitGitGadget, Jan 16, 2026
  19. 2/2 shallow: handling fetch relative-deepenSamo Pogačnik via GitGitGadget, Jan 16, 2026
  20. Patrick SteinhardtFeb 11, 2026
  21. Samo PogačnikFeb 13, 2026
  22. Samo PogačnikFeb 14, 2026
  23. Samo PogačnikFeb 15, 2026
  24. 0/2 shallow: handling fetch relative-deepenSamo Pogačnik via GitGitGadget, Feb 15, 2026
  25. 1/2 shallow: free local object_array allocationsSamo Pogačnik via GitGitGadget, Feb 15, 2026
  26. 2/2 shallow: handling fetch relative-deepenSamo Pogačnik via GitGitGadget, Feb 15, 2026
  27. Junio C HamanoFeb 20, 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.