Skip to content

Commit 3bd53ca

Browse files
gitsterdscho
authored andcommitted
Merge branch 'pw/rebase-i-cleanup-fix' into jch
"git rebase -i" failed to clean-up the commit log message when the command commits the final one in a chain of "fixup" commands, which has been corrected. * pw/rebase-i-cleanup-fix: sequencer: remove VERBATIM_MSG flag rebase -i: respect commit.cleanup when picking fixups
2 parents 31804ed + 82a0a73 commit 3bd53ca

File tree

2 files changed

+22
-18
lines changed

2 files changed

+22
-18
lines changed

sequencer.c

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1087,7 +1087,6 @@ N_("you have staged changes in your working tree\n"
10871087
#define CLEANUP_MSG (1<<3)
10881088
#define VERIFY_MSG (1<<4)
10891089
#define CREATE_ROOT_COMMIT (1<<5)
1090-
#define VERBATIM_MSG (1<<6)
10911090

10921091
static int run_command_silent_on_success(struct child_process *cmd)
10931092
{
@@ -1125,9 +1124,6 @@ static int run_git_commit(const char *defmsg,
11251124
{
11261125
struct child_process cmd = CHILD_PROCESS_INIT;
11271126

1128-
if ((flags & CLEANUP_MSG) && (flags & VERBATIM_MSG))
1129-
BUG("CLEANUP_MSG and VERBATIM_MSG are mutually exclusive");
1130-
11311127
cmd.git_cmd = 1;
11321128

11331129
if (is_rebase_i(opts) &&
@@ -1166,8 +1162,6 @@ static int run_git_commit(const char *defmsg,
11661162
strvec_pushl(&cmd.args, "-C", "HEAD", NULL);
11671163
if ((flags & CLEANUP_MSG))
11681164
strvec_push(&cmd.args, "--cleanup=strip");
1169-
if ((flags & VERBATIM_MSG))
1170-
strvec_push(&cmd.args, "--cleanup=verbatim");
11711165
if ((flags & EDIT_MSG))
11721166
strvec_push(&cmd.args, "-e");
11731167
else if (!(flags & CLEANUP_MSG) &&
@@ -1540,9 +1534,6 @@ static int try_to_commit(struct repository *r,
15401534
enum commit_msg_cleanup_mode cleanup;
15411535
int res = 0;
15421536

1543-
if ((flags & CLEANUP_MSG) && (flags & VERBATIM_MSG))
1544-
BUG("CLEANUP_MSG and VERBATIM_MSG are mutually exclusive");
1545-
15461537
if (parse_head(r, &current_head))
15471538
return -1;
15481539

@@ -1618,8 +1609,6 @@ static int try_to_commit(struct repository *r,
16181609

16191610
if (flags & CLEANUP_MSG)
16201611
cleanup = COMMIT_MSG_CLEANUP_ALL;
1621-
else if (flags & VERBATIM_MSG)
1622-
cleanup = COMMIT_MSG_CLEANUP_NONE;
16231612
else if ((opts->signoff || opts->record_origin) &&
16241613
!opts->explicit_cleanup)
16251614
cleanup = COMMIT_MSG_CLEANUP_SPACE;
@@ -2436,7 +2425,6 @@ static int do_pick_commit(struct repository *r,
24362425
if (!final_fixup)
24372426
msg_file = rebase_path_squash_msg();
24382427
else if (file_exists(rebase_path_fixup_msg())) {
2439-
flags |= VERBATIM_MSG;
24402428
msg_file = rebase_path_fixup_msg();
24412429
} else {
24422430
const char *dest = git_path_squash_msg(r);

t/t3415-rebase-autosquash.sh

Lines changed: 22 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -486,12 +486,28 @@ test_expect_success 'fixup a fixup' '
486486
test XZWY = $(git show | tr -cd W-Z)
487487
'
488488

489-
test_expect_success 'fixup does not clean up commit message' '
490-
oneline="#818" &&
491-
git commit --allow-empty -m "$oneline" &&
492-
git commit --fixup HEAD --allow-empty &&
493-
git -c commit.cleanup=strip rebase -ki --autosquash HEAD~2 &&
494-
test "$oneline" = "$(git show -s --format=%s)"
489+
test_expect_success 'pick and fixup respect commit.cleanup' '
490+
git reset --hard base &&
491+
test_commit --no-tag "fixup! second commit" file1 fixup &&
492+
test_commit something &&
493+
write_script .git/hooks/prepare-commit-msg <<-\EOF &&
494+
printf "\n# Prepared\n" >> "$1"
495+
EOF
496+
git rebase -i --autosquash HEAD~3 &&
497+
test_commit_message HEAD~1 <<-\EOF &&
498+
second commit
499+
500+
# Prepared
501+
EOF
502+
test_commit_message HEAD <<-\EOF &&
503+
something
504+
505+
# Prepared
506+
EOF
507+
git reset --hard something &&
508+
git -c commit.cleanup=strip rebase -i --autosquash HEAD~3 &&
509+
test_commit_message HEAD~1 -m "second commit" &&
510+
test_commit_message HEAD -m "something"
495511
'
496512

497513
test_done

0 commit comments

Comments
 (0)