#!/bin/sh # SPDX-License-Identifier: MIT set -eu export TZ=UTC LC_ALL=C export GIT_CONFIG_NOSYSTEM=1 GIT_CONFIG_GLOBAL=/dev/null export GIT_AUTHOR_NAME='Example Author' GIT_AUTHOR_EMAIL='author@example.invalid' export GIT_COMMITTER_NAME='Example Author' GIT_COMMITTER_EMAIL='author@example.invalid' export GIT_AUTHOR_DATE='2026-10-27T12:00:00+00:00' export GIT_COMMITTER_DATE='2026-10-27T12:00:00+00:00' test "$(git version)" = 'git version 2.56.0' mkdir rebase-example cd rebase-example printf '#!/bin/sh\nexit 0\n' > editor.sh chmod +x editor.sh case_setup() { mkdir "$1" cd "$1" git init --template= --bare -q --initial-branch=main origin.git git init --template= -q --initial-branch=main repo cd repo printf 'base\n' > note.txt git add note.txt git commit -qm 'Base' git remote add origin ../origin.git git push -q -u origin main >/dev/null git switch -qc topic printf 'topic\n' > note.txt git commit -qam 'Topic change' original=$(git rev-parse HEAD) git switch -q main printf 'upstream\n' > note.txt git commit -qam 'Upstream change' git push -q origin main git switch -q topic if git rebase main >../rebase-log 2>&1; then printf 'Expected a conflict\n' >&2 exit 1 fi } case_setup continued printf 'resolved\n' > note.txt git add note.txt GIT_EDITOR=../../editor.sh git rebase --continue >/dev/null 2>&1 test "$(cat note.txt)" = resolved test "$(git rev-parse HEAD)" != "$original" git merge-base --is-ancestor main HEAD printf 'Continue: resolved commit replayed on main\n' cd ../.. case_setup skipped git rebase --skip >/dev/null 2>&1 test "$(cat note.txt)" = upstream test "$(git rev-parse HEAD)" = "$(git rev-parse main)" printf 'Skip: conflicting topic commit omitted\n' cd ../.. case_setup aborted git rebase --abort test "$(git rev-parse HEAD)" = "$original" test "$(cat note.txt)" = topic printf 'Abort: original topic commit and content restored\n'