Subject: Re: [PATCH v2] subtree: validate --prefix against commit in split

From: Junio C Hamano <[email-masked]>
Date: Thu, 15 Jan 2026 08:30:31 -0800

Pushkar Singh <[email-masked]> writes:

> git subtree split currently validates --prefix against the working tree.
> This breaks when splitting an older commit or when the working tree does
> not contain the subtree, even though the commit does.
>
> For example:
>
>   git subtree split --prefix=pkg <commit>
>
> fails if pkg was removed later, even though it exists in <commit>.
>
> Fix this by validating the prefix against the specified commit using
> git ls-tree instead of the working tree.
>
> Signed-off-by: Pushkar Singh <[email-masked]>
> ---
>  contrib/subtree/git-subtree.sh | 9 +++++++++
>  1 file changed, 9 insertions(+)

Is this something you can protect from future breakage with a test,
perhaps in contrib/subtree/t/t7900-subtree.sh?

> diff --git a/contrib/subtree/git-subtree.sh b/contrib/subtree/git-subtree.sh
> index 17106d1a72..a5822b66d5 100755
> --- a/contrib/subtree/git-subtree.sh
> +++ b/contrib/subtree/git-subtree.sh
> @@ -257,6 +257,9 @@ main () {
>  		test -e "$arg_prefix" &&
>  			die "fatal: prefix '$arg_prefix' already exists."
>  		;;
> +	split)
> +        # checked later against the commit, not the working tree
> +        ;;

Funny indentation?