rebase -i: fix numbering in squash message
Commit e12a7ef597 ("rebase -i: Handle "combination of <n> commits" with GETTEXT_POISON", 2018-04-27) changed the way that individual commit messages are labelled when squashing commits together. In doing so a regression was introduced where the numbering of the messages is off by one. This commit fixes that and adds a test for the numbering. Signed-off-by: Phillip Wood <phillip.wood@dunelm.org.uk> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Phillip Wood committed
Aug 15, 2018 at 10:41 UTC
dd2e36ebaccd6dc2ca4d37759248ce9bbdf9113e
2 files changed
+5
-3
sequencer.c
+2
-2
@@ -1387,13 +1387,13 @@ static int update_squash_messages(enum todo_command command,
1387
unlink(rebase_path_fixup_msg());
1388
strbuf_addf(&buf, "\n%c ", comment_line_char);
1389
strbuf_addf(&buf, _("This is the commit message #%d:"),
1390
- ++opts->current_fixup_count);
1390
+ ++opts->current_fixup_count + 1);
1391
strbuf_addstr(&buf, "\n\n");
1392
strbuf_addstr(&buf, body);
1393
} else if (command == TODO_FIXUP) {
1394
strbuf_addf(&buf, "\n%c ", comment_line_char);
1395
strbuf_addf(&buf, _("The commit message #%d will be skipped:"),
1396
- ++opts->current_fixup_count);
1396
+ ++opts->current_fixup_count + 1);
1397
strbuf_addstr(&buf, "\n\n");
1398
strbuf_add_commented_lines(&buf, body, strlen(body));
1399
} else
t/t3418-rebase-continue.sh
+3
-1
@@ -128,13 +128,15 @@ test_expect_success '--skip after failed fixup cleans commit message' '
128
: The first squash was skipped, therefore: &&
129
git show HEAD >out &&
130
test_i18ngrep "# This is a combination of 2 commits" out &&
131
+ test_i18ngrep "# This is the commit message #2:" out &&
132
133
(test_set_editor "$PWD/copy-editor.sh" && git rebase --skip) &&
134
git show HEAD >out &&
135
test_i18ngrep ! "# This is a combination" out &&
136
137
: Final squash failed, but there was still a squash &&
137
- test_i18ngrep "# This is a combination of 2 commits" .git/copy.txt
138
+ test_i18ngrep "# This is a combination of 2 commits" .git/copy.txt &&
139
+ test_i18ngrep "# This is the commit message #2:" .git/copy.txt
140
'
141
142
test_expect_success 'setup rerere database' '