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
This commit is contained in:
Junio C Hamano
2018-07-24 14:50:47 -07:00
3 changed files with 17 additions and 31 deletions

12
refs.c
View File

@ -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)