@@ -880,74 +880,13 @@ int match_pathname(const char *pathname, int pathlen,
880
880
*/
881
881
if (!patternlen && !namelen )
882
882
return 1 ;
883
- /*
884
- * This can happen when we ignore some exclude rules
885
- * on directories in other to see if negative rules
886
- * may match. E.g.
887
- *
888
- * /abc
889
- * !/abc/def/ghi
890
- *
891
- * The pattern of interest is "/abc". On the first
892
- * try, we should match path "abc" with this pattern
893
- * in the "if" statement right above, but the caller
894
- * ignores it.
895
- *
896
- * On the second try with paths within "abc",
897
- * e.g. "abc/xyz", we come here and try to match it
898
- * with "/abc".
899
- */
900
- if (!patternlen && namelen && * name == '/' )
901
- return 1 ;
902
883
}
903
884
904
885
return fnmatch_icase_mem (pattern , patternlen ,
905
886
name , namelen ,
906
887
WM_PATHNAME ) == 0 ;
907
888
}
908
889
909
- /*
910
- * Return non-zero if pathname is a directory and an ancestor of the
911
- * literal path in a (negative) pattern. This is used to keep
912
- * descending in "foo" and "foo/bar" when the pattern is
913
- * "!foo/bar/.gitignore". "foo/notbar" will not be descended however.
914
- */
915
- static int match_neg_path (const char * pathname , int pathlen , int * dtype ,
916
- const char * base , int baselen ,
917
- const char * pattern , int prefix , int patternlen ,
918
- int flags )
919
- {
920
- assert ((flags & EXC_FLAG_NEGATIVE ) && !(flags & EXC_FLAG_NODIR ));
921
-
922
- if (* dtype == DT_UNKNOWN )
923
- * dtype = get_dtype (NULL , pathname , pathlen );
924
- if (* dtype != DT_DIR )
925
- return 0 ;
926
-
927
- if (* pattern == '/' ) {
928
- pattern ++ ;
929
- patternlen -- ;
930
- prefix -- ;
931
- }
932
-
933
- if (baselen ) {
934
- if (((pathlen < baselen && base [pathlen ] == '/' ) ||
935
- pathlen == baselen ) &&
936
- !strncmp_icase (pathname , base , pathlen ))
937
- return 1 ;
938
- pathname += baselen + 1 ;
939
- pathlen -= baselen + 1 ;
940
- }
941
-
942
-
943
- if (prefix &&
944
- ((pathlen < prefix && pattern [pathlen ] == '/' ) &&
945
- !strncmp_icase (pathname , pattern , pathlen )))
946
- return 1 ;
947
-
948
- return 0 ;
949
- }
950
-
951
890
/*
952
891
* Scan the given exclude list in reverse to see whether pathname
953
892
* should be ignored. The first match (i.e. the last on the list), if
@@ -961,7 +900,7 @@ static struct exclude *last_exclude_matching_from_list(const char *pathname,
961
900
struct exclude_list * el )
962
901
{
963
902
struct exclude * exc = NULL ; /* undecided */
964
- int i , matched_negative_path = 0 ;
903
+ int i ;
965
904
966
905
if (!el -> nr )
967
906
return NULL ; /* undefined */
@@ -996,18 +935,7 @@ static struct exclude *last_exclude_matching_from_list(const char *pathname,
996
935
exc = x ;
997
936
break ;
998
937
}
999
-
1000
- if ((x -> flags & EXC_FLAG_NEGATIVE ) && !matched_negative_path &&
1001
- match_neg_path (pathname , pathlen , dtype , x -> base ,
1002
- x -> baselen ? x -> baselen - 1 : 0 ,
1003
- exclude , prefix , x -> patternlen , x -> flags ))
1004
- matched_negative_path = 1 ;
1005
- }
1006
- if (exc &&
1007
- !(exc -> flags & EXC_FLAG_NEGATIVE ) &&
1008
- !(exc -> flags & EXC_FLAG_NODIR ) &&
1009
- matched_negative_path )
1010
- exc = NULL ;
938
+ }
1011
939
return exc ;
1012
940
}
1013
941
0 commit comments