Merge branch 'jk/for-each-ref-icase'

The "--ignore-case" option of "git for-each-ref" (and its friends)
did not work correctly, which has been fixed.

* jk/for-each-ref-icase:
  ref-filter: avoid backend filtering with --ignore-case
  for-each-ref: consistently pass WM_IGNORECASE flag
  t6300: add a test for --ignore-case
This commit is contained in:
Junio C Hamano 2018-07-24 14:50:44 -07:00
commit 4301330588
2 changed files with 21 additions and 1 deletions

View File

@ -1814,7 +1814,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;
@ -1869,6 +1869,15 @@ static int for_each_fullref_in_pattern(struct ref_filter *filter,
return for_each_fullref_in("", cb, cb_data, broken);
}
if (filter->ignore_case) {
/*
* we can't handle case-insensitive comparisons,
* so just return everything and let the caller
* sort it out.
*/
return for_each_fullref_in("", cb, cb_data, broken);
}
if (!filter->name_patterns[0]) {
/* no patterns; we have to look at everything */
return for_each_fullref_in("", cb, cb_data, broken);

View File

@ -795,4 +795,15 @@ test_expect_success ':remotename and :remoteref' '
)
'
test_expect_success 'for-each-ref --ignore-case ignores case' '
>expect &&
git for-each-ref --format="%(refname)" refs/heads/MASTER >actual &&
test_cmp expect actual &&
echo refs/heads/master >expect &&
git for-each-ref --format="%(refname)" --ignore-case \
refs/heads/MASTER >actual &&
test_cmp expect actual
'
test_done