diff --git a/org.eclipse.jgit.test/tst/org/eclipse/jgit/merge/MergeMessageFormatterTest.java b/org.eclipse.jgit.test/tst/org/eclipse/jgit/merge/MergeMessageFormatterTest.java index 04cfa2519..4ccc0f9be 100644 --- a/org.eclipse.jgit.test/tst/org/eclipse/jgit/merge/MergeMessageFormatterTest.java +++ b/org.eclipse.jgit.test/tst/org/eclipse/jgit/merge/MergeMessageFormatterTest.java @@ -168,6 +168,15 @@ public class MergeMessageFormatterTest extends SampleDataRepositoryTestCase { assertEquals("Merge branch 'a' into b", message); } + @Test + public void testIntoHeadOtherThanMaster() throws IOException { + Ref a = db.getRef("refs/heads/a"); + Ref b = db.getRef("refs/heads/b"); + SymbolicRef head = new SymbolicRef("HEAD", b); + String message = formatter.format(Arrays.asList(a), head); + assertEquals("Merge branch 'a' into b", message); + } + @Test public void testIntoSymbolicRefHeadPointingToMaster() throws IOException { Ref a = db.getRef("refs/heads/a"); diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/merge/MergeMessageFormatter.java b/org.eclipse.jgit/src/org/eclipse/jgit/merge/MergeMessageFormatter.java index 96395d0bf..11f3b7a3f 100644 --- a/org.eclipse.jgit/src/org/eclipse/jgit/merge/MergeMessageFormatter.java +++ b/org.eclipse.jgit/src/org/eclipse/jgit/merge/MergeMessageFormatter.java @@ -115,8 +115,7 @@ public class MergeMessageFormatter { String targetName = target.getLeaf().getName(); if (!targetName.equals(Constants.R_HEADS + Constants.MASTER)) { - String targetShortName = Repository - .shortenRefName(target.getName()); + String targetShortName = Repository.shortenRefName(targetName); sb.append(" into " + targetShortName); }