Bug 581723 - DirCache.read fails with DIRC checksum mismatch on git 2.40
Summary: DirCache.read fails with DIRC checksum mismatch on git 2.40
Status: RESOLVED FIXED
Alias: None
Product: JGit
Classification: Technology
Component: JGit (show other bugs)
Version: 6.5   Edit
Hardware: Macintosh Mac OS X
: P3 normal (vote)
Target Milestone: 5.13.2   Edit
Assignee: Project Inbox CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2023-03-27 06:59 EDT by Charlie Kolb CLA
Modified: 2023-05-11 11:49 EDT (History)
3 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Charlie Kolb CLA 2023-03-27 06:59:22 EDT
We're encountering an issue with DirCache when upgrading git to 2.40. 

After switching branches with this git version a call to DirCache.read(org.eclipse.jgit.lib.Repository) for a large repo consistently fails with:

Exception in thread "main" org.eclipse.jgit.errors.CorruptObjectException: DIRC checksum mismatch
	at org.eclipse.jgit.dircache.DirCache.readFrom(DirCache.java:547)
	at org.eclipse.jgit.dircache.DirCache.read(DirCache.java:406)
	at org.eclipse.jgit.dircache.DirCache.read(DirCache.java:191)
	at org.eclipse.jgit.dircache.DirCache.read(DirCache.java:163)

The exact repo config is 

new FileRepositoryBuilder().findGitDir(repoFile).setWorkTree(repoFile).build()


A functional workaround is to change (back) to git 2.37 and either switch branch again or run 

git update-index --index-version 4 && git update-index --really-refresh


One possibly related point in the git 2.40 release notes (https://lwn.net/Articles/926033/) is:

 * Use the SHA1DC implementation on macOS, just like other platforms,
   by default.

Though I'm not sure whether this would be used for more than literal collision detection.
 

This is on M1 macs running Ventura 13.2.1 on JVM 11 and was reproduced both on JGit 5.13 and 6.5 (not available in Version selection).


Thanks!
Comment 1 Matthias Sohn CLA 2023-03-27 11:35:07 EDT
This error occurs when the new option index.skipHash [1] is set to true.

JGit doesn't recognise this option yet and hence doesn't expect the index checksum to be a set of null-bytes if this option is turned on.

Setting this option to false and recreating the git index can workaround this problem until a fix is available.

[1] https://git-scm.com/docs/git-config#Documentation/git-config.txt-indexskipHash
Comment 2 Eclipse Genie CLA 2023-03-27 17:57:43 EDT
New Gerrit change created: https://git.eclipse.org/r/c/jgit/jgit/+/200916
Comment 3 Eclipse Genie CLA 2023-03-28 17:45:23 EDT
New Gerrit change created: https://git.eclipse.org/r/c/jgit/jgit/+/200948
Comment 5 Mark Fishman CLA 2023-05-03 13:50:24 EDT
Hello, I just have two questions about this fix.

1) the ticket mentions MAC.  does this also impact windows?

2) if it does impact windows also, it this fix included on the latest download I see of 2.40.1?
Comment 6 Mark Fishman CLA 2023-05-03 13:52:05 EDT
2 questions about this ticket.

1) ticket mentions mac impact.  does it also impact windows?

2) if windows is impacted, is the fix included in version 2.40.1 (latest availabe on site for download)

Thank you.
Comment 7 Thomas Wolf CLA 2023-05-03 14:25:07 EDT
(In reply to Mark Fishman from comment #6)
> 2 questions about this ticket.
> 
> 1) ticket mentions mac impact.  does it also impact windows?
> 
> 2) if windows is impacted, is the fix included in version 2.40.1 (latest
> availabe on site for download)
> 
> Thank you.

This is a problem in JGit, not in git 2.40. If you run into this problem with JGit, the work-around is to set git config index.skipHash to false.

Since this an interoperability issue between JGit and git.2.40 or newer, it occurs on all platforms when JGit is used on a git repository that has been manipulated by git 2.40 or newer.
Comment 8 Mark Fishman CLA 2023-05-03 17:51:55 EDT
thank you for the information.

looks like I get the jgit exception switching branches in eclipse.

can you tell me how to set that index.skipHash you mentioned and if there are any repercussions to doing so?
Comment 9 Thomas Wolf CLA 2023-05-04 06:28:07 EDT
(In reply to Mark Fishman from comment #8)
> thank you for the information.
> 
> looks like I get the jgit exception switching branches in eclipse.
> 
> can you tell me how to set that index.skipHash you mentioned and if there
> are any repercussions to doing so?

Set index.skipHash in the git config, either in the repository or in the global user config.

Or if you are using Eclipse 2022-12 or newer: update to EGit nightly; it should have the JGit fix for this issue.

EGit nightly can be installed from https://download.eclipse.org/egit/updates-nightly .
Comment 10 Mark Fishman CLA 2023-05-11 11:49:15 EDT
(In reply to Thomas Wolf from comment #9)
> (In reply to Mark Fishman from comment #8)
> > thank you for the information.
> > 
> > looks like I get the jgit exception switching branches in eclipse.
> > 
> > can you tell me how to set that index.skipHash you mentioned and if there
> > are any repercussions to doing so?
> 
> Set index.skipHash in the git config, either in the repository or in the
> global user config.
> 
> Or if you are using Eclipse 2022-12 or newer: update to EGit nightly; it
> should have the JGit fix for this issue.
> 
> EGit nightly can be installed from
> https://download.eclipse.org/egit/updates-nightly .

Hi Thomas, 
Just wanted to let you know that that fixed our issue.  Thank you so much for the help.  Really appreciate it.