From 76f9e569adb540a1ca1a590c512d57fce4eea878 Mon Sep 17 00:00:00 2001 From: Jeff King Date: Sun, 3 May 2020 05:11:57 -0400 Subject: ref-filter: apply --ignore-case to all sorting keys All of the ref-filter users (for-each-ref, branch, and tag) take an --ignore-case option which makes filtering and sorting case-insensitive. However, this option was applied only to the first element of the ref_sorting list. So: git for-each-ref --ignore-case --sort=refname would do what you expect, but: git for-each-ref --ignore-case --sort=refname --sort=taggername would sort the primary key (taggername) case-insensitively, but sort the refname case-sensitively. We have two options here: - teach callers to set ignore_case on the whole list - replace the ref_sorting list with a struct that contains both the list of sorting keys, as well as options that apply to _all_ keys I went with the first one here, as it gives more flexibility if we later want to let the users set the flag per-key (presumably through some special syntax when defining the key; for now it's all or nothing through --ignore-case). The new test covers this by sorting on both tagger and subject case-insensitively, which should compare "a" and "A" identically, but still sort them before "b" and "B". We'll break ties by sorting on the refname to give ourselves a stable output (this is actually supposed to be done automatically, but there's another bug which will be fixed in the next commit). Signed-off-by: Jeff King Signed-off-by: Junio C Hamano --- builtin/tag.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'builtin/tag.c') diff --git a/builtin/tag.c b/builtin/tag.c index 02f6bd1279..8903c851ea 100644 --- a/builtin/tag.c +++ b/builtin/tag.c @@ -465,7 +465,7 @@ int cmd_tag(int argc, const char **argv, const char *prefix) } if (!sorting) sorting = ref_default_sorting(); - sorting->ignore_case = icase; + ref_sorting_icase_all(sorting, icase); filter.ignore_case = icase; if (cmdmode == 'l') { int ret; -- cgit v1.2.3