Bug: 513726
Change-Id: I0e7c19f8883b93bad1b9de166f671d28f3e9c240
Signed-off-by: Andrey Loskutov <loskutov@gmx.de>
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();
}