jesseduffield.lazygit/pkg/commands
Stefan Haller e46dc1ead6 Use a better approach for determining pushed and merge statuses
Previously we would call git merge-base with the upstream branch to determine
where unpushed commits end and pushed commits start, and also git merge-base
with the main branch(es) to see where the merged commits start. This worked ok
in normal cases, but it had two problems:
- when filtering by path or by author, those merge-base commits would usually
not be part of the commit list, so we would miss the point where we should
switch from unpushed to pushed, or from pushed to merged. The consequence was
that in filtering mode, all commit hashes were always yellow.
- when main was merged into a feature branch, we would color all commits from
that merge on down in green, even ones that are only part of the feature branch
but not main.

To fix these problems, we switch our approach to one where we call git rev-list
with the branch in question, with negative refspecs for the upstream branch and
the main branches, respectively; this gives us the complete picture of which
commits are pushed/unpushed/merged, so it also works in the cases described
above.

And funnily, even though intuitively it feels more expensive, it actually
performs better than the merge-base calls (for normal usage scenarios at least),
so the commit-loading part of refresh is faster now in general. We are talking
about differences like 300ms before, 140ms after, in some unscientific
measurements I took (depends a lot on repo sizes, branch length, etc.). An
exception are degenerate cases like feature branches with hundreds of thousands
of commits, which are slower now; but I don't think we need to worry about those
too much.
2025-07-31 15:50:53 +02:00
..
git_commands Use a better approach for determining pushed and merge statuses 2025-07-31 15:50:53 +02:00
git_config Enable errorlint linter, and fix warnings 2025-06-30 18:30:11 +02:00
hosting_service Enable revive linter, and fix a bunch of warnings 2025-06-30 19:13:20 +02:00
models Move the Ref interface from gui/types to models 2025-07-31 15:21:34 +02:00
oscommands Remove deprecated edit configs 2025-07-08 16:32:21 +02:00
patch Don't use hunk mode for added or deleted files 2025-07-27 12:10:25 +02:00
testdata Support opening lazygit in a submodule 2019-05-12 17:59:49 +10:00
git.go Use WorkingTreeState instead of RebaseMode in CommitLoader 2025-04-20 15:53:17 +02:00
git_cmd_obj_builder.go Remove ICmdObj interface 2025-05-01 15:21:37 +02:00
git_cmd_obj_runner.go Enable intrange linter, and fix warnings 2025-06-30 18:30:11 +02:00