git@vger.kernel.org mailing list mirror (one of many)
 help / color / mirror / code / Atom feed
From: Jeremy Faith <jeremy.faith@jci.com>
To: Junio C Hamano <gitster@pobox.com>
Cc: "git@vger.kernel.org" <git@vger.kernel.org>
Subject: Re: bug:git-check-ignore exit status is wrong for negative patterns when -v option used
Date: Thu, 29 Apr 2021 14:10:05 +0000	[thread overview]
Message-ID: <CY4P132MB00885F00AAA46BCFAC76881B855F9@CY4P132MB0088.NAMP132.PROD.OUTLOOK.COM> (raw)
In-Reply-To: <xmqqfszac25x.fsf@gitster.g>

Junio C Hamano <gitster@pobox.com> wrote:
 
>Jeremy Faith <jeremy.faith@jci.com> writes:

>> 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

>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.

  reply	other threads:[~2021-04-29 14:10 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-04-27 16:30 bug:git-check-ignore exit status is wrong for negative patterns when -v option used Jeremy Faith
2021-04-28  6:15 ` Bagas Sanjaya
2021-04-29 14:26   ` Jeremy Faith
2021-04-28  7:13 ` Junio C Hamano
2021-04-29 14:10   ` Jeremy Faith [this message]
2021-04-30  0:22     ` Junio C Hamano
2021-04-30  9:56       ` Jeremy Faith
2021-04-30 20:51         ` Elijah Newren
2021-05-03  3:09         ` 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

  List information: http://vger.kernel.org/majordomo-info.html

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=CY4P132MB00885F00AAA46BCFAC76881B855F9@CY4P132MB0088.NAMP132.PROD.OUTLOOK.COM \
    --to=jeremy.faith@jci.com \
    --cc=git@vger.kernel.org \
    --cc=gitster@pobox.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.
Code repositories for project(s) associated with this public inbox

	https://80x24.org/mirrors/git.git

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 read-only IMAP folder(s) and NNTP newsgroup(s).