From: David Turner <dturner@xxxxxxxxxxxxxxxx> Rename copy_msg to copy_reflog_msg and add it to refs/refs-internal.h. Signed-off-by: David Turner <dturner@xxxxxxxxxxxxxxxx> Signed-off-by: Junio C Hamano <gitster@xxxxxxxxx> Signed-off-by: Michael Haggerty <mhagger@xxxxxxxxxxxx> --- refs/files-backend.c | 28 +--------------------------- refs/refs-internal.h | 7 +++++++ refs/refs.c | 21 +++++++++++++++++++++ 3 files changed, 29 insertions(+), 27 deletions(-) diff --git a/refs/files-backend.c b/refs/files-backend.c index 3a4aff6..4807b32 100644 --- a/refs/files-backend.c +++ b/refs/files-backend.c @@ -2665,32 +2665,6 @@ static int commit_ref(struct ref_lock *lock) return 0; } -/* - * copy the reflog message msg to buf, which has been allocated sufficiently - * large, while cleaning up the whitespaces. Especially, convert LF to space, - * because reflog file is one line per entry. - */ -static int copy_msg(char *buf, const char *msg) -{ - char *cp = buf; - char c; - int wasspace = 1; - - *cp++ = '\t'; - while ((c = *msg++)) { - if (wasspace && isspace(c)) - continue; - wasspace = isspace(c); - if (wasspace) - c = ' '; - *cp++ = c; - } - while (buf < cp && isspace(cp[-1])) - cp--; - *cp++ = '\n'; - return cp - buf; -} - static int should_autocreate_reflog(const char *refname) { if (!log_all_ref_updates) @@ -2774,7 +2748,7 @@ static int log_ref_write_fd(int fd, const unsigned char *old_sha1, sha1_to_hex(new_sha1), committer); if (msglen) - len += copy_msg(logrec + len - 1, msg) - 1; + len += copy_reflog_msg(logrec + len - 1, msg) - 1; written = len <= maxlen ? write_in_full(fd, logrec, len) : -1; free(logrec); diff --git a/refs/refs-internal.h b/refs/refs-internal.h index 5ae084b..a1655e3 100644 --- a/refs/refs-internal.h +++ b/refs/refs-internal.h @@ -114,4 +114,11 @@ struct ref_transaction { enum ref_transaction_state state; }; +/* + * Copy the reflog message msg to buf, which has been allocated sufficiently + * large, while cleaning up the whitespaces. Especially, convert LF to space, + * because reflog file is one line per entry. + */ +int copy_reflog_msg(char *buf, const char *msg); + #endif /* REFS_REFS_INTERNAL_H */ diff --git a/refs/refs.c b/refs/refs.c index 31f1b19..6bf790b 100644 --- a/refs/refs.c +++ b/refs/refs.c @@ -827,6 +827,27 @@ int for_each_remote_ref_submodule(const char *submodule, each_ref_fn fn, void *c return for_each_ref_in_submodule(submodule, "refs/remotes/", fn, cb_data); } +int copy_reflog_msg(char *buf, const char *msg) +{ + char *cp = buf; + char c; + int wasspace = 1; + + *cp++ = '\t'; + while ((c = *msg++)) { + if (wasspace && isspace(c)) + continue; + wasspace = isspace(c); + if (wasspace) + c = ' '; + *cp++ = c; + } + while (buf < cp && isspace(cp[-1])) + cp--; + *cp++ = '\n'; + return cp - buf; +} + int head_ref_namespaced(each_ref_fn fn, void *cb_data) { struct strbuf buf = STRBUF_INIT; -- 2.6.2 -- To unsubscribe from this list: send the line "unsubscribe git" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html