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

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

From
Florian Hassanen <florian.hassanen@gmail.com>
Date
Dec 11, 2014, 23:40 UTC
Message-ID
<CAMAJHBZpLY_Rwdpuw6hruJwST_tgY1S02ZPt=ueKPXOXHREHxQ@mail.gmail.com>
In-Reply-To
<xmqqa92tdb80.fsf@gitster.dls.corp.google.com>
> It smells like you spotted a bug in the behaviour, not a bug in the
> documentation, at least to me.

At first I thought so as well :-) I even prepared a patch, just to find out, that existing tests specifically test for this "unintuitive" behavior.

Then I read the docs in more detail and found this:
  If the pattern contained a ! prefix or / suffix, it will be
preserved in the output.

So it seems there is indeed the intent to output patterns, even if they are negated/negative.

Another problem I see with providing "correct" behavior is this:

If I do a test for a non existant file, it cannot be decided whether I mean a file or a directory.

e.g.
having a gitignore with a single line
  dir/
which only ignores die _directory_ dir, but not the _file_ dir
the exit code for
  $ git check-ignore dir

could either be 0 or 1, depending on whether a _file_ named "dir" or a _directory_ named "dir" was meant.

I assume that the command is meant to get the applying entry of the gitignore and then its up to the consumer to provide additional logic to determine whether the path is actually ignored or not.

I am not sure what the correct behavior should be. And whether some code already depends on this command.

My personal preference, would be a behavior like

$ # regardless whether dir exists or not $ git check-ignore dir # a file is meant $ git check-ignore dir/ # a directory is mean

and the exit code should only depend on whether the file is actually
ignored or not
- and not if there is an arbitrary matching pattern in gitignore
PS: btw, the previously discussed gitignore file should have read
(note the order)
cat > .gitignore << EOF
*.o
!vendor.o
EOF

because always the last matching entry applies (so exceptions must come last) - but the exit codes are still the same

On Fri, Dec 12, 2014 at 12:21 AM, Junio C Hamano <gitster@pobox.com> wrote:
Show 14 quoted lines
> Florian Hassanen <florian.hassanen@gmail.com> writes:
>
>> Maybe your global ignore file gets in the way?
>
> No, as I do not have one.
>
>> is one of a.o and vendor.o already in your index?
>
> Bingo.  I did "git add ." to see if the .gitignore file is doing the
> right thing before running that demonstration.
>
> It smells like you spotted a bug in the behaviour, not a bug in the
> documentation, at least to me.
>
Previous: Junio C Hamano
Message 5 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.