Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.kernel.org/pub/scm/git/git.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/refs.c
diff options
context:
space:
mode:
authorBen Peart <Ben.Peart@microsoft.com>2018-07-11 00:08:22 +0300
committerJunio C Hamano <gitster@pobox.com>2018-07-11 00:22:44 +0300
commit80a6c2073b4d90be3e1be21f86afe7a47d1ac7bc (patch)
tree3268229219296b7b7051066ee339ba8454bf6ba4 /refs.c
parente3331758f12da22f4103eec7efe1b5304a9be5e9 (diff)
convert log_ref_write_fd() to use strbuf
Since we don't care about how many bytes were written, simplify the return value logic. log_ref_write_fd() was written long before strbuf was fleshed out. Remove the old manual buffer management code and replace it with strbuf(). Also update copy_reflog_msg() which is called only by log_ref_write_fd() to use strbuf as it keeps things consistent. Signed-off-by: Ben Peart <Ben.Peart@microsoft.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
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 0eb379f931..50fe5c5d2c 100644
--- a/refs.c
+++ b/refs.c
@@ -786,25 +786,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)