Skip to content

Commit fc174dc

Browse files
committed
codex: stop rerere continuation without a staged resolution
A failed octopus merge can roll back its index and leave no unmerged paths. continue_rerere_resolution() treats that state as a completed rerere resolution and runs rebase --continue, dropping the merge and continuing with its descendants. Only continue when there are staged changes or MERGE_HEAD records a merge to commit. Keep an aborted octopus stopped so recovery can preserve its parents. Cover the clean-index failure with a real three-parent replay followed by another commit. Signed-off-by: Taylor Blau <ttaylorr@openai.com>
1 parent 50947ab commit fc174dc

2 files changed

Lines changed: 56 additions & 0 deletions

File tree

.github/workflows/codex-branch.sh

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3797,6 +3797,13 @@ continue_rerere_resolution () {
37973797
while rebase_in_progress "$worktree" &&
37983798
test -z "$(git -C "$worktree" -c core.fsmonitor=false ls-files -u)"
37993799
do
3800+
# A failed octopus can leave a clean index without a resolution.
3801+
# Continuing in that state would skip the failed merge.
3802+
if git -C "$worktree" diff --cached --quiet &&
3803+
! git -C "$worktree" rev-parse --verify -q MERGE_HEAD >/dev/null
3804+
then
3805+
return 1
3806+
fi
38003807
before=$(git -C "$worktree" rev-parse --verify REBASE_HEAD \
38013808
2>/dev/null || :)
38023809
if ! GIT_COMMITTER_NAME=$bot_name \

t/t9905-codex-branch.sh

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4513,6 +4513,55 @@ test_expect_success 'codex rerere history can resolve a topic rebase' '
45134513
)
45144514
'
45154515

4516+
test_expect_success 'rerere continuation stops at an aborted octopus merge' '
4517+
test_create_repo aborted-octopus &&
4518+
(
4519+
cd aborted-octopus &&
4520+
test_commit base shared &&
4521+
git switch -c side-a master &&
4522+
test_commit side-a shared &&
4523+
git switch -c side-b master &&
4524+
test_commit side-b side-file &&
4525+
git switch -c topic master &&
4526+
test_commit topic shared &&
4527+
write resolved shared &&
4528+
write side-b side-file &&
4529+
git add shared side-file &&
4530+
merge=$(git commit-tree "$(git write-tree)" \
4531+
-p HEAD -p side-a -p side-b -m "resolved octopus") &&
4532+
git reset --hard "$merge" &&
4533+
test_commit after-merge after-file &&
4534+
git switch -c onto master &&
4535+
test_commit onto onto-file &&
4536+
git switch topic &&
4537+
test_must_fail git -c rerere.enabled=true \
4538+
-c rerere.autoupdate=true \
4539+
rebase --rebase-merges --onto onto master \
4540+
>rebase.out 2>rebase.err &&
4541+
test "$merge" = "$(git rev-parse REBASE_HEAD)" &&
4542+
test -z "$(git ls-files -u)" &&
4543+
git diff --cached --exit-code &&
4544+
test_must_fail git rev-parse --verify -q MERGE_HEAD &&
4545+
git rev-parse HEAD >before &&
4546+
sed -n "/^rebase_in_progress () {$/,/^}/p;
4547+
/^continue_rerere_resolution () {$/,/^}/p" \
4548+
"$codex_branch" >../rerere-functions &&
4549+
test_expect_code 1 sh -c "
4550+
. ../rerere-functions
4551+
replay_rerere=true
4552+
bot_name=\"$codex_bot_name\"
4553+
bot_email=\"$codex_bot_email\"
4554+
continue_rerere_resolution .
4555+
" >continue.out 2>continue.err &&
4556+
git rev-parse HEAD >after &&
4557+
test_cmp before after &&
4558+
test "$merge" = "$(git rev-parse REBASE_HEAD)" &&
4559+
test_path_is_dir .git/rebase-merge &&
4560+
test_path_is_missing after-file &&
4561+
git rebase --abort
4562+
)
4563+
'
4564+
45164565
test_expect_success 'rewrite preserves a merge in an enrolled stable topic' '
45174566
git init --bare private.git &&
45184567
test_create_repo private-source &&

0 commit comments

Comments
 (0)