From: Jeff King <peff@peff.net>
To: Peter Wu <lekensteyn@gmail.com>
Cc: git@vger.kernel.org
Subject: [PATCH 0/2] improve "git branch --contains=<commit> <pattern>"
Date: Thu, 31 Jan 2013 01:43:57 -0500 [thread overview]
Message-ID: <20130131064357.GA24660@sigill.intra.peff.net> (raw)
In-Reply-To: <679787987.uZRbjA7AMj@al>
On Wed, Jan 30, 2013 at 07:57:03PM +0100, Peter Wu wrote:
> Hi,
>
> I was trying to check whether a certain branch contained a commit and ran:
>
> git branch --contains ddc150f7a33ae0c9cb16eaac3641abc00f56316f master
>
> This resulted in:
>
> fatal: A branch named 'master' already exists.
> When "name" does not exist, this command creates a branch. I expect this
> command to search the mentioned branch, not trying to create it. The manual
> page of git-branch(1) does not mention such special behavior either.
Yeah, it's sort-of a bug. It is a syntactic ambiguity that an argument
to git-branch could be a listing pattern or a new branch name. When
using a listing pattern, you need to explicitly specify that you want
list mode with `--list`. This is documented in git-branch under --list,
but it should be more prominent, in the section that covers the various
invocation modes. The first patch below fixes that.
That being said, we could be much more helpful. It seems like --contains
should imply listing mode, since it is nonsensical in other modes. The
second patch below adjusts that, and makes the command above do what you
expect.
[1/2]: docs: clarify git-branch --list behavior
[2/2]: branch: let branch filters imply --list
-Peff
next prev parent reply other threads:[~2013-01-31 6:44 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-01-30 18:57 [BUG] `git branch --contains ID name` creates branch "name" Peter Wu
2013-01-31 6:43 ` Jeff King [this message]
2013-01-31 6:45 ` [PATCH 1/2] docs: clarify git-branch --list behavior Jeff King
2013-02-01 0:20 ` Eric Sunshine
2013-02-01 0:37 ` Junio C Hamano
2013-02-01 5:06 ` Jeff King
2013-02-01 5:42 ` Junio C Hamano
2013-01-31 6:46 ` [PATCH 2/2] branch: let branch filters imply --list Jeff King
2013-01-31 16:13 ` Peter Wu
2013-01-31 17:02 ` Junio C Hamano
2013-01-31 15:53 ` [PATCH 0/2] improve "git branch --contains=<commit> <pattern>" Junio C Hamano
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=20130131064357.GA24660@sigill.intra.peff.net \
--to=peff@peff.net \
--cc=git@vger.kernel.org \
--cc=lekensteyn@gmail.com \
/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).