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

Re: Schrödinger's diff

From
EREric Raible <raible@gmail.com>
Date
Jul 8, 2009, 06:13 UTC
Message-ID
<279b37b20907072313t79ddded2k84c819887c234e8b@mail.gmail.com>
In-Reply-To
<7v8wizanqr.fsf@alter.siamese.dyndns.org>
On Tue, Jul 7, 2009 at 7:54 PM, Junio C Hamano<gitster@pobox.com> wrote:
Show 6 quoted lines
> Eric Raible <raible@gmail.com> writes:
>
>> So what's the best way of "fixing once and for all" a repo infected with
>> carriage returns when you want to use autocrlf=true moving forward?
>
> Didn't "rm -f .git/index && git reset --hard HEAD" work?

Will, it "worked" in the sense that it usually [1] allows "git diff --name-only" to correctly show the files that were checked in with crlf endings and core.autocrlf false.

Those files are then out-of-date when core.autocrlf is true and .git/index is up-to-date.

In other words, that first step worked around the fact that sometimes that .git/index was out of date.

By "fixing it once and for all" I was trying to refer to creating the correct commit to abolish the carriage returns from my repo.

I ended up with this crude-but-obvious loop which generates many LF->CRLF warnings [2]:

for i in `git diff --name-only`; do
      echo $i
      sed 's/0x0D//' < $i > foo
      mv foo $i
      git add $i
done
>> Would you accept a patch explaining how "git reset --hard" doesn't
>> actually rebuild the index from scratch,...
>
> Absolutely.
I'll try to get to it, given the $dayjob / $significant_other constraints.
- Eric
[1] I've had cases where for whatever reasons a "git read-tree HEAD"
     seemed to be required, but I don't have the recipe yet.
[2] Which can be abolished by wrapping it in autocrlf=false
     before and autocrlf=true after
Previous: Junio C HamanoNext: Eric Raible
Message 11 of 13 in “Schrödinger's diff”
  1. Eric RaibleJul 7, 2009
  2. Johannes SixtJul 7, 2009
  3. Andreas EricssonJul 7, 2009
  4. Daniel BarkalowJul 7, 2009
  5. Jeff KingJul 7, 2009
  6. Junio C HamanoJul 7, 2009
  7. Jeff KingJul 7, 2009
  8. Junio C HamanoJul 7, 2009
  9. Eric RaibleJul 8, 2009
  10. Junio C HamanoJul 8, 2009
  11. Eric RaibleJul 8, 2009
  12. Eric RaibleJul 7, 2009
  13. Jeff KingJul 7, 2009

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.