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

Re: [PATCH 2/2] branch: let branch filters imply --list

From
Peter Wu <lekensteyn@gmail.com>
Date
Jan 31, 2013, 16:13 UTC
Message-ID
<1504250.y8BAS4sG2O@al>
In-Reply-To
<20130131064611.GB25315@sigill.intra.peff.net>
On Thursday 31 January 2013 01:46:11 Jeff King wrote:
Show 26 quoted lines
> Currently, a branch filter like `--contains`, `--merged`, or
> `--no-merged` is ignored when we are not in listing mode.
> For example:
> 
>   git branch --contains=foo bar
> 
> will create the branch "bar" from the current HEAD, ignoring
> the `--contains` argument entirely. This is not very
> helpful. There are two reasonable behaviors for git here:
> 
>   1. Flag an error; the arguments do not make sense.
> 
>   2. Implicitly go into `--list` mode
> 
> This patch chooses the latter, as it is more convenient, and
> there should not be any ambiguity with attempting to create
> a branch; using `--contains` and not wanting to list is
> nonsensical.
> 
> That leaves the case where an explicit modification option
> like `-d` is given.  We already catch the case where
> `--list` is given alongside `-d` and flag an error. With
> this patch, we will also catch the use of `--contains` and
> other filter options alongside `-d`.
> 
> Signed-off-by: Jeff King <peff@peff.net>
Tested-by: Peter Wu <lekensteyn@gmail.com>
I have tested this patch on top of 1.8.1.2 and it seems to work.

One note, the following command spits out master without complaining about the non-existing branch name:

    git branch --contains <id> master <non-existant branch name>
(the order of branches doesn't affect the result.)

Regards, Peter

Previous: Jeff KingNext: Junio C Hamano
Message 9 of 11 in “[BUG] `git branch --contains ID name` creates branch "name"”
  1. Peter WuJan 30, 2013
  2. 0/2 improve "git branch --contains=<commit> <pattern>"Jeff King, Jan 31, 2013
  3. 1/2 docs: clarify git-branch --list behaviorJeff King, Jan 31, 2013
  4. Eric SunshineFeb 1, 2013
  5. Junio C HamanoFeb 1, 2013
  6. Jeff KingFeb 1, 2013
  7. Junio C HamanoFeb 1, 2013
  8. 2/2 branch: let branch filters imply --listJeff King, Jan 31, 2013
  9. Peter WuJan 31, 2013
  10. Junio C HamanoJan 31, 2013
  11. Junio C HamanoJan 31, 2013

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.