Re: No clear API/Error message to validate a "revision object" using git rev-parse
- Date: Tue, 29 Jan 2019 11:51:29 +0100
- From: Christian Couder <christian.couder@xxxxxxxxx>
- Subject: Re: No clear API/Error message to validate a "revision object" using git rev-parse
On Tue, Jan 29, 2019 at 10:30 AM Ντέντος Σταύρος <stdedos@xxxxxxxxx> wrote:
> 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 --
Yeah, it looks like a bug to me.
> A further leading argument, e.g. '' makes the situation worse:
> $ git rev-parse version-0.false -- ''
> `--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
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
This also works correctly.
$ git rev-parse --verify v2.2.0 --
also works correctly.