summaryrefslogtreecommitdiffstats
path: root/org.eclipse.jgit.test/tst
diff options
context:
space:
mode:
authorRobin Rosenberg <robin.rosenberg@dewire.com>2013-12-15 16:57:01 +0100
committerMatthias Sohn <matthias.sohn@sap.com>2014-03-02 20:30:42 +0100
commitfd62a456499a57e5ae09c490b8bf2c72ff55154a (patch)
tree05f39134c77bfd63e60de281fb0b7693aba59dae /org.eclipse.jgit.test/tst
parent31aeaa0931837f3601e6a0e4e3bd51075c1204c0 (diff)
downloadjgit-fd62a456499a57e5ae09c490b8bf2c72ff55154a.tar.gz
jgit-fd62a456499a57e5ae09c490b8bf2c72ff55154a.zip
Fix merge/cherry-picking in CRLF mode
This fixes a case where we have CRLF in the repo but LF in the worktree and are in autocrlf mode. Change-Id: I0388270c1cf0fd22dfd513bcaa404eb97268d39d Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
Diffstat (limited to 'org.eclipse.jgit.test/tst')
-rw-r--r--org.eclipse.jgit.test/tst/org/eclipse/jgit/merge/ResolveMergerTest.java32
1 files changed, 32 insertions, 0 deletions
diff --git a/org.eclipse.jgit.test/tst/org/eclipse/jgit/merge/ResolveMergerTest.java b/org.eclipse.jgit.test/tst/org/eclipse/jgit/merge/ResolveMergerTest.java
index 54de8cfb47..dd06168c30 100644
--- a/org.eclipse.jgit.test/tst/org/eclipse/jgit/merge/ResolveMergerTest.java
+++ b/org.eclipse.jgit.test/tst/org/eclipse/jgit/merge/ResolveMergerTest.java
@@ -53,6 +53,7 @@ import org.eclipse.jgit.api.Git;
import org.eclipse.jgit.api.MergeResult;
import org.eclipse.jgit.api.MergeResult.MergeStatus;
import org.eclipse.jgit.api.errors.CheckoutConflictException;
+import org.eclipse.jgit.api.errors.GitAPIException;
import org.eclipse.jgit.api.errors.JGitInternalException;
import org.eclipse.jgit.dircache.DirCache;
import org.eclipse.jgit.errors.NoMergeBaseException;
@@ -264,6 +265,37 @@ public class ResolveMergerTest extends RepositoryTestCase {
indexState(CONTENT));
}
+ @Theory
+ public void mergeWithCrlfInWT(MergeStrategy strategy) throws IOException,
+ GitAPIException {
+ Git git = Git.wrap(db);
+ db.getConfig().setString("core", null, "autocrlf", "false");
+ db.getConfig().save();
+ writeTrashFile("crlf.txt", "some\r\ndata\r\n");
+ git.add().addFilepattern("crlf.txt").call();
+ git.commit().setMessage("base").call();
+
+ git.branchCreate().setName("brancha").call();
+
+ writeTrashFile("crlf.txt", "some\r\nmore\r\ndata\r\n");
+ git.add().addFilepattern("crlf.txt").call();
+ git.commit().setMessage("on master").call();
+
+ git.checkout().setName("brancha").call();
+ writeTrashFile("crlf.txt", "some\r\ndata\r\ntoo\r\n");
+ git.add().addFilepattern("crlf.txt").call();
+ git.commit().setMessage("on brancha").call();
+
+ db.getConfig().setString("core", null, "autocrlf", "input");
+ db.getConfig().save();
+
+ MergeResult mergeResult = git.merge().setStrategy(strategy)
+ .include(db.resolve("master"))
+ .call();
+ assertEquals(MergeResult.MergeStatus.MERGED,
+ mergeResult.getMergeStatus());
+ }
+
/**
* Merging two equal subtrees when the index does not contain any file in
* that subtree should lead to a merged state.