asyncgit: support comma-separated branch.sort keys; add changelog

git accepts multi-key sort values like `-committerdate,refname`.
BranchSort::parse now splits on commas and honours the primary (first)
key rather than falling back to the default.

Add a test for the comma-separated case and a CHANGELOG entry.
This commit is contained in:
Scolliq 2026-04-27 20:58:24 +02:00
parent 5586cf1d5f
commit b81b6beb8f
2 changed files with 26 additions and 3 deletions

View file

@ -8,6 +8,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
## Unreleased
### Changed
* honour `branch.sort` git config when listing branches, including support for comma-separated multi-key values ([#2918](https://github.com/gitui-org/gitui/pull/2918))
* use [tombi](https://github.com/tombi-toml/tombi) for all toml file formatting
* open the external editor from the status diff view [[@WaterWhisperer](https://github.com/WaterWhisperer)] ([#2805](https://github.com/gitui-org/gitui/issues/2805))

View file

@ -250,10 +250,12 @@ impl BranchSort {
}
fn parse(raw: &str) -> Self {
let trimmed = raw.trim();
let (descending, key) = trimmed
// git accepts comma-separated lists (e.g. `-committerdate,refname`);
// honour only the primary (first) key.
let primary = raw.split(',').next().unwrap_or("").trim();
let (descending, key) = primary
.strip_prefix('-')
.map_or((false, trimmed), |rest| (true, rest));
.map_or((false, primary), |rest| (true, rest));
match key {
"committerdate" => Self {
field: BranchSortField::CommitterDate,
@ -874,6 +876,26 @@ mod tests_branch_sort {
);
}
#[test]
fn parse_comma_separated_uses_primary_key() {
// git allows multi-key sort like `-committerdate,refname`; we use
// only the first key and ignore the rest.
assert_eq!(
BranchSort::parse("-committerdate,refname"),
BranchSort {
field: BranchSortField::CommitterDate,
descending: true,
}
);
assert_eq!(
BranchSort::parse("authordate,-refname"),
BranchSort {
field: BranchSortField::AuthorDate,
descending: false,
}
);
}
#[test]
fn applies_committerdate_descending_from_config() {
let (_td, repo) = repo_init().unwrap();