From 0fbf380daf1367a5c203eb25b744f55634dab251 Mon Sep 17 00:00:00 2001 From: Joaquim Rocha Date: Wed, 18 Feb 2026 00:15:32 +0000 Subject: apply: normalize path in --directory argument When passing a relative path like --directory=./some/sub, the leading "./" caused apply to prepend it literally to patch filenames, resulting in an error (invalid path). There may be more cases like this where users pass some/./path to the directory which can easily be normalized to an acceptable path, so these changes try to normalize the path before using it. Signed-off-by: Joaquim Rocha Signed-off-by: Junio C Hamano --- apply.c | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'apply.c') diff --git a/apply.c b/apply.c index a2ceb3fb40..7c07d124f4 100644 --- a/apply.c +++ b/apply.c @@ -4963,6 +4963,10 @@ static int apply_option_parse_directory(const struct option *opt, strbuf_reset(&state->root); strbuf_addstr(&state->root, arg); + + if (strbuf_normalize_path(&state->root) < 0) + return error(_("unable to normalize directory: '%s'"), arg); + strbuf_complete(&state->root, '/'); return 0; } -- cgit v1.3