# RFC: what should git rev-parse --flags HEAD do?

4 messages from 2010-09-25 to 2010-09-25. Participants: Jon Seymour, Junio C Hamano.
Thread: https://gitlist.dev/t/25239

## Jon Seymour, 2010-09-25 10:11

Subject: RFC: what should git rev-parse --flags HEAD do?
Message-ID: <AANLkTimEToibgpUS1KTSruFRdggi3kbAJU5tfk9r6d2U@mail.gmail.com>
URL: https://gitlist.dev/e/AANLkTimEToibgpUS1KTSruFRdggi3kbAJU5tfk9r6d2U%40mail.gmail.com

```
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.

Can anyone see a reason why git rev-parse --flags should not be
modified to match the documentation?

If there is agreement that this should change, I can re-roll my
current rev-parse series to include such a change.

jon.

```

## Junio C Hamano, 2010-09-25 17:54

Subject: Re: RFC: what should git rev-parse --flags HEAD do?
Message-ID: <7vfwwxogiv.fsf@alter.siamese.dyndns.org>
URL: https://gitlist.dev/e/7vfwwxogiv.fsf%40alter.siamese.dyndns.org
In-Reply-To: <AANLkTimEToibgpUS1KTSruFRdggi3kbAJU5tfk9r6d2U@mail.gmail.com>

```
Jon Seymour <jon.seymour@gmail.com> writes:

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

```

## Jon Seymour, 2010-09-25 19:38

Subject: Re: RFC: what should git rev-parse --flags HEAD do?
Message-ID: <AANLkTikW=4NiZ_jCq6geqta_XHiWJPUhWvvEtJ1Q3G9S@mail.gmail.com>
URL: https://gitlist.dev/e/AANLkTikW%3D4NiZ_jCq6geqta_XHiWJPUhWvvEtJ1Q3G9S%40mail.gmail.com
In-Reply-To: <7vfwwxogiv.fsf@alter.siamese.dyndns.org>

```
On Sun, Sep 26, 2010 at 3:54 AM, Junio C Hamano <gitster@pobox.com> wrote:
>
> Perhaps you are missing --no-revs.
> ...

> "--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.
>

i am aware that --no-revs exists and can be used with --flags to
ensure that only flag arguments are displayed.

The issue is that the documentation currently implies that --flags
alone is sufficient to suppress anything that is not a flag when this
is not, in fact, the case.

If there is some reason --flags should not imply --no-revs, then the
documentation should be updated to state:

--flags::

```

## Jon Seymour, 2010-09-25 19:46

Subject: Re: RFC: what should git rev-parse --flags HEAD do?
Message-ID: <AANLkTim65zQp5Et2YQqk2ZZTuW-Dr0fJph+-8YZ0fDzw@mail.gmail.com>
URL: https://gitlist.dev/e/AANLkTim65zQp5Et2YQqk2ZZTuW-Dr0fJph%2B-8YZ0fDzw%40mail.gmail.com
In-Reply-To: <7vfwwxogiv.fsf@alter.siamese.dyndns.org>

```
On Sun, Sep 26, 2010 at 3:54 AM, Junio C Hamano <gitster@pobox.com> wrote:
>
> Perhaps you are missing --no-revs.
> ...

> "--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.
>

i am aware that --no-revs exists and can be used with --flags to
ensure that only flag arguments are displayed.

The issue is that the documentation currently implies that --flags
alone is sufficient to suppress anything that is not a flag when this
is not, in fact, the case.  To wit:

--flags::
       Do not output any non-flag parameters.

This is simply not accurate, given the current implementation.

If there is some reason --flags should not imply --no-revs, then the
documentation should be updated to state:

--flags::
       Do not output any non-flag parameters (unless the parameter
also specifies a revision). To output only the flag parameters,
specify --no-revs as well.

jon.

```
