Git development
 help / color / mirror / Atom feed
* [Bug] fetch --deepen truncates history in v2.54.0
@ 2026-04-29 11:27 Owen Stephens
  2026-04-29 13:14 ` Owen Stephens
                   ` (2 more replies)
  0 siblings, 3 replies; 14+ messages in thread
From: Owen Stephens @ 2026-04-29 11:27 UTC (permalink / raw)
  To: git

> 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

^ permalink raw reply	[flat|nested] 14+ messages in thread

end of thread, other threads:[~2026-05-11 19:21 UTC | newest]

Thread overview: 14+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-04-29 11:27 [Bug] fetch --deepen truncates history in v2.54.0 Owen Stephens
2026-04-29 13:14 ` Owen Stephens
2026-04-29 13:16 ` D. Ben Knoble
2026-04-30  9:10   ` Mikael Magnusson
2026-05-02  9:22 ` René Scharfe
2026-05-02 20:26   ` René Scharfe
2026-05-05 19:27     ` Samo Pogačnik
2026-05-05 20:34       ` René Scharfe
2026-05-05 21:26         ` Samo Pogačnik
2026-05-06 21:56         ` [PATCH 1/1] shallow: fix relative deepen on non-shallow repositories Samo Pogačnik
2026-05-11  0:09           ` Junio C Hamano
2026-05-11  7:45             ` René Scharfe
2026-05-11  8:30               ` Junio C Hamano
2026-05-11 19:20                 ` [PATCH v2] " Samo Pogačnik

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox