diff options
author | Robin Rosenberg <robin.rosenberg@dewire.com> | 2013-01-28 19:02:18 -0500 |
---|---|---|
committer | Gerrit Code Review @ Eclipse.org <gerrit@eclipse.org> | 2013-01-28 19:02:18 -0500 |
commit | 83032e9f66552a43504456233ad9900bc2712077 (patch) | |
tree | 68a81f503a08f92ca163cb8bc975ede50c0bf454 /org.eclipse.jgit.test/tst | |
parent | ee413067fded57d817af5b6b9978b8ceb6e6374e (diff) | |
parent | 642ff2cd7dd6ae361e4993255ade89a32e20601f (diff) | |
download | jgit-83032e9f66552a43504456233ad9900bc2712077.tar.gz jgit-83032e9f66552a43504456233ad9900bc2712077.zip |
Merge "Check for FF_ONLY merges correctly"
Diffstat (limited to 'org.eclipse.jgit.test/tst')
-rw-r--r-- | org.eclipse.jgit.test/tst/org/eclipse/jgit/api/MergeCommandTest.java | 39 |
1 files changed, 39 insertions, 0 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 589845ef67..df3cf58424 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 @@ -52,6 +52,7 @@ import static org.junit.Assert.fail; import java.io.File; import java.util.Iterator; +import org.eclipse.jgit.api.MergeCommand.FastForwardMode; import org.eclipse.jgit.api.MergeResult.MergeStatus; import org.eclipse.jgit.api.errors.InvalidMergeHeadsException; import org.eclipse.jgit.lib.Constants; @@ -203,6 +204,28 @@ 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 { @@ -1328,6 +1351,22 @@ public class MergeCommandTest extends RepositoryTestCase { assertEquals(StatusCommandTest.set("file2"), stat.getConflicting()); } + @Test + public void testFastForwardOnly() 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.FF_ONLY); + merge.include(db.getRef(Constants.MASTER)); + MergeResult result = merge.call(); + + assertEquals(MergeStatus.FAST_FORWARD, result.getMergeStatus()); + } private static void setExecutable(Git git, String path, boolean executable) { FS.DETECTED.setExecute( new File(git.getRepository().getWorkTree(), path), executable); |