From f8e2efdf326f99d7dee30bc9149bfd3f2d1c3ebe Mon Sep 17 00:00:00 2001 From: Christoph Bartschat Date: Mon, 29 Jan 2024 20:20:43 -0800 Subject: [PATCH 1/2] Fix check for nested sparse include --- src/libgit2/sparse.c | 3 ++- tests/libgit2/sparse/paths.c | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/src/libgit2/sparse.c b/src/libgit2/sparse.c index 324cd1482bb..3748b8cf619 100644 --- a/src/libgit2/sparse.c +++ b/src/libgit2/sparse.c @@ -185,7 +185,8 @@ static int parse_sparse_file( git_attr_fnmatch *parent_match; git_vector_foreach(&attrs->rules, k, parent_match) { if (pattern_matches_path(parent_match, &parent_path, parent_length)) { - matched = true; + matched = !HAS_FLAG(parent_match, GIT_ATTR_FNMATCH_NEGATIVE); + break; } } diff --git a/tests/libgit2/sparse/paths.c b/tests/libgit2/sparse/paths.c index db5f49de774..769c40fb06c 100644 --- a/tests/libgit2/sparse/paths.c +++ b/tests/libgit2/sparse/paths.c @@ -160,7 +160,7 @@ void test_sparse_paths__validate_cone(void) char *missing_parent_patterns[] = { "/A/B/", "/A/B/C/", - "/*\n!/A/B/*/\n/A/B/C/" + "/*\n!/A/B/*/\n/A/B/C/D/" }; for (i = 0; i < ARRAY_SIZE(good_patterns); i++) { From 9a82f4335f64ad0eabe474f9f071e94fda135e9b Mon Sep 17 00:00:00 2001 From: Christoph Bartschat Date: Tue, 30 Jan 2024 08:51:48 -0800 Subject: [PATCH 2/2] Fix check for nested sparse include --- src/libgit2/sparse.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/libgit2/sparse.c b/src/libgit2/sparse.c index 3748b8cf619..070e230cdb5 100644 --- a/src/libgit2/sparse.c +++ b/src/libgit2/sparse.c @@ -186,7 +186,7 @@ static int parse_sparse_file( git_vector_foreach(&attrs->rules, k, parent_match) { if (pattern_matches_path(parent_match, &parent_path, parent_length)) { matched = !HAS_FLAG(parent_match, GIT_ATTR_FNMATCH_NEGATIVE); - break; + break; } }