Re: [PATCH v2 2/5] setup: extract path_allowlist_apply()
flat view
From: Christian Couder <hidden>
Date: 2026-09-08 16:46:17
On Fri, Aug 14, 2026 at 7:56 PM Junio C Hamano [off-list ref] wrote:
Christian Couder [off-list ref] writes:
quoted
diff --git a/setup.c b/setup.c index 95909e9603..39dfa1cc5f 100644 --- a/setup.c +++ b/setup.c@@ -1339,6 +1339,64 @@ static int canonicalize_ceiling_entry(struct string_list_item *item,
[...]
quoted
+ + if (ends_with(normalized, "/*")) { + size_t len = strlen(normalized); + if (!fspathncmp(normalized, target_path, len - 1)) + *is_match = 1; + goto end; + } + + if (!fspathcmp(target_path, normalized)) + *is_match = 1; + +end: + free(normalized); + free(allowed); +}The name "is_match" somehow feels a bit awkward. How about calling it *matches = true/false; instead?
It was `int is_match` to match with `int is_safe` in `struct safe_directory_data`, as the function is called this way: path_allowlist_apply(key, value, data->path, &data->is_safe); But OK, I have changed both `int is_match` and `int is_safe` to `bool matches` and `bool safe` in the v3 I just sent. Thanks.