From b0559fc99a0d5dc07a8888aa0a677b38503ba843 Mon Sep 17 00:00:00 2001 From: Local Dev Date: Thu, 10 Sep 2026 22:39:58 +0200 Subject: [PATCH] scripts: push-split scrubs trailers from a throwaway worktree so a dirty main tree can't abort the push --- scripts/push-split.sh | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/scripts/push-split.sh b/scripts/push-split.sh index 8296107..ece165e 100644 --- a/scripts/push-split.sh +++ b/scripts/push-split.sh @@ -59,9 +59,20 @@ git subtree split --prefix="$prefix" HEAD -b "$branch" >/dev/null # "Co-authored-by: Claude ..." trailers from the ephemeral branch before push. # Local monorepo history is untouched — only what lands on the forge is filtered. echo "→ scrubbing Co-Authored-By: Claude trailers from $branch …" -FILTER_BRANCH_SQUELCH_WARNING=1 git filter-branch --force --msg-filter ' +# filter-branch refuses to run from a dirty working tree ("You have unstaged +# changes"), and with set -e that silently aborted the push whenever another +# session had uncommitted edits. Run it from a throwaway worktree of the +# ephemeral branch instead — refs are shared, the main tree is never touched. +scrubwt=$(mktemp -d "${TMPDIR:-/tmp}/push-split-XXXXXX") +git worktree add --detach --quiet "$scrubwt" "$branch" +if ! (cd "$scrubwt" && FILTER_BRANCH_SQUELCH_WARNING=1 git filter-branch --force --msg-filter ' sed -e "/^Co-[Aa]uthored-[Bb]y: Claude.*/d" -' "$branch" >/dev/null 2>&1 +' "$branch" >/dev/null 2>&1); then + git worktree remove --force "$scrubwt" >/dev/null 2>&1 || true + echo "error: trailer scrub failed — not pushing." >&2 + exit 1 +fi +git worktree remove --force "$scrubwt" >/dev/null 2>&1 || true # filter-branch leaves refs/original/refs/heads/$branch as a backup — delete it # so it can not be pushed by accident (--mirror isn't used here, but be safe). git update-ref -d "refs/original/refs/heads/$branch" 2>/dev/null || true