@@ -549,7 +549,7 @@ static int match_entry(const struct name_entry *entry, int pathlen,
549549 return 0 ;
550550}
551551
552- static int match_dir_prefix (const char * base , int baselen ,
552+ static int match_dir_prefix (const char * base ,
553553 const char * match , int matchlen )
554554{
555555 if (strncmp (base , match , matchlen ))
@@ -606,7 +606,7 @@ int tree_entry_interesting(const struct name_entry *entry,
606606
607607 if (baselen >= matchlen ) {
608608 /* If it doesn't match, move along... */
609- if (!match_dir_prefix (base_str , baselen , match , matchlen ))
609+ if (!match_dir_prefix (base_str , match , matchlen ))
610610 goto match_wildcards ;
611611
612612 if (!ps -> recursive || ps -> max_depth == -1 )
@@ -618,8 +618,8 @@ int tree_entry_interesting(const struct name_entry *entry,
618618 ps -> max_depth );
619619 }
620620
621- /* Does the base match? */
622- if (!strncmp (base_str , match , baselen )) {
621+ /* Either there must be no base, or the base must match. */
622+ if (baselen == 0 || !strncmp (base_str , match , baselen )) {
623623 if (match_entry (entry , pathlen ,
624624 match + baselen , matchlen - baselen ,
625625 & never_interesting ))
0 commit comments