git/list[1] front-page[2] threads[3] people[4] search[5] about
 

git diff --check in a bare repository

From
ANAndrei Neculau <andrei.neculau@gmail.com>
Date
Oct 6, 2015, 10:31 UTC
Message-ID
<CAOGnN1enXp42dQLO_JwzFBBWwuXn7psBUjRp4kj=_p1tkNGvOw@mail.gmail.com>
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

Message 1 of 1 in “git diff --check in a bare repository”
  1. Andrei NeculauOct 6, 2015

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.