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

name-rev: anchor pattern without --exclude?

From
Kyle Meyer <kyle@kyleam.com>
Date
Jul 6, 2017, 16:53 UTC
Message-ID
<87k23ltsl6.fsf@kyleam.com>
Hello,

I'm trying to restrict name-rev's output to a ref whose name begins with the supplied pattern [*]. Looking at "man git-name-rev", builtin/name-rev.c, and wildmatch.c, I don't see a way to accomplish this with "--refs=<pattern>".

Say, for example, that I want to limit name-rev's output to a ref in the "refs/heads/" namespace.

    * cc8f7dc (master) c
    * ad6d6f0 b
    | * 49a2156 (refs/wip/wtree/refs/heads/master) d
    |/  
    * b91f97a a
    --------------------------------------------------
    $ git name-rev b91f97a
    b91f97a wip/wtree/refs/heads/master~1
    $ git name-rev --refs="refs/heads/*" b91f97a
    b91f97a wip/wtree/refs/heads/master~1
    $ git name-rev --refs="^refs/heads/*" b91f97a
    b91f97a undefined

Starting with v2.13.0, I can get my desired output using the --exclude option.

    $ git name-rev --refs="refs/heads/*" --exclude="*/refs/heads/*" b91f97a
    b91f97a master~2

But, unfortunately, I'm trying to find a solution that works with earlier Git versions (back to v1.9.4).

Am I overlooking a way to do this without the --exclude option?
[*] A bit more information on why I'm trying to do this: In Magit, we
    have a work-in-progress feature that takes "snapshots" of changes
    before they are committed.  These snapshots are stored as
    "refs/wip/{wtree,index}/<full refname>".
    We want to use name-rev to map a commit to a name in "refs/heads/",
    ignoring these snapshot refs.
-- 
Kyle
Next: Junio C Hamano
Message 1 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.