git@vger.kernel.org mailing list mirror (one of many)
 help / color / mirror / code / Atom feed
* git check-ignore ignores negated entries
@ 2018-09-20 17:22 David Alphus
  2018-09-21 16:13 ` Duy Nguyen
  0 siblings, 1 reply; 2+ messages in thread
From: David Alphus @ 2018-09-20 17:22 UTC (permalink / raw)
  To: git

If a .gitignore contains a ! entry, git check-ignore will still say
the matching file is ignored if the file is not in the index.

Simple case to reproduce:

$ git init .
$ echo "*.c" > .gitignore
$ echo '!a.c' >> .gitignore
$ touch a.c b.c
$ git check-ignore a.c b.c
a.c
b.c
$ git add *.c
The following paths are ignored by one of your .gitignore files:
b.c
Use -f if you really want to add them.
$ git check-ignore a.c b.c
b.c
$ git check-ignore --no-index a.c b.c
a.c
b.c
$ git check-ignore --no-index --verbose a.c b.c
.gitignore:2:!a.c       a.c
.gitignore:1:*.c        b.c

In looking through check-ignore.c, it appears that we check that
last_exclude_matching() returns an exclude object. It should be noted
that we do not consider that exclude struct can be set with the
EXC_FLAG_NEGATIVE flag. This flag says that the final matching rule
should not be ignored.
check_ignore needs to consider this condition in order to work properly.

^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: git check-ignore ignores negated entries
  2018-09-20 17:22 git check-ignore ignores negated entries David Alphus
@ 2018-09-21 16:13 ` Duy Nguyen
  0 siblings, 0 replies; 2+ messages in thread
From: Duy Nguyen @ 2018-09-21 16:13 UTC (permalink / raw)
  To: david.alphus; +Cc: Git Mailing List

On Thu, Sep 20, 2018 at 7:25 PM David Alphus <david.alphus@gmail.com> wrote:
> In looking through check-ignore.c, it appears that we check that
> last_exclude_matching() returns an exclude object. It should be noted
> that we do not consider that exclude struct can be set with the
> EXC_FLAG_NEGATIVE flag. This flag says that the final matching rule
> should not be ignored.
> check_ignore needs to consider this condition in order to work properly.

I haven't checked the code yet. But since you already did, patches are
welcome ;-)
-- 
Duy

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2018-09-21 16:13 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-09-20 17:22 git check-ignore ignores negated entries David Alphus
2018-09-21 16:13 ` Duy Nguyen

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