9ff2f06069
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>
62 lines
1.2 KiB
Bash
Executable File
62 lines
1.2 KiB
Bash
Executable File
#!/bin/sh
|
|
|
|
test_description='rebase behavior when on-disk files are broken'
|
|
|
|
TEST_PASSES_SANITIZE_LEAK=true
|
|
. ./test-lib.sh
|
|
|
|
test_expect_success 'set up conflicting branches' '
|
|
test_commit base file &&
|
|
git checkout -b branch1 &&
|
|
test_commit one file &&
|
|
git checkout -b branch2 HEAD^ &&
|
|
test_commit two file
|
|
'
|
|
|
|
create_conflict () {
|
|
test_when_finished "git rebase --abort" &&
|
|
git checkout -B tmp branch2 &&
|
|
test_must_fail git rebase branch1
|
|
}
|
|
|
|
check_resolve_fails () {
|
|
echo resolved >file &&
|
|
git add file &&
|
|
test_must_fail git rebase --continue
|
|
}
|
|
|
|
for item in NAME EMAIL DATE
|
|
do
|
|
test_expect_success "detect missing GIT_AUTHOR_$item" '
|
|
create_conflict &&
|
|
|
|
grep -v $item .git/rebase-merge/author-script >tmp &&
|
|
mv tmp .git/rebase-merge/author-script &&
|
|
|
|
check_resolve_fails
|
|
'
|
|
done
|
|
|
|
for item in NAME EMAIL DATE
|
|
do
|
|
test_expect_success "detect duplicate GIT_AUTHOR_$item" '
|
|
create_conflict &&
|
|
|
|
grep -i $item .git/rebase-merge/author-script >tmp &&
|
|
cat tmp >>.git/rebase-merge/author-script &&
|
|
|
|
check_resolve_fails
|
|
'
|
|
done
|
|
|
|
test_expect_success 'unknown key in author-script' '
|
|
create_conflict &&
|
|
|
|
echo "GIT_AUTHOR_BOGUS=${SQ}whatever${SQ}" \
|
|
>>.git/rebase-merge/author-script &&
|
|
|
|
check_resolve_fails
|
|
'
|
|
|
|
test_done
|