Git development
 help / color / mirror / Atom feed
* [Question] git rev-parse verify for non-existent object
@ 2023-08-02  7:50 ZheNing Hu
  2023-08-02 10:24 ` Christian Couder
  0 siblings, 1 reply; 5+ messages in thread
From: ZheNing Hu @ 2023-08-02  7:50 UTC (permalink / raw)
  To: Git List; +Cc: Junio C Hamano, Taylor Blau, Linus Torvalds, Christian Couder

In my case, I often need to use "git rev-parse --verify" to verify
if a revision exists in the repository, and this usually works:

git rev-parse --verify HEAD
afa5ff0f56bc60d1c9abe839726e7fb2105a9ca3

git rev-parse --verify afa5ff0f56bc60d1c9abe839726e7fb2105a9ca3
afa5ff0f56bc60d1c9abe839726e7fb2105a9ca3

git rev-parse --verify aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
fatal: Needed a single revision

However, when I started checking for a non-existent OID that happened
to be exactly 40 characters long, something unexpected happened.
 "git rev-parse --verify" did not produce any error messages.
I consider this to be a BUG.

git rev-parse --verify aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa

I understand that using "git cat-file --batch-check="%(objectname)"
may be a potential solution, but I currently do not want to do it because
it would require significant changes and I am unsure if the behavior
would be consistent.

The simplest solution for me would be to fix "git rev-parse --verify".
What do you all think?

--
ZheNing Hu

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

end of thread, other threads:[~2023-08-03  6:16 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-08-02  7:50 [Question] git rev-parse verify for non-existent object ZheNing Hu
2023-08-02 10:24 ` Christian Couder
2023-08-02 13:03   ` ZheNing Hu
2023-08-02 16:32     ` Junio C Hamano
2023-08-03  6:16       ` ZheNing Hu

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