fix(git): treat rebase onto a named branch as a branch change

`git rebase <upstream> <branch>` checks out <branch>, so a later bare push was refused as if main
were still checked out. Pushes through xargs get refspecs the hook cannot see, so only an explicit
main is refused there.

Refs: #178

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_014uGZTNugst7K9Bd2FTR4Mi
This commit is contained in:
Defame1297andClaude Opus 5.5 committed 2026-12-04 22:54:50 +00:00
1 parent a988275347
commit 1ccf246598
3 files changed
+38 -3

No files matched your search

+11
View File
@@ -76,6 +76,7 @@ origin :main
-d origin main
--delete origin main
origin --all
origin --branches
--mirror origin
origin :
origin +:
@@ -106,6 +107,7 @@ done << 'CASES'
origin
--follow-tags
-o ci.skip origin
--repo=origin
origin HEAD
origin @
@@ -160,6 +162,15 @@ allow main git branch --move feat && git push -u origin HEAD
allow main git switch feat && cd sub && git push
allow main git checkout main && git pull && git checkout -b x && git push -u origin HEAD
refuse main git branch -a && git push
allow feat git switch main && git pull && git rebase main feat && git push
allow main git fetch && git rebase origin/main feat && git push --force-with-lease
allow main git rebase --onto main old feat && git push
refuse main git rebase origin/main && git push
refuse main git rebase --onto origin/main old && git push
refuse main git rebase -x true origin/main && git push
allow feat cd WORK/on-main && git switch main && git pull; cd WORK/on-feat && git push
allow main echo feat | xargs git push origin
allow main echo feat | xargs -n 1 git push origin HEAD
refuse feat git checkout main && git merge feat && git push
refuse feat git switch main && git pull && git push origin HEAD
refuse feat git -C WORK/on-feat switch main && git -C WORK/on-feat push