summaryrefslogtreecommitdiff
path: root/refs.c
diff options
context:
space:
mode:
authorJunio C Hamano <gitster@pobox.com>2018-07-24 21:50:47 (GMT)
committerJunio C Hamano <gitster@pobox.com>2018-07-24 21:50:47 (GMT)
commit9cb10ca9df2f95e97b5a75d7fea3087972c298ae (patch)
tree0b288477e15e44c5501880b32b74befd24c778da /refs.c
parent8fa8a4f1ec088ab937d1c460f3eb1701e51b8ffc (diff)
parent80a6c2073b4d90be3e1be21f86afe7a47d1ac7bc (diff)
downloadgit-9cb10ca9df2f95e97b5a75d7fea3087972c298ae.zip
git-9cb10ca9df2f95e97b5a75d7fea3087972c298ae.tar.gz
git-9cb10ca9df2f95e97b5a75d7fea3087972c298ae.tar.bz2
Merge branch 'bp/log-ref-write-fd-with-strbuf'
Code clean-up. * bp/log-ref-write-fd-with-strbuf: convert log_ref_write_fd() to use strbuf
Diffstat (limited to 'refs.c')
-rw-r--r--refs.c12
1 files changed, 4 insertions, 8 deletions
diff --git a/refs.c b/refs.c
index 3b4508a..08fb5a9 100644
--- a/refs.c
+++ b/refs.c
@@ -787,25 +787,21 @@ int delete_ref(const char *msg, const char *refname,
old_oid, flags);
}
-int copy_reflog_msg(char *buf, const char *msg)
+void copy_reflog_msg(struct strbuf *sb, const char *msg)
{
- char *cp = buf;
char c;
int wasspace = 1;
- *cp++ = '\t';
+ strbuf_addch(sb, '\t');
while ((c = *msg++)) {
if (wasspace && isspace(c))
continue;
wasspace = isspace(c);
if (wasspace)
c = ' ';
- *cp++ = c;
+ strbuf_addch(sb, c);
}
- while (buf < cp && isspace(cp[-1]))
- cp--;
- *cp++ = '\n';
- return cp - buf;
+ strbuf_rtrim(sb);
}
int should_autocreate_reflog(const char *refname)