]> source.dussan.org Git - jgit.git/commitdiff
Don't try to strip new line if the message buffer is empty 54/93154/1
authorAndrey Loskutov <loskutov@gmx.de>
Wed, 15 Mar 2017 19:29:21 +0000 (20:29 +0100)
committerAndrey Loskutov <loskutov@gmx.de>
Wed, 15 Mar 2017 19:29:21 +0000 (20:29 +0100)
Bug: 513726
Change-Id: I0e7c19f8883b93bad1b9de166f671d28f3e9c240
Signed-off-by: Andrey Loskutov <loskutov@gmx.de>
org.eclipse.jgit/src/org/eclipse/jgit/api/RebaseCommand.java

index f704492fe5ec487adcf91b30d7788d8ad916ecaa..850ff49695d0578c407773dd39ebbb3f9fe5e25e 100644 (file)
@@ -806,8 +806,12 @@ public class RebaseCommand extends GitCommand<RebaseResult> {
                        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();
        }