Skip to content

Commit eafc03d

Browse files
jltoblergitster
authored andcommitted
ref-filter: allow NULL filter pattern
When setting up `struct ref_filter` for filter_refs(), the `name_patterns` field must point to an array of pattern strings even if no patterns are required. To improve this interface, treat a NULL `name_patterns` field the same as when it points to an empty array. Signed-off-by: Justin Tobler <jltobler@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
1 parent 026ad60 commit eafc03d

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

ref-filter.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2664,7 +2664,7 @@ static int match_name_as_path(const char **pattern, const char *refname,
26642664
/* Return 1 if the refname matches one of the patterns, otherwise 0. */
26652665
static int filter_pattern_match(struct ref_filter *filter, const char *refname)
26662666
{
2667-
if (!*filter->name_patterns)
2667+
if (!filter->name_patterns || !*filter->name_patterns)
26682668
return 1; /* No pattern always matches */
26692669
if (filter->match_as_path)
26702670
return match_name_as_path(filter->name_patterns, refname,
@@ -2751,7 +2751,7 @@ static int for_each_fullref_in_pattern(struct ref_filter *filter,
27512751
return for_each_fullref_with_seek(filter, cb, cb_data, 0);
27522752
}
27532753

2754-
if (!filter->name_patterns[0]) {
2754+
if (!filter->name_patterns || !filter->name_patterns[0]) {
27552755
/* no patterns; we have to look at everything */
27562756
return for_each_fullref_with_seek(filter, cb, cb_data, 0);
27572757
}

0 commit comments

Comments
 (0)