threads / patch / 32942

v2, 3 partscontrib/subtree/t: Added tests for .gitsubtree support

Subject: [PATCH v2 2/3] contrib/subtree/t: Added tests for .gitsubtree support

## tl;dr

One message between Feb 19, 2013 and Feb 19, 2013. Diffs are folded; open one to read it.

replies: 0people: 1as markdown or json

Paul Campbell· Feb 19, 2013, 12:31 UTC · lore
add: ensure details are added to .gitsubtree
push: check for a SHA1 update line
pull: add a file on one subtree, push it to a branch, then pull into
    another subtree containing the same branch and confirm the files match
add: ensure stale .gitsubtree entry is replaced
Signed-off-by: Paul Campbell <pcampbell@kemitix.net>
---
 contrib/subtree/t/t7900-subtree.sh | 42 ++++++++++++++++++++++++++++++++++++++
 1 file changed, 42 insertions(+)
Show changes to contrib/subtree/t/t7900-subtree.sh +42 −0
diff --git a/contrib/subtree/t/t7900-subtree.sh
b/contrib/subtree/t/t7900-subtree.sh
index 80d3399..f1a24cf 100755
--- a/contrib/subtree/t/t7900-subtree.sh
+++ b/contrib/subtree/t/t7900-subtree.sh
@@ -465,4 +465,46 @@ test_expect_success 'verify one file change per commit' '
         ))
 '

+# return to mainline
+cd ../..
+
+# .gitsubtree
+test_expect_success 'added repository appears in .gitsubtree' '
+	git subtree add --prefix=copy0 sub1 &&
+	grep "^copy0 \. sub1$" .gitsubtree
+'
+
+test_expect_success 'change in subtree is pushed okay' '
+	(
+		cd copy0 &&
+		create new_file &&
+		git commit -m"Added new_file"
+	) &&
+	git ls-tree refs/heads/sub1 >output &&
+	! grep "new_file$" output &&
+	git subtree push --prefix=copy0 &&
+	git ls-tree refs/heads/sub1 >output &&
+	grep "new_file$" output
+'
+
+test_expect_success 'pull into subtree okay' '
+	git subtree add --prefix=copy1 sub1 &&
+	git subtree add --prefix=copy2 sub1 &&
+	(
+		cd copy1 &&
+		create new_file_in_copy1 &&
+		git commit -m"Added new_file_in_copy1"
+	) &&
+	git subtree push --prefix=copy1 &&
+	git subtree pull --prefix=copy2 >output &&
+	grep "^ create mode 100644 copy2/new_file_in_copy1$" output
+'
+
+test_expect_success 'replace outdated entry in .gitsubtree' '
+	echo "copy3 . sub2" >>.gitsubtree &&
+	git subtree add --prefix=copy3 sub1 &&
+	! grep "^copy3 . sub2$" .gitsubtree &&
+	grep "^copy3 . sub1$" .gitsubtree
+'
+
 test_done
-- 
1.8.2.rc0.16.g20a599e

← back to recent threads