From: Bruce Stephens <bruce.stephens@isode•com>
To: git@vger•kernel.org
Subject: Odd .gitignore behaviour
Date: Thu, 15 Nov 2007 12:49:21 +0000 [thread overview]
Message-ID: <80ir431xny.fsf@tiny.isode.net> (raw)
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?
next reply other threads:[~2007-11-15 12:49 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2007-11-15 12:49 Bruce Stephens [this message]
2007-11-15 18:56 ` Odd .gitignore behaviour 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
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=80ir431xny.fsf@tiny.isode.net \
--to=bruce.stephens@isode$(echo .)com \
--cc=git@vger$(echo .)kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox