Skip to content

Commit d9f292f

Browse files
committed
Merge branch 'jc/strbuf-comment-line-char' into seen
* jc/strbuf-comment-line-char: strbuf_add_commented_lines(): drop the comment_line_char parameter strbuf_commented_addf(): drop the comment_line_char parameter
2 parents d296003 + 5eda4b3 commit d9f292f

File tree

12 files changed

+40
-46
lines changed

12 files changed

+40
-46
lines changed

add-patch.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1106,11 +1106,11 @@ static int edit_hunk_manually(struct add_p_state *s, struct hunk *hunk)
11061106
size_t i;
11071107

11081108
strbuf_reset(&s->buf);
1109-
strbuf_commented_addf(&s->buf, comment_line_char,
1109+
strbuf_commented_addf(&s->buf,
11101110
_("Manual hunk edit mode -- see bottom for "
11111111
"a quick guide.\n"));
11121112
render_hunk(s, hunk, 0, 0, &s->buf);
1113-
strbuf_commented_addf(&s->buf, comment_line_char,
1113+
strbuf_commented_addf(&s->buf,
11141114
_("---\n"
11151115
"To remove '%c' lines, make them ' ' lines "
11161116
"(context).\n"
@@ -1119,13 +1119,13 @@ static int edit_hunk_manually(struct add_p_state *s, struct hunk *hunk)
11191119
s->mode->is_reverse ? '+' : '-',
11201120
s->mode->is_reverse ? '-' : '+',
11211121
comment_line_char);
1122-
strbuf_commented_addf(&s->buf, comment_line_char, "%s",
1122+
strbuf_commented_addf(&s->buf, "%s",
11231123
_(s->mode->edit_hunk_hint));
11241124
/*
11251125
* TRANSLATORS: 'it' refers to the patch mentioned in the previous
11261126
* messages.
11271127
*/
1128-
strbuf_commented_addf(&s->buf, comment_line_char,
1128+
strbuf_commented_addf(&s->buf,
11291129
_("If it does not apply cleanly, you will be "
11301130
"given an opportunity to\n"
11311131
"edit again. If all lines of the hunk are "

builtin/branch.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -668,7 +668,7 @@ static int edit_branch_description(const char *branch_name)
668668
exists = !read_branch_desc(&buf, branch_name);
669669
if (!buf.len || buf.buf[buf.len-1] != '\n')
670670
strbuf_addch(&buf, '\n');
671-
strbuf_commented_addf(&buf, comment_line_char,
671+
strbuf_commented_addf(&buf,
672672
_("Please edit the description for the branch\n"
673673
" %s\n"
674674
"Lines starting with '%c' will be stripped.\n"),

builtin/merge.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -858,15 +858,15 @@ static void prepare_to_commit(struct commit_list *remoteheads)
858858
strbuf_addch(&msg, '\n');
859859
if (cleanup_mode == COMMIT_MSG_CLEANUP_SCISSORS) {
860860
wt_status_append_cut_line(&msg);
861-
strbuf_commented_addf(&msg, comment_line_char, "\n");
861+
strbuf_commented_addf(&msg, "\n");
862862
}
863-
strbuf_commented_addf(&msg, comment_line_char,
863+
strbuf_commented_addf(&msg,
864864
_(merge_editor_comment));
865865
if (cleanup_mode == COMMIT_MSG_CLEANUP_SCISSORS)
866-
strbuf_commented_addf(&msg, comment_line_char,
866+
strbuf_commented_addf(&msg,
867867
_(scissors_editor_comment));
868868
else
869-
strbuf_commented_addf(&msg, comment_line_char,
869+
strbuf_commented_addf(&msg,
870870
_(no_scissors_editor_comment), comment_line_char);
871871
}
872872
if (signoff)

builtin/notes.c

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -181,7 +181,7 @@ static void write_commented_object(int fd, const struct object_id *object)
181181

182182
if (strbuf_read(&buf, show.out, 0) < 0)
183183
die_errno(_("could not read 'show' output"));
184-
strbuf_add_commented_lines(&cbuf, buf.buf, buf.len, comment_line_char);
184+
strbuf_add_commented_lines(&cbuf, buf.buf, buf.len);
185185
write_or_die(fd, cbuf.buf, cbuf.len);
186186

187187
strbuf_release(&cbuf);
@@ -209,10 +209,9 @@ static void prepare_note_data(const struct object_id *object, struct note_data *
209209
copy_obj_to_fd(fd, old_note);
210210

211211
strbuf_addch(&buf, '\n');
212-
strbuf_add_commented_lines(&buf, "\n", strlen("\n"), comment_line_char);
213-
strbuf_add_commented_lines(&buf, _(note_template), strlen(_(note_template)),
214-
comment_line_char);
215-
strbuf_add_commented_lines(&buf, "\n", strlen("\n"), comment_line_char);
212+
strbuf_add_commented_lines(&buf, "\n", strlen("\n"));
213+
strbuf_add_commented_lines(&buf, _(note_template), strlen(_(note_template)));
214+
strbuf_add_commented_lines(&buf, "\n", strlen("\n"));
216215
write_or_die(fd, buf.buf, buf.len);
217216

218217
write_commented_object(fd, object);

builtin/stripspace.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ static void comment_lines(struct strbuf *buf)
1313
size_t len;
1414

1515
msg = strbuf_detach(buf, &len);
16-
strbuf_add_commented_lines(buf, msg, len, comment_line_char);
16+
strbuf_add_commented_lines(buf, msg, len);
1717
free(msg);
1818
}
1919

builtin/tag.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -351,10 +351,10 @@ static void create_tag(const struct object_id *object, const char *object_ref,
351351
struct strbuf buf = STRBUF_INIT;
352352
strbuf_addch(&buf, '\n');
353353
if (opt->cleanup_mode == CLEANUP_ALL)
354-
strbuf_commented_addf(&buf, comment_line_char,
354+
strbuf_commented_addf(&buf,
355355
_(tag_template), tag, comment_line_char);
356356
else
357-
strbuf_commented_addf(&buf, comment_line_char,
357+
strbuf_commented_addf(&buf,
358358
_(tag_template_nocleanup), tag, comment_line_char);
359359
write_or_die(fd, buf.buf, buf.len);
360360
strbuf_release(&buf);

fmt-merge-msg.c

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -509,8 +509,7 @@ static void fmt_tag_signature(struct strbuf *tagbuf,
509509
strbuf_complete_line(tagbuf);
510510
if (sig->len) {
511511
strbuf_addch(tagbuf, '\n');
512-
strbuf_add_commented_lines(tagbuf, sig->buf, sig->len,
513-
comment_line_char);
512+
strbuf_add_commented_lines(tagbuf, sig->buf, sig->len);
514513
}
515514
}
516515

@@ -556,17 +555,15 @@ static void fmt_merge_msg_sigs(struct strbuf *out)
556555
strbuf_addch(&tagline, '\n');
557556
strbuf_add_commented_lines(&tagline,
558557
origins.items[first_tag].string,
559-
strlen(origins.items[first_tag].string),
560-
comment_line_char);
558+
strlen(origins.items[first_tag].string));
561559
strbuf_insert(&tagbuf, 0, tagline.buf,
562560
tagline.len);
563561
strbuf_release(&tagline);
564562
}
565563
strbuf_addch(&tagbuf, '\n');
566564
strbuf_add_commented_lines(&tagbuf,
567565
origins.items[i].string,
568-
strlen(origins.items[i].string),
569-
comment_line_char);
566+
strlen(origins.items[i].string));
570567
fmt_tag_signature(&tagbuf, &sig, buf, len);
571568
}
572569
strbuf_release(&payload);

rebase-interactive.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -71,14 +71,14 @@ void append_todo_help(int command_count,
7171

7272
if (!edit_todo) {
7373
strbuf_addch(buf, '\n');
74-
strbuf_commented_addf(buf, comment_line_char,
74+
strbuf_commented_addf(buf,
7575
Q_("Rebase %s onto %s (%d command)",
7676
"Rebase %s onto %s (%d commands)",
7777
command_count),
7878
shortrevisions, shortonto, command_count);
7979
}
8080

81-
strbuf_add_commented_lines(buf, msg, strlen(msg), comment_line_char);
81+
strbuf_add_commented_lines(buf, msg, strlen(msg));
8282

8383
if (get_missing_commit_check_level() == MISSING_COMMIT_CHECK_ERROR)
8484
msg = _("\nDo not remove any line. Use 'drop' "
@@ -87,7 +87,7 @@ void append_todo_help(int command_count,
8787
msg = _("\nIf you remove a line here "
8888
"THAT COMMIT WILL BE LOST.\n");
8989

90-
strbuf_add_commented_lines(buf, msg, strlen(msg), comment_line_char);
90+
strbuf_add_commented_lines(buf, msg, strlen(msg));
9191

9292
if (edit_todo)
9393
msg = _("\nYou are editing the todo file "
@@ -98,7 +98,7 @@ void append_todo_help(int command_count,
9898
msg = _("\nHowever, if you remove everything, "
9999
"the rebase will be aborted.\n\n");
100100

101-
strbuf_add_commented_lines(buf, msg, strlen(msg), comment_line_char);
101+
strbuf_add_commented_lines(buf, msg, strlen(msg));
102102
}
103103

104104
int edit_todo_list(struct repository *r, struct todo_list *todo_list,

sequencer.c

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -675,11 +675,11 @@ void append_conflicts_hint(struct index_state *istate,
675675
}
676676

677677
strbuf_addch(msgbuf, '\n');
678-
strbuf_commented_addf(msgbuf, comment_line_char, "Conflicts:\n");
678+
strbuf_commented_addf(msgbuf, "Conflicts:\n");
679679
for (i = 0; i < istate->cache_nr;) {
680680
const struct cache_entry *ce = istate->cache[i++];
681681
if (ce_stage(ce)) {
682-
strbuf_commented_addf(msgbuf, comment_line_char,
682+
strbuf_commented_addf(msgbuf,
683683
"\t%s\n", ce->name);
684684
while (i < istate->cache_nr &&
685685
!strcmp(ce->name, istate->cache[i]->name))
@@ -1866,7 +1866,7 @@ static void add_commented_lines(struct strbuf *buf, const void *str, size_t len)
18661866
s += count;
18671867
len -= count;
18681868
}
1869-
strbuf_add_commented_lines(buf, s, len, comment_line_char);
1869+
strbuf_add_commented_lines(buf, s, len);
18701870
}
18711871

18721872
/* Does the current fixup chain contain a squash command? */
@@ -1965,7 +1965,7 @@ static int append_squash_message(struct strbuf *buf, const char *body,
19651965
strbuf_addf(buf, _(nth_commit_msg_fmt),
19661966
++opts->current_fixup_count + 1);
19671967
strbuf_addstr(buf, "\n\n");
1968-
strbuf_add_commented_lines(buf, body, commented_len, comment_line_char);
1968+
strbuf_add_commented_lines(buf, body, commented_len);
19691969
/* buf->buf may be reallocated so store an offset into the buffer */
19701970
fixup_off = buf->len;
19711971
strbuf_addstr(buf, body + commented_len);
@@ -2055,8 +2055,7 @@ static int update_squash_messages(struct repository *r,
20552055
_(first_commit_msg_str));
20562056
strbuf_addstr(&buf, "\n\n");
20572057
if (is_fixup_flag(command, flag))
2058-
strbuf_add_commented_lines(&buf, body, strlen(body),
2059-
comment_line_char);
2058+
strbuf_add_commented_lines(&buf, body, strlen(body));
20602059
else
20612060
strbuf_addstr(&buf, body);
20622061

@@ -2075,8 +2074,7 @@ static int update_squash_messages(struct repository *r,
20752074
strbuf_addf(&buf, _(skip_nth_commit_msg_fmt),
20762075
++opts->current_fixup_count + 1);
20772076
strbuf_addstr(&buf, "\n\n");
2078-
strbuf_add_commented_lines(&buf, body, strlen(body),
2079-
comment_line_char);
2077+
strbuf_add_commented_lines(&buf, body, strlen(body));
20802078
} else
20812079
return error(_("unknown command: %d"), command);
20822080
repo_unuse_commit_buffer(r, commit, message);

strbuf.c

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
#include "git-compat-util.h"
2+
#include "environment.h"
23
#include "gettext.h"
34
#include "hex-ll.h"
45
#include "strbuf.h"
@@ -359,8 +360,8 @@ static void add_lines(struct strbuf *out,
359360
strbuf_complete_line(out);
360361
}
361362

362-
void strbuf_add_commented_lines(struct strbuf *out, const char *buf,
363-
size_t size, char comment_line_char)
363+
void strbuf_add_commented_lines(struct strbuf *out,
364+
const char *buf, size_t size)
364365
{
365366
static char prefix1[3];
366367
static char prefix2[2];
@@ -372,7 +373,7 @@ void strbuf_add_commented_lines(struct strbuf *out, const char *buf,
372373
add_lines(out, prefix1, prefix2, buf, size);
373374
}
374375

375-
void strbuf_commented_addf(struct strbuf *sb, char comment_line_char,
376+
void strbuf_commented_addf(struct strbuf *sb,
376377
const char *fmt, ...)
377378
{
378379
va_list params;
@@ -383,7 +384,7 @@ void strbuf_commented_addf(struct strbuf *sb, char comment_line_char,
383384
strbuf_vaddf(&buf, fmt, params);
384385
va_end(params);
385386

386-
strbuf_add_commented_lines(sb, buf.buf, buf.len, comment_line_char);
387+
strbuf_add_commented_lines(sb, buf.buf, buf.len);
387388
if (incomplete_line)
388389
sb->buf[--sb->len] = '\0';
389390

strbuf.h

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -287,8 +287,7 @@ void strbuf_splice(struct strbuf *sb, size_t pos, size_t len,
287287
* by a comment character and a blank.
288288
*/
289289
void strbuf_add_commented_lines(struct strbuf *out,
290-
const char *buf, size_t size,
291-
char comment_line_char);
290+
const char *buf, size_t size);
292291

293292

294293
/**
@@ -378,8 +377,8 @@ void strbuf_addf(struct strbuf *sb, const char *fmt, ...);
378377
* Add a formatted string prepended by a comment character and a
379378
* blank to the buffer.
380379
*/
381-
__attribute__((format (printf, 3, 4)))
382-
void strbuf_commented_addf(struct strbuf *sb, char comment_line_char, const char *fmt, ...);
380+
__attribute__((format (printf, 2, 3)))
381+
void strbuf_commented_addf(struct strbuf *sb, const char *fmt, ...);
383382

384383
__attribute__((format (printf,2,0)))
385384
void strbuf_vaddf(struct strbuf *sb, const char *fmt, va_list ap);

wt-status.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1028,7 +1028,7 @@ static void wt_longstatus_print_submodule_summary(struct wt_status *s, int uncom
10281028
if (s->display_comment_prefix) {
10291029
size_t len;
10301030
summary_content = strbuf_detach(&summary, &len);
1031-
strbuf_add_commented_lines(&summary, summary_content, len, comment_line_char);
1031+
strbuf_add_commented_lines(&summary, summary_content, len);
10321032
free(summary_content);
10331033
}
10341034

@@ -1103,8 +1103,8 @@ void wt_status_append_cut_line(struct strbuf *buf)
11031103
{
11041104
const char *explanation = _("Do not modify or remove the line above.\nEverything below it will be ignored.");
11051105

1106-
strbuf_commented_addf(buf, comment_line_char, "%s", cut_line);
1107-
strbuf_add_commented_lines(buf, explanation, strlen(explanation), comment_line_char);
1106+
strbuf_commented_addf(buf, "%s", cut_line);
1107+
strbuf_add_commented_lines(buf, explanation, strlen(explanation));
11081108
}
11091109

11101110
void wt_status_add_cut_line(FILE *fp)

0 commit comments

Comments
 (0)