{"thread":{"id":"33111","subject":"Ignore pattern with trailing whitespace in .gitignore is void using git 1.8.1.5","startedAt":"2013-03-09T01:36:32Z","lastAt":"2013-03-09T06:28:22Z","messageCount":3,"participants":["Thor Andreas Rognan","Junio C Hamano"],"isPatch":false,"patchVersion":null,"patchTotal":null},"messages":[{"id":"210865","messageId":"CAMn8hCexsiizsjoXO-ebfpEtZcW7n0dY-jV0q+aLh8U+pbUo9A@mail.gmail.com","threadId":"33111","inReplyTo":"CAMn8hCd6_V2Kq_OUgBFAoOkqqmrTpN_ohcP3wM44qWvQB_8R5g@mail.gmail.com","subject":"Ignore pattern with trailing whitespace in .gitignore is void using git 1.8.1.5","fromName":"Thor Andreas Rognan","fromEmail":"thor.rognan@gmail.com","sentAt":"2013-03-09T01:36:32Z","receivedAt":"2013-03-09T01:36:32Z","isPatch":false,"sender":{"key":"thor.rognan@gmail.com","avatar":null},"body":"Hi guys,\n\nMaybe I'm doing it wrong, or maybe it's the intended behaviour,\nbut I find that a trailing whitespace after a pattern in .gitignore\nmakes the pattern void with git 1.8.1.5.\n\nIt's a subtle error to make, although cleaning undesired commits\nfrom the git history can be educational and fun in itself.\n\nHow to reproduce:\n\n$ > mkdir -p ~/tmp/git-ignore-test/ \\\n&& cd ~/tmp/git-ignore-test/ \\\n&& touch .gitignore .secret-passwords .secret-passwords.swp \\\n&& echo \".*.sw? \" > .gitignore \\\n&& echo \".secret-passwords\" >> .gitignore \\\n&& git init && git status\n\nRemove the white space after ``` .*.sw?``` in .gitignore\nto see the .swp file disappear:\n\n$ > echo -e \".*.sw?\\n.secret-passwords\" > .gitignore > .gitignore \\\n&& git status\n\nYou will of course have to temporarily disable your\nglobal .gitignore file if you handle vim swap files correctly there.\n\nI am using git 1.8.1.5 installed with homebrew on os x 10.8.2.\n"},{"id":"210871","messageId":"7vehfpf8kk.fsf@alter.siamese.dyndns.org","threadId":"33111","inReplyTo":"CAMn8hCexsiizsjoXO-ebfpEtZcW7n0dY-jV0q+aLh8U+pbUo9A@mail.gmail.com","subject":"Re: Ignore pattern with trailing whitespace in .gitignore is void using git 1.8.1.5","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2013-03-09T05:25:47Z","receivedAt":"2013-03-09T05:25:47Z","isPatch":false,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Thor Andreas Rognan <thor.rognan@gmail.com> writes:\n\n> Maybe I'm doing it wrong, or maybe it's the intended behaviour,\n> but I find that a trailing whitespace after a pattern in .gitignore\n> makes the pattern void with git 1.8.1.5.\n\nI doubt we do anything clever like that.\n\n        $ git init\n        $ touch hello.o \"hello.o \" \"hello.o  \" hello.c\n        $ echo \"*.o \" >.gitignore\n        $ git status | cat -e\n        # On branch master$\n        #$\n        # Initial commit$\n        #$\n        # Untracked files:$\n        #   (use \"git add <file>...\" to include in what will be committed)$\n        #$\n        #       .gitignore$\n        #       hello.c$\n        #       hello.o$\n        #       hello.o  $\n        nothing added to commit but untracked files present (use \"git add\" to track)$\n        \nThe user tells to ignore anything followed by a dot followed by a\nlowercase Oh followed by a SP.  We ignore \"hello. \", but not \"hello.o\"\nnor \"hello.o  \" (two SPs at the end), just as told.\n"},{"id":"210873","messageId":"7va9qdf5o9.fsf@alter.siamese.dyndns.org","threadId":"33111","inReplyTo":"7vehfpf8kk.fsf@alter.siamese.dyndns.org","subject":"Re: Ignore pattern with trailing whitespace in .gitignore is void using git 1.8.1.5","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2013-03-09T06:28:22Z","receivedAt":"2013-03-09T06:28:22Z","isPatch":false,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Junio C Hamano <gitster@pobox.com> writes:\n\n> Thor Andreas Rognan <thor.rognan@gmail.com> writes:\n>\n>> Maybe I'm doing it wrong, or maybe it's the intended behaviour,\n>> but I find that a trailing whitespace after a pattern in .gitignore\n>> makes the pattern void with git 1.8.1.5.\n>\n> I doubt we do anything clever like that.\n> ...\n> The user tells to ignore anything followed by a dot followed by a\n> lowercase Oh followed by a SP.  We ignore \"hello. \", but not \"hello.o\"\n> nor \"hello.o  \" (two SPs at the end), just as told.\n\nOf course, having said all that, I do not think anybody objects too\ndeeply against a patch that change the behaviour to ignore trailing\nwhitespaces, as long as the patch leaves an escape hatch to allow\npeople who do want to specify a pattern that matches with pathnames\nwith trailing whitespaces.  Without thinking it through, perhaps\n\n\techo '*.o\\ ' >.gitignore\n\nor something?\n\nTechnically speaking, such a change is a regression, but I doubt\nthat many people would mind it too much.\n"}]}