{"thread":{"id":"4170","subject":"\"git add $ignored_file\" fail","startedAt":"2006-05-16T22:07:08Z","lastAt":"2006-05-17T23:20:27Z","messageCount":18,"participants":["Santi","Linus Torvalds","Jakub Narebski","Johannes Schindelin","Pavel Roskin","Sean","Junio C Hamano"],"isPatch":false,"patchVersion":null,"patchTotal":null},"messages":[{"id":"20082","messageId":"8aa486160605161507w3a27152dq@mail.gmail.com","threadId":"4170","inReplyTo":null,"subject":"\"git add $ignored_file\" fail","fromName":"Santi","fromEmail":"sbejar@gmail.com","sentAt":"2006-05-16T22:07:08Z","receivedAt":"2006-05-16T22:07:08Z","isPatch":false,"sender":{"key":"santi@agolina.net","avatar":null},"body":"Hi *,\n\n      When you try to add ignored files with the git-add command it\nfails because the call to:\n\ngit-ls-files -z \\\n        --exclude-from=\"$GIT_DIR/info/exclude\" \\\n        --others --exclude-per-directory=.gitignore\n\n      does not output this file because it is ignored. I know I can do it with:\n\ngit-update-index --add $ignored_file\n\nI understand the behaviour of git-ls-files but I think it is no the\nexpected for git-add, at least for me.\n\n    Thanks\n\n    Santi\n"},{"id":"20085","messageId":"Pine.LNX.4.64.0605161526210.16475@g5.osdl.org","threadId":"4170","inReplyTo":"8aa486160605161507w3a27152dq@mail.gmail.com","subject":"Re: \"git add $ignored_file\" fail","fromName":"Linus Torvalds","fromEmail":"torvalds@osdl.org","sentAt":"2006-05-16T22:28:09Z","receivedAt":"2006-05-16T22:28:09Z","isPatch":false,"sender":{"key":"torvalds@linux-foundation.org","avatar":"https://avatars.githubusercontent.com/u/1024025?v=4"},"body":"\n\nOn Wed, 17 May 2006, Santi wrote:\n> \n>      When you try to add ignored files with the git-add command it\n> fails because the call to:\n> \n> git-ls-files -z \\\n>        --exclude-from=\"$GIT_DIR/info/exclude\" \\\n>        --others --exclude-per-directory=.gitignore\n> \n>      does not output this file because it is ignored. I know I can do it with:\n> \n> git-update-index --add $ignored_file\n> \n> I understand the behaviour of git-ls-files but I think it is no the\n> expected for git-add, at least for me.\n\nWell, the thing is, git-add doesn't really take a \"file name\", it takes a \nfilename _pattern_.\n\nClearly we can't add everything that matches the pattern, because one \ncommon case is to add a whole subdirectory, and thus clearly the \n.gitignore file must override the pattern.\n\nSo it's consistent that it overrides it also for a single filename case, \nno?\n\n\t\tLinus\n"},{"id":"20087","messageId":"e4dkes$8e7$1@sea.gmane.org","threadId":"4170","inReplyTo":"Pine.LNX.4.64.0605161526210.16475@g5.osdl.org","subject":"Re: \"git add $ignored_file\" fail","fromName":"Jakub Narebski","fromEmail":"jnareb@gmail.com","sentAt":"2006-05-16T22:41:34Z","receivedAt":"2006-05-16T22:41:34Z","isPatch":false,"sender":{"key":"jnareb@gmail.com","avatar":"https://avatars.githubusercontent.com/u/2706?v=4"},"body":"Linus Torvalds wrote:\n\n> Well, the thing is, git-add doesn't really take a \"file name\", it takes a \n> filename _pattern_.\n> \n> Clearly we can't add everything that matches the pattern, because one \n> common case is to add a whole subdirectory, and thus clearly the \n> .gitignore file must override the pattern.\n> \n> So it's consistent that it overrides it also for a single filename case, \n> no?\n\nWell, if shell expansion cannot find a file matching pattern, it uses\npattern as file name literaly.\n\nIt would be nice to have easy (git core porcelain level) way to add files\nwhich match ignore pattern.\n\n-- \nJakub Narebski\nWarsaw, Poland\n"},{"id":"20088","messageId":"8aa486160605161542u704ccf03w@mail.gmail.com","threadId":"4170","inReplyTo":"Pine.LNX.4.64.0605161526210.16475@g5.osdl.org","subject":"Re: \"git add $ignored_file\" fail","fromName":"Santi","fromEmail":"sbejar@gmail.com","sentAt":"2006-05-16T22:42:25Z","receivedAt":"2006-05-16T22:42:25Z","isPatch":false,"sender":{"key":"santi@agolina.net","avatar":null},"body":"2006/5/17, Linus Torvalds <torvalds@osdl.org>:\n>\n>\n> On Wed, 17 May 2006, Santi wrote:\n> >\n> >      When you try to add ignored files with the git-add command it\n> > fails because the call to:\n> >\n> > git-ls-files -z \\\n> >        --exclude-from=\"$GIT_DIR/info/exclude\" \\\n> >        --others --exclude-per-directory=.gitignore\n> >\n> >      does not output this file because it is ignored. I know I can do it with:\n> >\n> > git-update-index --add $ignored_file\n> >\n> > I understand the behaviour of git-ls-files but I think it is no the\n> > expected for git-add, at least for me.\n>\n> Well, the thing is, git-add doesn't really take a \"file name\", it takes a\n> filename _pattern_.\n>\n> Clearly we can't add everything that matches the pattern, because one\n> common case is to add a whole subdirectory, and thus clearly the\n> .gitignore file must override the pattern.\n>\n> So it's consistent that it overrides it also for a single filename case,\n> no?\n>\n\nIt's consistent from an implementation point of view, but not from the\n(my?) user point of view. This is why I say I understand it for\ngit-ls-files. For the case of git-add even the usage and the man page\ntalk about <file>...\n\nClearly for the case of a whole subdirectory, or even \".\",  the\n.gitignore file must override the pattern, but not for the case of a\npattern that is a single existing file.\n\nSanti\n"},{"id":"20134","messageId":"Pine.LNX.4.63.0605171306400.19012@wbgn013.biozentrum.uni-wuerzburg.de","threadId":"4170","inReplyTo":"8aa486160605161542u704ccf03w@mail.gmail.com","subject":"Re: \"git add $ignored_file\" fail","fromName":"Johannes Schindelin","fromEmail":"johannes.schindelin@gmx.de","sentAt":"2006-05-17T11:08:58Z","receivedAt":"2006-05-17T11:08:58Z","isPatch":false,"sender":{"key":"johannes.schindelin@gmx.de","avatar":"https://avatars.githubusercontent.com/u/127790?v=4"},"body":"\n\nOn Wed, 17 May 2006, Santi wrote:\n\n> 2006/5/17, Linus Torvalds <torvalds@osdl.org>:\n> > \n> > \n> > On Wed, 17 May 2006, Santi wrote:\n> > >\n> > >      When you try to add ignored files with the git-add command it\n> > > fails [...]\n> > >\n> > [...]\n> >\n> > So it's consistent that it overrides it also for a single filename case,\n> > no?\n> > \n> \n> It's consistent from an implementation point of view, but not from the\n> (my?) user point of view.\n\nSo, you told git to ignore the file. And then you say \"please add it\". I \nfind it highly consistent that git does not do anything, because *you* \ndecided it should ignore it in the first place.\n\nCiao,\nDscho\n"},{"id":"20139","messageId":"8aa486160605170641p2ab8704o@mail.gmail.com","threadId":"4170","inReplyTo":"81b0412b0605170604i689a8f7axa5aeb7752dc72072@mail.gmail.com","subject":"Re: \"git add $ignored_file\" fail","fromName":"Santi","fromEmail":"sbejar@gmail.com","sentAt":"2006-05-17T13:41:05Z","receivedAt":"2006-05-17T13:41:05Z","isPatch":false,"sender":{"key":"santi@agolina.net","avatar":null},"body":"2006/5/17, Alex Riesen <raa.lkml@gmail.com>:\n> On 5/17/06, Johannes Schindelin <Johannes.Schindelin@gmx.de> wrote:\n> > >\n> > > It's consistent from an implementation point of view, but not from the\n> > > (my?) user point of view.\n> >\n> > So, you told git to ignore the file. And then you say \"please add it\". I\n> > find it highly consistent that git does not do anything, because *you*\n> > decided it should ignore it in the first place.\n> >\n>\n> Well, he didn't say to ignore exactly this file. And Santi didn't know\n> git-add uses git-ls-files here. So it actually is unexpected for a novice.\n> It was unexpected for me too, until I looked into git-add.sh\n>\n\nActually I'm not a novice, but that is the point.\n\nIn the other way, now I find the value of being able to say:\n\n$ git add t*\n\nand be sure that it does not add an ignored file. Unfortunately\ngit-add cannot distinguish between both. So what I propose is to\ndocument it explicitly, something like:\n\ndiff --git a/Documentation/git-add.txt /Documentation/git-add.txt\nindex 5e31129..42f1e33 100644\n--- a/Documentation/git-add.txt\n+++ b/Documentation/git-add.txt\n@@ -7,18 +7,20 @@ git-add - Add files to the index file\n\n SYNOPSIS\n --------\n-'git-add' [-n] [-v] [--] <file>...\n+'git-add' [-n] [-v] [--] <filespec>...\n\n DESCRIPTION\n -----------\n A simple wrapper for git-update-index to add files to the index,\n for people used to do \"cvs add\".\n\n+It only adds non-ignored files, to add ignored files use\n+\"git-update-index --add\".\n\n OPTIONS\n -------\n-<file>...::\n-       Files to add to the index.\n+<filespec>...::\n+       Files to add to the index (see git-ls-files).\n\n -n::\n         Don't actually add the file(s), just show if they exist.\ndiff --git a/git-add.sh b/git-add.sh\nindex d6a4bc7..394793f 100755\n--- a/git-add.sh\n+++ b/git-add.sh\n@@ -1,6 +1,6 @@\n #!/bin/sh\n\n-USAGE='[-n] [-v] <file>...'\n+USAGE='[-n] [-v] <filespec>...'\n SUBDIRECTORY_OK='Yes'\n . git-sh-setup\n"},{"id":"20140","messageId":"e4f9eo$b60$1@sea.gmane.org","threadId":"4170","inReplyTo":"8aa486160605170641p2ab8704o@mail.gmail.com","subject":"Re: \"git add $ignored_file\" fail","fromName":"Jakub Narebski","fromEmail":"jnareb@gmail.com","sentAt":"2006-05-17T13:46:04Z","receivedAt":"2006-05-17T13:46:04Z","isPatch":false,"sender":{"key":"jnareb@gmail.com","avatar":"https://avatars.githubusercontent.com/u/2706?v=4"},"body":"Santi wrote:\n\n> In the other way, now I find the value of being able to say:\n> \n> $ git add t*\n> \n> and be sure that it does not add an ignored file. Unfortunately\n> git-add cannot distinguish between both.\n\nWell, it could. If 'git add <filespec>' would result in NO files \nadded, take <filespec> as literate <file> (filename), regardless\nof ignores.\n\n-- \nJakub Narebski\nWarsaw, Poland\n"},{"id":"20141","messageId":"Pine.LNX.4.63.0605171546350.1522@wbgn013.biozentrum.uni-wuerzburg.de","threadId":"4170","inReplyTo":"8aa486160605170641p2ab8704o@mail.gmail.com","subject":"Re: \"git add $ignored_file\" fail","fromName":"Johannes Schindelin","fromEmail":"johannes.schindelin@gmx.de","sentAt":"2006-05-17T13:48:09Z","receivedAt":"2006-05-17T13:48:09Z","isPatch":false,"sender":{"key":"johannes.schindelin@gmx.de","avatar":"https://avatars.githubusercontent.com/u/127790?v=4"},"body":"Hi,\n\nOn Wed, 17 May 2006, Santi wrote:\n\n> In the other way, now I find the value of being able to say:\n> \n> $ git add t*\n> \n> and be sure that it does not add an ignored file. Unfortunately\n> git-add cannot distinguish between both. So what I propose is to\n> document it explicitly, something like:\n> \n> [...]\n\nHow about a \"--force\" AKA \"-f\" flag that overrides the ignore file?\n\nI would implement it if I had time, but I am gone for three days in about \n1 minute :-(\n\nCiao,\nDscho\n"},{"id":"20148","messageId":"Pine.LNX.4.64.0605170747280.10823@g5.osdl.org","threadId":"4170","inReplyTo":"8aa486160605170641p2ab8704o@mail.gmail.com","subject":"Re: \"git add $ignored_file\" fail","fromName":"Linus Torvalds","fromEmail":"torvalds@osdl.org","sentAt":"2006-05-17T14:49:03Z","receivedAt":"2006-05-17T14:49:03Z","isPatch":false,"sender":{"key":"torvalds@linux-foundation.org","avatar":"https://avatars.githubusercontent.com/u/1024025?v=4"},"body":"\n\nOn Wed, 17 May 2006, Santi wrote:\n> \n> In the other way, now I find the value of being able to say:\n> \n> $ git add t*\n\nExactly. The shell will expand the path, so the fact that the path exists \non the command line does not mean that \"git add\" should just trust it.\n\n> and be sure that it does not add an ignored file. Unfortunately\n> git-add cannot distinguish between both. So what I propose is to\n> document it explicitly, something like:\n\nDocumenting this more clearly (and the workaround of forcing it with \n\"git-update-index --add\" by hand) is certainly a good idea.\n\n\t\t\tLinus\n"},{"id":"20172","messageId":"1147893786.16654.5.camel@dv","threadId":"4170","inReplyTo":"e4f9eo$b60$1@sea.gmane.org","subject":"Re: \"git add $ignored_file\" fail","fromName":"Pavel Roskin","fromEmail":"proski@gnu.org","sentAt":"2006-05-17T19:23:06Z","receivedAt":"2006-05-17T19:23:06Z","isPatch":false,"sender":{"key":"proski@gnu.org","avatar":null},"body":"On Wed, 2006-05-17 at 15:46 +0200, Jakub Narebski wrote:\n> Santi wrote:\n> \n> > In the other way, now I find the value of being able to say:\n> > \n> > $ git add t*\n> > \n> > and be sure that it does not add an ignored file. Unfortunately\n> > git-add cannot distinguish between both.\n> \n> Well, it could. If 'git add <filespec>' would result in NO files \n> added, take <filespec> as literate <file> (filename), regardless\n> of ignores.\n\nCan we apply the ignore rules to the directories but not the files?\n\nThis way, \"git-add *\" would add all files (rarely a good idea), whereas \n\"git-add .\" would respect the ignore rules.\n\nKludgy as it is, this approach would generally produce more expected\nresults than others.  If you let the shell expand the pattern, expect\nall junk to be added.  If you let git expand the pattern, expect it to\nadhere to the ignore rules.\n\n-- \nRegards,\nPavel Roskin\n"},{"id":"20176","messageId":"BAYC1-PASMTP12920BE00C27B0CF31CB9FAEA10@CEZ.ICE","threadId":"4170","inReplyTo":"1147893786.16654.5.camel@dv","subject":"Re: \"git add $ignored_file\" fail","fromName":"Sean","fromEmail":"seanlkml@sympatico.ca","sentAt":"2006-05-17T19:39:03Z","receivedAt":"2006-05-17T19:39:03Z","isPatch":false,"sender":{"key":"seanlkml@sympatico.ca","avatar":"https://gravatar.com/avatar/f92923f54fc08c401fc59b71829d4b89e9b8087fbba45ff87c82e6a83aee02ae?d=mp&s=160"},"body":"On Wed, 17 May 2006 15:23:06 -0400\nPavel Roskin <proski@gnu.org> wrote:\n\n> Can we apply the ignore rules to the directories but not the files?\n> \n> This way, \"git-add *\" would add all files (rarely a good idea), whereas \n> \"git-add .\" would respect the ignore rules.\n> \n> Kludgy as it is, this approach would generally produce more expected\n> results than others.  If you let the shell expand the pattern, expect\n> all junk to be added.  If you let git expand the pattern, expect it to\n> adhere to the ignore rules. \n\nShouldn't git just always respect the ignore rules?  Forcing someone to\nremove a file from the .gitignore or employ the other work around\nmentioned earlier doesn't seem too bad.  How often are people adding\nfiles that are explicitly ignored?\n\nSean\n"},{"id":"20177","messageId":"e4fuu3$vv$1@sea.gmane.org","threadId":"4170","inReplyTo":"BAYC1-PASMTP12920BE00C27B0CF31CB9FAEA10@CEZ.ICE","subject":"Re: \"git add $ignored_file\" fail","fromName":"Jakub Narebski","fromEmail":"jnareb@gmail.com","sentAt":"2006-05-17T19:52:41Z","receivedAt":"2006-05-17T19:52:41Z","isPatch":false,"sender":{"key":"jnareb@gmail.com","avatar":"https://avatars.githubusercontent.com/u/2706?v=4"},"body":"Sean wrote:\n\n\n> Shouldn't git just always respect the ignore rules?  Forcing someone to\n> remove a file from the .gitignore [...]\n\nOr adding exclude rule (!filename) for specific file to .gitignore.\n\n-- \nJakub Narebski\nWarsaw, Poland\n"},{"id":"20178","messageId":"1147895816.30618.6.camel@dv","threadId":"4170","inReplyTo":"20060517153903.6b896fdd.seanlkml@sympatico.ca","subject":"Re: \"git add $ignored_file\" fail","fromName":"Pavel Roskin","fromEmail":"proski@gnu.org","sentAt":"2006-05-17T19:56:56Z","receivedAt":"2006-05-17T19:56:56Z","isPatch":false,"sender":{"key":"proski@gnu.org","avatar":null},"body":"On Wed, 2006-05-17 at 15:39 -0400, Sean wrote:\n> On Wed, 17 May 2006 15:23:06 -0400\n> Pavel Roskin <proski@gnu.org> wrote:\n> \n> Shouldn't git just always respect the ignore rules?  Forcing someone to\n> remove a file from the .gitignore or employ the other work around\n> mentioned earlier doesn't seem too bad.  How often are people adding\n> files that are explicitly ignored?\n\nThat's a good idea!  And the implementation should be easy - if the file\nis present, but git-ls-file doesn't show it, tell the user to\nadjust .gitignore or to use some flag like --force.\n\nLibification of git-ls-files would allow even more precise messages.\n\n-- \nRegards,\nPavel Roskin\n"},{"id":"20183","messageId":"Pine.LNX.4.64.0605171325200.10823@g5.osdl.org","threadId":"4170","inReplyTo":"1147895816.30618.6.camel@dv","subject":"Re: \"git add $ignored_file\" fail","fromName":"Linus Torvalds","fromEmail":"torvalds@osdl.org","sentAt":"2006-05-17T20:26:32Z","receivedAt":"2006-05-17T20:26:32Z","isPatch":false,"sender":{"key":"torvalds@linux-foundation.org","avatar":"https://avatars.githubusercontent.com/u/1024025?v=4"},"body":"\n\nOn Wed, 17 May 2006, Pavel Roskin wrote:\n\n> On Wed, 2006-05-17 at 15:39 -0400, Sean wrote:\n> > On Wed, 17 May 2006 15:23:06 -0400\n> > Pavel Roskin <proski@gnu.org> wrote:\n> > \n> > Shouldn't git just always respect the ignore rules?  Forcing someone to\n> > remove a file from the .gitignore or employ the other work around\n> > mentioned earlier doesn't seem too bad.  How often are people adding\n> > files that are explicitly ignored?\n> \n> That's a good idea!  And the implementation should be easy - if the file\n> is present, but git-ls-file doesn't show it, tell the user to\n> adjust .gitignore or to use some flag like --force.\n\nUmm. That's exactly the semantics for \"git add\" right now. We _always_ \nrespect the ignore rules.\n\nThat was what people were complaining about.\n\nAlthough I think Santi realized why we do it, and isn't even complaining \nany more. \n\nSo we're all good again.\n\n\t\tLinus\n"},{"id":"20184","messageId":"e4g1f4$anv$1@sea.gmane.org","threadId":"4170","inReplyTo":"Pine.LNX.4.64.0605171325200.10823@g5.osdl.org","subject":"Re: \"git add $ignored_file\" fail","fromName":"Jakub Narebski","fromEmail":"jnareb@gmail.com","sentAt":"2006-05-17T20:35:55Z","receivedAt":"2006-05-17T20:35:55Z","isPatch":false,"sender":{"key":"jnareb@gmail.com","avatar":"https://avatars.githubusercontent.com/u/2706?v=4"},"body":"Linus Torvalds wrote:\n\n> On Wed, 17 May 2006, Pavel Roskin wrote:\n\n>> [...] implementation should be easy - if the file\n>> is present, but git-ls-file doesn't show it, tell the user to\n>> adjust .gitignore or to use some flag like --force.\n> \n> Umm. That's exactly the semantics for \"git add\" right now. We _always_ \n> respect the ignore rules.\n> \n> That was what people were complaining about.\n> \n> Although I think Santi realized why we do it, and isn't even complaining \n> any more. \n> \n> So we're all good again.\n\nThe changes in docummentation are nice and dandy, but it would be even nicer\nif \"git add\" told us about \"git update-index --add\" when it adds no files,\nas it is certainly the case when something is wrong (perhaps user\nexpectations, but still...).\n\n-- \nJakub Narebski\nWarsaw, Poland\n"},{"id":"20185","messageId":"Pine.LNX.4.64.0605171342370.10823@g5.osdl.org","threadId":"4170","inReplyTo":"e4g1f4$anv$1@sea.gmane.org","subject":"Re: \"git add $ignored_file\" fail","fromName":"Linus Torvalds","fromEmail":"torvalds@osdl.org","sentAt":"2006-05-17T20:53:09Z","receivedAt":"2006-05-17T20:53:09Z","isPatch":false,"sender":{"key":"torvalds@linux-foundation.org","avatar":"https://avatars.githubusercontent.com/u/1024025?v=4"},"body":"\n\nOn Wed, 17 May 2006, Jakub Narebski wrote:\n> \n> The changes in docummentation are nice and dandy, but it would be even nicer\n> if \"git add\" told us about \"git update-index --add\" when it adds no files,\n> as it is certainly the case when something is wrong (perhaps user\n> expectations, but still...).\n\nWell, with the new-and-improved builtin \"git add\", you could probably do \nsomething like the appended (on top of my most recent patch).\n\nIt says\n\n\tNo added files - did you perhaps mean to do a 'git update-index'?\n\nwhenever it finds that \"git add\" has ignored a file and not actually added \nanything. That, btw, can happen either because it refused to see the file \nin the first place (ie it was ignored), or because all the files listed \nwere already added.\n\nIn both cases the warning may or may not be sensible.\n\nAnyway, I dunno. I don't have any strong opinions on this.\n\n\t\tLinus\n\n---\ndiff --git a/builtin-add.c b/builtin-add.c\nindex 82e8f44..8641137 100644\n--- a/builtin-add.c\n+++ b/builtin-add.c\n@@ -12,6 +12,8 @@ #include \"dir.h\"\n static const char builtin_add_usage[] =\n \"git-add [-n] [-v] <filepattern>...\";\n \n+static int ignored;\n+\n static int common_prefix(const char **pathspec)\n {\n \tconst char *path, *slash, *next;\n@@ -123,8 +125,10 @@ static void prune_directory(struct dir_s\n \n \t\t/* Existing file? We must have ignored it */\n \t\tmatch = pathspec[i];\n-\t\tif (!lstat(match, &st))\n+\t\tif (!lstat(match, &st)) {\n+\t\t\tignored = 1;\n \t\t\tcontinue;\n+\t\t}\n \t\tdie(\"pathspec '%s' did not match any files\", match);\n \t}\n }\n@@ -257,6 +261,9 @@ int cmd_add(int argc, const char **argv,\n \tfor (i = 0; i < dir.nr; i++)\n \t\tadd_file_to_index(dir.entries[i]->name, verbose);\n \n+\tif (ignored && !active_cache_changed)\n+\t\tfprintf(stderr, \"No added files - did you perhaps mean to do a 'git update-index'?\\n\");\n+\n \tif (active_cache_changed) {\n \t\tif (write_cache(newfd, active_cache, active_nr) ||\n \t\t    commit_index_file(&cache_file))\n"},{"id":"20192","messageId":"7vd5ecb688.fsf@assigned-by-dhcp.cox.net","threadId":"4170","inReplyTo":"Pine.LNX.4.64.0605171342370.10823@g5.osdl.org","subject":"Re: \"git add $ignored_file\" fail","fromName":"Junio C Hamano","fromEmail":"junkio@cox.net","sentAt":"2006-05-17T23:07:35Z","receivedAt":"2006-05-17T23:07:35Z","isPatch":false,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Linus Torvalds <torvalds@osdl.org> writes:\n\n> Well, with the new-and-improved builtin \"git add\", you could probably do \n> something like the appended (on top of my most recent patch).\n>\n> It says\n>\n> \tNo added files - did you perhaps mean to do a 'git update-index'?\n>\n> whenever it finds that \"git add\" has ignored a file and not actually added \n> anything. That, btw, can happen either because it refused to see the file \n> in the first place (ie it was ignored), or because all the files listed \n> were already added.\n>\n> In both cases the warning may or may not be sensible.\n>\n> Anyway, I dunno. I don't have any strong opinions on this.\n\nIf you give a pattern that would match two files but one of them\nwere hidden by .gitignore, this approach would not help you\nmuch.\n\nEven if we wanted to say something like \"if the user explicitly\ntells us to add etc/mtab~ by spelling it out, we should ignore\n*~ entry in .gitignore\", the shell expansion bites us because it\nis done before we get to what the user give us.  We cannot\ndistinguish that with the user typing etc/?tab* for example.\n\nIf somebody (Jakub, perhaps?) cares strong enough, we could show\nby default \"matched the pathspec but ignored by .gitignore\"\npaths with fprintf(stderr, \"ignoring '%s'\\n\"), and have an\noption -q to squelch it.\n\nI do not have strong feeling on this, so I'll see if somebody\ncomes up with a better implementation.\n"},{"id":"20193","messageId":"Pine.LNX.4.64.0605171614250.10823@g5.osdl.org","threadId":"4170","inReplyTo":"7vd5ecb688.fsf@assigned-by-dhcp.cox.net","subject":"Re: \"git add $ignored_file\" fail","fromName":"Linus Torvalds","fromEmail":"torvalds@osdl.org","sentAt":"2006-05-17T23:20:27Z","receivedAt":"2006-05-17T23:20:27Z","isPatch":false,"sender":{"key":"torvalds@linux-foundation.org","avatar":"https://avatars.githubusercontent.com/u/1024025?v=4"},"body":"\n\nOn Wed, 17 May 2006, Junio C Hamano wrote:\n> \n> If you give a pattern that would match two files but one of them\n> were hidden by .gitignore, this approach would not help you\n> much.\n\nCorrect. On the other hand, what could you do?\n\nI think that the common case for that is literally something like\n\n\tgit add dirname/\n\nor\n\n\tgit add file*\n\nand it turns out that there are object files under the directory, or that \nthere's a file.c, file.h _and_ a already-compiled file.o file.\n\nUnder both of those circumstances (one pattern that matches multiple files \nbut ignores others - or several different patterns where _some_ of the \npatterns are ignored), we actually do what I think is the only sane thing. \n\nNamely to just silently add everything that makes sense to add.\n\n> Even if we wanted to say something like \"if the user explicitly\n> tells us to add etc/mtab~ by spelling it out, we should ignore\n> *~ entry in .gitignore\", the shell expansion bites us because it\n> is done before we get to what the user give us.  We cannot\n> distinguish that with the user typing etc/?tab* for example.\n\nRight.\n\nThe only case that we cando anything at all about is really the case where \nwe didn't add anything at all, and then we might reasonably ask \"do you \nknow what the heck you're doing\".\n\nThat's kind of what my last patch did. It's a total special case, but it's \nthe _only_ special case that I can see that is at all relevant (ie in all \nother cases it would just be annoying as _hell_ if we started talking \nabout how we're ignoring object files. Of _course_ we're ignoring them, \nand that's why they are listed in .gitignore).\n\nSo I'd love to have the built-in \"git add\", but quite frankly, if you drop \nthat last patch as \"too ugly to live\", I certainly won't complain. I sent \nit out more as a \"we -could- do this\" thing rather than anything more \nserious.\n\n\t\t\tLinus\n"}]}