public inbox for git@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] subtree: validate --prefix against commit in split
@ 2026-01-15 12:09 Pushkar Singh
  2026-01-15 12:24 ` [PATCH v2] " Pushkar Singh
  0 siblings, 1 reply; 19+ messages in thread
From: Pushkar Singh @ 2026-01-15 12:09 UTC (permalink / raw)
  To: git; +Cc: Pushkar Singh

---
 contrib/subtree/git-subtree.sh | 17 +++++++++++++----
 1 file changed, 13 insertions(+), 4 deletions(-)

diff --git a/contrib/subtree/git-subtree.sh b/contrib/subtree/git-subtree.sh
index 17106d1a72..a1b60eac8b 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
+        ;;
 	*)
 		test -e "$arg_prefix" ||
 			die "fatal: '$arg_prefix' does not exist; use 'git subtree add'"
@@ -958,13 +961,19 @@ cmd_add_commit () {
 cmd_split () {
 	if test $# -eq 0
 	then
-		rev=$(git rev-parse HEAD)
+			rev=$(git rev-parse HEAD)
 	elif test $# -eq 1 || test $# -eq 2
 	then
-		rev=$(git rev-parse -q --verify "$1^{commit}") ||
-			die "fatal: '$1' does not refer to a commit"
+			rev=$(git rev-parse -q --verify "$1^{commit}") ||
+					die "fatal: '$1' does not refer to a commit"
 	else
-		die "fatal: you must provide exactly one revision, and optionally a repository.  Got: '$*'"
+			die "fatal: you must provide exactly one revision, and optionally a repository.  Got: '$*'"
+	fi
+
+	# Now validate prefix against the commit, not the working tree
+	if ! git ls-tree -d "$rev" -- "$dir" >/dev/null
+	then
+			die "fatal: '$dir' does not exist in commit $rev"
 	fi
 	repository=""
 	if test "$#" = 2
-- 
2.43.0


^ permalink raw reply related	[flat|nested] 19+ messages in thread

end of thread, other threads:[~2026-02-05 20:54 UTC | newest]

Thread overview: 19+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-01-15 12:09 [PATCH] subtree: validate --prefix against commit in split Pushkar Singh
2026-01-15 12:24 ` [PATCH v2] " Pushkar Singh
2026-01-15 16:30   ` Junio C Hamano
2026-01-15 17:52     ` [PATCH v3] " Pushkar Singh
2026-02-02 18:54       ` Josh Steadmon
2026-02-02 19:10         ` Junio C Hamano
2026-02-02 21:07         ` Junio C Hamano
2026-02-03 15:30           ` [RFH] adding test coverage for contrib/ in CI jobs Junio C Hamano
2026-02-03 17:06             ` Re* " Junio C Hamano
2026-02-03 23:09               ` Junio C Hamano
2026-02-04  4:38               ` Colin Stagner
2026-02-04 19:55                 ` Junio C Hamano
2026-02-05  6:05               ` Colin Stagner
2026-02-05 16:39                 ` Junio C Hamano
2026-02-05 20:54                   ` Junio C Hamano
2026-02-03 21:26             ` Junio C Hamano
2026-02-03 21:53               ` Jeff King
2026-02-03 16:48       ` [PATCH v4] subtree: validate --prefix against commit in split Pushkar Singh
2026-02-03 17:37         ` Junio C Hamano

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox