summaryrefslogtreecommitdiffstats
path: root/org.eclipse.jgit.test
diff options
context:
space:
mode:
authorRobin Rosenberg <robin.rosenberg@dewire.com>2013-01-20 14:01:38 -0500
committerGerrit Code Review @ Eclipse.org <gerrit@eclipse.org>2013-01-20 14:01:38 -0500
commit910a69d4c8a892a71f4ac1f8c54f7d91887001d5 (patch)
tree461b98e89633db3dd14dc9501a7a09489e677148 /org.eclipse.jgit.test
parent9f7b97c90ab065fa3d8fcc6392bda087664bbef9 (diff)
parentbaf7ca9cc0d2bdf237a9bb19486d6fde5250a7f5 (diff)
downloadjgit-910a69d4c8a892a71f4ac1f8c54f7d91887001d5.tar.gz
jgit-910a69d4c8a892a71f4ac1f8c54f7d91887001d5.zip
Merge "Improve handling of checkout conflicts"
Diffstat (limited to 'org.eclipse.jgit.test')
-rw-r--r--org.eclipse.jgit.test/tst/org/eclipse/jgit/api/RebaseCommandTest.java74
1 files changed, 26 insertions, 48 deletions
diff --git a/org.eclipse.jgit.test/tst/org/eclipse/jgit/api/RebaseCommandTest.java b/org.eclipse.jgit.test/tst/org/eclipse/jgit/api/RebaseCommandTest.java
index ba97e905b3..fbaef76e1c 100644
--- a/org.eclipse.jgit.test/tst/org/eclipse/jgit/api/RebaseCommandTest.java
+++ b/org.eclipse.jgit.test/tst/org/eclipse/jgit/api/RebaseCommandTest.java
@@ -1059,7 +1059,6 @@ public class RebaseCommandTest extends RepositoryTestCase {
}
@Test
- @SuppressWarnings("null")
public void testRebaseWithUnstagedTopicChange() throws Exception {
// create file1, add and commit
writeTrashFile(FILE1, "file1");
@@ -1084,19 +1083,14 @@ public class RebaseCommandTest extends RepositoryTestCase {
writeTrashFile("file2", "unstaged file2");
// rebase
- JGitInternalException exception = null;
- try {
- git.rebase().setUpstream("refs/heads/master").call();
- } catch (JGitInternalException e) {
- exception = e;
- }
- assertNotNull(exception);
- assertEquals("Checkout conflict with files: \nfile2",
- exception.getMessage());
+ RebaseResult result = git.rebase().setUpstream("refs/heads/master")
+ .call();
+ assertEquals(Status.CONFLICTS, result.getStatus());
+ assertEquals(1, result.getConflicts().size());
+ assertEquals("file2", result.getConflicts().get(0));
}
@Test
- @SuppressWarnings("null")
public void testRebaseWithUncommittedTopicChange() throws Exception {
// create file1, add and commit
writeTrashFile(FILE1, "file1");
@@ -1122,23 +1116,17 @@ public class RebaseCommandTest extends RepositoryTestCase {
git.add().addFilepattern("file2").call();
// do not commit
- // rebase
- JGitInternalException exception = null;
- try {
- git.rebase().setUpstream("refs/heads/master").call();
- } catch (JGitInternalException e) {
- exception = e;
- }
- assertNotNull(exception);
- assertEquals("Checkout conflict with files: \nfile2",
- exception.getMessage());
+ RebaseResult result = git.rebase().setUpstream("refs/heads/master")
+ .call();
+ assertEquals(Status.CONFLICTS, result.getStatus());
+ assertEquals(1, result.getConflicts().size());
+ assertEquals("file2", result.getConflicts().get(0));
checkFile(uncommittedFile, "uncommitted file2");
assertEquals(RepositoryState.SAFE, git.getRepository().getRepositoryState());
}
@Test
- @SuppressWarnings("null")
public void testRebaseWithUnstagedMasterChange() throws Exception {
// create file1, add and commit
writeTrashFile(FILE1, "file1");
@@ -1163,19 +1151,14 @@ public class RebaseCommandTest extends RepositoryTestCase {
writeTrashFile(FILE1, "unstaged modified file1");
// rebase
- JGitInternalException exception = null;
- try {
- git.rebase().setUpstream("refs/heads/master").call();
- } catch (JGitInternalException e) {
- exception = e;
- }
- assertNotNull(exception);
- assertEquals("Checkout conflict with files: \nfile1",
- exception.getMessage());
+ RebaseResult result = git.rebase().setUpstream("refs/heads/master")
+ .call();
+ assertEquals(Status.CONFLICTS, result.getStatus());
+ assertEquals(1, result.getConflicts().size());
+ assertEquals(FILE1, result.getConflicts().get(0));
}
@Test
- @SuppressWarnings("null")
public void testRebaseWithUncommittedMasterChange() throws Exception {
// create file1, add and commit
writeTrashFile(FILE1, "file1");
@@ -1202,15 +1185,11 @@ public class RebaseCommandTest extends RepositoryTestCase {
// do not commit
// rebase
- JGitInternalException exception = null;
- try {
- git.rebase().setUpstream("refs/heads/master").call();
- } catch (JGitInternalException e) {
- exception = e;
- }
- assertNotNull(exception);
- assertEquals("Checkout conflict with files: \nfile1",
- exception.getMessage());
+ RebaseResult result = git.rebase().setUpstream("refs/heads/master")
+ .call();
+ assertEquals(Status.CONFLICTS, result.getStatus());
+ assertEquals(1, result.getConflicts().size());
+ assertEquals(FILE1, result.getConflicts().get(0));
}
@Test
@@ -1496,14 +1475,13 @@ public class RebaseCommandTest extends RepositoryTestCase {
File theFile = writeTrashFile(FILE1, "dirty the file");
// and attempt to rebase
- try {
- RebaseResult rebaseResult = git.rebase()
+ RebaseResult rebaseResult = git.rebase()
.setUpstream("refs/heads/master").call();
- fail("Checkout with conflict should have occured, not "
- + rebaseResult.getStatus());
- } catch (JGitInternalException e) {
- checkFile(theFile, "dirty the file");
- }
+ assertEquals(Status.CONFLICTS, rebaseResult.getStatus());
+ assertEquals(1, rebaseResult.getConflicts().size());
+ assertEquals(FILE1, rebaseResult.getConflicts().get(0));
+
+ checkFile(theFile, "dirty the file");
assertEquals(RepositoryState.SAFE, git.getRepository()
.getRepositoryState());