git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* Odd .gitignore behaviour
@ 2007-11-15 12:49 Bruce Stephens
  2007-11-15 18:56 ` Linus Torvalds
  0 siblings, 1 reply; 8+ messages in thread
From: Bruce Stephens @ 2007-11-15 12:49 UTC (permalink / raw)
  To: git

Perhaps I'm misreading the manpage, but I think this is wrong:

    % mkdir base; cd base
    % git init
    % mkdir -p sub1/sub2
    % cd sub1
    % echo foo > .gitignore; echo '!sub2/foo' >> .gitignore
    % touch sub2/foo
    % git add sub2/foo
    The following paths are ignored by one of your .gitignore files:
    sub1/sub2/foo
    Use -f if you really want to add them.
    fatal: no files added

So sub1/sub2/foo matches the first pattern in sub1/.gitignore, but it
also matches the negated pattern '!sub2/foo' (in the same file, so
precedence isn't an issue).  And the manpage says

       o An optional prefix ! which negates the pattern; any matching
           file excluded by a previous pattern will become included
           again. If a negated pattern matches, this will override
           lower precedence patterns sources.

So surely sub1/sub2/foo ought to be included again?  Or is the first
line in sub1/.gitignore not "a previous pattern" in this sense?

If I move the "foo" pattern up a level, creating a .gitignore in base
just containing "foo", then sub1/sub2/foo is still regarded as
ignored, even though it surely matches the negating pattern
sub1/.gitignore, and that should be of higher precedence than the
pattern in base/.gitignore?

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

end of thread, other threads:[~2007-11-16 15:05 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2007-11-15 12:49 Odd .gitignore behaviour Bruce Stephens
2007-11-15 18:56 ` Linus Torvalds
2007-11-15 20:15   ` Bruce Stephens
2007-11-15 21:51     ` Junio C Hamano
2007-11-15 22:13       ` Junio C Hamano
2007-11-16  9:15       ` Fix per-directory exclude handing for "git add" Junio C Hamano
2007-11-16 13:50         ` Bruce Stephens
2007-11-16 15:05           ` Bruce Stephens

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 NNTP newsgroup(s).