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 5, 2026, 20:34 UTC
Message-ID
<e8257951-4ea7-40ba-8043-f4f2a080b70b@web.de>
In-Reply-To
<2afd4a28a9a542f8baeab488cb0801d6b98adb0a.camel@t-2.net>
On 5/5/26 9:27 PM, Samo Pogačnik wrote:
> 
> Hi, thanks for pointing out this edge case. Would you care to check the
> following change (the provided test is also a bit modified):
There's spurious wrapping in the patch, but the changes look good to me.
Care to send them with a commit message and sign-off?
René
Show 16 quoted lines
> diff --git a/shallow.c b/shallow.c
> index a156006d88..ec95653132 100644
> --- a/shallow.c
> +++ b/shallow.c
> @@ -245,7 +245,11 @@ struct commit_list *get_shallow_commits(struct object_array
> *heads,
>                                         int depth, int shallow_flag, int
> not_shallow_flag)
>  {
>         if (shallows && deepen_relative) {
> -               depth += get_shallows_depth(heads, shallows);
> +               int cur_shallow_depth = get_shallows_depth(heads, shallows);
> +               if (cur_shallow_depth)
> +                       depth += cur_shallow_depth;
> +               else
> +                       return NULL;

Nice. get_shallows_depth() returns 0 on full clones; translating it to an empty list of shallow commits makes sense.

Show 18 quoted lines
>         }
>         return get_shallows_or_depth(heads, NULL, NULL,
>                                      depth, shallow_flag, not_shallow_flag);
> diff --git a/t/t5537-fetch-shallow.sh b/t/t5537-fetch-shallow.sh
> index 6588ce6226..9982dd2aa6 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 -C full-clone rev-parse --is-shallow-repository >expect &&
> +       git -C full-clone 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 &&

Using the exact same commands to prepare expect and actual creates a pleasant symmetry.

Show 6 quoted lines
> +       test_cmp expect actual
> +'
> +
>  . "$TEST_DIRECTORY"/lib-httpd.sh
>  start_httpd
> 
Previous: Samo PogačnikNext: Samo Pogačnik
Message 8 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.