git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: [PATCH 2/3] name-rev: strip trailing ^0 in when --name-only

From
Junio C Hamano <gitster@pobox.com>
Date
Jul 7, 2013, 18:16 UTC
Message-ID
<7vd2qu44mm.fsf@alter.siamese.dyndns.org>
In-Reply-To
<1373200996-9753-3-git-send-email-artagnon@gmail.com>
Ramkumar Ramachandra <artagnon@gmail.com> writes:
Show 17 quoted lines
> 236157 (Teach git-describe how to run name-rev, 2007-05-21) introduced
> `git name-rev --name-only`, with the intent of using it to implement
> `git describe --contains`.  According to the message, one of the primary
> objectives of --name-only was to make the output of name-rev match that
> of describe.
>
>   $ git describe --contains --all master
>   master
>
>   $ git describe --contains --all master~1
>   master~1
>
>   $ git describe --contains --all v1.8.3~1
>   v1.8.3~1
>
>   $ git describe --contains --all v1.8.3
>   v1.8.3^0
WRT "describe --contains", I do agree that both of these
    $ git describe $(git rev-parse v1.8.3^0)
    $ git describe --contains $(git rev-parse v1.8.3^0)
        
should just say "v1.8.3" without ~0/^0/~0~0~0 etc. and the last
example you showed will be improved by dropping ^0 at the end.
However.

I was a bit bothered by the description talking _only_ about describe, but the actual change is to modify what name-rev gives its direct users as well. And that made me realize that the patch itself has an undesirable side effect.

"describe" is _only_ about commit history graph, so in its context v1.8.3 means the same thing as v1.8.3^0 (we never want to get a tag; we always want a commit). But I do not think "name-rev" is limited to commits, in the sense that you would see this:

    $ git rev-parse v1.8.3 v1.8.3^0 | git name-rev --stdin
    8af06057d0c31a24e8737ae846ac2e116e8bafb9
    edca4152560522a431a51fc0a06147fc680b5b18 (tags/v1.8.3^0)

The second object is _not_ v1.8.3 but is v1.8.3^0 in the context of name-rev, whose purpose is to give you a string you can feed "rev-parse" and get the object name back. "rev-parse v1.8.3" will not give you the commit object name, so you need to keep "^0".

Previous: Ramkumar RamachandraNext: Junio C Hamano
Message 6 of 10 in “Iron output of describe --contains --all”
  1. 0/3 Iron output of describe --contains --allRamkumar Ramachandra, Jul 7, 2013
  2. 1/3 name-rev: fix assumption about --name-only usageRamkumar Ramachandra, Jul 7, 2013
  3. Junio C HamanoJul 7, 2013
  4. Ramkumar RamachandraJul 8, 2013
  5. 2/3 name-rev: strip trailing ^0 in when --name-onlyRamkumar Ramachandra, Jul 7, 2013
  6. Junio C HamanoJul 7, 2013
  7. Junio C HamanoJul 7, 2013
  8. Ramkumar RamachandraJul 8, 2013
  9. 3/3 name-rev doc: rewrite --stdin paragraphRamkumar Ramachandra, Jul 7, 2013
  10. Junio C HamanoJul 7, 2013

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.