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

Re: [BUG] in rev-parse

From
Jeff King <peff@peff.net>
Date
Dec 14, 2011, 21:01 UTC
Message-ID
<20111214210157.GA8990@sigill.intra.peff.net>
In-Reply-To
<20111214184926.GB18335@llunet.cs.wisc.edu>
On Wed, Dec 14, 2011 at 12:49:27PM -0600, nathan.panike@gmail.com wrote:
Show 12 quoted lines
> In my local git.git:
> 
> $ git rev-parse 73c6b3575bc638b7096ec913bd91193707e2265d^@
> 57526fde5df201a99afa6d122c3266b3a1c5673a
> 942e6baa92846e5628752c65a22bc4957d8de4d0
> 
> $ git rev-parse --short 73c6b3575bc638b7096ec913bd91193707e2265d^@
> 57526fd
> 942e6ba
> fatal: Needed a single revision
> 
> ^^^ I don't believe this "fatal" message should be here

It looks like "--short" implies "--verify", and you cannot "--verify" multiple sha1s.

But the documentation for "--short" says only:
  --short::
  --short=number::
          Instead of outputting the full SHA1 values of object names try to
          abbreviate them to a shorter unique name. When no length is specified
          7 is used. The minimum length is 4.

which would imply to me that not only should your example work, but this should, too:

  $ git rev-parse HEAD HEAD^
  803b1a83b0ec5f04dfb770e83e11211e0015630f
  28c2058b6048d32abc0a23b827ab0b26a0332b9b
  $ git rev-parse --short HEAD HEAD^
  fatal: Needed a single revision

On the other hand, it has been like this since it was introduced in 2006, and I wonder if scripts rely on the --verify side effect.

As a work-around, you can get what you want with:
  git rev-list --no-walk --abbrev-commit $sha1^@
-Peff
Previous: nathan.panike@gmail.comNext: Junio C Hamano
Message 2 of 7 in “[BUG] in rev-parse”
  1. nathan.panike@gmail.comDec 14, 2011
  2. Jeff KingDec 14, 2011
  3. Junio C HamanoDec 15, 2011
  4. Jeff KingDec 15, 2011
  5. Junio C HamanoDec 15, 2011
  6. Michael HaggertyDec 15, 2011
  7. Jeff KingDec 17, 2011

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.