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

Re: rev-parse: -- is sometimes a flag and sometimes an arg?

From
brian m. carlson <sandals@crustytoothpaste.net>
Date
Aug 23, 2022, 00:51 UTC
Message-ID
<YwQki4nAEOp4wvv9@tapette.crustytoothpaste.net>
In-Reply-To
<xmqqzgfyh0vj.fsf@gitster.g>
On 2022-08-21 at 00:54:40, Junio C Hamano wrote:
Show 11 quoted lines
> Tim Hockin <thockin@google.com> writes:
> 
> > Sorry, I assumed it was clear, but that was dumb of me.
> >
> > I have a string - might be a tag name, might be a branch name, might
> > be a SHA (complete or partial).  I want to resolve that into a
> > canonical SHA.
> 
> "git rev-parse --verify string" would insist that 'string' is an
> object name and show it as an object name to the standard output, or
> gives an error message and exits with a non-zero status.

Note that this will print a full hex object ID whether it exists in the repo or not if one is given (for example, the all-zeros object ID). If you want to verify that the object exists, write this:

git rev-parse --verify string^{object}
-- 
brian m. carlson (he/him or they/them)
Toronto, Ontario, CA
Previous: Junio C HamanoNext: Tim Hockin
Message 7 of 8 in “rev-parse: -- is sometimes a flag and sometimes an arg?”
  1. Tim HockinAug 20, 2022
  2. Junio C HamanoAug 20, 2022
  3. Tim HockinAug 21, 2022
  4. Junio C HamanoAug 21, 2022
  5. Tim HockinAug 21, 2022
  6. Junio C HamanoAug 21, 2022
  7. brian m. carlsonAug 23, 2022
  8. Tim HockinAug 23, 2022

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.