mirror of
https://github.com/jesseduffield/lazygit.git
synced 2026-10-06 05:57:38 -04:00
Fast-forwarding a branch that isn't checked out ran a single `git fetch <remote> refs/heads/<branch>:<branch>`, so git's own refusal to move a local branch backwards served as the safety check. A later commit widens the set of branches the command accepts, and for that lazygit has to make that decision itself. Fetch the remote branch on its own, updating only its remote-tracking branch. Then ask git whether the branch is an ancestor of it, and only then move the branch: with `git update-ref` when it isn't checked out anywhere, guarded by the hash we knew it to have, and with `git merge --ff-only` in its worktree when it is checked out there. Keeping `git pull --ff-only` for the latter case would fetch a second time. Fast-forwarding a branch that isn't checked out in a worktree had no integration test at all, so add one. The second new test covers a repo that keeps no reflogs, because a later commit starts reading those and this case has to keep working without them. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>