dir.c: accept a directory as part of cone-mode patterns
commit69bdbdb0ee25bd64bd3ad2fe241d434442e96f75
authorDerrick Stolee <dstolee@microsoft.com>
Wed, 14 Jul 2021 13:12:34 +0000 (14 13:12 +0000)
committerJunio C Hamano <gitster@pobox.com>
Wed, 14 Jul 2021 20:42:49 +0000 (14 13:42 -0700)
tree7f2128154a7188a619d56a6d9ae9bd2c5a81b4a1
parent523506df51e2e13c8c354dff1eea3378bac8dec8
dir.c: accept a directory as part of cone-mode patterns

When we have sparse directory entries in the index, we want to compare
that directory against sparse-checkout patterns. Those pattern matching
algorithms are built expecting a file path, not a directory path. This
is especially important in the "cone mode" patterns which will match
files that exist within the "parent directories" as well as the
recursive directory matches.

If path_matches_pattern_list() is given a directory, we can add a fake
filename ("-") to the directory and get the same results as before,
assuming we are in cone mode. Since sparse index requires cone mode
patterns, this is an acceptable assumption.

Reviewed-by: Elijah Newren <newren@gmail.com>
Signed-off-by: Derrick Stolee <dstolee@microsoft.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
dir.c