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

Re: [PATCH] object-name: explain why <ref>~N fails in a shallow clone

From
D. Ben Knoble <ben.knoble@gmail.com>
Date
Sep 20, 2026, 21:59 UTC
Message-ID
<CALnO6CB6DSwPKffy2BBgBk3fhJZXrMaoZm-ScBwgvoGQn_cwMQ@mail.gmail.com>
In-Reply-To
<pull.2413.git.git.1789898013916.gitgitgadget@gmail.com>
[This is not a complete review, just something I noticed]

On Sun, Sep 20, 2026 at 5:55 AM Harald Nordgren via GitGitGadget <gitgitgadget@gmail.com> wrote:

Show 13 quoted lines
>
> From: Harald Nordgren <haraldnordgren@gmail.com>
>
> Asking for a commit's ancestor with <ref>~N or <ref>^N in a shallow
> clone that does not have N commits of history locally fails with a
> bare "is not a commit" error, with no indication that the repository
> being shallow is the reason, or what to do about it.
>
> Add a hint, shown when the walk runs out of parents exactly at a
> recorded shallow boundary, explaining that history was intentionally
> truncated there. When <ref> looks like <remote>/<branch> and <remote>
> is configured, the suggested command names that remote and branch
> directly.

Here, we mention the most common "ref" cases directly, and it might make sense to restrict this feature only to the use of refs (since we might need such a ref to unshallow via fetch?).

> For <ref>~N it suggests the exact --deepen needed,
> accounting for any history already present instead of just N. For
> <ref>^N the suggestion is always --deepen=1, regardless of N:
But here…
Show 15 quoted lines
> diff --git a/Documentation/config/advice.adoc b/Documentation/config/advice.adoc
> index 81f80a9274..5b44037fff 100644
> --- a/Documentation/config/advice.adoc
> +++ b/Documentation/config/advice.adoc
> @@ -128,6 +128,10 @@ all advice messages.
>                 give directions on how to proceed from the current state.
>         sequencerInUse::
>                 Shown when a sequencer command is already in progress.
> +       shallowHistory::
> +               Shown when `~<n>` or `^<n>` cannot resolve enough ancestors
> +               because history stops at a shallow boundary, to suggest
> +               fetching more history.
>         skippedCherryPicks::
>                 Shown when linkgit:git-rebase[1] skips a commit that has already
>                 been cherry-picked onto the upstream branch.

…and here, it's not clear to me what kinds of things trigger the hint. The "~N" and "^N" syntax work with any commit-ish, after all!

Either way, the hint documentation should probably not show "bare" "~N"/~^N", since that's not syntax accepted by Git. The gitrevisions(7) manual uses "<rev>~<n>" and "<rev>^[<n>]".

Perhaps you meant "rev" instead of "ref" in the commit message? Hm.
-- 
D. Ben Knoble
Previous: Harald Nordgren via GitGitGadgetNext: Junio C Hamano
Message 2 of 26 in “object-name: explain why <ref>~N fails in a shallow clone”
  1. object-name: explain why <ref>~N fails in a shallow cloneHarald Nordgren via GitGitGadget, Sep 20, 2026
  2. D. Ben KnobleSep 20, 2026
  3. Junio C HamanoSep 21, 2026
  4. Harald NordgrenSep 21, 2026
  5. Junio C HamanoSep 21, 2026
  6. shallow: advise when a walk stops at a shallow boundaryHarald Nordgren via GitGitGadget, Sep 22, 2026
  7. Junio C HamanoSep 22, 2026
  8. object-name: explain why <rev>~N fails in a shallow cloneHarald Nordgren via GitGitGadget, Sep 23, 2026
  9. Junio C HamanoNov 2, 2026
  10. Harald NordgrenNov 2, 2026
  11. Kristoffer HaugsbakkNov 2, 2026
  12. Harald NordgrenNov 2, 2026
  13. Patrick SteinhardtNov 2, 2026
  14. Kristoffer HaugsbakkNov 2, 2026
  15. Harald NordgrenNov 2, 2026
  16. Patrick SteinhardtNov 2, 2026
  17. Harald NordgrenNov 2, 2026
  18. Phillip WoodNov 2, 2026
  19. Harald NordgrenNov 2, 2026
  20. Junio C HamanoNov 2, 2026
  21. Junio C HamanoNov 2, 2026
  22. Kristoffer HaugsbakkNov 2, 2026
  23. Harald NordgrenNov 2, 2026
  24. Patrick SteinhardtNov 2, 2026
  25. Junio C HamanoNov 2, 2026
  26. Junio C HamanoNov 5, 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.