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

Re: [Bug] fetch --deepen truncates history in v2.54.0

From
René Scharfe <l.s.r@web.de>
Date
May 2, 2026, 09:22 UTC
Message-ID
<a5fd970d-fd78-41bc-98f8-a6a87a7f39cc@web.de>
In-Reply-To
<CANOh7gEEw+6146NN3JV8EYxQarj0KkyA7r3RZ6v-DxeqQZLrCA@mail.gmail.com>
On 4/29/26 1:27 PM, Owen Stephens wrote:
Show 26 quoted lines
>> What did you do before the bug happened? (Steps to reproduce your issue)
> 
> Repeatedy called `git fetch --deepen 2` inside a shallow repo that was a
> file:// clone of another repo. Once all commits had been fetched, a subsequent
> `fetch --deepen` appears to "reset" the repo back to being shallow with a depth
> of 2. A reproduction script is included below. This issue appears to have been
> introduced in v2.54.0.
> 
>> What did you expect to happen? (Expected behavior)
> 
> I expected `git fetch --deepen` in a non-shallow repo with no upstream commits
> to be a no-op.
> 
>> What happened instead? (Actual behavior)
> 
> `git log` history is truncated to two commits, and repo is considered shallow
> by `git rev-parse --is-shallow-repository`.
> 
>> What's different between what you expected and what actually happened?
> 
> The previously-present commits in `git log` are missing, and the repo is again
> considered shallow.
> 
>> Anything else you want to add:
> 
> Commit 3ef68ff seems relevant.

Indeed, bisect identifies 3ef68ff40e (shallow: handling fetch relative-deepen, 2026-02-15) and reverting it fixes the issue. Copying its author.

Show 29 quoted lines
> The following script reproduces the issue in 2.54.0, and does not reproduce the
> issue in 2.53.0:
> 
> ```
> mkdir repro.git
> cd repro.git
> 
> git init
> 
> for i in $(seq 1 4); do
>   echo "$i" >> file.txt
>   git add file.txt
>   git commit -m "Change $i"
> done
> 
> cd ..
> 
> git clone --depth 2 "file://$PWD/repro.git" repro_clone.git
> cd repro_clone.git
> 
> echo "Shallow repo? $(git rev-parse --is-shallow-repository)"
> git log --oneline
> 
> for i in $(seq 1 3); do
>   git fetch --deepen 2
>   echo "Shallow repo? $(git rev-parse --is-shallow-repository)"
>   git log --oneline
> done
> ```
Nice!  Here's a test for that:
diff --git a/t/t5537-fetch-shallow.sh b/t/t5537-fetch-shallow.sh
index 6588ce6226..fdb1dd9823 100755
--- a/t/t5537-fetch-shallow.sh
+++ b/t/t5537-fetch-shallow.sh
@@ -251,6 +251,16 @@ test_expect_success '.git/shallow is edited by repack' '
 		origin "+refs/heads/*:refs/remotes/origin/*"
 '
 
+test_expect_success 'fetch --deepen does not truncate' '
+	git clone --no-local .git full-clone &&
+	git rev-parse --is-shallow-repository >expect &&
+	git log --oneline >>expect &&
+	git -C full-clone fetch --deepen=1 &&
+	git -C full-clone rev-parse --is-shallow-repository >actual &&
+	git -C full-clone log --oneline >>actual &&
+	test_cmp expect actual
+'
+
 . "$TEST_DIRECTORY"/lib-httpd.sh
 start_httpd
 

 
Previous: Mikael MagnussonNext: René Scharfe
Message 5 of 14 in “[Bug] fetch --deepen truncates history in v2.54.0”
  1. Owen StephensApr 29, 2026
  2. Owen StephensApr 29, 2026
  3. D. Ben KnobleApr 29, 2026
  4. Mikael MagnussonApr 30, 2026
  5. René ScharfeMay 2, 2026
  6. René ScharfeMay 2, 2026
  7. Samo PogačnikMay 5, 2026
  8. René ScharfeMay 5, 2026
  9. Samo PogačnikMay 5, 2026
  10. 1/1 shallow: fix relative deepen on non-shallow repositoriesSamo Pogačnik, May 6, 2026
  11. Junio C HamanoMay 11, 2026
  12. René ScharfeMay 11, 2026
  13. Junio C HamanoMay 11, 2026
  14. shallow: fix relative deepen on non-shallow repositoriesSamo Pogačnik, May 11, 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.