Web lists-archives.com

name-rev: anchor pattern without --exclude?




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