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

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



> 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@xxxxxxxxx> wrote:
> Florian Hassanen <florian.hassanen@xxxxxxxxx> 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.
>
--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html




[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]