Skip to content

cat-file: do not die on reflog entries out of range

Caspar Duregger git 1 version New

Get series with b4
b4 am [email protected]

Versions newest first

  1. v1 Latest4 patches 0 repliesNew

Patches in v1 No applies recorded yet

#Subject and filesSizeRepliesApplied
1/4object-name: do not read a peel suffix as a reflog selectorobject-name.c t/t1508-at-combinations.sh+10 -00 replies
2/4object-name: let GET_OID_GENTLY affect only failing lookupsobject-name.c t/t3903-stash.sh+13 -50 replies
3/4refs: let read_ref_at() fail gently on an empty reflogobject-name.c refs.c refs.h +1 more+23 -40 replies
4/4cat-file: report out-of-range reflog entries as missingbuiltin/cat-file.c t/t1006-cat-file.sh+36 -00 replies

Reviews trailers per patch

No Reviewed-by, Acked-by or Tested-by trailers for v1 yet.

Read the v1 thread

Cover letter [PATCH 0/4] cat-file: do not die on reflog entries out of range

Hi,

I necropost with a patch as I stumbled on this the other day.

I have one "git cat-file --batch-check" process per worktree, but it dies on "ref@{N}" past the end of the reflog. I work around by using the old "git rev-parse" for these but it's sad.

Passing GET_OID_GENTLY from cat-file is the obvious fix, but on its own it would change answers, not only failures:

- "ref@{N}" for a reflog with N entries and "ref@{<old date>}" resolve today, but fail with GET_OID_GENTLY (patch 2, which picks up a review question from the series that added the flag [1]);

- "ref@{999999}^{tree}" would resolve to the current value of the ref instead of dying, because after the peel fails get_oid_basic() reads "999999}^{tree}" as an approxidate. The same bug already makes "git rev-parse --verify 'HEAD@{1}^{blob}'" print a commit (patch 1);

- an emptied reflog still dies inside read_ref_at() (patch 3).

Patch 4 then flips the flag in cat-file. As Peff noted, this does not make batch lookups die-free: "HEAD@{999999}~1" and "@{upstream}" on a detached HEAD still die. The former needs get_parent() and get_nth_ancestor() to pass flags down, which I left for a separate series.

[1] https://lore.kernel.org/git/[email protected]/

Caspar Duregger (4):
object-name: do not read a peel suffix as a reflog selector
object-name: let GET_OID_GENTLY affect only failing lookups
refs: let read_ref_at() fail gently on an empty reflog
cat-file: report out-of-range reflog entries as missing

 builtin/cat-file.c         |  1 +
 object-name.c              | 28 +++++++++++++++++++---------
 refs.c                     |  2 ++
 refs.h                     |  4 ++++
 t/t1006-cat-file.sh        | 35 +++++++++++++++++++++++++++++++++++
 t/t1508-at-combinations.sh |  4 ++++
 t/t3903-stash.sh           | 17 +++++++++++++++++
 7 files changed, 82 insertions(+), 9 deletions(-)
Signature · 1 line
2.56.1.windows.1