git diff --check in a bare repository

From: Andrei Neculau <hidden>
Date: 2016-06-15 23:06:46

Hello

I am using "git diff --check" on the "server-side" (i.e. in a bare
repository as part of a git hook)
with a .gitattributes rule saying

*.md text whitespace=-trailing-space # notice the - in front of trailing

I can check that the attribute is set/read correctly thanks to another
thread on this mailing list

$ export GIT_INDEX_FILE=index.tmp
$ git read-tree --reset -i $SHA
$ git check-attr --cached foo.md # shows up whitespace: -trailing-space
$ rm index.tmp

but then when I run

$ git diff --check $SHA^..$SHA -- foo.md

then I get an error that foo.md contains a trailing space (as if the
.gitattributes in $SHA is ignored).

The reverse applies as well. Since trailing-space is enabled by
default, I edited ~/.gitconfig and set core.whitespace =
-trailing-space.

now "git diff --check" doesn't complain, but if I commit and push a
rule in .gitattributes saying

*.md text whitespace=trailing-space

then I do not get an error when pushing foo.md with trailing-space.

I experience the same behaviour in 1.9.1 and 2.6.1.
For what it's worth as input to the above issue, I have also tried

$ export GIT_INDEX_FILE=index.tmp
$ git read-tree --reset -i $SHA
$ git diff --check --cached -- foo.md

but the same behaviour can be noticed.

I am not subscribed to the mailing list, so please keep me in CC

Thank you in advance,
Andrei

--
andreineculau.com
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help