strbuf: remove global variable
As a library that only interacts with other primitives, strbuf should not utilize the comment_line_char global variable within its functions. Therefore, add an additional parameter for functions that use comment_line_char and refactor callers to pass it in instead. strbuf_stripspace() removes the skip_comments boolean and checks if comment_line_char is a non-NUL character to determine whether to skip comments or not. Signed-off-by: Calvin Wan <calvinwan@google.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
This commit is contained in:

committed by
Junio C Hamano

parent
aba0706832
commit
787cb8a48a
12
add-patch.c
12
add-patch.c
@ -1105,10 +1105,11 @@ static int edit_hunk_manually(struct add_p_state *s, struct hunk *hunk)
|
||||
size_t i;
|
||||
|
||||
strbuf_reset(&s->buf);
|
||||
strbuf_commented_addf(&s->buf, _("Manual hunk edit mode -- see bottom for "
|
||||
"a quick guide.\n"));
|
||||
strbuf_commented_addf(&s->buf, comment_line_char,
|
||||
_("Manual hunk edit mode -- see bottom for "
|
||||
"a quick guide.\n"));
|
||||
render_hunk(s, hunk, 0, 0, &s->buf);
|
||||
strbuf_commented_addf(&s->buf,
|
||||
strbuf_commented_addf(&s->buf, comment_line_char,
|
||||
_("---\n"
|
||||
"To remove '%c' lines, make them ' ' lines "
|
||||
"(context).\n"
|
||||
@ -1117,12 +1118,13 @@ static int edit_hunk_manually(struct add_p_state *s, struct hunk *hunk)
|
||||
s->mode->is_reverse ? '+' : '-',
|
||||
s->mode->is_reverse ? '-' : '+',
|
||||
comment_line_char);
|
||||
strbuf_commented_addf(&s->buf, "%s", _(s->mode->edit_hunk_hint));
|
||||
strbuf_commented_addf(&s->buf, comment_line_char, "%s",
|
||||
_(s->mode->edit_hunk_hint));
|
||||
/*
|
||||
* TRANSLATORS: 'it' refers to the patch mentioned in the previous
|
||||
* messages.
|
||||
*/
|
||||
strbuf_commented_addf(&s->buf,
|
||||
strbuf_commented_addf(&s->buf, comment_line_char,
|
||||
_("If it does not apply cleanly, you will be "
|
||||
"given an opportunity to\n"
|
||||
"edit again. If all lines of the hunk are "
|
||||
|
Reference in New Issue
Block a user