]> git.ipfire.org Git - thirdparty/git.git/commit
subtree: validate --prefix against commit in split
authorPushkar Singh <pushkarkumarsingh1970@gmail.com>
Thu, 15 Jan 2026 17:52:26 +0000 (17:52 +0000)
committerJunio C Hamano <gitster@pobox.com>
Thu, 15 Jan 2026 19:10:28 +0000 (11:10 -0800)
commitd09107e43996d9ea558a07047f71e80737c90556
tree56a5a9564598db2a91d3a8d1f305ad60683889f6
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 ls-tree 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