jesseduffield.lazygit/pkg/commands
Stefan Haller dd03884087 Pick base branch by smallest ahead instead of relying on for-each-ref's order
GetBaseBranch was treating "contains the merge-base" as the equivalence
class for "is the closest base," which is too loose — multiple main
branches can contain the merge-base when one is dramatically closer
to the feature branch than another. The candidate it returned was
then whichever ref git for-each-ref happened to list first.

For example, a branch forked off "develop" can have its combined
merge-base with [main, develop] land on a commit reachable from both
(via develop's own branch-off from main). Both main and develop end
up in the candidate set, even though by any reasonable measure of
closeness the branch differs from develop by a small ahead count and
from main by a much larger one.

Discriminate within the candidate set using ahead values: for each
configured main branch that contains the merge-base, compute the
ahead count from branch to base, and pick the candidate with the
smallest ahead — the closest base. When more than one candidate is
tied at the minimum, return that tied set unchanged so callers can
flag the case as genuinely ambiguous instead of silently collapsing
it; subsequent commits build the disambiguation prompt on top.
2026-07-03 19:35:33 +02:00
..
direnv Offer direnv .envrc approval from inside lazygit 2026-06-04 09:05:01 +02:00
git_commands Pick base branch by smallest ahead instead of relying on for-each-ref's order 2026-07-03 19:35:33 +02:00
git_config Enable errorlint linter, and fix warnings 2025-06-30 18:30:11 +02:00
hosting_service Optimize regex compilations 2026-05-10 15:28:14 +02:00
models Add HeadCommitIdx helper function 2026-06-22 09:16:57 +02:00
oscommands Use ConPTY on Windows for pty-backed command execution 2026-07-03 18:47:15 +02:00
patch Fix selection after staging an added line 2026-03-19 16:57:53 +01:00
testdata Support opening lazygit in a submodule 2019-05-12 17:59:49 +10:00
git.go Add GitHub commands and model for fetching PR status 2026-04-01 09:13:55 +02:00
git_cmd_obj_builder.go Suppress optional locks by default again, except foreground refresh 2026-07-02 16:05:08 +02:00
git_cmd_obj_builder_test.go Suppress optional locks by default again, except foreground refresh 2026-07-02 16:05:08 +02:00
git_cmd_obj_runner.go retry on ref lock errors during fetch/pull 2026-04-20 09:04:50 +02:00