Skip to content

Commit d094748

Browse files
avargitster
authored andcommitted
ref-filter: move "cmp_fn" assignment into "else if" arm
Further amend code changed in 7c5045f (ref-filter: apply fallback refname sort only after all user sorts, 2020-05-03) to move an assignment only used in the "else if" arm to happen there. Before that commit the cmp_fn would be used outside of it. We could also just skip the "cmp_fn" assignment and use strcasecmp/strcmp directly in a ternary statement here, but this is probably more readable. Signed-off-by: Ævar Arnfjörð Bjarmason <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 75c50e5 commit d094748

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

ref-filter.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2355,18 +2355,18 @@ static int cmp_ref_sorting(struct ref_sorting *s, struct ref_array_item *a, stru
23552355
struct atom_value *va, *vb;
23562356
int cmp;
23572357
cmp_type cmp_type = used_atom[s->atom].type;
2358-
int (*cmp_fn)(const char *, const char *);
23592358
struct strbuf err = STRBUF_INIT;
23602359

23612360
if (get_ref_atom_value(a, s->atom, &va, &err))
23622361
die("%s", err.buf);
23632362
if (get_ref_atom_value(b, s->atom, &vb, &err))
23642363
die("%s", err.buf);
23652364
strbuf_release(&err);
2366-
cmp_fn = s->ignore_case ? strcasecmp : strcmp;
23672365
if (s->version) {
23682366
cmp = versioncmp(va->s, vb->s);
23692367
} else if (cmp_type == FIELD_STR) {
2368+
int (*cmp_fn)(const char *, const char *);
2369+
cmp_fn = s->ignore_case ? strcasecmp : strcmp;
23702370
cmp = cmp_fn(va->s, vb->s);
23712371
} else {
23722372
if (va->value < vb->value)

0 commit comments

Comments
 (0)