Skip to content

Commit 4af130a

Browse files
committed
Merge branch 'en/sequencer-empty-edit-result-aborts'
"git rebase" etc. in Git 2.19 fails to abort when given an empty commit log message as result of editing, which has been corrected. * en/sequencer-empty-edit-result-aborts: sequencer: fix --allow-empty-message behavior, make it smarter
2 parents 0f7ac90 + a3ec9ea commit 4af130a

File tree

4 files changed

+14
-17
lines changed

4 files changed

+14
-17
lines changed

sequencer.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -903,7 +903,7 @@ static int run_git_commit(const char *defmsg, struct replay_opts *opts,
903903
if ((flags & ALLOW_EMPTY))
904904
argv_array_push(&cmd.args, "--allow-empty");
905905

906-
if (opts->allow_empty_message)
906+
if (!(flags & EDIT_MSG))
907907
argv_array_push(&cmd.args, "--allow-empty-message");
908908

909909
if (cmd.err == -1) {
@@ -1317,7 +1317,7 @@ static int try_to_commit(struct strbuf *msg, const char *author,
13171317

13181318
if (cleanup != COMMIT_MSG_CLEANUP_NONE)
13191319
strbuf_stripspace(msg, cleanup == COMMIT_MSG_CLEANUP_ALL);
1320-
if (!opts->allow_empty_message && message_is_empty(msg, cleanup)) {
1320+
if ((flags & EDIT_MSG) && message_is_empty(msg, cleanup)) {
13211321
res = 1; /* run 'git commit' to display error message */
13221322
goto out;
13231323
}

t/t3404-rebase-interactive.sh

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -569,16 +569,15 @@ test_expect_success '--continue tries to commit, even for "edit"' '
569569
'
570570

571571
test_expect_success 'aborted --continue does not squash commits after "edit"' '
572-
test_when_finished "git rebase --abort" &&
573572
old=$(git rev-parse HEAD) &&
574573
test_tick &&
575574
set_fake_editor &&
576575
FAKE_LINES="edit 1" git rebase -i HEAD^ &&
577576
echo "edited again" > file7 &&
578577
git add file7 &&
579-
echo all the things >>conflict &&
580-
test_must_fail git rebase --continue &&
581-
test $old = $(git rev-parse HEAD)
578+
test_must_fail env FAKE_COMMIT_MESSAGE=" " git rebase --continue &&
579+
test $old = $(git rev-parse HEAD) &&
580+
git rebase --abort
582581
'
583582

584583
test_expect_success 'auto-amend only edited commits after "edit"' '

t/t3405-rebase-malformed.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ test_expect_success 'rebase -m commit with empty message' '
8383
test_expect_success 'rebase -i commit with empty message' '
8484
git checkout diff-in-message &&
8585
set_fake_editor &&
86-
env FAKE_COMMIT_MESSAGE=" " FAKE_LINES="reword 1" \
86+
test_must_fail env FAKE_COMMIT_MESSAGE=" " FAKE_LINES="reword 1" \
8787
git rebase -i HEAD^
8888
'
8989

t/t3505-cherry-pick-empty.sh

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -11,34 +11,32 @@ test_expect_success setup '
1111
test_tick &&
1212
git commit -m "first" &&
1313
14-
git checkout -b empty-branch &&
15-
test_tick &&
16-
git commit --allow-empty -m "empty" &&
17-
14+
git checkout -b empty-message-branch &&
1815
echo third >> file1 &&
1916
git add file1 &&
2017
test_tick &&
2118
git commit --allow-empty-message -m "" &&
2219
2320
git checkout master &&
24-
git checkout -b empty-branch2 &&
21+
git checkout -b empty-change-branch &&
2522
test_tick &&
2623
git commit --allow-empty -m "empty"
2724
2825
'
2926

3027
test_expect_success 'cherry-pick an empty commit' '
3128
git checkout master &&
32-
test_expect_code 1 git cherry-pick empty-branch^
29+
test_expect_code 1 git cherry-pick empty-change-branch
3330
'
3431

3532
test_expect_success 'index lockfile was removed' '
3633
test ! -f .git/index.lock
3734
'
3835

3936
test_expect_success 'cherry-pick a commit with an empty message' '
37+
test_when_finished "git reset --hard empty-message-branch~1" &&
4038
git checkout master &&
41-
test_expect_code 1 git cherry-pick empty-branch
39+
git cherry-pick empty-message-branch
4240
'
4341

4442
test_expect_success 'index lockfile was removed' '
@@ -47,20 +45,20 @@ test_expect_success 'index lockfile was removed' '
4745

4846
test_expect_success 'cherry-pick a commit with an empty message with --allow-empty-message' '
4947
git checkout -f master &&
50-
git cherry-pick --allow-empty-message empty-branch
48+
git cherry-pick --allow-empty-message empty-message-branch
5149
'
5250

5351
test_expect_success 'cherry pick an empty non-ff commit without --allow-empty' '
5452
git checkout master &&
5553
echo fourth >>file2 &&
5654
git add file2 &&
5755
git commit -m "fourth" &&
58-
test_must_fail git cherry-pick empty-branch2
56+
test_must_fail git cherry-pick empty-change-branch
5957
'
6058

6159
test_expect_success 'cherry pick an empty non-ff commit with --allow-empty' '
6260
git checkout master &&
63-
git cherry-pick --allow-empty empty-branch2
61+
git cherry-pick --allow-empty empty-change-branch
6462
'
6563

6664
test_expect_success 'cherry pick with --keep-redundant-commits' '

0 commit comments

Comments
 (0)