Junio C Hamano <gitster@xxxxxxxxx> writes: > Hmph. Do we still need "found" here? If there are include patterns > given explicitly from the command line, a ref MUST match one of them > in order to be included, and a ref that matches one of them will be > included no matter that exclude config says. > > So shouldn't the updated logic for the include patterns part be more > like ... I still think that the two clean-ups I mentioned are both worth doing, but without them, but with the simplification of the code I suggested, the resulting helper becomes like this, which I think is quite easy to understand. It seems to pass t4202, which you updated, too. int ref_filter_match(const char *refname, const struct string_list *include_patterns, const struct string_list *exclude_patterns, const struct string_list *exclude_patterns_config) { struct string_list_item *item; if (exclude_patterns && exclude_patterns->nr) { for_each_string_list_item(item, exclude_patterns) { if (match_ref_pattern(refname, item)) return 0; } } if (include_patterns && include_patterns->nr) { for_each_string_list_item(item, include_patterns) { if (match_ref_pattern(refname, item)) { return 1; } } return 0; } if (exclude_patterns_config && exclude_patterns_config->nr) { for_each_string_list_item(item, exclude_patterns_config) { if (match_ref_pattern(refname, item)) return 0; } } return 1; }