#!/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' export GIT_AUTHOR_EMAIL='author@example.invalid' export GIT_COMMITTER_NAME='Example Author' export GIT_COMMITTER_EMAIL='author@example.invalid' export GIT_AUTHOR_DATE='2026-10-25T12:00:00Z' export GIT_COMMITTER_DATE='2026-10-25T12:00:00Z' test "$(git --version)" = 'git version 2.56.0' mkdir diff-example cd diff-example git -c init.templateDir= init -q -b main printf 'base\n' > note.txt git add note.txt git commit -qm 'Base' printf 'staged draft\n' > note.txt git add note.txt printf 'working draft\n' > note.txt printf '%s\n' '--- staged difference ---' git diff --cached -- note.txt printf '%s\n' '--- working difference ---' git diff -- note.txt test "$(git show HEAD:note.txt)" = base test "$(git show :note.txt)" = 'staged draft' test "$(cat note.txt)" = 'working draft' printf '%s\n' '--- staged version committed ---' git commit -qm 'Commit staged draft' test "$(git show HEAD:note.txt)" = 'staged draft' test -z "$(git diff --cached -- note.txt)" test -n "$(git diff -- note.txt)" printf 'commit: staged draft committed; working draft remains\n'