{"thread":{"id":"16757","subject":"git ignore","startedAt":"2008-12-16T22:43:00Z","lastAt":"2011-07-08T18:39:30Z","messageCount":7,"participants":["Max Power","Linus Torvalds","Junio C Hamano","Michael J Gruber","Stephen Haberman"],"isPatch":false,"patchVersion":null,"patchTotal":null},"messages":[{"id":"98084","messageId":"21043430.post@talk.nabble.com","threadId":"16757","inReplyTo":null,"subject":"git ignore","fromName":"Max Power","fromEmail":"mkwright@gmail.com","sentAt":"2008-12-16T22:43:00Z","receivedAt":"2008-12-16T22:43:00Z","isPatch":false,"sender":{"key":"mkwright@gmail.com","avatar":null},"body":"\nSo I understand how to use the .gitignore file to ignore specific\nfiles/directories that I put in there... is there a way to ignore everything\nBUT a given file extension? \n-- \nView this message in context: http://www.nabble.com/git-ignore-tp21043430p21043430.html\nSent from the git mailing list archive at Nabble.com.\n"},{"id":"98086","messageId":"alpine.LFD.2.00.0812161450010.14014@localhost.localdomain","threadId":"16757","inReplyTo":"21043430.post@talk.nabble.com","subject":"Re: git ignore","fromName":"Linus Torvalds","fromEmail":"torvalds@linux-foundation.org","sentAt":"2008-12-16T22:53:07Z","receivedAt":"2008-12-16T22:53:07Z","isPatch":false,"sender":{"key":"torvalds@linux-foundation.org","avatar":"https://avatars.githubusercontent.com/u/1024025?v=4"},"body":"\n\nOn Tue, 16 Dec 2008, Max Power wrote:\n> \n> So I understand how to use the .gitignore file to ignore specific\n> files/directories that I put in there... is there a way to ignore everything\n> BUT a given file extension? \n\nSomething like\n\n\t*\n\t!*.jpg\n\nto only save the jpegs in your pr0n collection?\n\nThe first rule says \"ignore everything\". The second one says \"don't \nignore *.jpg files\".\n\nUntested. \n\n\t\tLinus\n"},{"id":"98087","messageId":"7viqpjra57.fsf@gitster.siamese.dyndns.org","threadId":"16757","inReplyTo":"alpine.LFD.2.00.0812161450010.14014@localhost.localdomain","subject":"Re: git ignore","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2008-12-16T23:08:20Z","receivedAt":"2008-12-16T23:08:20Z","isPatch":false,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Linus Torvalds <torvalds@linux-foundation.org> writes:\n\n> On Tue, 16 Dec 2008, Max Power wrote:\n>> \n>> So I understand how to use the .gitignore file to ignore specific\n>> files/directories that I put in there... is there a way to ignore everything\n>> BUT a given file extension? \n>\n> Something like\n>\n> \t*\n> \t!*.jpg\n>\n> to only save the jpegs in your pr0n collection?\n\nHmm, do people still keep p0rn collection in jpgs?  I somehow had an\nimpression that they moved to avis ;-)\n\n> The first rule says \"ignore everything\". The second one says \"don't \n> ignore *.jpg files\".\n>\n> Untested. \n\nt3001-ls-files-others-exclude.sh has some tests but there is nothing that\nexplicitly tests overlapping patterns.  Perhaps it should (hint, hint...)\n\n\"man gitignore\" documentation has an example to ignore all *.html files\nbut not foo.html using a similar construct, i.e.\n\n\t*.html\n        !foo.html\n"},{"id":"98265","messageId":"1229620278-25152-1-git-send-email-git@drmicha.warpmail.net","threadId":"16757","inReplyTo":"7viqpjra57.fsf@gitster.siamese.dyndns.org","subject":"[PATCH] test overlapping ignore patterns","fromName":"Michael J Gruber","fromEmail":"git@drmicha.warpmail.net","sentAt":"2008-12-18T17:11:18Z","receivedAt":"2008-12-18T17:11:18Z","isPatch":true,"sender":{"key":"git@grubix.eu","avatar":"https://avatars.githubusercontent.com/u/233215?v=4"},"body":"Add a test which checks that negated patterns such as \"!foo.html\" can\noverride previous patterns such as \"*.html\". This is documented\nbehaviour but had not been tested so far.\n\nSigned-off-by: Michael J Gruber <git@drmicha.warpmail.net>\n---\n t/t3001-ls-files-others-exclude.sh |    6 ++++++\n 1 files changed, 6 insertions(+), 0 deletions(-)\n\ndiff --git a/t/t3001-ls-files-others-exclude.sh b/t/t3001-ls-files-others-exclude.sh\nindex 8666946..85aef12 100755\n--- a/t/t3001-ls-files-others-exclude.sh\n+++ b/t/t3001-ls-files-others-exclude.sh\n@@ -140,4 +140,10 @@ test_expect_success 'trailing slash in exclude forces directory match (2)' '\n \n '\n \n+test_expect_success 'negated exclude matches can override previous ones' '\n+\n+\tgit ls-files --others --exclude=\"a.*\" --exclude=\"!a.1\" >output &&\n+\tgrep \"^a.1\" output\n+'\n+\n test_done\n-- \n1.6.1.rc1\n"},{"id":"170980","messageId":"1310062372893-6559395.post@n2.nabble.com","threadId":"16757","inReplyTo":"1229620278-25152-1-git-send-email-git@drmicha.warpmail.net","subject":"Re: [PATCH] test overlapping ignore patterns","fromName":"Stephen Haberman","fromEmail":"stephen@exigencecorp.com","sentAt":"2011-07-07T18:12:52Z","receivedAt":"2011-07-07T18:12:52Z","isPatch":true,"sender":{"key":"stephen@exigencecorp.com","avatar":"https://gravatar.com/avatar/23b93ad70a06ce53505f17ddba65176edbcfb6588e7a4c1a2dca04aaf0a6aff1?d=mp&s=160"},"body":"\n> Add a test which checks that negated patterns such as \"!foo.html\" can \n> override previous patterns such as \"*.html\". This is documented \n> behaviour but had not been tested so far. \n\nNegated excludes with a pattern does not seem to work with sub directories,\ne.g. the following test fails for me.\n\nThe file /one/two/a.1 exists, and is initially excluded by *, but not\nre-included by \"!*.1\" (where as /a.1 is re-included).\n\ndiff --git i/t/t3001-ls-files-others-exclude.sh\nw/t/t3001-ls-files-others-exclude.sh\nindex c8fe978..e6c86ff 100755\n--- i/t/t3001-ls-files-others-exclude.sh\n+++ w/t/t3001-ls-files-others-exclude.sh\n@@ -175,6 +175,12 @@ test_expect_success 'negated exclude matches can\noverride previous ones' '\n  grep \"^a.1\" output\n '\n \n+test_expect_success 'negated exclude matches can override previous ones 2'\n'\n+\n+ git ls-files --others --exclude=\"*\" --exclude=\"!*.1\" >output &&\n+ grep \"^one/two/a.1\" output\n+'\n+\n\n(Replying to this old thread via nabble; hopefully it works.)\n\n- Stephen\n\n\n--\nView this message in context: http://git.661346.n2.nabble.com/git-ignore-tp1665336p6559395.html\nSent from the git mailing list archive at Nabble.com.\n"},{"id":"171017","messageId":"7vk4bsfy8c.fsf@alter.siamese.dyndns.org","threadId":"16757","inReplyTo":"1310062372893-6559395.post@n2.nabble.com","subject":"Re: [PATCH] test overlapping ignore patterns","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2011-07-08T18:01:23Z","receivedAt":"2011-07-08T18:01:23Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Stephen Haberman <stephen@exigencecorp.com> writes:\n\n> +test_expect_success 'negated exclude matches can override previous ones 2'\n> '\n> +\n> + git ls-files --others --exclude=\"*\" --exclude=\"!*.1\" >output &&\n> + grep \"^one/two/a.1\" output\n> +'\n\nDoes this has anything to do with \"negated overrides\"?\n\nDoesn't the first \"*\" tells us to not to look at the contents of one/\ndirectory at all, so we that we do not have to waste time descending into\nit?  We wouldn't even know what pathnames are underneath it, so \"!*.1\"\nwould not have any effect inside one/ at all, I think.\n"},{"id":"171018","messageId":"20110708133930.04b04a49@sh9","threadId":"16757","inReplyTo":"7vk4bsfy8c.fsf@alter.siamese.dyndns.org","subject":"Re: [PATCH] test overlapping ignore patterns","fromName":"Stephen Haberman","fromEmail":"stephen@exigencecorp.com","sentAt":"2011-07-08T18:39:30Z","receivedAt":"2011-07-08T18:39:30Z","isPatch":true,"sender":{"key":"stephen@exigencecorp.com","avatar":"https://gravatar.com/avatar/23b93ad70a06ce53505f17ddba65176edbcfb6588e7a4c1a2dca04aaf0a6aff1?d=mp&s=160"},"body":"\n> Doesn't the first \"*\" tells us to not to look at the contents of one/\n> directory at all, so we that we do not have to waste time descending\n> into it?  We wouldn't even know what pathnames are underneath it, so\n> \"!*.1\" would not have any effect inside one/ at all, I think.\n\nIf that's the way the feature should work, that's fine.\n\nI came across this thread via google referencing Linus's post from 2008\nwhich mentioned versioning only jpg files. I want to do the same sort of\nthing, but with a directory hierarchy.\n\nIf I say \"exclude *.jpg\" in my root .gitignore file, that applies into\nsub directories, so I just assumed \"exclude !*.jpg\" would also apply to\nsub directories.\n\nAm I missing another way to accomplish this?\n\nI understand from an implementation perspective, skipping all\nsubdirectories when you see \"exlude *\" is a smart thing to do, but\nperhaps it should only be done if there are no negative excludes that\ncould bring items back into play?\n\nThanks,\nStephen\n"}]}