File tree Expand file tree Collapse file tree 1 file changed +8
-10
lines changed Expand file tree Collapse file tree 1 file changed +8
-10
lines changed Original file line number Diff line number Diff line change @@ -696,14 +696,14 @@ static int convert_pathspec_to_bloom_keyvec(struct bloom_keyvec **out,
696
696
char * path_alloc = NULL ;
697
697
const char * path ;
698
698
size_t len ;
699
- int res = 0 ;
699
+ int res = -1 ; /* be pessimistic */
700
700
701
701
len = pi -> nowildcard_len ;
702
702
if (len != pi -> len ) {
703
703
/*
704
- * for path like "/ dir/file*", nowildcard part would be
705
- * "/ dir/file", but only "/ dir" should be used for the
706
- * bloom filter
704
+ * for path like "dir/file*", nowildcard part would be
705
+ * "dir/file", but only "dir" should be used for the
706
+ * bloom filter.
707
707
*/
708
708
while (len > 0 && pi -> match [len - 1 ] != '/' )
709
709
len -- ;
@@ -712,19 +712,17 @@ static int convert_pathspec_to_bloom_keyvec(struct bloom_keyvec **out,
712
712
if (len > 0 && pi -> match [len - 1 ] == '/' )
713
713
len -- ;
714
714
715
+ if (!len )
716
+ goto cleanup ;
717
+
715
718
if (len != pi -> len ) {
716
719
path_alloc = xmemdupz (pi -> match , len );
717
720
path = path_alloc ;
718
721
} else
719
722
path = pi -> match ;
720
723
721
- len = strlen (path );
722
- if (!len ) {
723
- res = -1 ;
724
- goto cleanup ;
725
- }
726
-
727
724
* out = bloom_keyvec_new (path , len , settings );
725
+ res = 0 ;
728
726
729
727
cleanup :
730
728
free (path_alloc );
You can’t perform that action at this time.
0 commit comments