summaryrefslogtreecommitdiffstats
path: root/org.eclipse.jgit.test
diff options
context:
space:
mode:
authorPhilipp Thun <philipp.thun@sap.com>2011-03-21 12:33:58 +0100
committerPhilipp Thun <philipp.thun@sap.com>2011-03-21 12:33:58 +0100
commitdcf7bd9a8f7acafbd1461dc0414aded2db030983 (patch)
treebecc224ee4f4cf77178cce4cf5f5142257edd7f8 /org.eclipse.jgit.test
parentdcefc660f15a85fcc2b4ca21ca5d12938b157e82 (diff)
downloadjgit-dcf7bd9a8f7acafbd1461dc0414aded2db030983.tar.gz
jgit-dcf7bd9a8f7acafbd1461dc0414aded2db030983.zip
Improve MergeResult
Add paths causing abnormal merge failures (e.g. due to unstaged changes) to the MergeResult returned by MergeCommand. This helps callers to better handle (e.g. present) merge results. Change-Id: Idb8cf04c5cecfb6a12cb880e16febfc3b9358564 Signed-off-by: Philipp Thun <philipp.thun@sap.com>
Diffstat (limited to 'org.eclipse.jgit.test')
-rw-r--r--org.eclipse.jgit.test/tst/org/eclipse/jgit/api/MergeCommandTest.java15
1 files changed, 11 insertions, 4 deletions
diff --git a/org.eclipse.jgit.test/tst/org/eclipse/jgit/api/MergeCommandTest.java b/org.eclipse.jgit.test/tst/org/eclipse/jgit/api/MergeCommandTest.java
index 132aaa1ac8..94f0906a30 100644
--- a/org.eclipse.jgit.test/tst/org/eclipse/jgit/api/MergeCommandTest.java
+++ b/org.eclipse.jgit.test/tst/org/eclipse/jgit/api/MergeCommandTest.java
@@ -57,6 +57,7 @@ import org.eclipse.jgit.lib.Constants;
import org.eclipse.jgit.lib.RepositoryState;
import org.eclipse.jgit.lib.RepositoryTestCase;
import org.eclipse.jgit.merge.MergeStrategy;
+import org.eclipse.jgit.merge.ResolveMerger.MergeFailureReason;
import org.eclipse.jgit.revwalk.RevCommit;
import org.junit.Test;
@@ -664,7 +665,8 @@ public class MergeCommandTest extends RepositoryTestCase {
MergeResult result = git.merge().include(sideCommit.getId())
.setStrategy(MergeStrategy.RESOLVE).call();
- checkMergeFailedResult(result, indexState, fileA);
+ checkMergeFailedResult(result, MergeFailureReason.DIRTY_INDEX,
+ indexState, fileA);
}
@Test
@@ -701,7 +703,8 @@ public class MergeCommandTest extends RepositoryTestCase {
MergeResult result = git.merge().include(sideCommit.getId())
.setStrategy(MergeStrategy.RESOLVE).call();
- checkMergeFailedResult(result, indexState, fileA);
+ checkMergeFailedResult(result, MergeFailureReason.DIRTY_INDEX,
+ indexState, fileA);
}
@Test
@@ -735,7 +738,8 @@ public class MergeCommandTest extends RepositoryTestCase {
MergeResult result = git.merge().include(sideCommit.getId())
.setStrategy(MergeStrategy.RESOLVE).call();
- checkMergeFailedResult(result, indexState, fileA);
+ checkMergeFailedResult(result, MergeFailureReason.DIRTY_WORKTREE,
+ indexState, fileA);
}
@Test
@@ -771,7 +775,8 @@ public class MergeCommandTest extends RepositoryTestCase {
MergeResult result = git.merge().include(sideCommit.getId())
.setStrategy(MergeStrategy.RESOLVE).call();
- checkMergeFailedResult(result, indexState, fileA);
+ checkMergeFailedResult(result, MergeFailureReason.DIRTY_WORKTREE,
+ indexState, fileA);
}
private RevCommit addAllAndCommit(final Git git) throws Exception {
@@ -780,8 +785,10 @@ public class MergeCommandTest extends RepositoryTestCase {
}
private void checkMergeFailedResult(final MergeResult result,
+ final MergeFailureReason reason,
final String indexState, final File fileA) throws Exception {
assertEquals(MergeStatus.FAILED, result.getMergeStatus());
+ assertEquals(reason, result.getFailingPaths().get("a"));
assertEquals("a(modified)", read(fileA));
assertFalse(new File(db.getWorkTree(), "b").exists());
assertEquals("c", read(new File(db.getWorkTree(), "c")));