aboutsummaryrefslogtreecommitdiffstats
path: root/org.eclipse.jgit.pgm.test
diff options
context:
space:
mode:
Diffstat (limited to 'org.eclipse.jgit.pgm.test')
-rw-r--r--org.eclipse.jgit.pgm.test/tst/org/eclipse/jgit/pgm/BlameTest.java35
1 files changed, 35 insertions, 0 deletions
diff --git a/org.eclipse.jgit.pgm.test/tst/org/eclipse/jgit/pgm/BlameTest.java b/org.eclipse.jgit.pgm.test/tst/org/eclipse/jgit/pgm/BlameTest.java
index e806872c14..732c54e332 100644
--- a/org.eclipse.jgit.pgm.test/tst/org/eclipse/jgit/pgm/BlameTest.java
+++ b/org.eclipse.jgit.pgm.test/tst/org/eclipse/jgit/pgm/BlameTest.java
@@ -42,8 +42,13 @@
*/
package org.eclipse.jgit.pgm;
+import static org.junit.Assert.assertTrue;
+
import org.eclipse.jgit.api.Git;
+import org.eclipse.jgit.api.MergeResult;
import org.eclipse.jgit.lib.CLIRepositoryTestCase;
+import org.eclipse.jgit.lib.Constants;
+import org.eclipse.jgit.revwalk.RevCommit;
import org.junit.Rule;
import org.junit.Test;
import org.junit.rules.ExpectedException;
@@ -119,4 +124,34 @@ public class BlameTest extends CLIRepositoryTestCase {
thrown.expectMessage("no such path 'sub/does_not_exist.txt' in HEAD");
execute("git blame sub/does_not_exist.txt");
}
+
+ @Test
+ public void testBlameMergeConflict() throws Exception {
+ try (Git git = new Git(db)) {
+ writeTrashFile("file", "Origin\n");
+ git.add().addFilepattern("file").call();
+ git.commit().setMessage("initial commit").call();
+ git.checkout().setCreateBranch(true)
+ .setName("side").call();
+ writeTrashFile("file",
+ "Conflicting change from side branch\n");
+ git.add().addFilepattern("file").call();
+ RevCommit side = git.commit().setMessage("side commit").call();
+ git.checkout().setName(Constants.MASTER).call();
+ writeTrashFile("file", "Change on master branch\n");
+ git.add().addFilepattern("file").call();
+ git.commit().setMessage("Commit conflict on master").call();
+ MergeResult result = git.merge()
+ .include("side", side).call();
+ assertTrue("Expected conflict on 'file'",
+ result.getConflicts().containsKey("file"));
+ }
+ String[] expected = {
+ " (Not Committed Yet 1) <<<<<<< HEAD",
+ "7a918de5 (GIT_COMMITTER_NAME 2009-08-15 20:12:58 -0330 2) Change on master branch",
+ " (Not Committed Yet 3) =======",
+ "beb52f68 (GIT_COMMITTER_NAME 2009-08-15 20:12:58 -0330 4) Conflicting change from side branch",
+ " (Not Committed Yet 5) >>>>>>> side" };
+ assertArrayOfLinesEquals(expected, execute("git blame file"));
+ }
}