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

Re: "git tag --contains <id>" is too chatty, if <id> is invalid

From
Chirayu Desai <chirayudesai1@gmail.com>
Date
Mar 24, 2016, 17:22 UTC
Message-ID
<CAJj6+1Fvei-iv3QgP+P8o-0XqxOFVPL=DP6GOa1VKEx04VfGUg@mail.gmail.com>
In-Reply-To
<20160323224113.GB12531@sigill.intra.peff.net>
On Thu, Mar 24, 2016 at 4:11 AM, Jeff King <peff@peff.net> wrote:
Show 14 quoted lines
> On Sun, Mar 20, 2016 at 12:19:46PM +0530, Chirayu Desai wrote:
>
>> I went for 3, and have sent a patch for that here - [PATCH/GSoC]
>> parse-options: Add a new nousage opt
>> However, it currently has one bug
>> Running 'git tag --contains qq' twice will first show an error, then
>> print qq, meaning that the first command creates the tag qq.
>> Running 'git tag -l --contains qq' works fine.
>> My first question is if 'git tag --contains' (without '-l') supposed to work?
>> If not, then I would fix that bug, otherwise fix the bug my code
>> introduced, and add tests for it.
>
> Yes, "--contains" should imply "-l", and we should complain if there is
> an attempt to create a tag.
Right, makes sense.
Show 27 quoted lines
>
> This seems to work with the tip of "master":
>
>   $ git tag --contains v2.8.0-rc3
>   v2.8.0-rc3
>   v2.8.0-rc4
>
>   $ git tag --contains qq
>   error: malformed object name qq
>   [...and then the usage...]
>
>   $ git tag --contains HEAD qq
>   fatal: --contains option is only allowed with -l.
>
>   $ git rev-parse --verify qq
>   fatal: Needed a single revision
>
> but with your patch:
>
>   $ git tag --contains qq
>   error: malformed object name qq
>
>   $ git rev-parse --verify qq
>   e9cacb7f8231dd6616671f9bcdd0945043483064
>
> So presumably we're not aborting the program when the options fail to
> parse, and it continues to process the "qq" as a tag to be created.

Yep, it was because I was returning PARSE_OPT_DONE on case -3 in parse-options.c::parse_options_step Making it return -1 fixed that.

>
> -Peff
Thank you for the help, detailed explanations and code reviews.
Previous: Jeff KingNext: Junio C Hamano
Message 9 of 10 in “Re: "git tag --contains <id>" is too chatty, if <id> is invalid”
  1. Chirayu DesaiMar 19, 2016
  2. Pranit BauvaMar 19, 2016
  3. Chirayu DesaiMar 19, 2016
  4. Jeff KingMar 19, 2016
  5. Chirayu DesaiMar 19, 2016
  6. Jeff KingMar 19, 2016
  7. Chirayu DesaiMar 20, 2016
  8. Jeff KingMar 23, 2016
  9. Chirayu DesaiMar 24, 2016
  10. Junio C HamanoMar 20, 2016

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.