threads / patch / 46719

patchmatch_name_as_path: Pass WM_CASEFOLD to wildmatch

Subject: [PATCH] match_name_as_path: Pass WM_CASEFOLD to wildmatch

## tl;dr

2 messages between Sep 7, 2017 and Sep 7, 2017. Diffs are folded; open one to read it.

replies: 1people: 2as markdown or json

Aleksandr Makarov· Sep 7, 2017, 13:51 UTC · lore
---
  ref-filter.c | 2 +-
  1 file changed, 1 insertion(+), 1 deletion(-)
Show changes to ref-filter.c +1 −1
diff --git a/ref-filter.c b/ref-filter.c
index bc591f4..3746628 100644
--- a/ref-filter.c
+++ b/ref-filter.c
@@ -1663,7 +1663,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.7.4
Jeff King· Sep 7, 2017, 14:50 UTC · re: Aleksandr Makarov · lore

Re: [PATCH] match_name_as_path: Pass WM_CASEFOLD to wildmatch

On Thu, Sep 07, 2017 at 04:51:36PM +0300, Aleksandr Makarov wrote:
> ---

Your commit message leaves me with a lot of questions. Let me see if I can answer them. :)

Can this code path be triggered? We need to set filter->ignore_case, but also filter->match_as_patch. So "git branch --ignore-case" works, but "git for-each-ref --ignore-case" is totally broken.

When did this break? It looks like ignore-case never worked with for-each-ref. This should have been part of Duy's (+cc) 3bb16a8bf2 (tag, branch, for-each-ref: add --ignore-case for sorting and filtering, 2016-12-04). It got the match_pattern() one right, but missed this tweak in match_as_path.

How come we didn't notice? Because 3bb16a8bf2 has tests for branch and tag, but not for-each-ref. We should probably add one as part of this fix.

And finally, your patch needs a sign-off to be included in the project (see Documentation/SubmittingPatches).

Show 10 quoted lines
> diff --git a/ref-filter.c b/ref-filter.c
> index bc591f4..3746628 100644
> --- a/ref-filter.c
> +++ b/ref-filter.c
> @@ -1663,7 +1663,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))
The patch itself looks correct to me. Thanks.
-Peff

← back to recent threads