diff options
author | Axel Richard <axel.richard@obeo.fr> | 2014-08-29 14:37:09 +0200 |
---|---|---|
committer | Matthias Sohn <matthias.sohn@sap.com> | 2014-08-30 01:17:24 +0200 |
commit | 46f3007b52a5d12c5a973957128ac38680b20ab8 (patch) | |
tree | c51edac33977b1885f310945a6bba8e8220abdea /org.eclipse.jgit.test/tst | |
parent | 7b7d033ee1fdd8e81ae2ad7dc9e1ae12cbd9ddfa (diff) | |
download | jgit-46f3007b52a5d12c5a973957128ac38680b20ab8.tar.gz jgit-46f3007b52a5d12c5a973957128ac38680b20ab8.zip |
Handle -m option for Merge command
Set the commit message to be used for the merge commit (in case one is
created)
Bug: 442886
Change-Id: Ie5ecc13822faa366f00b3daa07f74c8441cae195
Signed-off-by: Axel Richard <axel.richard@obeo.fr>
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
Diffstat (limited to 'org.eclipse.jgit.test/tst')
-rw-r--r-- | org.eclipse.jgit.test/tst/org/eclipse/jgit/api/MergeCommandTest.java | 65 |
1 files changed, 64 insertions, 1 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 1eeb9f7c0d..761aafa3f9 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 @@ -1,6 +1,6 @@ /* * Copyright (C) 2010, Stefan Lay <stefan.lay@sap.com> - * Copyright (C) 2010-2012, Christian Halstrick <christian.halstrick@sap.com> + * Copyright (C) 2010-2014, Christian Halstrick <christian.halstrick@sap.com> * and other copyright owners as documented in the project's IP log. * * This program and the accompanying materials are made available @@ -1566,6 +1566,69 @@ public class MergeCommandTest extends RepositoryTestCase { assertEquals(MergeStatus.CONFLICTING, result.getMergeStatus()); } + @Test + public void testMergeWithMessageOption() throws Exception { + Git git = new Git(db); + + writeTrashFile("a", "1\na\n3\n"); + git.add().addFilepattern("a").call(); + RevCommit initialCommit = git.commit().setMessage("initial").call(); + + createBranch(initialCommit, "refs/heads/side"); + checkoutBranch("refs/heads/side"); + + writeTrashFile("b", "1\nb\n3\n"); + git.add().addFilepattern("b").call(); + git.commit().setMessage("side").call(); + + checkoutBranch("refs/heads/master"); + + writeTrashFile("c", "1\nc\n3\n"); + git.add().addFilepattern("c").call(); + git.commit().setMessage("main").call(); + + Ref sideBranch = db.getRef("side"); + + git.merge().include(sideBranch).setStrategy(MergeStrategy.RESOLVE) + .setMessage("user message").call(); + + assertNull(db.readMergeCommitMsg()); + + Iterator<RevCommit> it = git.log().call().iterator(); + RevCommit newHead = it.next(); + assertEquals("user message", newHead.getFullMessage()); + } + + @Test + public void testMergeConflictWithMessageOption() throws Exception { + Git git = new Git(db); + + writeTrashFile("a", "1\na\n3\n"); + git.add().addFilepattern("a").call(); + RevCommit initialCommit = git.commit().setMessage("initial").call(); + + createBranch(initialCommit, "refs/heads/side"); + checkoutBranch("refs/heads/side"); + + writeTrashFile("a", "1\na(side)\n3\n"); + git.add().addFilepattern("a").call(); + git.commit().setMessage("side").call(); + + checkoutBranch("refs/heads/master"); + + writeTrashFile("a", "1\na(main)\n3\n"); + git.add().addFilepattern("a").call(); + git.commit().setMessage("main").call(); + + Ref sideBranch = db.getRef("side"); + + git.merge().include(sideBranch).setStrategy(MergeStrategy.RESOLVE) + .setMessage("user message").call(); + + assertEquals("user message\n\nConflicts:\n\ta\n", + db.readMergeCommitMsg()); + } + private static void setExecutable(Git git, String path, boolean executable) { FS.DETECTED.setExecute( new File(git.getRepository().getWorkTree(), path), executable); |