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

Re: wrong handling of text git attribute leading to files incorrectly reported as modified

From
HHHolger Hellmuth <hellmuth@ira.uka.de>
Date
Apr 16, 2014, 17:03 UTC
Message-ID
<534EB7E1.7060807@ira.uka.de>
In-Reply-To
<E8A9F28E-FF68-4899-B02C-DB7A2C66F38A@ammeter.ch>
Am 11.04.2014 22:20, schrieb Frank Ammeter:
Show 17 quoted lines
> #!/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.

It is. In the repository is stored a crlffile with \r in it which would be changed when you would do a commit (with your current gitattributes)

> # only way to resolve is to modify .gitattributes
No. This works too:

git add crlffile git commit -m . # practically removes the \r inside the repository git status crlffile #shows up clean

Previous: Junio C Hamano
Message 8 of 8 in “wrong handling of text git attribute leading to files incorrectly reported as modified”
  1. Frank AmmeterApr 11, 2014
  2. Torsten BögershausenApr 11, 2014
  3. Frank AmmeterApr 12, 2014
  4. Brandon McCaigApr 15, 2014
  5. Junio C HamanoApr 15, 2014
  6. Frank AmmeterApr 16, 2014
  7. Junio C HamanoApr 16, 2014
  8. Holger HellmuthApr 16, 2014

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.