Git development
 help / color / mirror / Atom feed
From: "René Scharfe" <l.s.r@web.de>
To: Owen Stephens <owen@owenstephens.co.uk>, git@vger.kernel.org
Cc: "Samo Pogačnik" <samo_pogacnik@t-2.net>
Subject: Re: [Bug] fetch --deepen truncates history in v2.54.0
Date: Sat, 2 May 2026 22:26:34 +0200	[thread overview]
Message-ID: <e39f6770-fcc4-49a2-b3ba-5ac2ec9e047b@web.de> (raw)
In-Reply-To: <a5fd970d-fd78-41bc-98f8-a6a87a7f39cc@web.de>

On 5/2/26 11:22 AM, René Scharfe wrote:
> On 4/29/26 1:27 PM, Owen Stephens wrote:
>>> 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.

Here's a simple fix, but it feels like cheating.  A proper one should
live in shallow.c, no?


diff --git a/builtin/fetch.c b/builtin/fetch.c
index a22c319467..310099b96d 100644
--- a/builtin/fetch.c
+++ b/builtin/fetch.c
@@ -2664,7 +2664,8 @@ int cmd_fetch(int argc,
 			die(_("negative depth in --deepen is not supported"));
 		if (depth)
 			die(_("options '%s' and '%s' cannot be used together"), "--deepen", "--depth");
-		depth = xstrfmt("%d", deepen_relative);
+		if (is_repository_shallow(the_repository))
+			depth = xstrfmt("%d", deepen_relative);
 	}
 	if (unshallow) {
 		if (depth)


  reply	other threads:[~2026-05-02 20:26 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
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 [this message]
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

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=e39f6770-fcc4-49a2-b3ba-5ac2ec9e047b@web.de \
    --to=l.s.r@web.de \
    --cc=git@vger.kernel.org \
    --cc=owen@owenstephens.co.uk \
    --cc=samo_pogacnik@t-2.net \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox