Fix apply --force against a dirty tree; clarify patch-count guard
Two issues found by exercising the scripts end to end: - `git checkout -B` refuses to run when the worktree is dirty, so `make apply FORCE=1` aborted in exactly the situation FORCE exists to handle. Use `checkout -f -B`; the non-forced path has already verified the tree is clean, so forcing changes nothing there. - The commit-count guard claimed the user forgot `make rebuild`, but deleting a patch file on purpose trips it identically. Say both, and document the FORCE=1 form in the README's "drop the example patches" instructions, which would otherwise have failed. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Opus 5
parent
618c8e31ee
commit
27f078331d
@@ -38,8 +38,9 @@ else
|
||||
want="$(count_patches)"
|
||||
if [[ "$have" != "$want" ]]; then
|
||||
die "work/ has $have commit(s) above $BASE_TAG but patches/ has $want patch file(s).
|
||||
You probably forgot to run 'make rebuild' after committing.
|
||||
To discard the work/ commits and replay patches/ as-is: make apply FORCE=1"
|
||||
Either you committed in work/ without running 'make rebuild' (export it:
|
||||
make rebuild), or you added/removed patch files on purpose -- in which case
|
||||
discard the work/ commits and replay patches/ as-is: make apply FORCE=1"
|
||||
fi
|
||||
fi
|
||||
fi
|
||||
@@ -58,7 +59,10 @@ gitdir="$(git rev-parse --git-dir)"
|
||||
[[ -d "$gitdir/rebase-apply" ]] && git am --abort >/dev/null 2>&1 || true
|
||||
|
||||
info "Resetting work/ to upstream $(git rev-parse --short "$REV")"
|
||||
git checkout -q -B "$WORK_BRANCH" "$REV"
|
||||
# -f is required: without it checkout refuses to run against a dirty tree, which
|
||||
# is precisely the case FORCE=1 exists to handle. The tree is already known
|
||||
# clean on the non-forced path, so forcing costs nothing there.
|
||||
git checkout -q -f -B "$WORK_BRANCH" "$REV"
|
||||
git reset -q --hard "$REV"
|
||||
|
||||
# -x removes ignored files too, which is what we want for a pristine tree --
|
||||
|
||||
Reference in New Issue
Block a user