Skip to content

Commit c992499

Browse files
weynhamzpeff
authored andcommitted
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 <[email protected]> Signed-off-by: David A. Greene <[email protected]> Signed-off-by: Jeff King <[email protected]>
1 parent a686701 commit c992499

File tree

1 file changed

+19
-0
lines changed

1 file changed

+19
-0
lines changed

contrib/subtree/t/t7900-subtree.sh

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -127,12 +127,24 @@ test_expect_success 'no merge from non-existent subtree' '
127127
test_must_fail git subtree merge --prefix="sub dir" FETCH_HEAD
128128
'
129129

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+
130136
test_expect_success 'check if --message works for add' '
131137
git subtree add --prefix="sub dir" --message="Added subproject" sub1 &&
132138
check_equal ''"$(last_commit_message)"'' "Added subproject" &&
133139
undo
134140
'
135141

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+
136148
test_expect_success 'check if --message works as -m and --prefix as -P' '
137149
git subtree add -P "sub dir" -m "Added subproject using git subtree" sub1 &&
138150
check_equal ''"$(last_commit_message)"'' "Added subproject using git subtree" &&
@@ -145,6 +157,13 @@ test_expect_success 'check if --message works with squash too' '
145157
undo
146158
'
147159

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
148167
test_expect_success 'add subproj to mainline' '
149168
git subtree add --prefix="sub dir"/ FETCH_HEAD &&
150169
check_equal ''"$(last_commit_message)"'' "Add '"'sub dir/'"' from commit '"'"'''"$(git rev-parse sub1)"'''"'"'"

0 commit comments

Comments
 (0)