asyncgit: honour branch.sort config when listing branches#2918
asyncgit: honour branch.sort config when listing branches#2918Scolliq wants to merge 1 commit intogitui-org:masterfrom
Conversation
Currently get_branches_info hardcodes a lexicographic sort on the branch name. Read the branch.sort git config (refname, committerdate, authordate, with optional `-` prefix for descending) so users get the order their git config already requests. Falls back to the existing refname-ascending behaviour when the config is unset or carries an unsupported value (e.g. version:refname). Closes gitui-org#2024
Thanks for taking care of this. The only problem i see is that we make the remote branch list very hard to read if there are different remotes. I know this is exactly as I can see a better solution to do a hirarchical tree view first and only sort by this factor inside the same "folder". Is that something you could see yourself doing as a followup? Right now this is likely still better than the status quo. Please add a changelog entry and rebase to current upstream master. Also it would be great to update #2146 on top of this where we store the GUI selected sorting into the local git config and use that as the source of truth. |
|
Git accepts a comma-separated list (e.g. -committerdate,refname). |

Closes #2024.
Why:
get_branches_infohardcodes a lex-asc sort on the branch name, so users withbranch.sort = -committerdate(orauthordate, or-refname) in their git config see GitUI's branch list ignore that preference.What changed: read
branch.sortfrom the repo config and apply it. Supportsrefname,committerdate,authordate, each with the optional-prefix for descending. Anything else (includingversion:refname, which I left out for scope) falls back to the existing refname-ascending behaviour. Public API unchanged.Tests: 6 parser unit tests covering recognised values, the descending prefix, whitespace, and unknown-falls-back. 2 integration tests with
write_commit_file_atto pin the actual sort behaviour for-committerdateand the unset-config baseline.cargo test -p asyncgit --lib sync::branch→ 36 pass.cargo clippy -p asyncgit --all-featuresclean.cargo fmt --checkclean.Future scope:
version:refnamewould need a semver-aware comparator — happy to follow up if there's interest.