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

Re: BUG: "git branch --contains <commit> <name>" does nothing, silently fails

From
Ævar Arnfjörð Bjarmason <avarab@gmail.com>
Date
Mar 10, 2017, 13:23 UTC
Message-ID
<CACBZZX7Npivd9bSsA2_D1Xgk9Qjru00KbeNFRgNQUJ5_NBh3bA@mail.gmail.com>
In-Reply-To
<20170310124247.jvrmmcz2pbv4qf3o@sigill.intra.peff.net>
On Fri, Mar 10, 2017 at 1:42 PM, Jeff King <peff@peff.net> wrote:
Show 34 quoted lines
> On Fri, Mar 10, 2017 at 11:43:15AM +0100, Ævar Arnfjörð Bjarmason wrote:
>
>> Ran into this when preparing my --no-contains series, this is a long
>> standing bug:
>>
>>     $ ./git branch -D test; ./git branch --contains v2.8.0 test; echo
>> $?; git rev-parse test
>>     error: branch 'test' not found.
>>     0
>>     test
>>     fatal: ambiguous argument 'test': unknown revision or path not in
>> the working tree.
>
> Isn't that asking to list branches starting with "test" that contain
> v2.8.0? There are none to report (since you just made sure to delete
> it), so the empty output is correct.
>
>> I.e. this should return an error like "git tag" does:
>>
>>     $ ./git tag -d test; ./git tag --contains v2.8.0 test; echo $?;
>> git rev-parse test
>>     error: tag 'test' not found.
>>     fatal: --contains option is only allowed with -l.
>>     128
>>     test
>>     fatal: ambiguous argument 'test': unknown revision or path not in
>> the working tree.
>
> The difference between "branch" and "tag" here is that "branch
> --contains" implies "--list" (and the argument becomes a pattern).
> Whereas "tag --contains" just detects the situation and complains.
>
> If anything, I'd think we would consider teaching "tag" to behave more
> like "branch".
Yes you're right, sorry about the noise, e.g. this works:
    git branch --contains v2.8.0 'a*'
    git branch --contains v2.8.0 --list 'a*'
Whereas with "git tag" you always need -l as you point out.
Previous: Jeff KingNext: Ævar Arnfjörð Bjarmason
Message 3 of 11 in “BUG: "git branch --contains <commit> <name>" does nothing, silently fails”
  1. Ævar Arnfjörð BjarmasonMar 10, 2017
  2. Jeff KingMar 10, 2017
  3. Ævar Arnfjörð BjarmasonMar 10, 2017
  4. tag: Implicitly supply --list given another list-like optionÆvar Arnfjörð Bjarmason, Mar 11, 2017
  5. Ævar Arnfjörð BjarmasonMar 11, 2017
  6. Junio C HamanoMar 12, 2017
  7. Junio C HamanoMar 12, 2017
  8. Ævar Arnfjörð BjarmasonMar 12, 2017
  9. Junio C HamanoMar 12, 2017
  10. Ævar Arnfjörð BjarmasonMar 12, 2017
  11. Jeff KingMar 12, 2017

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.