strbuf: accept a comment string for strbuf_commented_addf()

As part of our transition to multi-byte comment characters, let's take a
NUL-terminated string pointer for strbuf_commented_addf() rather than a
single character.

All of the callers have to be adjusted, but they can just pass
comment_line_str rather than comment_line_char.

Note that we rely on strbuf_add_commented_lines() under the hood, so
we'll cheat a bit to squeeze our string into a single character (for now
the two are equivalent, and we'll address this TODO in the next patch).

Signed-off-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
This commit is contained in:
Jeff King
2024-03-12 05:17:29 -04:00
committed by Junio C Hamano
parent 2982b65690
commit 3a35d96284
9 changed files with 24 additions and 18 deletions

View File

@@ -852,15 +852,15 @@ static void prepare_to_commit(struct commit_list *remoteheads)
strbuf_addch(&msg, '\n');
if (cleanup_mode == COMMIT_MSG_CLEANUP_SCISSORS) {
wt_status_append_cut_line(&msg);
strbuf_commented_addf(&msg, comment_line_char, "\n");
strbuf_commented_addf(&msg, comment_line_str, "\n");
}
strbuf_commented_addf(&msg, comment_line_char,
strbuf_commented_addf(&msg, comment_line_str,
_(merge_editor_comment));
if (cleanup_mode == COMMIT_MSG_CLEANUP_SCISSORS)
strbuf_commented_addf(&msg, comment_line_char,
strbuf_commented_addf(&msg, comment_line_str,
_(scissors_editor_comment));
else
strbuf_commented_addf(&msg, comment_line_char,
strbuf_commented_addf(&msg, comment_line_str,
_(no_scissors_editor_comment), comment_line_char);
}
if (signoff)