Matthew DeVore <[email protected]> writes:

> -     if (s->version)
> +     if (s->version) {
>               cmp = versioncmp(va->s, vb->s);
> -     else if (cmp_type == FIELD_STR)
> -             cmp = cmp_fn(va->s, vb->s);
> -     else {

Ah, this must be the patch noise Jonathan was (half) complaining
about.  It does make it a bit distracting to read the patch but the
resulting code is of course easier to follow ;-).

> +     } else if (cmp_type == FIELD_STR) {
> +             const int a_detached = a->kind & FILTER_REFS_DETACHED_HEAD;
> +
> +             /*
> +              * When sorting by name, we should put "detached" head lines,
> +              * which are all the lines in parenthesis, before all others.
> +              * This usually is automatic, since "(" is before "refs/" and
> +              * "remotes/", but this does not hold for zh_CN, which uses
> +              * full-width parenthesis, so make the ordering explicit.
> +              */
> +             if (a_detached != (b->kind & FILTER_REFS_DETACHED_HEAD))
> +                     cmp = a_detached ? -1 : 1;

So, comparing a detached and an undetached ones, the detached side
always sorts lower.  Good.  And ...

> +             else
> +                     cmp = cmp_fn(va->s, vb->s);

... otherwise we compare the string using the given function.

Sounds sensible.  Will queue.

Reply via email to