From a4b9c73391d75b6069908ce67e4414f30105c947 Mon Sep 17 00:00:00 2001 From: Andrey Loskutov Date: Wed, 15 Mar 2017 20:29:21 +0100 Subject: Don't try to strip new line if the message buffer is empty Bug: 513726 Change-Id: I0e7c19f8883b93bad1b9de166f671d28f3e9c240 Signed-off-by: Andrey Loskutov --- org.eclipse.jgit/src/org/eclipse/jgit/api/RebaseCommand.java | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) (limited to 'org.eclipse.jgit/src') diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/api/RebaseCommand.java b/org.eclipse.jgit/src/org/eclipse/jgit/api/RebaseCommand.java index f704492fe5..850ff49695 100644 --- a/org.eclipse.jgit/src/org/eclipse/jgit/api/RebaseCommand.java +++ b/org.eclipse.jgit/src/org/eclipse/jgit/api/RebaseCommand.java @@ -806,8 +806,12 @@ public class RebaseCommand extends GitCommand { if (!line.trim().startsWith("#")) //$NON-NLS-1$ result.append(line).append("\n"); //$NON-NLS-1$ } - if (!commitMessage.endsWith("\n")) //$NON-NLS-1$ - result.deleteCharAt(result.length() - 1); + if (!commitMessage.endsWith("\n")) { //$NON-NLS-1$ + int bufferSize = result.length(); + if (bufferSize > 0 && result.charAt(bufferSize - 1) == '\n') { + result.deleteCharAt(bufferSize - 1); + } + } return result.toString(); } -- cgit v1.2.3