bug(git-gate): force push not forwarded to upstream #233

Closed
opened 2026-06-10 22:16:27 -04:00 by didericis-claude · 0 comments
Collaborator

Problem

When a client force-pushes through git-gate, the hook builds a plain refspec ($new:$ref) when forwarding to the upstream. The upstream rejects it as a non-fast-forward because the + force prefix is missing.

Root cause

git_gate_render_hook() in bot_bottle/git_gate.py always constructs the refspec as $new:$ref for non-delete pushes. It never checks whether $old is an ancestor of $new, so force pushes are indistinguishable from regular pushes in the forwarded command.

Expected behaviour

When $old != $zero and $new is not a descendant of $old (git merge-base --is-ancestor $old $new fails), the gate should forward +$new:$ref so the upstream accepts the force push.

Steps to reproduce

git rebase origin/main  # moves branch tip, making it non-fast-forward
git push --force origin <branch>
# remote: ! [rejected] ... (non-fast-forward)

Noted while trying to push the rebased branch for PR #211.

## Problem When a client force-pushes through git-gate, the hook builds a plain refspec (`$new:$ref`) when forwarding to the upstream. The upstream rejects it as a non-fast-forward because the `+` force prefix is missing. ## Root cause `git_gate_render_hook()` in `bot_bottle/git_gate.py` always constructs the refspec as `$new:$ref` for non-delete pushes. It never checks whether `$old` is an ancestor of `$new`, so force pushes are indistinguishable from regular pushes in the forwarded command. ## Expected behaviour When `$old != $zero` and `$new` is not a descendant of `$old` (`git merge-base --is-ancestor $old $new` fails), the gate should forward `+$new:$ref` so the upstream accepts the force push. ## Steps to reproduce ``` git rebase origin/main # moves branch tip, making it non-fast-forward git push --force origin <branch> # remote: ! [rejected] ... (non-fast-forward) ``` Noted while trying to push the rebased branch for PR #211.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: didericis/bot-bottle#233