[Bug] fetch --deepen truncates history in v2.54.0
- From
- Owen Stephens <owen@owenstephens.co.uk>
- Date
- Apr 29, 2026, 11:27 UTC
- Message-ID
- <CANOh7gEEw+6146NN3JV8EYxQarj0KkyA7r3RZ6v-DxeqQZLrCA@mail.gmail.com>
> 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.
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 ```
The key lines in the output are: ``` Shallow repo? true 63d1ebe (HEAD -> master, origin/master, origin/HEAD) Change 4 864e13c (grafted) Change 3 remote: Enumerating objects: 10, done. remote: Counting objects: 100% (10/10), done. remote: Compressing objects: 100% (2/2), done. remote: Total 6 (delta 1), reused 0 (delta 0), pack-reused 0 (from 0) Unpacking objects: 100% (6/6), 351 bytes | 175.00 KiB/s, done.
Shallow repo? true 63d1ebe (HEAD -> master, origin/master, origin/HEAD) Change 4 864e13c Change 3 3e05d14 Change 2 1d9fe14 (grafted) Change 1 remote: Total 0 (delta 0), reused 0 (delta 0), pack-reused 0 (from 0)
Shallow repo? false 63d1ebe (HEAD -> master, origin/master, origin/HEAD) Change 4 864e13c Change 3 3e05d14 Change 2 1d9fe14 Change 1 remote: Total 0 (delta 0), reused 0 (delta 0), pack-reused 0 (from 0)
Shallow repo? true 63d1ebe (HEAD -> master, origin/master, origin/HEAD) Change 4 864e13c (grafted) Change 351 ```
N.b. that 1d9fe14 was present after the second iteration but missing after the third, along with `--is-shallow-repository` changing from false back to true.
[System Info] git version: git version 2.54.0 cpu: arm64 no commit associated with this build sizeof-long: 8 sizeof-size_t: 8 shell-path: /bin/sh rust: disabled feature: fsmonitor--daemon gettext: enabled libcurl: 8.7.1 zlib: 1.2.12 SHA-1: SHA1_DC SHA-256: SHA256_BLK default-ref-format: files default-hash: sha1 uname: Darwin 25.4.0 Darwin Kernel Version 25.4.0: Thu Mar 19 19:33:25 PDT 2026; root:xnu-12377.101.15~1/RELEASE_ARM64_T6041 arm64 compiler info: clang: 21.0.0 (clang-2100.0.123.102) libc info: no libc information available $SHELL (typically, interactive shell): /bin/zsh