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

[Question] git rev-parse verify for non-existent object

From
ZheNing Hu <adlternative@gmail.com>
Date
Aug 2, 2023, 07:50 UTC
Message-ID
<CAOLTT8RvAbmS1SwFja8_+NSBBoL0gTH1RgpSN5CYtDWZscMYZA@mail.gmail.com>

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

Next: Christian Couder
Message 1 of 5 in “[Question] git rev-parse verify for non-existent object”
  1. ZheNing HuAug 2, 2023
  2. Christian CouderAug 2, 2023
  3. ZheNing HuAug 2, 2023
  4. Junio C HamanoAug 2, 2023
  5. ZheNing HuAug 3, 2023

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.