Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » EGit / JGit » EGit (JGit) incorrectly detects modifications if autocrlf is changed after repo creation
EGit (JGit) incorrectly detects modifications if autocrlf is changed after repo creation [message #1064196] Tue, 18 June 2013 08:21 Go to next message
Vadim Dmitriev is currently offline Vadim DmitrievFriend
Messages: 74
Registered: July 2009
Member
Hello. My name is Vadim and I have a problem! Wink

This problem actually is about staging view, file modifications and how JGit and command line git handle line-ending differences. AFAIR, it all began when I committed bunch of files with core.autocrlf=false, but now I try to use core.autocrlf=true whenever I can. If I touch the file in the working copy, JGit always indicates that the file is modified (if I revert core.autocrlf back to false, file is correctly considered unchanged). In contrast, command line git handles this case and correctly reports no modifications with core.autocrlf both true or false.

I already wrote what I have found on so far on the issue here [1]:
"Originally file was committed with hash computed for win-style line endings several months ago. If I touch the file now its hash is recomputed for "canonicalized" unix-style endings.
I don't know why exactly: either something changed in jgit or I altered repository config. However, as a result org.eclipse.jgit.treewalk.WorkingTreeIterator#contentCheck(DirCacheEntry) sees different hashes and marks file as changed. Console git works around this somehow, but jgit doesn't."

One day I found filed bug regarding this problem, but forgot to bookmark it. Now I can't find it neither through bugzilla search, nor by google Sad Will be grateful if someone will point me to that bug.
If it happens that developers never heard of this problem, I will create a new entry, but I want to avoid duplicates if possible.

Thanks in advance!

[1] https://bugs.eclipse.org/bugs/show_bug.cgi?id=392382#c4
Re: EGit (JGit) incorrectly detects modifications if autocrlf is changed after repo creation [message #1064594 is a reply to message #1064196] Thu, 20 June 2013 07:33 Go to previous message
Christian Halstrick is currently offline Christian HalstrickFriend
Messages: 274
Registered: July 2009
Senior Member
Hi,

I can reproduce the problem regarding the autocrlf handling with the test repo (1). There is definitely a bug in E/JGit regarding showing the status when core.autocrlf is true. When core.autocrlf is false then there seems to be no problem.

There is a strange trick which can serve as a workaround until the bug is fixed. Whenever you see this problem in EGit run a native git "git status" in that repo - this should fix it.

'git status' is not a pure read only operation. Whenever you do a "git status" in native git or a "Staging view refresh" in EGit then the same thing happens. CGit/JGit will iterate over all non-ignored files in the working tree. Each file which has the same "last-modified-timestamp" as the timestamp we have recorded in the index is reported as "not-changed" (2). If the timestamps differ CGit/JGit check explicitly if file content and index content differ. If they don't differ, means index and file are equal, native git "git status" will update the index and write the new last-modification-timestamp into the index. So, next time you do git status git can skip the expensive content check because now file modification time and the timestamp in the index are equal.

JGit fails to do the content comparison correctly when file and index timestamps differ and autocrlf is true. That's tricky because you can can't simply compare the bytes from the file to the bytes in the index, but you have to convert back the CRLFs you see in the file to LFs (the opposite operation you did during checkout where LFs have been changed to CRLFs). This should be fixed.

Ciao
Chris

(1) https://github.com/chalstrick/test_crlf
(2) There are exceptions to this rule which I ignore for this answer: 1) when index differs from HEAD 2) racy-git problems
Previous Topic:Projects only on a branch are lost when switching between branches
Next Topic:Error installing EGit Mylyn GitHub
Goto Forum:
  


Current Time: Thu Apr 25 12:25:21 GMT 2024

Powered by FUDForum. Page generated in 0.02706 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top