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

Re: bug:git-check-ignore exit status is wrong for negative patterns when -v option used

From
JFJeremy Faith <jeremy.faith@jci.com>
Date
Apr 29, 2021, 14:10 UTC
Message-ID
<CY4P132MB00885F00AAA46BCFAC76881B855F9@CY4P132MB0088.NAMP132.PROD.OUTLOOK.COM>
In-Reply-To
<xmqqfszac25x.fsf@gitster.g>
Junio C Hamano <gitster@pobox.com> wrote:
 
>Jeremy Faith <jeremy.faith@jci.com> writes:
Show 10 quoted lines
>> git version 2.31.1.362.g311531c9de
>> git-check-ignore 
>> When a negative pattern is the last .gitignore match the -v option causes the exit status to be 0 rather than the expected 1.
>> e.g say .gitignore contains  one line: !hello
>> git check-ignore hello #outputs nothing
>> echo $?  #shows correct exit status=1 i.e None of the provided paths are ignored.
>> but
>> git check-ignore -v hello #output is next line
>> .gitignore:4:!hello   hello
>> echo $?  #shows wrong exit status=0 i.e. One or more of the provided paths is ignored
Show 7 quoted lines
>Hmph.  This is kind of understandable given the history of the
>command, which was *not* about programatically ask "is this path
>ignored?" question at all.  Instead, it was invented to answer this
>question: I am puzzled by the fact that Git considers this path is
>to be ignored (or "not to be ignored").  Show me which entry in what
>exclude file made the final decision to ignore (or "not to ignore")
>it to help me debug my ignore file(s).
>And the exit code was to signal "yes, I found a relevant entry",
>which made sense for the tool's nature as a debugging aid.
man git-check-ignore states:-
EXIT STATUS
-----------
0::
	One or more of the provided paths is ignored.
1::
	None of the provided paths are ignored.
128::
	A fatal error was encountered.
So my change matches what the manual states.
>So, I suspect that this is working as designed/intended.  I agree
>that it is debatable that the way it was designed to work is a good
>one, though.
I doubt that changing the exit status when -v is added is intended behaviour.
Previous: Junio C HamanoNext: Junio C Hamano
Message 5 of 9 in “bug:git-check-ignore exit status is wrong for negative patterns when -v option used”
  1. Jeremy FaithApr 27, 2021
  2. Bagas SanjayaApr 28, 2021
  3. Jeremy FaithApr 29, 2021
  4. Junio C HamanoApr 28, 2021
  5. Jeremy FaithApr 29, 2021
  6. Junio C HamanoApr 30, 2021
  7. Jeremy FaithApr 30, 2021
  8. Elijah NewrenApr 30, 2021
  9. Junio C HamanoMay 3, 2021

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.