@@ -593,31 +593,40 @@ void path_exclude_check_clear(struct path_exclude_check *check)
593
593
}
594
594
595
595
/*
596
- * Is the ce-> name excluded? This is for a caller like show_files() that
596
+ * Is this name excluded? This is for a caller like show_files() that
597
597
* do not honor directory hierarchy and iterate through paths that are
598
598
* possibly in an ignored directory.
599
599
*
600
600
* A path to a directory known to be excluded is left in check->path to
601
601
* optimize for repeated checks for files in the same excluded directory.
602
602
*/
603
- int path_excluded (struct path_exclude_check * check , struct cache_entry * ce )
603
+ int path_excluded (struct path_exclude_check * check ,
604
+ const char * name , int namelen , int * dtype )
604
605
{
605
- int i , dtype ;
606
+ int i ;
606
607
struct strbuf * path = & check -> path ;
607
608
609
+ /*
610
+ * we allow the caller to pass namelen as an optimization; it
611
+ * must match the length of the name, as we eventually call
612
+ * excluded() on the whole name string.
613
+ */
614
+ if (namelen < 0 )
615
+ namelen = strlen (name );
616
+
608
617
if (path -> len &&
609
- path -> len <= ce_namelen ( ce ) &&
610
- !memcmp (ce -> name , path -> buf , path -> len ) &&
611
- (!ce -> name [path -> len ] || ce -> name [path -> len ] == '/' ))
618
+ path -> len <= namelen &&
619
+ !memcmp (name , path -> buf , path -> len ) &&
620
+ (!name [path -> len ] || name [path -> len ] == '/' ))
612
621
return 1 ;
613
622
614
623
strbuf_setlen (path , 0 );
615
- for (i = 0 ; ce -> name [i ]; i ++ ) {
616
- int ch = ce -> name [i ];
624
+ for (i = 0 ; name [i ]; i ++ ) {
625
+ int ch = name [i ];
617
626
618
627
if (ch == '/' ) {
619
- dtype = DT_DIR ;
620
- if (excluded (check -> dir , path -> buf , & dtype ))
628
+ int dt = DT_DIR ;
629
+ if (excluded (check -> dir , path -> buf , & dt ))
621
630
return 1 ;
622
631
}
623
632
strbuf_addch (path , ch );
@@ -626,8 +635,7 @@ int path_excluded(struct path_exclude_check *check, struct cache_entry *ce)
626
635
/* An entry in the index; cannot be a directory with subentries */
627
636
strbuf_setlen (path , 0 );
628
637
629
- dtype = ce_to_dtype (ce );
630
- return excluded (check -> dir , ce -> name , & dtype );
638
+ return excluded (check -> dir , name , dtype );
631
639
}
632
640
633
641
static struct dir_entry * dir_entry_new (const char * pathname , int len )
0 commit comments