]> git.ipfire.org Git - thirdparty/git.git/commit
subtree: validate --prefix against commit in split
authorPushkar Singh <pushkarkumarsingh1970@gmail.com>
Tue, 3 Feb 2026 16:48:16 +0000 (16:48 +0000)
committerJunio C Hamano <gitster@pobox.com>
Tue, 3 Feb 2026 17:26:45 +0000 (09:26 -0800)
commita606fcdceb807b93013542e5e4d5f4c233aa6c83
treeba8a94c783e2175b5a1e66cff9a49af7bbba9c55
parentd529f3a197364881746f558e5652f0236131eb86
subtree: validate --prefix against commit in split

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 cat-file instead of the working tree.

Add a test to ensure this behavior does not regress.

Signed-off-by: Pushkar Singh <pushkarkumarsingh1970@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
contrib/subtree/git-subtree.sh
contrib/subtree/t/t7900-subtree.sh