{
struct atom_value *va, *vb;
int cmp;
+ int cmp_detached_head = 0;
cmp_type cmp_type = used_atom[s->atom].type;
struct strbuf err = STRBUF_INIT;
if (s->sort_flags & REF_SORTING_DETACHED_HEAD_FIRST &&
((a->kind | b->kind) & FILTER_REFS_DETACHED_HEAD)) {
cmp = compare_detached_head(a, b);
+ cmp_detached_head = 1;
} else if (s->sort_flags & REF_SORTING_VERSION) {
cmp = versioncmp(va->s, vb->s);
} else if (cmp_type == FIELD_STR) {
cmp = 1;
}
- return (s->sort_flags & REF_SORTING_REVERSE) ? -cmp : cmp;
+ return (s->sort_flags & REF_SORTING_REVERSE && !cmp_detached_head)
+ ? -cmp : cmp;
}
static int compare_refs(const void *a_, const void *b_, void *ref_sorting)
test_i18ncmp expect actual &&
cat >expect <<-\EOF &&
+ * (HEAD detached from fromtag)
branch-one
main
branch-two
- * (HEAD detached from fromtag)
EOF
git branch --sort=-objectsize >actual &&
test_i18ncmp expect actual
test_i18ncmp expect actual &&
cat >expect <<-\EOF &&
+ * (HEAD detached from fromtag)
branch-one
branch-two
main
- * (HEAD detached from fromtag)
EOF
git branch --sort=-type >actual &&
test_i18ncmp expect actual
test_i18ncmp expect actual &&
cat >expect <<-\EOF &&
+ * (HEAD detached from fromtag)
main
branch-two
branch-one
- * (HEAD detached from fromtag)
EOF
git branch --sort=-version:refname >actual &&
test_i18ncmp expect actual