{"thread":{"id":"40498","subject":"git diff --check in a bare repository","startedAt":"2015-10-06T10:31:45Z","lastAt":"2015-10-06T10:31:45Z","messageCount":1,"participants":["Andrei Neculau"],"isPatch":false,"patchVersion":null,"patchTotal":null},"messages":[{"id":"271212","messageId":"CAOGnN1enXp42dQLO_JwzFBBWwuXn7psBUjRp4kj=_p1tkNGvOw@mail.gmail.com","threadId":"40498","inReplyTo":null,"subject":"git diff --check in a bare repository","fromName":"Andrei Neculau","fromEmail":"andrei.neculau@gmail.com","sentAt":"2015-10-06T10:31:45Z","receivedAt":"2015-10-06T10:31:45Z","isPatch":false,"sender":{"key":"andrei.neculau@gmail.com","avatar":null},"body":"Hello\n\nI am using \"git diff --check\" on the \"server-side\" (i.e. in a bare\nrepository as part of a git hook)\nwith a .gitattributes rule saying\n\n*.md text whitespace=-trailing-space # notice the - in front of trailing\n\nI can check that the attribute is set/read correctly thanks to another\nthread on this mailing list\n\n$ export GIT_INDEX_FILE=index.tmp\n$ git read-tree --reset -i $SHA\n$ git check-attr --cached foo.md # shows up whitespace: -trailing-space\n$ rm index.tmp\n\nbut then when I run\n\n$ git diff --check $SHA^..$SHA -- foo.md\n\nthen I get an error that foo.md contains a trailing space (as if the\n.gitattributes in $SHA is ignored).\n\nThe reverse applies as well. Since trailing-space is enabled by\ndefault, I edited ~/.gitconfig and set core.whitespace =\n-trailing-space.\n\nnow \"git diff --check\" doesn't complain, but if I commit and push a\nrule in .gitattributes saying\n\n*.md text whitespace=trailing-space\n\nthen I do not get an error when pushing foo.md with trailing-space.\n\nI experience the same behaviour in 1.9.1 and 2.6.1.\nFor what it's worth as input to the above issue, I have also tried\n\n$ export GIT_INDEX_FILE=index.tmp\n$ git read-tree --reset -i $SHA\n$ git diff --check --cached -- foo.md\n\nbut the same behaviour can be noticed.\n\nI am not subscribed to the mailing list, so please keep me in CC\n\nThank you in advance,\nAndrei\n\n--\nandreineculau.com\n"}]}