summaryrefslogtreecommitdiffstats
path: root/strbuf.c
diff options
context:
space:
mode:
authorJunio C Hamano <gitster@pobox.com>2018-11-02 03:04:54 +0100
committerJunio C Hamano <gitster@pobox.com>2018-11-02 03:04:54 +0100
commit39f73315454d2553b2d3219a58f5110a60eba5a1 (patch)
tree2a55eab60e69c17bba16f115e775ce1aacf49e6f /strbuf.c
parentMerge branch 'pk/rebase-in-c-2-basic' (diff)
parentbuiltin rebase: stop if `git am` is in progress (diff)
downloadgit-39f73315454d2553b2d3219a58f5110a60eba5a1.tar.xz
git-39f73315454d2553b2d3219a58f5110a60eba5a1.zip
Merge branch 'pk/rebase-in-c-3-acts'
Rewrite "git rebase" in C. * pk/rebase-in-c-3-acts: builtin rebase: stop if `git am` is in progress builtin rebase: actions require a rebase in progress builtin rebase: support --edit-todo and --show-current-patch builtin rebase: support --quit builtin rebase: support --abort builtin rebase: support --skip builtin rebase: support --continue
Diffstat (limited to 'strbuf.c')
-rw-r--r--strbuf.c9
1 files changed, 9 insertions, 0 deletions
diff --git a/strbuf.c b/strbuf.c
index 64041c3c24..f6a6cf78b9 100644
--- a/strbuf.c
+++ b/strbuf.c
@@ -120,6 +120,15 @@ void strbuf_trim_trailing_dir_sep(struct strbuf *sb)
sb->buf[sb->len] = '\0';
}
+void strbuf_trim_trailing_newline(struct strbuf *sb)
+{
+ if (sb->len > 0 && sb->buf[sb->len - 1] == '\n') {
+ if (--sb->len > 0 && sb->buf[sb->len - 1] == '\r')
+ --sb->len;
+ sb->buf[sb->len] = '\0';
+ }
+}
+
void strbuf_ltrim(struct strbuf *sb)
{
char *b = sb->buf;