scripts/replay-prior-patch.sh
scripts/replay-prior-patch.shBrowse 2 files
278 tokens
816 bytes
Token encoding: o200k_base
Snapshot 646e806
← Back to SKILL.md
1set -euo pipefail2 3OLD_MB=$14PRIOR_SHA=$25NEW_MB=$36PATCH_TMP=$(mktemp -d)7 8# A separate index leaves the sandbox checkout and its real index unchanged.9export GIT_INDEX_FILE="$PATCH_TMP/index"10git read-tree "$NEW_MB"11 12set +e13git diff --binary --no-renames "$OLD_MB" "$PRIOR_SHA" \14 | git apply --cached --binary --3way --allow-empty \15 >"$PATCH_TMP/apply.out" 2>"$PATCH_TMP/apply.err"16PIPE_STATUSES=("${PIPESTATUS[@]}")17set -e18if [ "${PIPE_STATUSES[0]}" -ne 0 ]; then19 exit 2020fi21if [ "${PIPE_STATUSES[1]}" -ne 0 ]; then22 if [ "${PIPE_STATUSES[1]}" -eq 1 ]; then23 exit 1024 fi25 exit 2026fi27 28REPLAY_TREE=$(git write-tree)29if git diff --quiet "$REPLAY_TREE" HEAD; then30 exit 031else32 DIFF_STATUS=$?33 if [ "$DIFF_STATUS" -ne 1 ]; then34 exit 2035 fi36fi37 38git diff --binary --no-renames "$REPLAY_TREE" HEAD39