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

Re: No clear API/Error message to validate a "revision object" using git rev-parse

From
Christian Couder <christian.couder@gmail.com>
Date
Jan 29, 2019, 10:51 UTC
Message-ID
<CAP8UFD0eQ0hPkd-wsNR8e0hQSJC+dUQatvV1xgdJOUxtXYqC_g@mail.gmail.com>
In-Reply-To
<CAHMHMxWpqTDyCQPXPY6WPeMBHFzYGE=Z0Q8pSL=9TecwuP9fwg@mail.gmail.com>
Hi,
On Tue, Jan 29, 2019 at 10:30 AM Ντέντος Σταύρος <stdedos@gmail.com> wrote:
Show 12 quoted lines
> So, I follow the recommendation to add '--', since I know that I won't
> be adding any paths:
>
> $ git rev-parse version.3 --
> fatal: bad revision 'version.3'
>
> However, what happens with the correct tags is, I get the trailing
> double dash in:
> $  git rev-parse version-0.false --
> d43292476ea9ab8c3d32940352b680549b64e8d8
> --
> $
Yeah, it looks like a bug to me.
Show 6 quoted lines
> A further leading argument, e.g. '' makes the situation worse:
> $ git rev-parse version-0.false -- ''
> d43292476ea9ab8c3d32940352b680549b64e8d8
> --
>
> $
This also.
> `--verify`s error message is even more cryptic:
> $ git rev-parse --verify version.3
> fatal: Needed a single revision
Yeah, but it works.

The error message could perhaps be improved. On the other hand it has been the same for a very very long time and very few people complained about it.

As you are writing a script, you can at least easily redirect it to /dev/null and output something else.

In fact as `git rev-parse` is a "plumbing command" it's supposed to be used mostly by scripts and power user who can easily deal with such an error message, which explains why there has not been much incentive to change this error message.

> $ git rev-parse --verify version-0.false
> 80f20b100cca5166b22cbcc1f4a6ac1eae64a0d0
This also works correctly.
And:

$ git rev-parse --verify v2.2.0 -- 74d2a8cf12bf102a8cedaf66736503bb3fe88dfb $

also works correctly.

Best, Christian.

Previous: Ντέντος ΣταύροςNext: Ντέντος Σταύρος
Message 2 of 3 in “No clear API/Error message to validate a "revision object" using git rev-parse”
  1. Ντέντος ΣταύροςJan 29, 2019
  2. Christian CouderJan 29, 2019
  3. Ντέντος ΣταύροςJan 29, 2019

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.