dir.c: accept a directory as part of cone-mode patterns
authorDerrick Stolee <dstolee@microsoft.com>
Fri, 21 May 2021 11:59:37 +0000 (11:59 +0000)
committerJunio C Hamano <gitster@pobox.com>
Sat, 22 May 2021 08:58:19 +0000 (17:58 +0900)
commit70c088977e699e2505ad771f78973a352c4a4d37
tree9ecb9cf847648f2029267a53e9d501b53c912ff3
parent5afb21bfd2b0a27633f04b716f11f7a72991e8ae
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.

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