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

Re: name-rev: anchor pattern without --exclude?

From
Bryan Turner <bturner@atlassian.com>
Date
Jul 6, 2017, 18:02 UTC
Message-ID
<CAGyf7-HiwR+CDtDCvQ7q9Dd_TYfvN0133UOYTO65F=4qOHqy9w@mail.gmail.com>
In-Reply-To
<87h8yptr7t.fsf@kyleam.com>
On Thu, Jul 6, 2017 at 10:23 AM, Kyle Meyer <kyle@kyleam.com> wrote:
Show 11 quoted lines
> Junio C Hamano <gitster@pobox.com> writes:
>> Kyle Meyer <kyle@kyleam.com> writes:
>
>> What is the answer desired by your application when two or more
>> branches point at the same commit you are interested in?  Pick one at
>> random?  An error saying it cannot decide where to place the snapshot?
>
> Our use of name-rev is just to get a friendly name for a hash.  If two
> branches point to the same commit, we're fine with whatever decision
> "git name-rev" makes; we just want to limit it to refs in the
> "refs/heads/" namespace.

If you don't need the ancestor traversals "git name-rev" provides, "git for-each-ref --count 1 --format "%(refname:short)" --points-at <hash> refs/heads/" might work. That only goes back to Git 2.7.0, though; still quite a ways off your 1.9 target. ("git branch --points-at" does the same thing, I should add, and only for branches, but you can't directly limit its output like you can with "for-each-ref".. Perhaps that doesn't matter for your use case.) If you want names like "master~2", from your example, though, "--points-at" won't do what you need.

Bryan
>
> --
> Kyle
Previous: Kyle MeyerNext: Kyle Meyer
Message 4 of 5 in “name-rev: anchor pattern without --exclude?”
  1. Kyle MeyerJul 6, 2017
  2. Junio C HamanoJul 6, 2017
  3. Kyle MeyerJul 6, 2017
  4. Bryan TurnerJul 6, 2017
  5. Kyle MeyerJul 6, 2017

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.