Skip to content

Commit 36fd1e8

Browse files
committed
Merge branch 'pw/rebase-i-squash-number-fix'
When "git rebase -i" is told to squash two or more commits into one, it labeled the log message for each commit with its number. It correctly called the first one "1st commit", but the next one was "commit #1", which was off-by-one. This has been corrected. * pw/rebase-i-squash-number-fix: rebase -i: fix numbering in squash message
2 parents 2a2c18f + dd2e36e commit 36fd1e8

File tree

2 files changed

+5
-3
lines changed

2 files changed

+5
-3
lines changed

sequencer.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1552,13 +1552,13 @@ static int update_squash_messages(enum todo_command command,
15521552
unlink(rebase_path_fixup_msg());
15531553
strbuf_addf(&buf, "\n%c ", comment_line_char);
15541554
strbuf_addf(&buf, _("This is the commit message #%d:"),
1555-
++opts->current_fixup_count);
1555+
++opts->current_fixup_count + 1);
15561556
strbuf_addstr(&buf, "\n\n");
15571557
strbuf_addstr(&buf, body);
15581558
} else if (command == TODO_FIXUP) {
15591559
strbuf_addf(&buf, "\n%c ", comment_line_char);
15601560
strbuf_addf(&buf, _("The commit message #%d will be skipped:"),
1561-
++opts->current_fixup_count);
1561+
++opts->current_fixup_count + 1);
15621562
strbuf_addstr(&buf, "\n\n");
15631563
strbuf_add_commented_lines(&buf, body, strlen(body));
15641564
} else

t/t3418-rebase-continue.sh

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -160,13 +160,15 @@ test_expect_success '--skip after failed fixup cleans commit message' '
160160
: The first squash was skipped, therefore: &&
161161
git show HEAD >out &&
162162
test_i18ngrep "# This is a combination of 2 commits" out &&
163+
test_i18ngrep "# This is the commit message #2:" out &&
163164
164165
(test_set_editor "$PWD/copy-editor.sh" && git rebase --skip) &&
165166
git show HEAD >out &&
166167
test_i18ngrep ! "# This is a combination" out &&
167168
168169
: Final squash failed, but there was still a squash &&
169-
test_i18ngrep "# This is a combination of 2 commits" .git/copy.txt
170+
test_i18ngrep "# This is a combination of 2 commits" .git/copy.txt &&
171+
test_i18ngrep "# This is the commit message #2:" .git/copy.txt
170172
'
171173

172174
test_expect_success 'setup rerere database' '

0 commit comments

Comments
 (0)