Subject: Re: [PATCH] apply: strip ./ prefix from --directory argument

From: Junio C Hamano <[email-masked]>
Date: Tue, 17 Feb 2026 12:27:39 -0800

Patrick Steinhardt <[email-masked]> writes:

> While this change here fixes your observed issues, the next person might
> run into a totally different one. So more generally, I think what we'd
> rather want to do is to fully normalize the path. How about this
> instead:

Sorry, but I am confused.  Why isn't "don't do it then" a good
answer for a case like this?

>
> diff --git a/apply.c b/apply.c
> index 9de2eb953e..8946b133a3 100644
> --- a/apply.c
> +++ b/apply.c
> @@ -5002,6 +5002,7 @@ static int apply_option_parse_directory(const struct option *opt,
>  
>  	strbuf_reset(&state->root);
>  	strbuf_addstr(&state->root, arg);
> +	strbuf_normalize_path(&state->root);
>  	strbuf_complete(&state->root, '/');
>  	return 0;
>  }
>
> `strbuf_normalize_path()` drops "." components, removes ".." and it
> squashes multiple directory separators. So it handles your specific use
> case, but also others.
>
> Thanks!
>
> Patrick