mirror of
https://github.com/git/git
synced 2024-08-28 12:09:19 +00:00
![Ævar Arnfjörð Bjarmason](/assets/img/avatar_default.png)
Make the replay_opts_release() function added in the preceding commit non-static, and use it for freeing the "struct replay_opts" constructed for "rebase" and "revert". To safely call our new replay_opts_release() we'll need to stop calling it in sequencer_remove_state(), and instead call it where we allocate the "struct replay_opts" itself. This is because in e.g. do_interactive_rebase() we construct a "struct replay_opts" with "get_replay_opts()", and then call "complete_action()". If we get far enough in that function without encountering errors we'll call "pick_commits()" which (indirectly) calls sequencer_remove_state() at the end. But if we encounter errors anywhere along the way we'd punt out early, and not free() the memory we allocated. Remembering whether we previously called sequencer_remove_state() would be a hassle. Using a FREE_AND_NULL() pattern would also work, as it would be safe to call replay_opts_release() repeatedly. But let's fix this properly instead, by having the owner of the data free() it. Signed-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
50 lines
1.1 KiB
Bash
Executable file
50 lines
1.1 KiB
Bash
Executable file
#!/bin/sh
|
|
|
|
test_description='git rebase interactive with rewording'
|
|
|
|
TEST_PASSES_SANITIZE_LEAK=true
|
|
. ./test-lib.sh
|
|
|
|
. "$TEST_DIRECTORY"/lib-rebase.sh
|
|
|
|
test_expect_success 'setup' '
|
|
test_commit main file-1 test &&
|
|
|
|
git checkout -b stuff &&
|
|
|
|
test_commit feature_a file-2 aaa &&
|
|
test_commit feature_b file-2 ddd
|
|
'
|
|
|
|
test_expect_success 'reword without issues functions as intended' '
|
|
test_when_finished "reset_rebase" &&
|
|
|
|
git checkout stuff^0 &&
|
|
|
|
set_fake_editor &&
|
|
FAKE_LINES="pick 1 reword 2" FAKE_COMMIT_MESSAGE="feature_b_reworded" \
|
|
git rebase -i -v main &&
|
|
|
|
test "$(git log -1 --format=%B)" = "feature_b_reworded" &&
|
|
test $(git rev-list --count HEAD) = 3
|
|
'
|
|
|
|
test_expect_success 'reword after a conflict preserves commit' '
|
|
test_when_finished "reset_rebase" &&
|
|
|
|
git checkout stuff^0 &&
|
|
|
|
set_fake_editor &&
|
|
test_must_fail env FAKE_LINES="reword 2" \
|
|
git rebase -i -v main &&
|
|
|
|
git checkout --theirs file-2 &&
|
|
git add file-2 &&
|
|
FAKE_COMMIT_MESSAGE="feature_b_reworded" git rebase --continue &&
|
|
|
|
test "$(git log -1 --format=%B)" = "feature_b_reworded" &&
|
|
test $(git rev-list --count HEAD) = 2
|
|
'
|
|
|
|
test_done
|