git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Jeff King <peff@peff.net>
To: Felipe Contreras <felipe.contreras@gmail.com>
Cc: git@vger.kernel.org
Subject: Re: Query for certain branches, but not the rest
Date: Tue, 27 Nov 2012 20:57:14 -0500	[thread overview]
Message-ID: <20121128015714.GB23776@sigill.intra.peff.net> (raw)
In-Reply-To: <CAMP44s02=E3imOv00dwyXR13nQdo1XeZTjJb_y0EVQoyYMEcQw@mail.gmail.com>

On Sun, Nov 25, 2012 at 10:24:59AM +0100, Felipe Contreras wrote:

> Suppose I have these branches:
> 
>   fc/feature-a
>   fc/feature-b
>   master
>   next
> 
> I want to show this: fc/feature-a fc/feature-b ^master ^next. I can do
> 'git log --branches=fc' to show the branches that begin with fc/, but
> there's no way to specify the rest. If they were under a prefix, I
> could do '--not --branches=prefix', but they are not.
> 
> Anybody knows a way to query branches that don't have any prefix?

I don't think there is a way. `--branches` can take a pattern (and there
is always `--glob`), but we do not pass FNM_PATHNAME to fnmatch, so "*"
will match across `/` boundaries.

You are stuck with:

  git log --branches=fc --not $(
    git for-each-ref --format='%(refname:short)' refs/heads |
    grep -v /
  )

which is at least robust due to the restrictions on refnames (i.e., no
whitespace).

As an aside, I noticed that:

  git log --branches=does-not-exist

will see that we matched no refs and fall back to showing HEAD. That
seems a bit surprising to me.

-Peff

      reply	other threads:[~2012-11-28  1:57 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-11-25  9:24 Query for certain branches, but not the rest Felipe Contreras
2012-11-28  1:57 ` Jeff King [this message]

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=20121128015714.GB23776@sigill.intra.peff.net \
    --to=peff@peff.net \
    --cc=felipe.contreras@gmail.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).