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

Re: [PATCH] git-check-ignore.txt: Clarify exit codes

From
Junio C Hamano <gitster@pobox.com>
Date
Dec 11, 2014, 23:01 UTC
Message-ID
<xmqqiohhdc5j.fsf@gitster.dls.corp.google.com>
In-Reply-To
<1418323355-23935-1-git-send-email-florian.hassanen@gmail.com>
Florian Hassanen <florian.hassanen@gmail.com> writes:
> check-ignore disregards whether a path is matched by a
> positive or negative pattern. Thus for a file that is _not_
> ignored, but is captured by negative pattern in .gitignore,
> the exit code is 0. The docs suggested otherwise.

I am not sure that is the actual behaviour of the command. Given this .gitignore file:

    $ cat .gitignore; echo END
    !vendor.o
    *.o
    END

which is designed to allow binary-only blob "vendor.o" supplied by the vendor to be tracked, but to ignore all the other usual build artifacts, you see this:

    $ for o in a.o vendor.o; do git check-ignore $o >/dev/null; echo $?; done
    0
    1
Puzzled...
Show 34 quoted lines
>
> Clarify docs to explain that only the match matters, not
> whether the path is actually ignored or not.
>
> Signed-off-by: Florian Hassanen <florian.hassanen@gmail.com>
> ---
> Today when working with the check-ignore command, I misunderstood
> the docs into thinking, that I could use check-ignore's exit code
> to determine, whether a file is ignored or not - but this is not
> how the exit code works :(
> Here is a suggestion, on how to update the docs to describe the 
> exit code's behavior more clearly.
>
>  Documentation/git-check-ignore.txt | 5 +++--
>  1 file changed, 3 insertions(+), 2 deletions(-)
>
> diff --git a/Documentation/git-check-ignore.txt b/Documentation/git-check-ignore.txt
> index ee2e091..bdd8b7c 100644
> --- a/Documentation/git-check-ignore.txt
> +++ b/Documentation/git-check-ignore.txt
> @@ -97,10 +97,11 @@ EXIT STATUS
>  -----------
>  
>  0::
> -	One or more of the provided paths is ignored.
> +	At least one of the provided paths matches some (possibly negative)
> +	pattern.
>  
>  1::
> -	None of the provided paths are ignored.
> +	None of the provided paths match any pattern.
>  
>  128::
>  	A fatal error was encountered.
Previous: Florian HassanenNext: Florian Hassanen
Message 2 of 5 in “git-check-ignore.txt: Clarify exit codes”
  1. git-check-ignore.txt: Clarify exit codesFlorian Hassanen, Dec 11, 2014
  2. Junio C HamanoDec 11, 2014
  3. Florian HassanenDec 11, 2014
  4. Junio C HamanoDec 11, 2014
  5. Florian HassanenDec 11, 2014

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.