Skip to content

Commit e674eb2

Browse files
peffgitster
authored andcommitted
ref-filter: avoid backend filtering with --ignore-case
When for-each-ref is used with --ignore-case, we expect match_name_as_path() to do a case-insensitive match. But there's an extra layer of filtering that happens before we even get there. Since commit cfe004a (ref-filter: limit traversal to prefix, 2017-05-22), we feed the prefix to the ref backend so that it can optimize the ref iteration. There's no mechanism for us to tell the backend we're matching case-insensitively. Nor is there likely to be one anytime soon, since the packed backend relies on binary-searching the sorted list of refs. Let's just punt on this case. The extra filtering is an optimization that we simply can't do. We'll still give the correct answer via the filtering in match_name_as_path(). Signed-off-by: Jeff King <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 639ab5e commit e674eb2

File tree

2 files changed

+10
-1
lines changed

2 files changed

+10
-1
lines changed

ref-filter.c

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1769,6 +1769,15 @@ static int for_each_fullref_in_pattern(struct ref_filter *filter,
17691769
return for_each_fullref_in("", cb, cb_data, broken);
17701770
}
17711771

1772+
if (filter->ignore_case) {
1773+
/*
1774+
* we can't handle case-insensitive comparisons,
1775+
* so just return everything and let the caller
1776+
* sort it out.
1777+
*/
1778+
return for_each_fullref_in("", cb, cb_data, broken);
1779+
}
1780+
17721781
if (!filter->name_patterns[0]) {
17731782
/* no patterns; we have to look at everything */
17741783
return for_each_fullref_in("", cb, cb_data, broken);

t/t6300-for-each-ref.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -795,7 +795,7 @@ test_expect_success ':remotename and :remoteref' '
795795
)
796796
'
797797

798-
test_expect_failure 'for-each-ref --ignore-case ignores case' '
798+
test_expect_success 'for-each-ref --ignore-case ignores case' '
799799
>expect &&
800800
git for-each-ref --format="%(refname)" refs/heads/MASTER >actual &&
801801
test_cmp expect actual &&

0 commit comments

Comments
 (0)