contrib/subtree: Add tests for subtree add
Add some tests to check various options to subtree add. These test various combinations of --message, --prefix and --squash. Signed-off-by: Techlive Zheng <techlivezheng@gmail.com> Signed-off-by: David A. Greene <greened@obbligato.org> Signed-off-by: Jeff King <peff@peff.net>
Techlive Zheng committed
Nov 12, 2015 at 20:32 UTC
c9924996c95cfcc7633448e7ee8b88f440ccbd2b
1 file changed
+19
contrib/subtree/t/t7900-subtree.sh
+19
@@ -127,12 +127,24 @@ test_expect_success 'no merge from non-existent subtree' '
127
test_must_fail git subtree merge --prefix="sub dir" FETCH_HEAD
128
'
129
130
+test_expect_success 'add subproj as subtree into sub dir/ with --prefix' '
131
+ git subtree add --prefix="sub dir" sub1 &&
132
+ check_equal "$(last_commit_message)" "Add '\''sub dir/'\'' from commit '\''$(git rev-parse sub1)'\''" &&
133
+ undo
134
+'
135
+
136
test_expect_success 'check if --message works for add' '
137
git subtree add --prefix="sub dir" --message="Added subproject" sub1 &&
138
check_equal ''"$(last_commit_message)"'' "Added subproject" &&
139
undo
140
'
141
142
+test_expect_success 'add subproj as subtree into sub dir/ with --prefix and --message' '
143
+ git subtree add --prefix="sub dir" --message="Added subproject" sub1 &&
144
+ check_equal "$(last_commit_message)" "Added subproject" &&
145
+ undo
146
+'
147
+
148
test_expect_success 'check if --message works as -m and --prefix as -P' '
149
git subtree add -P "sub dir" -m "Added subproject using git subtree" sub1 &&
150
check_equal ''"$(last_commit_message)"'' "Added subproject using git subtree" &&
@@ -145,6 +157,13 @@ test_expect_success 'check if --message works with squash too' '
157
undo
158
'
159
160
+test_expect_success 'add subproj as subtree into sub dir/ with --squash and --prefix and --message' '
161
+ git subtree add --prefix="sub dir" --message="Added subproject with squash" --squash sub1 &&
162
+ check_equal "$(last_commit_message)" "Added subproject with squash" &&
163
+ undo
164
+'
165
+
166
+# Maybe delete
167
test_expect_success 'add subproj to mainline' '
168
git subtree add --prefix="sub dir"/ FETCH_HEAD &&
169
check_equal ''"$(last_commit_message)"'' "Add '"'sub dir/'"' from commit '"'"'''"$(git rev-parse sub1)"'''"'"'"