git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* wrong handling of text git attribute leading to files incorrectly reported as modified
@ 2014-04-11 20:20 Frank Ammeter
  2014-04-11 20:38 ` Torsten Bögershausen
  2014-04-16 17:03 ` Holger Hellmuth
  0 siblings, 2 replies; 8+ messages in thread
From: Frank Ammeter @ 2014-04-11 20:20 UTC (permalink / raw)
  To: git

I’m not a git expert and this might be the wrong place to ask this question,
so please send me somewhere else if I’m in the wrong place.

I asked the same question on stack overflow, but didn’t get any response:
http://stackoverflow.com/questions/22823004/files-incorrectly-reported-modified-git-attributes-buggy-leading-to-inconsist

If a file is committed with crlf line endings with the text attribute unset in the working tree, but the text attribute is set in the repo, the file will be incorrectly shown as modified - for all users checking out the file.
Resetting or manually modifying the file will not help - The only remedy is to commit the .gitattributes with the text attribute set for the file.

Wouldn’t it be better to only consider the checked-in gitattributes instead of the attributes in the working tree?
Is this a bug in git handling gitattributes or is this wrong usage? If it is wrong usage, is it documented anywhere?

The following shell script demonstrates the problem:

#!/bin/bash
# creating a git repo "repo"
rm -rf repo
mkdir repo
cd repo
git init
# committing gitattributes with text attribute set for all files
echo "* text" > .gitattributes
git add .gitattributes
git commit -m "added .gitattributes"
# add a file with CRLF line ending with text attribute unset
echo -e "crlf\r" > crlffile
echo "* -text" > .gitattributes
git add crlffile
git commit -m "added crlffile"
git checkout .gitattributes
# now "crlffile" shows as modified, even though it isn't.
# only way to resolve is to modify .gitattributes   
git status crlffile
# crlffile shown as modified.
git checkout crlffile
git status crlffile
# crlffile shown as modified.
git reset --hard
git status
# crlffile shown as modified.
# git diff will report the CR as the difference
git diff 
# but external diff reports no differences.
git difftool --extcmd=diff --no-prompt

Thanks for your help
Frank Ammeter

^ permalink raw reply	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2014-04-16 16:58 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-04-11 20:20 wrong handling of text git attribute leading to files incorrectly reported as modified Frank Ammeter
2014-04-11 20:38 ` Torsten Bögershausen
2014-04-12 11:29   ` Frank Ammeter
2014-04-15 20:12     ` Brandon McCaig
2014-04-15 21:23       ` Junio C Hamano
2014-04-16 11:49         ` Frank Ammeter
2014-04-16 16:50           ` Junio C Hamano
2014-04-16 17:03 ` Holger Hellmuth

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).