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>

Calvin Wan committed Jun 6, 2023 at 19:48 UTC 787cb8a48ae24ff07fa7c763909bb204bfdc84a7
16 files changed +90 -64
add-patch.c
+7 -5
@@ -1105,10 +1105,11 @@ static int edit_hunk_manually(struct add_p_state *s, struct hunk *hunk)
1105 size_t i;
1106
1107 strbuf_reset(&s->buf);
1108 - strbuf_commented_addf(&s->buf, _("Manual hunk edit mode -- see bottom for "
1109 - "a quick guide.\n"));
1108 + strbuf_commented_addf(&s->buf, comment_line_char,
1109 + _("Manual hunk edit mode -- see bottom for "
1110 + "a quick guide.\n"));
1111 render_hunk(s, hunk, 0, 0, &s->buf);
1111 - strbuf_commented_addf(&s->buf,
1112 + strbuf_commented_addf(&s->buf, comment_line_char,
1113 _("---\n"
1114 "To remove '%c' lines, make them ' ' lines "
1115 "(context).\n"
@@ -1117,12 +1118,13 @@ static int edit_hunk_manually(struct add_p_state *s, struct hunk *hunk)
1118 s->mode->is_reverse ? '+' : '-',
1119 s->mode->is_reverse ? '-' : '+',
1120 comment_line_char);
1120 - strbuf_commented_addf(&s->buf, "%s", _(s->mode->edit_hunk_hint));
1121 + strbuf_commented_addf(&s->buf, comment_line_char, "%s",
1122 + _(s->mode->edit_hunk_hint));
1123 /*
1124 * TRANSLATORS: 'it' refers to the patch mentioned in the previous
1125 * messages.
1126 */
1125 - strbuf_commented_addf(&s->buf,
1127 + strbuf_commented_addf(&s->buf, comment_line_char,
1128 _("If it does not apply cleanly, you will be "
1129 "given an opportunity to\n"
1130 "edit again. If all lines of the hunk are "
builtin/am.c
+1 -1
@@ -1283,7 +1283,7 @@ static int parse_mail(struct am_state *state, const char *mail)
1283
1284 strbuf_addstr(&msg, "\n\n");
1285 strbuf_addbuf(&msg, &mi.log_message);
1286 - strbuf_stripspace(&msg, 0);
1286 + strbuf_stripspace(&msg, '\0');
1287
1288 assert(!state->author_name);
1289 state->author_name = strbuf_detach(&author_name, NULL);
builtin/branch.c
+2 -2
@@ -674,7 +674,7 @@ static int edit_branch_description(const char *branch_name)
674 exists = !read_branch_desc(&buf, branch_name);
675 if (!buf.len || buf.buf[buf.len-1] != '\n')
676 strbuf_addch(&buf, '\n');
677 - strbuf_commented_addf(&buf,
677 + strbuf_commented_addf(&buf, comment_line_char,
678 _("Please edit the description for the branch\n"
679 " %s\n"
680 "Lines starting with '%c' will be stripped.\n"),
@@ -685,7 +685,7 @@ static int edit_branch_description(const char *branch_name)
685 strbuf_release(&buf);
686 return -1;
687 }
688 - strbuf_stripspace(&buf, 1);
688 + strbuf_stripspace(&buf, comment_line_char);
689
690 strbuf_addf(&name, "branch.%s.description", branch_name);
691 if (buf.len || exists)
builtin/commit.c
+1 -1
@@ -893,7 +893,7 @@ static int prepare_to_commit(const char *index_file, const char *prefix,
893 s->hints = 0;
894
895 if (clean_message_contents)
896 - strbuf_stripspace(&sb, 0);
896 + strbuf_stripspace(&sb, '\0');
897
898 if (signoff)
899 append_signoff(&sb, ignore_non_trailer(sb.buf, sb.len), 0);
builtin/merge.c
+6 -4
@@ -879,13 +879,15 @@ static void prepare_to_commit(struct commit_list *remoteheads)
879 strbuf_addch(&msg, '\n');
880 if (cleanup_mode == COMMIT_MSG_CLEANUP_SCISSORS) {
881 wt_status_append_cut_line(&msg);
882 - strbuf_commented_addf(&msg, "\n");
882 + strbuf_commented_addf(&msg, comment_line_char, "\n");
883 }
884 - strbuf_commented_addf(&msg, _(merge_editor_comment));
884 + strbuf_commented_addf(&msg, comment_line_char,
885 + _(merge_editor_comment));
886 if (cleanup_mode == COMMIT_MSG_CLEANUP_SCISSORS)
886 - strbuf_commented_addf(&msg, _(scissors_editor_comment));
887 + strbuf_commented_addf(&msg, comment_line_char,
888 + _(scissors_editor_comment));
889 else
888 - strbuf_commented_addf(&msg,
890 + strbuf_commented_addf(&msg, comment_line_char,
891 _(no_scissors_editor_comment), comment_line_char);
892 }
893 if (signoff)
builtin/notes.c
+9 -7
@@ -11,6 +11,7 @@
11 #include "config.h"
12 #include "builtin.h"
13 #include "editor.h"
14 +#include "environment.h"
15 #include "gettext.h"
16 #include "hex.h"
17 #include "notes.h"
@@ -157,7 +158,7 @@ static void write_commented_object(int fd, const struct object_id *object)
158
159 if (strbuf_read(&buf, show.out, 0) < 0)
160 die_errno(_("could not read 'show' output"));
160 - strbuf_add_commented_lines(&cbuf, buf.buf, buf.len);
161 + strbuf_add_commented_lines(&cbuf, buf.buf, buf.len, comment_line_char);
162 write_or_die(fd, cbuf.buf, cbuf.len);
163
164 strbuf_release(&cbuf);
@@ -185,9 +186,10 @@ static void prepare_note_data(const struct object_id *object, struct note_data *
186 copy_obj_to_fd(fd, old_note);
187
188 strbuf_addch(&buf, '\n');
188 - strbuf_add_commented_lines(&buf, "\n", strlen("\n"));
189 - strbuf_add_commented_lines(&buf, _(note_template), strlen(_(note_template)));
190 - strbuf_add_commented_lines(&buf, "\n", strlen("\n"));
189 + strbuf_add_commented_lines(&buf, "\n", strlen("\n"), comment_line_char);
190 + strbuf_add_commented_lines(&buf, _(note_template), strlen(_(note_template)),
191 + comment_line_char);
192 + strbuf_add_commented_lines(&buf, "\n", strlen("\n"), comment_line_char);
193 write_or_die(fd, buf.buf, buf.len);
194
195 write_commented_object(fd, object);
@@ -199,7 +201,7 @@ static void prepare_note_data(const struct object_id *object, struct note_data *
201 if (launch_editor(d->edit_path, &d->buf, NULL)) {
202 die(_("please supply the note contents using either -m or -F option"));
203 }
202 - strbuf_stripspace(&d->buf, 1);
204 + strbuf_stripspace(&d->buf, comment_line_char);
205 }
206 }
207
@@ -225,7 +227,7 @@ static int parse_msg_arg(const struct option *opt, const char *arg, int unset)
227 if (d->buf.len)
228 strbuf_addch(&d->buf, '\n');
229 strbuf_addstr(&d->buf, arg);
228 - strbuf_stripspace(&d->buf, 0);
230 + strbuf_stripspace(&d->buf, '\0');
231
232 d->given = 1;
233 return 0;
@@ -244,7 +246,7 @@ static int parse_file_arg(const struct option *opt, const char *arg, int unset)
246 die_errno(_("cannot read '%s'"), arg);
247 } else if (strbuf_read_file(&d->buf, arg, 1024) < 0)
248 die_errno(_("could not open or read '%s'"), arg);
247 - strbuf_stripspace(&d->buf, 0);
249 + strbuf_stripspace(&d->buf, '\0');
250
251 d->given = 1;
252 return 0;
builtin/rebase.c
+1 -1
@@ -209,7 +209,7 @@ static int edit_todo_file(unsigned flags)
209 if (strbuf_read_file(&todo_list.buf, todo_file, 0) < 0)
210 return error_errno(_("could not read '%s'."), todo_file);
211
212 - strbuf_stripspace(&todo_list.buf, 1);
212 + strbuf_stripspace(&todo_list.buf, comment_line_char);
213 res = edit_todo_list(the_repository, &todo_list, &new_todo, NULL, NULL, flags);
214 if (!res && todo_list_write_to_file(the_repository, &new_todo, todo_file,
215 NULL, NULL, -1, flags & ~(TODO_LIST_SHORTEN_IDS)))
builtin/stripspace.c
+4 -2
@@ -1,6 +1,7 @@
1 #include "builtin.h"
2 #include "cache.h"
3 #include "config.h"
4 +#include "environment.h"
5 #include "gettext.h"
6 #include "parse-options.h"
7 #include "setup.h"
@@ -13,7 +14,7 @@ static void comment_lines(struct strbuf *buf)
14 size_t len;
15
16 msg = strbuf_detach(buf, &len);
16 - strbuf_add_commented_lines(buf, msg, len);
17 + strbuf_add_commented_lines(buf, msg, len, comment_line_char);
18 free(msg);
19 }
20
@@ -58,7 +59,8 @@ int cmd_stripspace(int argc, const char **argv, const char *prefix)
59 die_errno("could not read the input");
60
61 if (mode == STRIP_DEFAULT || mode == STRIP_COMMENTS)
61 - strbuf_stripspace(&buf, mode == STRIP_COMMENTS);
62 + strbuf_stripspace(&buf,
63 + mode == STRIP_COMMENTS ? comment_line_char : '\0');
64 else
65 comment_lines(&buf);
66
builtin/tag.c
+6 -3
@@ -311,9 +311,11 @@ static void create_tag(const struct object_id *object, const char *object_ref,
311 struct strbuf buf = STRBUF_INIT;
312 strbuf_addch(&buf, '\n');
313 if (opt->cleanup_mode == CLEANUP_ALL)
314 - strbuf_commented_addf(&buf, _(tag_template), tag, comment_line_char);
314 + strbuf_commented_addf(&buf, comment_line_char,
315 + _(tag_template), tag, comment_line_char);
316 else
316 - strbuf_commented_addf(&buf, _(tag_template_nocleanup), tag, comment_line_char);
317 + strbuf_commented_addf(&buf, comment_line_char,
318 + _(tag_template_nocleanup), tag, comment_line_char);
319 write_or_die(fd, buf.buf, buf.len);
320 strbuf_release(&buf);
321 }
@@ -327,7 +329,8 @@ static void create_tag(const struct object_id *object, const char *object_ref,
329 }
330
331 if (opt->cleanup_mode != CLEANUP_NONE)
330 - strbuf_stripspace(buf, opt->cleanup_mode == CLEANUP_ALL);
332 + strbuf_stripspace(buf,
333 + opt->cleanup_mode == CLEANUP_ALL ? comment_line_char : '\0');
334
335 if (!opt->message_given && !buf->len)
336 die(_("no tag message?"));
fmt-merge-msg.c
+6 -3
@@ -508,7 +508,8 @@ static void fmt_tag_signature(struct strbuf *tagbuf,
508 strbuf_complete_line(tagbuf);
509 if (sig->len) {
510 strbuf_addch(tagbuf, '\n');
511 - strbuf_add_commented_lines(tagbuf, sig->buf, sig->len);
511 + strbuf_add_commented_lines(tagbuf, sig->buf, sig->len,
512 + comment_line_char);
513 }
514 }
515
@@ -554,7 +555,8 @@ static void fmt_merge_msg_sigs(struct strbuf *out)
555 strbuf_addch(&tagline, '\n');
556 strbuf_add_commented_lines(&tagline,
557 origins.items[first_tag].string,
557 - strlen(origins.items[first_tag].string));
558 + strlen(origins.items[first_tag].string),
559 + comment_line_char);
560 strbuf_insert(&tagbuf, 0, tagline.buf,
561 tagline.len);
562 strbuf_release(&tagline);
@@ -562,7 +564,8 @@ static void fmt_merge_msg_sigs(struct strbuf *out)
564 strbuf_addch(&tagbuf, '\n');
565 strbuf_add_commented_lines(&tagbuf,
566 origins.items[i].string,
565 - strlen(origins.items[i].string));
567 + strlen(origins.items[i].string),
568 + comment_line_char);
569 fmt_tag_signature(&tagbuf, &sig, buf, len);
570 }
571 strbuf_release(&payload);
gpg-interface.c
+3 -2
@@ -13,6 +13,7 @@
13 #include "tempfile.h"
14 #include "alias.h"
15 #include "wrapper.h"
16 +#include "environment.h"
17
18 static int git_gpg_config(const char *, const char *, void *);
19
@@ -586,8 +587,8 @@ static int verify_ssh_signed_buffer(struct signature_check *sigc,
587 }
588 }
589
589 - strbuf_stripspace(&ssh_keygen_out, 0);
590 - strbuf_stripspace(&ssh_keygen_err, 0);
590 + strbuf_stripspace(&ssh_keygen_out, '\0');
591 + strbuf_stripspace(&ssh_keygen_err, '\0');
592 /* Add stderr outputs to show the user actual ssh-keygen errors */
593 strbuf_add(&ssh_keygen_out, ssh_principals_err.buf, ssh_principals_err.len);
594 strbuf_add(&ssh_keygen_out, ssh_keygen_err.buf, ssh_keygen_err.len);
rebase-interactive.c
+8 -7
@@ -72,13 +72,14 @@ void append_todo_help(int command_count,
72
73 if (!edit_todo) {
74 strbuf_addch(buf, '\n');
75 - strbuf_commented_addf(buf, Q_("Rebase %s onto %s (%d command)",
76 - "Rebase %s onto %s (%d commands)",
77 - command_count),
75 + strbuf_commented_addf(buf, comment_line_char,
76 + Q_("Rebase %s onto %s (%d command)",
77 + "Rebase %s onto %s (%d commands)",
78 + command_count),
79 shortrevisions, shortonto, command_count);
80 }
81
81 - strbuf_add_commented_lines(buf, msg, strlen(msg));
82 + strbuf_add_commented_lines(buf, msg, strlen(msg), comment_line_char);
83
84 if (get_missing_commit_check_level() == MISSING_COMMIT_CHECK_ERROR)
85 msg = _("\nDo not remove any line. Use 'drop' "
@@ -87,7 +88,7 @@ void append_todo_help(int command_count,
88 msg = _("\nIf you remove a line here "
89 "THAT COMMIT WILL BE LOST.\n");
90
90 - strbuf_add_commented_lines(buf, msg, strlen(msg));
91 + strbuf_add_commented_lines(buf, msg, strlen(msg), comment_line_char);
92
93 if (edit_todo)
94 msg = _("\nYou are editing the todo file "
@@ -98,7 +99,7 @@ void append_todo_help(int command_count,
99 msg = _("\nHowever, if you remove everything, "
100 "the rebase will be aborted.\n\n");
101
101 - strbuf_add_commented_lines(buf, msg, strlen(msg));
102 + strbuf_add_commented_lines(buf, msg, strlen(msg), comment_line_char);
103 }
104
105 int edit_todo_list(struct repository *r, struct todo_list *todo_list,
@@ -130,7 +131,7 @@ int edit_todo_list(struct repository *r, struct todo_list *todo_list,
131 if (launch_sequence_editor(todo_file, &new_todo->buf, NULL))
132 return -2;
133
133 - strbuf_stripspace(&new_todo->buf, 1);
134 + strbuf_stripspace(&new_todo->buf, comment_line_char);
135 if (initial && new_todo->buf.len == 0)
136 return -3;
137
sequencer.c
+15 -9
@@ -660,11 +660,12 @@ void append_conflicts_hint(struct index_state *istate,
660 }
661
662 strbuf_addch(msgbuf, '\n');
663 - strbuf_commented_addf(msgbuf, "Conflicts:\n");
663 + strbuf_commented_addf(msgbuf, comment_line_char, "Conflicts:\n");
664 for (i = 0; i < istate->cache_nr;) {
665 const struct cache_entry *ce = istate->cache[i++];
666 if (ce_stage(ce)) {
667 - strbuf_commented_addf(msgbuf, "\t%s\n", ce->name);
667 + strbuf_commented_addf(msgbuf, comment_line_char,
668 + "\t%s\n", ce->name);
669 while (i < istate->cache_nr &&
670 !strcmp(ce->name, istate->cache[i]->name))
671 i++;
@@ -1143,7 +1144,8 @@ void cleanup_message(struct strbuf *msgbuf,
1144 cleanup_mode == COMMIT_MSG_CLEANUP_SCISSORS)
1145 strbuf_setlen(msgbuf, wt_status_locate_end(msgbuf->buf, msgbuf->len));
1146 if (cleanup_mode != COMMIT_MSG_CLEANUP_NONE)
1146 - strbuf_stripspace(msgbuf, cleanup_mode == COMMIT_MSG_CLEANUP_ALL);
1147 + strbuf_stripspace(msgbuf,
1148 + cleanup_mode == COMMIT_MSG_CLEANUP_ALL ? comment_line_char : '\0');
1149 }
1150
1151 /*
@@ -1174,7 +1176,8 @@ int template_untouched(const struct strbuf *sb, const char *template_file,
1176 if (!template_file || strbuf_read_file(&tmpl, template_file, 0) <= 0)
1177 return 0;
1178
1177 - strbuf_stripspace(&tmpl, cleanup_mode == COMMIT_MSG_CLEANUP_ALL);
1179 + strbuf_stripspace(&tmpl,
1180 + cleanup_mode == COMMIT_MSG_CLEANUP_ALL ? comment_line_char : '\0');
1181 if (!skip_prefix(sb->buf, tmpl.buf, &start))
1182 start = sb->buf;
1183 strbuf_release(&tmpl);
@@ -1546,7 +1549,8 @@ static int try_to_commit(struct repository *r,
1549 cleanup = opts->default_msg_cleanup;
1550
1551 if (cleanup != COMMIT_MSG_CLEANUP_NONE)
1549 - strbuf_stripspace(msg, cleanup == COMMIT_MSG_CLEANUP_ALL);
1552 + strbuf_stripspace(msg,
1553 + cleanup == COMMIT_MSG_CLEANUP_ALL ? comment_line_char : '\0');
1554 if ((flags & EDIT_MSG) && message_is_empty(msg, cleanup)) {
1555 res = 1; /* run 'git commit' to display error message */
1556 goto out;
@@ -1840,7 +1844,7 @@ static void add_commented_lines(struct strbuf *buf, const void *str, size_t len)
1844 s += count;
1845 len -= count;
1846 }
1843 - strbuf_add_commented_lines(buf, s, len);
1847 + strbuf_add_commented_lines(buf, s, len, comment_line_char);
1848 }
1849
1850 /* Does the current fixup chain contain a squash command? */
@@ -1939,7 +1943,7 @@ static int append_squash_message(struct strbuf *buf, const char *body,
1943 strbuf_addf(buf, _(nth_commit_msg_fmt),
1944 ++opts->current_fixup_count + 1);
1945 strbuf_addstr(buf, "\n\n");
1942 - strbuf_add_commented_lines(buf, body, commented_len);
1946 + strbuf_add_commented_lines(buf, body, commented_len, comment_line_char);
1947 /* buf->buf may be reallocated so store an offset into the buffer */
1948 fixup_off = buf->len;
1949 strbuf_addstr(buf, body + commented_len);
@@ -2029,7 +2033,8 @@ static int update_squash_messages(struct repository *r,
2033 _(first_commit_msg_str));
2034 strbuf_addstr(&buf, "\n\n");
2035 if (is_fixup_flag(command, flag))
2032 - strbuf_add_commented_lines(&buf, body, strlen(body));
2036 + strbuf_add_commented_lines(&buf, body, strlen(body),
2037 + comment_line_char);
2038 else
2039 strbuf_addstr(&buf, body);
2040
@@ -2048,7 +2053,8 @@ static int update_squash_messages(struct repository *r,
2053 strbuf_addf(&buf, _(skip_nth_commit_msg_fmt),
2054 ++opts->current_fixup_count + 1);
2055 strbuf_addstr(&buf, "\n\n");
2051 - strbuf_add_commented_lines(&buf, body, strlen(body));
2056 + strbuf_add_commented_lines(&buf, body, strlen(body),
2057 + comment_line_char);
2058 } else
2059 return error(_("unknown command: %d"), command);
2060 repo_unuse_commit_buffer(r, commit, message);
strbuf.c
+10 -8
@@ -1,6 +1,5 @@
1 #include "git-compat-util.h"
2 #include "alloc.h"
3 -#include "environment.h"
3 #include "gettext.h"
4 #include "hex.h"
5 #include "strbuf.h"
@@ -362,7 +361,8 @@ static void add_lines(struct strbuf *out,
361 strbuf_complete_line(out);
362 }
363
365 -void strbuf_add_commented_lines(struct strbuf *out, const char *buf, size_t size)
364 +void strbuf_add_commented_lines(struct strbuf *out, const char *buf,
365 + size_t size, char comment_line_char)
366 {
367 static char prefix1[3];
368 static char prefix2[2];
@@ -374,7 +374,8 @@ void strbuf_add_commented_lines(struct strbuf *out, const char *buf, size_t size
374 add_lines(out, prefix1, prefix2, buf, size);
375 }
376
377 -void strbuf_commented_addf(struct strbuf *sb, const char *fmt, ...)
377 +void strbuf_commented_addf(struct strbuf *sb, char comment_line_char,
378 + const char *fmt, ...)
379 {
380 va_list params;
381 struct strbuf buf = STRBUF_INIT;
@@ -384,7 +385,7 @@ void strbuf_commented_addf(struct strbuf *sb, const char *fmt, ...)
385 strbuf_vaddf(&buf, fmt, params);
386 va_end(params);
387
387 - strbuf_add_commented_lines(sb, buf.buf, buf.len);
388 + strbuf_add_commented_lines(sb, buf.buf, buf.len, comment_line_char);
389 if (incomplete_line)
390 sb->buf[--sb->len] = '\0';
391
@@ -1051,10 +1052,10 @@ static size_t cleanup(char *line, size_t len)
1052 *
1053 * If last line does not have a newline at the end, one is added.
1054 *
1054 - * Enable skip_comments to skip every line starting with comment
1055 - * character.
1055 + * Pass a non-NUL comment_line_char to skip every line starting
1056 + * with it.
1057 */
1057 -void strbuf_stripspace(struct strbuf *sb, int skip_comments)
1058 +void strbuf_stripspace(struct strbuf *sb, char comment_line_char)
1059 {
1060 size_t empties = 0;
1061 size_t i, j, len, newlen;
@@ -1067,7 +1068,8 @@ void strbuf_stripspace(struct strbuf *sb, int skip_comments)
1068 eol = memchr(sb->buf + i, '\n', sb->len - i);
1069 len = eol ? eol - (sb->buf + i) + 1 : sb->len - i;
1070
1070 - if (skip_comments && len && sb->buf[i] == comment_line_char) {
1071 + if (comment_line_char && len &&
1072 + sb->buf[i] == comment_line_char) {
1073 newlen = 0;
1074 continue;
1075 }
strbuf.h
+8 -6
@@ -291,7 +291,8 @@ void strbuf_splice(struct strbuf *sb, size_t pos, size_t len,
291 * by a comment character and a blank.
292 */
293 void strbuf_add_commented_lines(struct strbuf *out,
294 - const char *buf, size_t size);
294 + const char *buf, size_t size,
295 + char comment_line_char);
296
297
298 /**
@@ -420,8 +421,8 @@ void strbuf_addf(struct strbuf *sb, const char *fmt, ...);
421 * Add a formatted string prepended by a comment character and a
422 * blank to the buffer.
423 */
423 -__attribute__((format (printf, 2, 3)))
424 -void strbuf_commented_addf(struct strbuf *sb, const char *fmt, ...);
424 +__attribute__((format (printf, 3, 4)))
425 +void strbuf_commented_addf(struct strbuf *sb, char comment_line_char, const char *fmt, ...);
426
427 __attribute__((format (printf,2,0)))
428 void strbuf_vaddf(struct strbuf *sb, const char *fmt, va_list ap);
@@ -543,10 +544,11 @@ int strbuf_getcwd(struct strbuf *sb);
544 int strbuf_normalize_path(struct strbuf *sb);
545
546 /**
546 - * Strip whitespace from a buffer. The second parameter controls if
547 - * comments are considered contents to be removed or not.
547 + * Strip whitespace from a buffer. If comment_line_char is non-NUL,
548 + * then lines beginning with that character are considered comments,
549 + * thus removed.
550 */
549 -void strbuf_stripspace(struct strbuf *buf, int skip_comments);
551 +void strbuf_stripspace(struct strbuf *buf, char comment_line_char);
552
553 static inline int strbuf_strip_suffix(struct strbuf *sb, const char *suffix)
554 {
wt-status.c
+3 -3
@@ -1024,7 +1024,7 @@ static void wt_longstatus_print_submodule_summary(struct wt_status *s, int uncom
1024 if (s->display_comment_prefix) {
1025 size_t len;
1026 summary_content = strbuf_detach(&summary, &len);
1027 - strbuf_add_commented_lines(&summary, summary_content, len);
1027 + strbuf_add_commented_lines(&summary, summary_content, len, comment_line_char);
1028 free(summary_content);
1029 }
1030
@@ -1099,8 +1099,8 @@ void wt_status_append_cut_line(struct strbuf *buf)
1099 {
1100 const char *explanation = _("Do not modify or remove the line above.\nEverything below it will be ignored.");
1101
1102 - strbuf_commented_addf(buf, "%s", cut_line);
1103 - strbuf_add_commented_lines(buf, explanation, strlen(explanation));
1102 + strbuf_commented_addf(buf, comment_line_char, "%s", cut_line);
1103 + strbuf_add_commented_lines(buf, explanation, strlen(explanation), comment_line_char);
1104 }
1105
1106 void wt_status_add_cut_line(FILE *fp)