#!/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 revert-example cd revert-example git init --template= --bare -q --initial-branch=main origin.git git init --template= -q --initial-branch=main writer cd writer printf 'original\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 printf 'shared change\n' >> note.txt git commit -qam 'Shared change' git push -q origin main shared=$(git rev-parse HEAD) printf '#!/bin/sh\nexit 0\n' > ../editor.sh chmod +x ../editor.sh GIT_EDITOR=../editor.sh git revert HEAD >/dev/null git merge-base --is-ancestor "$shared" HEAD test "$(cat note.txt)" = original test "$(git rev-list --count HEAD)" = 3 printf 'Revert made a new commit; shared commit remains an ancestor\n' git push -q origin main test "$(git rev-parse HEAD)" = "$(git --git-dir=../origin.git rev-parse refs/heads/main)" printf 'Local bare remote received the new revert commit\n'