Community
Participate
Working Groups
I think this is the same issue as git used to have prior to version 2.10 https://github.com/git/git/blob/master/Documentation/RelNotes/2.10.0.txt#L248 A "* text=auto eol=lf" set in .gitattributes should be interpreted as "automatically detect which files are text files and use lf". Instead, when jGit sees it, it uses lf in all files. Here's a minimal example demonstrating the inconsistency of git (2.16.6) and jGit (5.7.0.202003110725-r) behaviours: This works fine: git clone https://github.com/RafalSumislawski/jgit-text-auto-issue.git . git checkout test-branch This (usually) fails with a CheckoutConflictException, because when checking for modifications, jGit replaces a \r\n in the png header of whitepixel.png with a \n and then sees it as a modification/conflict: Code: package aaa; import org.eclipse.jgit.api.CreateBranchCommand; import org.eclipse.jgit.api.Git; import org.eclipse.jgit.api.errors.GitAPIException; import org.eclipse.jgit.lib.Ref; import java.io.IOException; import java.nio.file.Path; import java.nio.file.Paths; public class Test { public static void main(String[] args) throws GitAPIException, IOException { String url = "https://github.com/RafalSumislawski/jgit-text-auto-issue.git"; String branch = "test-branch"; Path dir = Paths.get(args[0]); Git git = Git.cloneRepository() .setCloneAllBranches(false) .setURI(url) .setDirectory(dir.toFile()) .setBranch("master") .call(); Ref headsRef = git.getRepository().findRef("refs/heads/" + branch); if (headsRef == null) { git.branchCreate() .setName(branch) .setUpstreamMode(CreateBranchCommand.SetupUpstreamMode.TRACK) .setStartPoint("origin/" + branch) .setForce(true) .call(); } git.checkout().setName("refs/heads/" + branch).call(); } } Output: Exception in thread "main" whitepixel.png at org.eclipse.jgit.api.CheckoutCommand.call(CheckoutCommand.java:252) at aaa.Test.main(Test.java:38) Caused by: org.eclipse.jgit.errors.CheckoutConflictException: Checkout conflict with files: whitepixel.png at org.eclipse.jgit.dircache.DirCacheCheckout.doCheckout(DirCacheCheckout.java:502) at org.eclipse.jgit.dircache.DirCacheCheckout.checkout(DirCacheCheckout.java:467) at org.eclipse.jgit.api.CheckoutCommand.call(CheckoutCommand.java:248) ... 1 more
New Gerrit change created: https://git.eclipse.org/r/159904
See also https://www.eclipse.org/forums/index.php/t/1103192/
Gerrit change https://git.eclipse.org/r/159904 was merged to [master]. Commit: http://git.eclipse.org/c/jgit/jgit.git/commit/?id=3c34e0acbfcac236daaf746690130c6e99a8e524