diff options
author | Robin Rosenberg <robin.rosenberg@dewire.com> | 2013-01-29 08:05:00 +0100 |
---|---|---|
committer | Robin Rosenberg <robin.rosenberg@dewire.com> | 2013-01-29 08:05:00 +0100 |
commit | eb6093293022e468c2aea93a11f63b366e0d3891 (patch) | |
tree | abc08cfd4528f7a2a770345e55e43706d42687d1 /org.eclipse.jgit.test | |
parent | 83032e9f66552a43504456233ad9900bc2712077 (diff) | |
download | jgit-eb6093293022e468c2aea93a11f63b366e0d3891.tar.gz jgit-eb6093293022e468c2aea93a11f63b366e0d3891.zip |
Fix Check for FF_ONLY merges again
Added more FF-mode tests
Change-Id: I33eed5737d9411cc1cf214da62ce719916a1b736
Diffstat (limited to 'org.eclipse.jgit.test')
-rw-r--r-- | org.eclipse.jgit.test/tst/org/eclipse/jgit/api/MergeCommandTest.java | 57 |
1 files changed, 35 insertions, 22 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 df3cf58424..f4e418def5 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 @@ -204,28 +204,6 @@ public class MergeCommandTest extends RepositoryTestCase { } } - @Test - public void testMergeCannotDoRequiredFastForward() throws Exception { - Git git = new Git(db); - - RevCommit first = git.commit().setMessage("first").call(); - createBranch(first, "refs/heads/side"); - - writeTrashFile("a", "a"); - git.add().addFilepattern("a").call(); - git.commit().setMessage("second").call(); - - checkoutBranch("refs/heads/side"); - writeTrashFile("b", "b"); - git.add().addFilepattern("b").call(); - git.commit().setMessage("third").call(); - - MergeResult result = git.merge().include(db.getRef(Constants.MASTER)) - .setFastForward(FastForwardMode.NO_FF) - .call(); - assertEquals(MergeStatus.ABORTED, result.getMergeStatus()); - } - @Theory public void testMergeSuccessAllStrategies(MergeStrategy mergeStrategy) throws Exception { @@ -1367,6 +1345,41 @@ public class MergeCommandTest extends RepositoryTestCase { assertEquals(MergeStatus.FAST_FORWARD, result.getMergeStatus()); } + @Test + public void testNoFastForward() throws Exception { + Git git = new Git(db); + RevCommit initialCommit = git.commit().setMessage("initial commit") + .call(); + createBranch(initialCommit, "refs/heads/branch1"); + git.commit().setMessage("second commit").call(); + checkoutBranch("refs/heads/branch1"); + + MergeCommand merge = git.merge(); + merge.setFastForward(FastForwardMode.NO_FF); + merge.include(db.getRef(Constants.MASTER)); + MergeResult result = merge.call(); + + assertEquals(MergeStatus.MERGED, result.getMergeStatus()); + } + + @Test + public void testFastForwardOnlyNotPossible() throws Exception { + Git git = new Git(db); + RevCommit initialCommit = git.commit().setMessage("initial commit") + .call(); + createBranch(initialCommit, "refs/heads/branch1"); + git.commit().setMessage("second commit").call(); + checkoutBranch("refs/heads/branch1"); + writeTrashFile("file1", "branch1"); + git.add().addFilepattern("file").call(); + git.commit().setMessage("second commit on branch1").call(); + MergeCommand merge = git.merge(); + merge.setFastForward(FastForwardMode.FF_ONLY); + merge.include(db.getRef(Constants.MASTER)); + MergeResult result = merge.call(); + + assertEquals(MergeStatus.ABORTED, result.getMergeStatus()); + } private static void setExecutable(Git git, String path, boolean executable) { FS.DETECTED.setExecute( new File(git.getRepository().getWorkTree(), path), executable); |