Allow custom "comment char"

Some users do want to write a line that begin with a pound sign, #, in their commit log message. Many tracking system recognise a token of #<bugid> form, for example. The support we offer these use cases is not very friendly to the end users. They have a choice between - Don't do it. Avoid such a line by rewrapping or indenting; and - Use --cleanup=whitespace but remove all the hint lines we add. Give them a way to set a custom comment char, e.g. $ git -c core.commentchar="%" commit so that they do not have to do either of the two workarounds. [jc: although I started the topic, all the tests and documentation updates, many of the call sites of the new strbuf_add_commented_*() functions, and the change to git-submodule.sh scripted Porcelain are from Ralf.] Signed-off-by: Junio C Hamano <gitster@pobox.com> Signed-off-by: Ralf Thielow <ralf.thielow@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>

Junio C Hamano committed Jan 16, 2013 at 20:18 UTC eff80a9fd990de3605063050dae32f969ef18ba8
20 files changed +284 -78
Documentation/config.txt
+6
@@ -528,6 +528,12 @@ core.editor::
528 variable when it is set, and the environment variable
529 `GIT_EDITOR` is not set. See linkgit:git-var[1].
530
531 +core.commentchar::
532 + Commands such as `commit` and `tag` that lets you edit
533 + messages consider a line that begins with this character
534 + commented, and removes them after the editor returns
535 + (default '#').
536 +
537 sequence.editor::
538 Text editor used by `git rebase -i` for editing the rebase insn file.
539 The value is meant to be interpreted by the shell when it is used.
Documentation/git-stripspace.txt
+7 -1
@@ -35,7 +35,13 @@ OPTIONS
35 -------
36 -s::
37 --strip-comments::
38 - Skip and remove all lines starting with '#'.
38 + Skip and remove all lines starting with comment character (default '#').
39 +
40 +-c::
41 +--comment-lines::
42 + Prepend comment character and blank to each line. Lines will automatically
43 + be terminated with a newline. On empty lines, only the comment character
44 + will be prepended.
45
46 EXAMPLES
47 --------
Documentation/technical/api-strbuf.txt
+10
@@ -156,6 +156,11 @@ then they will free() it.
156 Remove the bytes between `pos..pos+len` and replace it with the given
157 data.
158
159 +`strbuf_add_commented_lines`::
160 +
161 + Add a NUL-terminated string to the buffer. Each line will be prepended
162 + by a comment character and a blank.
163 +
164 `strbuf_add`::
165
166 Add data of given length to the buffer.
@@ -229,6 +234,11 @@ which can be used by the programmer of the callback as she sees fit.
234
235 Add a formatted string to the buffer.
236
237 +`strbuf_commented_addf`::
238 +
239 + Add a formatted string prepended by a comment character and a
240 + blank to the buffer.
241 +
242 `strbuf_fread`::
243
244 Read a given size of data from a FILE* pointer to the buffer.
builtin/branch.c
+5 -5
@@ -706,11 +706,11 @@ static int edit_branch_description(const char *branch_name)
706 read_branch_desc(&buf, branch_name);
707 if (!buf.len || buf.buf[buf.len-1] != '\n')
708 strbuf_addch(&buf, '\n');
709 - strbuf_addf(&buf,
710 - "# Please edit the description for the branch\n"
711 - "# %s\n"
712 - "# Lines starting with '#' will be stripped.\n",
713 - branch_name);
709 + strbuf_commented_addf(&buf,
710 + "Please edit the description for the branch\n"
711 + " %s\n"
712 + "Lines starting with '%c' will be stripped.\n",
713 + branch_name, comment_line_char);
714 fp = fopen(git_path(edit_description), "w");
715 if ((fwrite(buf.buf, 1, buf.len, fp) < buf.len) || fclose(fp)) {
716 strbuf_release(&buf);
builtin/commit.c
+6 -6
@@ -733,15 +733,15 @@ static int prepare_to_commit(const char *index_file, const char *prefix,
733 if (cleanup_mode == CLEANUP_ALL)
734 status_printf(s, GIT_COLOR_NORMAL,
735 _("Please enter the commit message for your changes."
736 - " Lines starting\nwith '#' will be ignored, and an empty"
737 - " message aborts the commit.\n"));
736 + " Lines starting\nwith '%c' will be ignored, and an empty"
737 + " message aborts the commit.\n"), comment_line_char);
738 else /* CLEANUP_SPACE, that is. */
739 status_printf(s, GIT_COLOR_NORMAL,
740 _("Please enter the commit message for your changes."
741 - " Lines starting\n"
742 - "with '#' will be kept; you may remove them"
743 - " yourself if you want to.\n"
744 - "An empty message aborts the commit.\n"));
741 + " Lines starting\n"
742 + "with '%c' will be kept; you may remove them"
743 + " yourself if you want to.\n"
744 + "An empty message aborts the commit.\n"), comment_line_char);
745 if (only_include_assumed)
746 status_printf_ln(s, GIT_COLOR_NORMAL,
747 "%s", only_include_assumed);
builtin/fmt-merge-msg.c
+1 -1
@@ -464,7 +464,7 @@ static void fmt_tag_signature(struct strbuf *tagbuf,
464 strbuf_complete_line(tagbuf);
465 if (sig->len) {
466 strbuf_addch(tagbuf, '\n');
467 - strbuf_add_lines(tagbuf, "# ", sig->buf, sig->len);
467 + strbuf_add_commented_lines(tagbuf, sig->buf, sig->len);
468 }
469 }
470
builtin/merge.c
+2 -3
@@ -788,17 +788,16 @@ static const char merge_editor_comment[] =
788 N_("Please enter a commit message to explain why this merge is necessary,\n"
789 "especially if it merges an updated upstream into a topic branch.\n"
790 "\n"
791 - "Lines starting with '#' will be ignored, and an empty message aborts\n"
791 + "Lines starting with '%c' will be ignored, and an empty message aborts\n"
792 "the commit.\n");
793
794 static void prepare_to_commit(struct commit_list *remoteheads)
795 {
796 struct strbuf msg = STRBUF_INIT;
797 - const char *comment = _(merge_editor_comment);
797 strbuf_addbuf(&msg, &merge_msg);
798 strbuf_addch(&msg, '\n');
799 if (0 < option_edit)
801 - strbuf_add_lines(&msg, "# ", comment, strlen(comment));
800 + strbuf_commented_addf(&msg, _(merge_editor_comment), comment_line_char);
801 write_merge_msg(&msg);
802 if (run_hook(get_index_file(), "prepare-commit-msg",
803 git_path("MERGE_MSG"), "merge", NULL, NULL))
builtin/notes.c
+15 -19
@@ -92,10 +92,7 @@ static const char * const git_notes_get_ref_usage[] = {
92 };
93
94 static const char note_template[] =
95 - "\n"
96 - "#\n"
97 - "# Write/edit the notes for the following object:\n"
98 - "#\n";
95 + "\nWrite/edit the notes for the following object:\n";
96
97 struct msg_arg {
98 int given;
@@ -129,7 +126,7 @@ static void write_commented_object(int fd, const unsigned char *object)
126 {"show", "--stat", "--no-notes", sha1_to_hex(object), NULL};
127 struct child_process show;
128 struct strbuf buf = STRBUF_INIT;
132 - FILE *show_out;
129 + struct strbuf cbuf = STRBUF_INIT;
130
131 /* Invoke "git show --stat --no-notes $object" */
132 memset(&show, 0, sizeof(show));
@@ -142,21 +139,14 @@ static void write_commented_object(int fd, const unsigned char *object)
139 die(_("unable to start 'show' for object '%s'"),
140 sha1_to_hex(object));
141
145 - /* Open the output as FILE* so strbuf_getline() can be used. */
146 - show_out = xfdopen(show.out, "r");
147 - if (show_out == NULL)
148 - die_errno(_("can't fdopen 'show' output fd"));
142 + if (strbuf_read(&buf, show.out, 0) < 0)
143 + die_errno(_("could not read 'show' output"));
144 + strbuf_add_commented_lines(&cbuf, buf.buf, buf.len);
145 + write_or_die(fd, cbuf.buf, cbuf.len);
146
150 - /* Prepend "# " to each output line and write result to 'fd' */
151 - while (strbuf_getline(&buf, show_out, '\n') != EOF) {
152 - write_or_die(fd, "# ", 2);
153 - write_or_die(fd, buf.buf, buf.len);
154 - write_or_die(fd, "\n", 1);
155 - }
147 + strbuf_release(&cbuf);
148 strbuf_release(&buf);
157 - if (fclose(show_out))
158 - die_errno(_("failed to close pipe to 'show' for object '%s'"),
159 - sha1_to_hex(object));
149 +
150 if (finish_command(&show))
151 die(_("failed to finish 'show' for object '%s'"),
152 sha1_to_hex(object));
@@ -170,6 +160,7 @@ static void create_note(const unsigned char *object, struct msg_arg *msg,
160
161 if (msg->use_editor || !msg->given) {
162 int fd;
163 + struct strbuf buf = STRBUF_INIT;
164
165 /* write the template message before editing: */
166 path = git_pathdup("NOTES_EDITMSG");
@@ -181,11 +172,16 @@ static void create_note(const unsigned char *object, struct msg_arg *msg,
172 write_or_die(fd, msg->buf.buf, msg->buf.len);
173 else if (prev && !append_only)
174 write_note_data(fd, prev);
184 - write_or_die(fd, note_template, strlen(note_template));
175 +
176 + strbuf_addch(&buf, '\n');
177 + strbuf_add_commented_lines(&buf, note_template, strlen(note_template));
178 + strbuf_addch(&buf, '\n');
179 + write_or_die(fd, buf.buf, buf.len);
180
181 write_commented_object(fd, object);
182
183 close(fd);
184 + strbuf_release(&buf);
185 strbuf_reset(&(msg->buf));
186
187 if (launch_editor(path, &(msg->buf), NULL)) {
builtin/stripspace.c
+41 -8
@@ -30,7 +30,8 @@ static size_t cleanup(char *line, size_t len)
30 *
31 * If last line does not have a newline at the end, one is added.
32 *
33 - * Enable skip_comments to skip every line starting with "#".
33 + * Enable skip_comments to skip every line starting with comment
34 + * character.
35 */
36 void stripspace(struct strbuf *sb, int skip_comments)
37 {
@@ -45,7 +46,7 @@ void stripspace(struct strbuf *sb, int skip_comments)
46 eol = memchr(sb->buf + i, '\n', sb->len - i);
47 len = eol ? eol - (sb->buf + i) + 1 : sb->len - i;
48
48 - if (skip_comments && len && sb->buf[i] == '#') {
49 + if (skip_comments && len && sb->buf[i] == comment_line_char) {
50 newlen = 0;
51 continue;
52 }
@@ -66,21 +67,53 @@ void stripspace(struct strbuf *sb, int skip_comments)
67 strbuf_setlen(sb, j);
68 }
69
70 +static void comment_lines(struct strbuf *buf)
71 +{
72 + char *msg;
73 + size_t len;
74 +
75 + msg = strbuf_detach(buf, &len);
76 + strbuf_add_commented_lines(buf, msg, len);
77 + free(msg);
78 +}
79 +
80 +static const char *usage_msg = "\n"
81 +" git stripspace [-s | --strip-comments] < input\n"
82 +" git stripspace [-c | --comment-lines] < input";
83 +
84 int cmd_stripspace(int argc, const char **argv, const char *prefix)
85 {
86 struct strbuf buf = STRBUF_INIT;
87 int strip_comments = 0;
88 + enum { INVAL = 0, STRIP_SPACE = 1, COMMENT_LINES = 2 } mode = STRIP_SPACE;
89 +
90 + if (argc == 2) {
91 + if (!strcmp(argv[1], "-s") ||
92 + !strcmp(argv[1], "--strip-comments")) {
93 + strip_comments = 1;
94 + } else if (!strcmp(argv[1], "-c") ||
95 + !strcmp(argv[1], "--comment-lines")) {
96 + mode = COMMENT_LINES;
97 + } else {
98 + mode = INVAL;
99 + }
100 + } else if (argc > 1) {
101 + mode = INVAL;
102 + }
103 +
104 + if (mode == INVAL)
105 + usage(usage_msg);
106
74 - if (argc == 2 && (!strcmp(argv[1], "-s") ||
75 - !strcmp(argv[1], "--strip-comments")))
76 - strip_comments = 1;
77 - else if (argc > 1)
78 - usage("git stripspace [-s | --strip-comments] < input");
107 + if (strip_comments || mode == COMMENT_LINES)
108 + git_config(git_default_config, NULL);
109
110 if (strbuf_read(&buf, 0, 1024) < 0)
111 die_errno("could not read the input");
112
83 - stripspace(&buf, strip_comments);
113 + if (mode == STRIP_SPACE)
114 + stripspace(&buf, strip_comments);
115 + else
116 + comment_lines(&buf);
117
118 write_or_die(1, buf.buf, buf.len);
119 strbuf_release(&buf);
builtin/tag.c
+16 -18
@@ -246,19 +246,13 @@ static int do_sign(struct strbuf *buffer)
246 }
247
248 static const char tag_template[] =
249 - N_("\n"
250 - "#\n"
251 - "# Write a tag message\n"
252 - "# Lines starting with '#' will be ignored.\n"
253 - "#\n");
249 + N_("\nWrite a tag message\n"
250 + "Lines starting with '%c' will be ignored.\n");
251
252 static const char tag_template_nocleanup[] =
256 - N_("\n"
257 - "#\n"
258 - "# Write a tag message\n"
259 - "# Lines starting with '#' will be kept; you may remove them"
260 - " yourself if you want to.\n"
261 - "#\n");
253 + N_("\nWrite a tag message\n"
254 + "Lines starting with '%c' will be kept; you may remove them"
255 + " yourself if you want to.\n");
256
257 static int git_tag_config(const char *var, const char *value, void *cb)
258 {
@@ -346,14 +340,18 @@ static void create_tag(const unsigned char *object, const char *tag,
340 if (fd < 0)
341 die_errno(_("could not create file '%s'"), path);
342
349 - if (!is_null_sha1(prev))
343 + if (!is_null_sha1(prev)) {
344 write_tag_body(fd, prev);
351 - else if (opt->cleanup_mode == CLEANUP_ALL)
352 - write_or_die(fd, _(tag_template),
353 - strlen(_(tag_template)));
354 - else
355 - write_or_die(fd, _(tag_template_nocleanup),
356 - strlen(_(tag_template_nocleanup)));
345 + } else {
346 + struct strbuf buf = STRBUF_INIT;
347 + strbuf_addch(&buf, '\n');
348 + if (opt->cleanup_mode == CLEANUP_ALL)
349 + strbuf_commented_addf(&buf, _(tag_template), comment_line_char);
350 + else
351 + strbuf_commented_addf(&buf, _(tag_template_nocleanup), comment_line_char);
352 + write_or_die(fd, buf.buf, buf.len);
353 + strbuf_release(&buf);
354 + }
355 close(fd);
356
357 if (launch_editor(path, buf, NULL)) {
cache.h
+6
@@ -562,6 +562,12 @@ extern int core_preload_index;
562 extern int core_apply_sparse_checkout;
563 extern int precomposed_unicode;
564
565 +/*
566 + * The character that begins a commented line in user-editable file
567 + * that is subject to stripspace.
568 + */
569 +extern char comment_line_char;
570 +
571 enum branch_track {
572 BRANCH_TRACK_UNSPECIFIED = -1,
573 BRANCH_TRACK_NEVER = 0,
config.c
+8
@@ -717,6 +717,14 @@ static int git_default_core_config(const char *var, const char *value)
717 if (!strcmp(var, "core.editor"))
718 return git_config_string(&editor_program, var, value);
719
720 + if (!strcmp(var, "core.commentchar")) {
721 + const char *comment;
722 + int ret = git_config_string(&comment, var, value);
723 + if (!ret)
724 + comment_line_char = comment[0];
725 + return ret;
726 + }
727 +
728 if (!strcmp(var, "core.askpass"))
729 return git_config_string(&askpass_program, var, value);
730
environment.c
+6
@@ -62,6 +62,12 @@ int precomposed_unicode = -1; /* see probe_utf8_pathname_composition() */
62 struct startup_info *startup_info;
63 unsigned long pack_size_limit_cfg;
64
65 +/*
66 + * The character that begins a commented line in user-editable file
67 + * that is subject to stripspace.
68 + */
69 +char comment_line_char = '#';
70 +
71 /* Parallel index stat data preload? */
72 int core_preload_index = 0;
73
git-submodule.sh
+4 -4
@@ -976,12 +976,12 @@ cmd_summary() {
976 done |
977 if test -n "$for_status"; then
978 if [ -n "$files" ]; then
979 - gettextln "# Submodules changed but not updated:"
979 + gettextln "Submodules changed but not updated:" | git stripspace -c
980 else
981 - gettextln "# Submodule changes to be committed:"
981 + gettextln "Submodule changes to be committed:" | git stripspace -c
982 fi
983 - echo "#"
984 - sed -e 's|^|# |' -e 's|^# $|#|'
983 + printf "\n" | git stripspace -c
984 + git stripspace -c
985 else
986 cat
987 fi
strbuf.c
+49 -9
@@ -204,6 +204,54 @@ void strbuf_addf(struct strbuf *sb, const char *fmt, ...)
204 va_end(ap);
205 }
206
207 +static void add_lines(struct strbuf *out,
208 + const char *prefix1,
209 + const char *prefix2,
210 + const char *buf, size_t size)
211 +{
212 + while (size) {
213 + const char *prefix;
214 + const char *next = memchr(buf, '\n', size);
215 + next = next ? (next + 1) : (buf + size);
216 +
217 + prefix = (prefix2 && buf[0] == '\n') ? prefix2 : prefix1;
218 + strbuf_addstr(out, prefix);
219 + strbuf_add(out, buf, next - buf);
220 + size -= next - buf;
221 + buf = next;
222 + }
223 + strbuf_complete_line(out);
224 +}
225 +
226 +void strbuf_add_commented_lines(struct strbuf *out, const char *buf, size_t size)
227 +{
228 + static char prefix1[3];
229 + static char prefix2[2];
230 +
231 + if (prefix1[0] != comment_line_char) {
232 + sprintf(prefix1, "%c ", comment_line_char);
233 + sprintf(prefix2, "%c", comment_line_char);
234 + }
235 + add_lines(out, prefix1, prefix2, buf, size);
236 +}
237 +
238 +void strbuf_commented_addf(struct strbuf *sb, const char *fmt, ...)
239 +{
240 + va_list params;
241 + struct strbuf buf = STRBUF_INIT;
242 + int incomplete_line = sb->len && sb->buf[sb->len - 1] != '\n';
243 +
244 + va_start(params, fmt);
245 + strbuf_vaddf(&buf, fmt, params);
246 + va_end(params);
247 +
248 + strbuf_add_commented_lines(sb, buf.buf, buf.len);
249 + if (incomplete_line)
250 + sb->buf[--sb->len] = '\0';
251 +
252 + strbuf_release(&buf);
253 +}
254 +
255 void strbuf_vaddf(struct strbuf *sb, const char *fmt, va_list ap)
256 {
257 int len;
@@ -414,15 +462,7 @@ int strbuf_read_file(struct strbuf *sb, const char *path, size_t hint)
462 void strbuf_add_lines(struct strbuf *out, const char *prefix,
463 const char *buf, size_t size)
464 {
417 - while (size) {
418 - const char *next = memchr(buf, '\n', size);
419 - next = next ? (next + 1) : (buf + size);
420 - strbuf_addstr(out, prefix);
421 - strbuf_add(out, buf, next - buf);
422 - size -= next - buf;
423 - buf = next;
424 - }
425 - strbuf_complete_line(out);
465 + add_lines(out, prefix, NULL, buf, size);
466 }
467
468 void strbuf_addstr_xml_quoted(struct strbuf *buf, const char *s)
strbuf.h
+4
@@ -110,6 +110,8 @@ extern void strbuf_remove(struct strbuf *, size_t pos, size_t len);
110 extern void strbuf_splice(struct strbuf *, size_t pos, size_t len,
111 const void *, size_t);
112
113 +extern void strbuf_add_commented_lines(struct strbuf *out, const char *buf, size_t size);
114 +
115 extern void strbuf_add(struct strbuf *, const void *, size_t);
116 static inline void strbuf_addstr(struct strbuf *sb, const char *s) {
117 strbuf_add(sb, s, strlen(s));
@@ -131,6 +133,8 @@ extern void strbuf_addbuf_percentquote(struct strbuf *dst, const struct strbuf *
133
134 __attribute__((format (printf,2,3)))
135 extern void strbuf_addf(struct strbuf *sb, const char *fmt, ...);
136 +__attribute__((format (printf, 2, 3)))
137 +extern void strbuf_commented_addf(struct strbuf *sb, const char *fmt, ...);
138 __attribute__((format (printf,2,0)))
139 extern void strbuf_vaddf(struct strbuf *sb, const char *fmt, va_list ap);
140
t/t0030-stripspace.sh
+35
@@ -397,4 +397,39 @@ test_expect_success 'strip comments, too' '
397 test -z "$(echo "# comment" | git stripspace -s)"
398 '
399
400 +test_expect_success 'strip comments with changed comment char' '
401 + test ! -z "$(echo "; comment" | git -c core.commentchar=";" stripspace)" &&
402 + test -z "$(echo "; comment" | git -c core.commentchar=";" stripspace -s)"
403 +'
404 +
405 +test_expect_success '-c with single line' '
406 + printf "# foo\n" >expect &&
407 + printf "foo" | git stripspace -c >actual &&
408 + test_cmp expect actual
409 +'
410 +
411 +test_expect_success '-c with single line followed by empty line' '
412 + printf "# foo\n#\n" >expect &&
413 + printf "foo\n\n" | git stripspace -c >actual &&
414 + test_cmp expect actual
415 +'
416 +
417 +test_expect_success '-c with newline only' '
418 + printf "#\n" >expect &&
419 + printf "\n" | git stripspace -c >actual &&
420 + test_cmp expect actual
421 +'
422 +
423 +test_expect_success '--comment-lines with single line' '
424 + printf "# foo\n" >expect &&
425 + printf "foo" | git stripspace -c >actual &&
426 + test_cmp expect actual
427 +'
428 +
429 +test_expect_success '-c with changed comment char' '
430 + printf "; foo\n" >expect &&
431 + printf "foo" | git -c core.commentchar=";" stripspace -c >actual &&
432 + test_cmp expect actual
433 +'
434 +
435 test_done
t/t7502-commit.sh
+7
@@ -447,4 +447,11 @@ use_template="-t template"
447
448 try_commit_status_combo
449
450 +test_expect_success 'commit --status with custom comment character' '
451 + test_when_finished "git config --unset core.commentchar" &&
452 + git config core.commentchar ";" &&
453 + try_commit --status &&
454 + test_i18ngrep "^; Changes to be committed:" .git/COMMIT_EDITMSG
455 +'
456 +
457 test_done
t/t7508-status.sh
+50
@@ -1253,6 +1253,56 @@ test_expect_success ".git/config ignore=dirty doesn't suppress submodule summary
1253 git config -f .gitmodules --remove-section submodule.subname
1254 '
1255
1256 +cat > expect << EOF
1257 +; On branch master
1258 +; Changes to be committed:
1259 +; (use "git reset HEAD <file>..." to unstage)
1260 +;
1261 +; modified: sm
1262 +;
1263 +; Changes not staged for commit:
1264 +; (use "git add <file>..." to update what will be committed)
1265 +; (use "git checkout -- <file>..." to discard changes in working directory)
1266 +;
1267 +; modified: dir1/modified
1268 +; modified: sm (new commits)
1269 +;
1270 +; Submodule changes to be committed:
1271 +;
1272 +; * sm $head...$new_head (1):
1273 +; > Add bar
1274 +;
1275 +; Submodules changed but not updated:
1276 +;
1277 +; * sm $new_head...$head2 (1):
1278 +; > 2nd commit
1279 +;
1280 +; Untracked files:
1281 +; (use "git add <file>..." to include in what will be committed)
1282 +;
1283 +; .gitmodules
1284 +; dir1/untracked
1285 +; dir2/modified
1286 +; dir2/untracked
1287 +; expect
1288 +; output
1289 +; untracked
1290 +EOF
1291 +
1292 +test_expect_success "status (core.commentchar with submodule summary)" '
1293 + test_when_finished "git config --unset core.commentchar" &&
1294 + git config core.commentchar ";" &&
1295 + git status >output &&
1296 + test_i18ncmp expect output
1297 +'
1298 +
1299 +test_expect_success "status (core.commentchar with two chars with submodule summary)" '
1300 + test_when_finished "git config --unset core.commentchar" &&
1301 + git config core.commentchar ";;" &&
1302 + git status >output &&
1303 + test_i18ncmp expect output
1304 +'
1305 +
1306 cat > expect << EOF
1307 # On branch master
1308 # Changes not staged for commit:
wt-status.c
+6 -4
@@ -45,7 +45,7 @@ static void status_vprintf(struct wt_status *s, int at_bol, const char *color,
45
46 strbuf_vaddf(&sb, fmt, ap);
47 if (!sb.len) {
48 - strbuf_addch(&sb, '#');
48 + strbuf_addch(&sb, comment_line_char);
49 if (!trail)
50 strbuf_addch(&sb, ' ');
51 color_print_strbuf(s->fp, color, &sb);
@@ -59,7 +59,7 @@ static void status_vprintf(struct wt_status *s, int at_bol, const char *color,
59
60 strbuf_reset(&linebuf);
61 if (at_bol) {
62 - strbuf_addch(&linebuf, '#');
62 + strbuf_addch(&linebuf, comment_line_char);
63 if (*line != '\n' && *line != '\t')
64 strbuf_addch(&linebuf, ' ');
65 }
@@ -760,8 +760,10 @@ static void wt_status_print_tracking(struct wt_status *s)
760
761 for (cp = sb.buf; (ep = strchr(cp, '\n')) != NULL; cp = ep + 1)
762 color_fprintf_ln(s->fp, color(WT_STATUS_HEADER, s),
763 - "# %.*s", (int)(ep - cp), cp);
764 - color_fprintf_ln(s->fp, color(WT_STATUS_HEADER, s), "#");
763 + "%c %.*s", comment_line_char,
764 + (int)(ep - cp), cp);
765 + color_fprintf_ln(s->fp, color(WT_STATUS_HEADER, s), "%c",
766 + comment_line_char);
767 }
768
769 static int has_unmerged(struct wt_status *s)