Skip to content

Commit 71ee81c

Browse files
charvi-077gitster
authored andcommitted
sequencer: use const variable for commit message comments
This makes it easier to use and reuse the comments. Mentored-by: Christian Couder <[email protected]> Mentored-by: Phillip Wood <[email protected]> Reviewed-by: Taylor Blau <[email protected]> Signed-off-by: Charvi Mendiratta <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent ae70e34 commit 71ee81c

File tree

1 file changed

+10
-5
lines changed

1 file changed

+10
-5
lines changed

sequencer.c

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1732,6 +1732,11 @@ static size_t subject_length(const char *body)
17321732
return p - body;
17331733
}
17341734

1735+
static const char first_commit_msg_str[] = N_("This is the 1st commit message:");
1736+
static const char nth_commit_msg_fmt[] = N_("This is the commit message #%d:");
1737+
static const char skip_nth_commit_msg_fmt[] = N_("The commit message #%d will be skipped:");
1738+
static const char combined_commit_msg_fmt[] = N_("This is a combination of %d commits.");
1739+
17351740
static void append_squash_message(struct strbuf *buf, const char *body,
17361741
struct replay_opts *opts)
17371742
{
@@ -1741,7 +1746,7 @@ static void append_squash_message(struct strbuf *buf, const char *body,
17411746
if (starts_with(body, "squash!") || starts_with(body, "fixup!"))
17421747
commented_len = subject_length(body);
17431748
strbuf_addf(buf, "\n%c ", comment_line_char);
1744-
strbuf_addf(buf, _("This is the commit message #%d:"),
1749+
strbuf_addf(buf, _(nth_commit_msg_fmt),
17451750
++opts->current_fixup_count + 1);
17461751
strbuf_addstr(buf, "\n\n");
17471752
strbuf_add_commented_lines(buf, body, commented_len);
@@ -1770,7 +1775,7 @@ static int update_squash_messages(struct repository *r,
17701775
buf.buf : strchrnul(buf.buf, '\n');
17711776

17721777
strbuf_addf(&header, "%c ", comment_line_char);
1773-
strbuf_addf(&header, _("This is a combination of %d commits."),
1778+
strbuf_addf(&header, _(combined_commit_msg_fmt),
17741779
opts->current_fixup_count + 2);
17751780
strbuf_splice(&buf, 0, eol - buf.buf, header.buf, header.len);
17761781
strbuf_release(&header);
@@ -1794,9 +1799,9 @@ static int update_squash_messages(struct repository *r,
17941799
}
17951800

17961801
strbuf_addf(&buf, "%c ", comment_line_char);
1797-
strbuf_addf(&buf, _("This is a combination of %d commits."), 2);
1802+
strbuf_addf(&buf, _(combined_commit_msg_fmt), 2);
17981803
strbuf_addf(&buf, "\n%c ", comment_line_char);
1799-
strbuf_addstr(&buf, _("This is the 1st commit message:"));
1804+
strbuf_addstr(&buf, _(first_commit_msg_str));
18001805
strbuf_addstr(&buf, "\n\n");
18011806
strbuf_addstr(&buf, body);
18021807

@@ -1812,7 +1817,7 @@ static int update_squash_messages(struct repository *r,
18121817
append_squash_message(&buf, body, opts);
18131818
} else if (command == TODO_FIXUP) {
18141819
strbuf_addf(&buf, "\n%c ", comment_line_char);
1815-
strbuf_addf(&buf, _("The commit message #%d will be skipped:"),
1820+
strbuf_addf(&buf, _(skip_nth_commit_msg_fmt),
18161821
++opts->current_fixup_count + 1);
18171822
strbuf_addstr(&buf, "\n\n");
18181823
strbuf_add_commented_lines(&buf, body, strlen(body));

0 commit comments

Comments
 (0)