Re: RFC: what should git rev-parse --flags HEAD do?
- From
Junio C Hamano <gitster@pobox.com>
- Date
- Sep 25, 2010, 17:54 UTC
- Message-ID
- <7vfwwxogiv.fsf@alter.siamese.dyndns.org>
- In-Reply-To
- <AANLkTimEToibgpUS1KTSruFRdggi3kbAJU5tfk9r6d2U@mail.gmail.com>
Jon Seymour <jon.seymour@gmail.com> writes:
Show 10 quoted lines
> The documentation for git rev-parse --flags currently states: > > Do not output non-flag parameters. > > Therefore, one might expect: > $ git rev-parse --flags HEAD > > to produce no output. > > In fact, it outputs the sha1 hash of HEAD.
Perhaps you are missing --no-revs.
Linus wrote rev-parse to implement this in a shell script:
git log [other-options-and-args] [revision-traversal-options-and-args]
which needs to be transformed to:
git rev-list [revision-traversal-options-and-args] |
git diff-tree --stdin [other-options-and-args]so that it can parse "-p HEAD" with and without "--no-revs" to produce "HEAD" and "-p" respectively. It does so by knowing options that are relevant to rev-list invocation (shown by default, or --revs-only) and everything else (hidden when --no-revs is given).
"--flags" is an afterthought that filters out non-flags in other parts; I do not think it applied to the "rev" part (i.e. giving --no-revs at the same time would be a valid workaround if you know you do not want HEAD or any revision traversal argument) in any released version of git.