summaryrefslogtreecommitdiff
path: root/builtin/branch.c
diff options
context:
space:
mode:
authorLibravatar Junio C Hamano <gitster@pobox.com>2021-02-08 14:05:55 -0800
committerLibravatar Junio C Hamano <gitster@pobox.com>2021-02-08 14:05:55 -0800
commitf2d156dc4891dc1f0e86907fe20d3ac08d3cfde1 (patch)
treed7459e3da29b75acc4b3ab4d865bb1a77855362a /builtin/branch.c
parentMerge branch 'ma/more-opaque-lock-file' into maint (diff)
parentbranch: show "HEAD detached" first under reverse sort (diff)
downloadtgif-f2d156dc4891dc1f0e86907fe20d3ac08d3cfde1.tar.xz
Merge branch 'ab/branch-sort' into maint
The implementation of "git branch --sort" wrt the detached HEAD display has always been hacky, which has been cleaned up. * ab/branch-sort: branch: show "HEAD detached" first under reverse sort branch: sort detached HEAD based on a flag ref-filter: move ref_sorting flags to a bitfield ref-filter: move "cmp_fn" assignment into "else if" arm ref-filter: add braces to if/else if/else chain branch tests: add to --sort tests branch: change "--local" to "--list" in comment
Diffstat (limited to 'builtin/branch.c')
-rw-r--r--builtin/branch.c6
1 files changed, 4 insertions, 2 deletions
diff --git a/builtin/branch.c b/builtin/branch.c
index 9b68591add..8c0b428104 100644
--- a/builtin/branch.c
+++ b/builtin/branch.c
@@ -726,7 +726,7 @@ int cmd_branch(int argc, const char **argv, const char *prefix)
print_current_branch_name();
return 0;
} else if (list) {
- /* git branch --local also shows HEAD when it is detached */
+ /* git branch --list also shows HEAD when it is detached */
if ((filter.kind & FILTER_REFS_BRANCHES) && filter.detached)
filter.kind |= FILTER_REFS_DETACHED_HEAD;
filter.name_patterns = argv;
@@ -739,7 +739,9 @@ int cmd_branch(int argc, const char **argv, const char *prefix)
*/
if (!sorting)
sorting = ref_default_sorting();
- ref_sorting_icase_all(sorting, icase);
+ ref_sorting_set_sort_flags_all(sorting, REF_SORTING_ICASE, icase);
+ ref_sorting_set_sort_flags_all(
+ sorting, REF_SORTING_DETACHED_HEAD_FIRST, 1);
print_ref_list(&filter, sorting, &format);
print_columns(&output, colopts, NULL);
string_list_clear(&output, 0);