From 7546e3b4c5612e5f6ee564d0d01b17533e7e0b3b Mon Sep 17 00:00:00 2001 From: Robin Stocker Date: Thu, 5 May 2011 17:33:01 +0200 Subject: [PATCH] Fix "into" part of merge message for HEAD Merging into a non-master branch would result in the following message: Merge branch 'a' into HEAD Now the merge message is correct: Merge branch 'a' into b Change-Id: I488f97190e4c1711c23a7a3cbd64f8b13a87bbac Signed-off-by: Robin Stocker --- .../eclipse/jgit/merge/MergeMessageFormatterTest.java | 9 +++++++++ .../org/eclipse/jgit/merge/MergeMessageFormatter.java | 3 +-- 2 files changed, 10 insertions(+), 2 deletions(-) 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); }