All of lore.kernel.org
 help / color / mirror / Atom feed
From: Kyle Meyer <kyle@kyleam.com>
To: git@vger.kernel.org
Subject: name-rev: anchor pattern without --exclude?
Date: Thu, 06 Jul 2017 12:53:25 -0400	[thread overview]
Message-ID: <87k23ltsl6.fsf@kyleam.com> (raw)

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

             reply	other threads:[~2017-07-06 16:53 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-07-06 16:53 Kyle Meyer [this message]
2017-07-06 17:03 ` name-rev: anchor pattern without --exclude? Junio C Hamano
2017-07-06 17:23   ` Kyle Meyer
2017-07-06 18:02     ` Bryan Turner
2017-07-06 18:26       ` Kyle Meyer

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=87k23ltsl6.fsf@kyleam.com \
    --to=kyle@kyleam.com \
    --cc=git@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.