Skip to content

Commit cdfacff

Browse files
committed
fixup! bloom: enable bloom filter with wildcard pathspec in revision traversal
1 parent a8db000 commit cdfacff

File tree

1 file changed

+8
-10
lines changed

1 file changed

+8
-10
lines changed

revision.c

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -696,14 +696,14 @@ static int convert_pathspec_to_bloom_keyvec(struct bloom_keyvec **out,
696696
char *path_alloc = NULL;
697697
const char *path;
698698
size_t len;
699-
int res = 0;
699+
int res = -1; /* be pessimistic */
700700

701701
len = pi->nowildcard_len;
702702
if (len != pi->len) {
703703
/*
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.
707707
*/
708708
while (len > 0 && pi->match[len - 1] != '/')
709709
len--;
@@ -712,19 +712,17 @@ static int convert_pathspec_to_bloom_keyvec(struct bloom_keyvec **out,
712712
if (len > 0 && pi->match[len - 1] == '/')
713713
len--;
714714

715+
if (!len)
716+
goto cleanup;
717+
715718
if (len != pi->len) {
716719
path_alloc = xmemdupz(pi->match, len);
717720
path = path_alloc;
718721
} else
719722
path = pi->match;
720723

721-
len = strlen(path);
722-
if (!len) {
723-
res = -1;
724-
goto cleanup;
725-
}
726-
727724
*out = bloom_keyvec_new(path, len, settings);
725+
res = 0;
728726

729727
cleanup:
730728
free(path_alloc);

0 commit comments

Comments
 (0)