Thread (18 messages) flat view 18 messages, 1 author, 2016-06-15
STALE3716d

[PATCH/RFC 7/7] contrib/subtree: Handle '--prefix' argument with a slash appended

From: Techlive Zheng <hidden>
Date: 2016-06-15 22:55:44
Subsystem: the rest · Maintainer: Linus Torvalds

'git subtree merge' will fail if the argument of '--prefix' has a slash
appended.

Signed-off-by: Techlive Zheng <redacted>
---
 contrib/subtree/git-subtree.sh     |  2 +-
 contrib/subtree/t/t7900-subtree.sh | 19 +++++++++++++++++++
 2 files changed, 20 insertions(+), 1 deletion(-)
diff --git a/contrib/subtree/git-subtree.sh b/contrib/subtree/git-subtree.sh
index 018ee32..574ff04 100755
--- a/contrib/subtree/git-subtree.sh
+++ b/contrib/subtree/git-subtree.sh
@@ -83,7 +83,7 @@ while [ $# -gt 0 ]; do
 		--annotate) annotate="$1"; shift ;;
 		--no-annotate) annotate= ;;
 		-b) branch="$1"; shift ;;
-		-P) prefix="$1"; shift ;;
+		-P) prefix="${1%/}"; shift ;;
 		-m) message="$1"; shift ;;
 		--no-prefix) prefix= ;;
 		--onto) onto="$1"; shift ;;
diff --git a/contrib/subtree/t/t7900-subtree.sh b/contrib/subtree/t/t7900-subtree.sh
index 1492303..8e09606 100755
--- a/contrib/subtree/t/t7900-subtree.sh
+++ b/contrib/subtree/t/t7900-subtree.sh
@@ -238,6 +238,25 @@ test_expect_success 'merge new subproj history into subdir/ with --squash and --
     )
 '
 
+test_expect_success 'merge new subproj history into subdir/ with a slash appended to the argument of --prefix' '
+    test_create_repo "$test_count" &&
+    test_create_repo "$test_count/subproj" &&
+    test_create_commit "$test_count" main1 &&
+    test_create_commit "$test_count/subproj" sub1 &&
+    (
+        cd "$test_count" &&
+        git fetch ./subproj master &&
+        git subtree add --prefix=subdir/ FETCH_HEAD
+    ) &&
+    test_create_commit "$test_count/subproj" sub2 &&
+    (
+        cd "$test_count" &&
+        git fetch ./subproj master &&
+        git subtree merge --prefix=subdir/ FETCH_HEAD &&
+        test_equal "$(last_commit_message)" "Merge commit '\''$(git rev-parse FETCH_HEAD)'\''"
+    )
+'
+
 #
 # Tests for 'git subtree split'
 #
-- 
1.8.1
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help