From 46f3007b52a5d12c5a973957128ac38680b20ab8 Mon Sep 17 00:00:00 2001 From: Axel Richard Date: Fri, 29 Aug 2014 14:37:09 +0200 Subject: 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 Signed-off-by: Matthias Sohn --- .../src/org/eclipse/jgit/api/MergeCommand.java | 23 ++++++++++++++++++++-- 1 file changed, 21 insertions(+), 2 deletions(-) (limited to 'org.eclipse.jgit/src/org/eclipse') diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/api/MergeCommand.java b/org.eclipse.jgit/src/org/eclipse/jgit/api/MergeCommand.java index 6f0313dfda..0488a418af 100644 --- a/org.eclipse.jgit/src/org/eclipse/jgit/api/MergeCommand.java +++ b/org.eclipse.jgit/src/org/eclipse/jgit/api/MergeCommand.java @@ -1,6 +1,6 @@ /* * Copyright (C) 2010, Christian Halstrick - * Copyright (C) 2010-2012, Stefan Lay + * Copyright (C) 2010-2014, Stefan Lay * and other copyright owners as documented in the project's IP log. * * This program and the accompanying materials are made available @@ -104,6 +104,8 @@ public class MergeCommand extends GitCommand { private FastForwardMode fastForwardMode; + private String message; + /** * The modes available for fast forward merges corresponding to the * --ff, --no-ff and --ff-only @@ -313,7 +315,10 @@ public class MergeCommand extends GitCommand { } String mergeMessage = ""; //$NON-NLS-1$ if (!squash) { - mergeMessage = new MergeMessageFormatter().format( + if (message != null) + mergeMessage = message; + else + mergeMessage = new MergeMessageFormatter().format( commits, head); repo.writeMergeCommitMsg(mergeMessage); repo.writeMergeHeads(Arrays.asList(ref.getObjectId())); @@ -565,4 +570,18 @@ public class MergeCommand extends GitCommand { this.commit = Boolean.valueOf(commit); return this; } + + /** + * Set the commit message to be used for the merge commit (in case one is + * created) + * + * @param message + * the message to be used for the merge commit + * @return {@code this} + * @since 3.5 + */ + public MergeCommand setMessage(String message) { + this.message = message; + return this; + } } -- cgit v1.2.3