git/list[1] front-page[2] threads[3] people[4] search[5] about
 

[PATCH 2/3] for-each-ref: consistently pass WM_IGNORECASE flag

From
Jeff King <peff@peff.net>
Date
Jul 2, 2018, 21:11 UTC
Message-ID
<20180702211159.GB23324@sigill.intra.peff.net>
In-Reply-To
<20180702211100.GA20885@sigill.intra.peff.net>
From: Aleksandr Makarov <aleksandr.o.makarov@gmail.com>

The match_name_as_path() function learned to set WM_IGNORECASE in the "flags" field when the user passed --ignore-case. But it forgot to actually pass the flags to wildmatch()!

As a result, the --ignore-case feature has been broken since it was added in 3bb16a8bf2 (tag, branch, for-each-ref: add --ignore-case for sorting and filtering, 2016-12-04). We didn't notice because we added tests only for git-branch and git-tag. Whereas git-for-each-ref has slightly different matching rules, and thus uses a different function (the related function match_pattern() does it correctly).

Incidentally, this also caused clang's scan-build to complain about the code; the assignment to "flags" was dead code.

Note that we can't flip the test in t6300 to expect_success yet. There's another bug, which will be dealt with in the next patch.

Commit-message-by: Jeff King <peff@peff.net>
Signed-off-by: Jeff King <peff@peff.net>
---
 ref-filter.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/ref-filter.c b/ref-filter.c
index fa3685d91f..5c0cbde52b 100644
--- a/ref-filter.c
+++ b/ref-filter.c
@@ -1813,7 +1813,7 @@ static int match_name_as_path(const struct ref_filter *filter, const char *refna
 		     refname[plen] == '/' ||
 		     p[plen-1] == '/'))
 			return 1;
-		if (!wildmatch(p, refname, WM_PATHNAME))
+		if (!wildmatch(p, refname, flags))
 			return 1;
 	}
 	return 0;
-- 
2.18.0.359.ge51c883f96
Previous: Jeff KingNext: Jeff King
Message 3 of 5 in “un-break for-each-ref --ignore-case”
  1. 0/3 un-break for-each-ref --ignore-caseJeff King, Jul 2, 2018
  2. 1/3 t6300: add a test for --ignore-caseJeff King, Jul 2, 2018
  3. 2/3 for-each-ref: consistently pass WM_IGNORECASE flagJeff King, Jul 2, 2018
  4. 3/3 ref-filter: avoid backend filtering with --ignore-caseJeff King, Jul 2, 2018
  5. Eric SunshineJul 2, 2018

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.