Git development
 help / color / mirror / Atom feed
From: Linus Torvalds <torvalds@osdl.org>
To: Sven Verdoolaege <skimo@liacs.nl>
Cc: git@vger.kernel.org
Subject: Re: rev-parse, unknown arguments and extended sha1's
Date: Fri, 24 Jun 2005 10:32:13 -0700 (PDT)	[thread overview]
Message-ID: <Pine.LNX.4.58.0506241026490.11175@ppc970.osdl.org> (raw)
In-Reply-To: <Pine.LNX.4.58.0506240941520.11175@ppc970.osdl.org>



On Fri, 24 Jun 2005, Linus Torvalds wrote:
> 
> Anyway, I think I'll make git-rev-parse have some option to "error out if 
> the result is anything but a single revision number", since this is really 
> the only reason for git-rev-parse in the first place: to make readable 
> scripts.

How about something like

	rev=$(git-rev-parse --default HEAD --revs-only --verify "$@") || exit 1

which now should work correctly.

In particular, the "--default" field is now expanded properly as a
revision, instead of just output raw, so the "HEAD" actually gets
translated into its SHA1 representation (and this also means that you can
now use SHA1 expressions in "default", ie you don't need to do two
git-rev-parse phases to do "--default HEAD^" etc).

The "--verify" thing then checks that the end result isn't a revision
argument (ie "--max-age=.." isn't accepted), and that there's exactly one
revision in the result (ie no ranges or multiple revisions some other
way).

So now you shouldn't need to check the result any more. You know that if
it worked, "rev" will be a nice SHA1 (of course, it might still be an
_invalid_ SHA1, that's a different issue. But it's at least syntactically
ok)

		Linus

      reply	other threads:[~2005-06-24 17:26 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2005-06-24 12:24 rev-parse, unknown arguments and extended sha1's Sven Verdoolaege
2005-06-24 16:09 ` Linus Torvalds
2005-06-24 16:17   ` Sven Verdoolaege
2005-06-24 16:43     ` Linus Torvalds
2005-06-24 17:32       ` Linus Torvalds [this message]

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=Pine.LNX.4.58.0506241026490.11175@ppc970.osdl.org \
    --to=torvalds@osdl.org \
    --cc=git@vger.kernel.org \
    --cc=skimo@liacs.nl \
    /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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox