1

I have checked out an SVN repository using git svn with git 2.35.1. It has worked for a long time, but as of recently I get ghost-diffs:

$ git status
On branch master
Changes not staged for commit:
  (use "git add <file>..." to update what will be committed)
  (use "git restore <file>..." to discard changes in working directory)
    modified:   tools/a.cpp
    modified:   tools/b.cpp
    modified:   tools/c.cpp
    ...

If I git checkout . I get:

$ git checkout .
Updated 28 paths from the index

But nothing changes, i.e. git status keeps showing the same differences. I cannot git svn rebase from the remote SVN server:

$ git svn rebase
tools/a.cpp: needs update
tools/b.cpp: needs update
tools/c.cpp: needs update
...

When I use git diff I get full differences for all the files in this list. Using git diff -w says

$ git diff -w
warning: LF will be replaced by CRLF in tools/a.cpp.
The file will have its original line endings in your working directory

I understand this is caused by whitespace changes between the local git checkout and the SVN server. I just cannot figure out any combination of options or configuration settings that will fix the problem.

EDIT:

I actually found a solution to update the repository: I checked out the revision before tools/a.cpp and friends were committed, and from there do a git svn rebase. This updates to the latest revision. But the problem is there again, and if I want to update further I have to repeat this revert and rebase process, so this is not a real solution, especially for large histories.

hochl
  • 12,524
  • 10
  • 53
  • 87
  • You've told Git to mess with your files. Tell Git *not* to mess with your files (turn off `core.autocrlf` and/or supply a `.gitattrbutes` file that tells Git files are not to have EOL modifications applied) and Git won't mess with them. Whether and how SVN will mess with them is a separate issue (to which i don't know the answer). – torek May 23 '22 at 20:27
  • I actually didn't set any of these options and they are not set as far as I can see :( – hochl May 24 '22 at 13:14
  • Perhaps git-svn (the SVN add-on for Git) set them? I don't know, I've never used git-svn myself. – torek May 25 '22 at 03:15

1 Answers1

0

With Git 2.37, the warning will change and become.

On a platform whose native line endings are not LF (e.g. Windows), those indexed files trigger:

In the working copy of 'tools/a.cpp', LF will be replaced by CRLF the next time Git touches it.

Make sure first and foremost that git config core.autocrlf is set to false, and try again, to see if anything automagically change.
At least:

git config  --global core.autocrlf false
VonC
  • 1,262,500
  • 529
  • 4,410
  • 5,250
  • This did not change a thing, unfortunately :( I can even `git checkout tools/a.cpp` and it says `Updated 1 path from the index` and it still shows a modification for this file. – hochl May 27 '22 at 12:26
  • @hochl What would a [`git add --renormalize .`](https://stackoverflow.com/a/56822362/6309) show you? Would there still be diffs in the status? – VonC May 27 '22 at 15:31
  • If I use that on `a.cpp` I get `Changes to be committed: ... modified: tools/a.cpp`. `git diff --cached` shows a full diff, `git diff -w --cached` shows nothing. – hochl May 27 '22 at 17:34
  • @hochl That seems better. But it might interfer with git-svn. – VonC May 27 '22 at 18:20
  • I mean it actually made no difference and still does not work :( – hochl May 30 '22 at 08:54