diff options
Diffstat (limited to 'contrib/subtree/t/t7900-subtree.sh')
-rwxr-xr-x | contrib/subtree/t/t7900-subtree.sh | 56 |
1 files changed, 56 insertions, 0 deletions
diff --git a/contrib/subtree/t/t7900-subtree.sh b/contrib/subtree/t/t7900-subtree.sh index ce6861c22d..2561e25f43 100755 --- a/contrib/subtree/t/t7900-subtree.sh +++ b/contrib/subtree/t/t7900-subtree.sh @@ -324,6 +324,62 @@ test_expect_success 'split sub dir/ with --rejoin and --message' ' ) ' +test_expect_success 'split "sub dir"/ with --rejoin and --squash' ' + subtree_test_create_repo "$test_count" && + subtree_test_create_repo "$test_count/sub proj" && + test_create_commit "$test_count" main1 && + test_create_commit "$test_count/sub proj" sub1 && + ( + cd "$test_count" && + git fetch ./"sub proj" HEAD && + git subtree add --prefix="sub dir" --squash FETCH_HEAD + ) && + test_create_commit "$test_count" "sub dir"/main-sub1 && + test_create_commit "$test_count" main2 && + test_create_commit "$test_count/sub proj" sub2 && + test_create_commit "$test_count" "sub dir"/main-sub2 && + ( + cd "$test_count" && + git subtree pull --prefix="sub dir" --squash ./"sub proj" HEAD && + MAIN=$(git rev-parse --verify HEAD) && + SUB=$(git -C "sub proj" rev-parse --verify HEAD) && + + SPLIT=$(git subtree split --prefix="sub dir" --annotate="*" --rejoin --squash) && + + test_must_fail git merge-base --is-ancestor $SUB HEAD && + test_must_fail git merge-base --is-ancestor $SPLIT HEAD && + git rev-list HEAD ^$MAIN >commit-list && + test_line_count = 2 commit-list && + test "$(git rev-parse --verify HEAD:)" = "$(git rev-parse --verify $MAIN:)" && + test "$(git rev-parse --verify HEAD:"sub dir")" = "$(git rev-parse --verify $SPLIT:)" && + test "$(git rev-parse --verify HEAD^1)" = $MAIN && + test "$(git rev-parse --verify HEAD^2)" != $SPLIT && + test "$(git rev-parse --verify HEAD^2:)" = "$(git rev-parse --verify $SPLIT:)" && + test "$(last_commit_subject)" = "Split '\''sub dir/'\'' into commit '\''$SPLIT'\''" + ) +' + +test_expect_success 'split then pull "sub dir"/ with --rejoin and --squash' ' + # 1. "add" + subtree_test_create_repo "$test_count" && + subtree_test_create_repo "$test_count/sub proj" && + test_create_commit "$test_count" main1 && + test_create_commit "$test_count/sub proj" sub1 && + git -C "$test_count" subtree --prefix="sub dir" add --squash ./"sub proj" HEAD && + + # 2. commit from parent + test_create_commit "$test_count" "sub dir"/main-sub1 && + + # 3. "split --rejoin --squash" + git -C "$test_count" subtree --prefix="sub dir" split --rejoin --squash && + + # 4. "pull --squash" + test_create_commit "$test_count/sub proj" sub2 && + git -C "$test_count" subtree -d --prefix="sub dir" pull --squash ./"sub proj" HEAD && + + test_must_fail git merge-base HEAD FETCH_HEAD +' + test_expect_success 'split "sub dir"/ with --branch' ' subtree_test_create_repo "$test_count" && subtree_test_create_repo "$test_count/sub proj" && |