ref-filter: move "cmp_fn" assignment into "else if" arm

Further amend code changed in 7c5045fc180 (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 <avarab@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>

Ævar Arnfjörð Bjarmason committed Jan 7, 2021 at 10:51 UTC d0947483a3386204918447775b617ab3dac833b0
1 file changed +2 -2
ref-filter.c
+2 -2
@@ -2355,7 +2355,6 @@ static int cmp_ref_sorting(struct ref_sorting *s, struct ref_array_item *a, stru
2355 struct atom_value *va, *vb;
2356 int cmp;
2357 cmp_type cmp_type = used_atom[s->atom].type;
2358 - int (*cmp_fn)(const char *, const char *);
2358 struct strbuf err = STRBUF_INIT;
2359
2360 if (get_ref_atom_value(a, s->atom, &va, &err))
@@ -2363,10 +2362,11 @@ static int cmp_ref_sorting(struct ref_sorting *s, struct ref_array_item *a, stru
2362 if (get_ref_atom_value(b, s->atom, &vb, &err))
2363 die("%s", err.buf);
2364 strbuf_release(&err);
2366 - cmp_fn = s->ignore_case ? strcasecmp : strcmp;
2365 if (s->version) {
2366 cmp = versioncmp(va->s, vb->s);
2367 } else if (cmp_type == FIELD_STR) {
2368 + int (*cmp_fn)(const char *, const char *);
2369 + cmp_fn = s->ignore_case ? strcasecmp : strcmp;
2370 cmp = cmp_fn(va->s, vb->s);
2371 } else {
2372 if (va->value < vb->value)