All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Ντέντος Σταύρος" <stdedos@gmail.com>
To: git <git@vger.kernel.org>
Subject: No clear API/Error message to validate a "revision object" using git rev-parse
Date: Tue, 29 Jan 2019 11:25:18 +0200	[thread overview]
Message-ID: <CAHMHMxWpqTDyCQPXPY6WPeMBHFzYGE=Z0Q8pSL=9TecwuP9fwg@mail.gmail.com> (raw)

Hello there everyone,

Minor bug report:
I have a utility script to find "reference points" that contain a
commit (git-x-in-y)

The script needs to accept "any valid reference point", that includes
e.g. tags as well.
I validate said input by passing whatever argument through git rev-parse.

If the tag name is invalid, say:
$ git rev-parse version.3
version.3
fatal: ambiguous argument 'version.3': unknown revision or path not in
the working tree.
Use '--' to separate paths from revisions, like this:
'git <command> [<revision>...] -- [<file>...]'

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
--
$

A further leading argument, e.g. '' makes the situation worse:
$ git rev-parse version-0.false -- ''
d43292476ea9ab8c3d32940352b680549b64e8d8
--

$

`--verify`s error message is even more cryptic:
$ git rev-parse --verify version.3
fatal: Needed a single revision
$ git rev-parse --verify version-0.false
80f20b100cca5166b22cbcc1f4a6ac1eae64a0d0

Further attempts do not help either:
$  git rev-parse --revs-only version-3 ; echo $?
0
$

Am I writing the command wrong, or is there some part of it I don't understand?

Ntentos Stavros

             reply	other threads:[~2019-01-29  9:25 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-01-29  9:25 Ντέντος Σταύρος [this message]
2019-01-29 10:51 ` No clear API/Error message to validate a "revision object" using git rev-parse Christian Couder
2019-01-29 12:01   ` Ντέντος Σταύρος

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to='CAHMHMxWpqTDyCQPXPY6WPeMBHFzYGE=Z0Q8pSL=9TecwuP9fwg@mail.gmail.com' \
    --to=stdedos@gmail.com \
    --cc=git@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.