test_create_commit "$subtree_test_count/sub proj" sub1 &&
(
cd "$subtree_test_count" &&
- git fetch ./"sub proj" master &&
+ git fetch ./"sub proj" HEAD &&
test_must_fail git subtree merge --prefix="sub dir" FETCH_HEAD
)
'
test_create_commit "$subtree_test_count/sub proj" sub1 &&
(
cd "$subtree_test_count" &&
- git fetch ./"sub proj" master &&
- test_must_fail git subtree pull --prefix="sub dir" ./"sub proj" master
+ git fetch ./"sub proj" HEAD &&
+ test_must_fail git subtree pull --prefix="sub dir" ./"sub proj" HEAD
)'
next_test
test_create_commit "$subtree_test_count/sub proj" sub1 &&
(
cd "$subtree_test_count" &&
- git fetch ./"sub proj" master &&
+ git fetch ./"sub proj" HEAD &&
git subtree add --prefix="sub dir" FETCH_HEAD &&
check_equal "$(last_commit_message)" "Add '\''sub dir/'\'' from commit '\''$(git rev-parse FETCH_HEAD)'\''"
)
test_create_commit "$subtree_test_count/sub proj" sub1 &&
(
cd "$subtree_test_count" &&
- git fetch ./"sub proj" master &&
+ git fetch ./"sub proj" HEAD &&
git subtree add --prefix="sub dir" --message="Added subproject" FETCH_HEAD &&
check_equal "$(last_commit_message)" "Added subproject"
)
test_create_commit "$subtree_test_count/sub proj" sub1 &&
(
cd "$subtree_test_count" &&
- git fetch ./"sub proj" master &&
+ git fetch ./"sub proj" HEAD &&
git subtree add -P "sub dir" -m "Added subproject" FETCH_HEAD &&
check_equal "$(last_commit_message)" "Added subproject"
)
test_create_commit "$subtree_test_count/sub proj" sub1 &&
(
cd "$subtree_test_count" &&
- git fetch ./"sub proj" master &&
+ git fetch ./"sub proj" HEAD &&
git subtree add --prefix="sub dir" --message="Added subproject with squash" --squash FETCH_HEAD &&
check_equal "$(last_commit_message)" "Added subproject with squash"
)
test_create_commit "$subtree_test_count/sub proj" sub1 &&
(
cd "$subtree_test_count" &&
- git fetch ./"sub proj" master &&
+ git fetch ./"sub proj" HEAD &&
git subtree add --prefix="sub dir" FETCH_HEAD
) &&
test_create_commit "$subtree_test_count/sub proj" sub2 &&
(
cd "$subtree_test_count" &&
- git fetch ./"sub proj" master &&
+ git fetch ./"sub proj" HEAD &&
git subtree merge --prefix="sub dir" FETCH_HEAD &&
check_equal "$(last_commit_message)" "Merge commit '\''$(git rev-parse FETCH_HEAD)'\''"
)
test_create_commit "$subtree_test_count/sub proj" sub1 &&
(
cd "$subtree_test_count" &&
- git fetch ./"sub proj" master &&
+ git fetch ./"sub proj" HEAD &&
git subtree add --prefix="sub dir" FETCH_HEAD
) &&
test_create_commit "$subtree_test_count/sub proj" sub2 &&
(
cd "$subtree_test_count" &&
- git fetch ./"sub proj" master &&
+ git fetch ./"sub proj" HEAD &&
git subtree merge --prefix="sub dir" --message="Merged changes from subproject" FETCH_HEAD &&
check_equal "$(last_commit_message)" "Merged changes from subproject"
)
test_create_commit "$subtree_test_count/sub proj" sub1 &&
(
cd "$subtree_test_count" &&
- git fetch ./"sub proj" master &&
+ git fetch ./"sub proj" HEAD &&
git subtree add --prefix="sub dir" FETCH_HEAD
) &&
test_create_commit "$subtree_test_count/sub proj" sub2 &&
(
cd "$subtree_test_count" &&
- git fetch ./"sub proj" master &&
+ git fetch ./"sub proj" HEAD &&
git subtree merge --prefix="sub dir" --message="Merged changes from subproject using squash" --squash FETCH_HEAD &&
check_equal "$(last_commit_message)" "Merged changes from subproject using squash"
)
test_create_commit "$subtree_test_count/sub proj" sub1 &&
(
cd "$subtree_test_count" &&
- git fetch ./"sub proj" master &&
+ git fetch ./"sub proj" HEAD &&
git subtree add --prefix="sub dir" FETCH_HEAD &&
# this shouldn not actually do anything, since FETCH_HEAD
# is already a parent
test_create_commit "$test_count/subproj" sub1 &&
(
cd "$test_count" &&
- git fetch ./subproj master &&
+ git fetch ./subproj HEAD &&
git subtree add --prefix=subdir/ FETCH_HEAD
) &&
test_create_commit "$test_count/subproj" sub2 &&
(
cd "$test_count" &&
- git fetch ./subproj master &&
+ git fetch ./subproj HEAD &&
git subtree merge --prefix=subdir/ FETCH_HEAD &&
check_equal "$(last_commit_message)" "Merge commit '\''$(git rev-parse FETCH_HEAD)'\''"
)
test_create_commit "$subtree_test_count/sub proj" sub1 &&
(
cd "$subtree_test_count" &&
- git fetch ./"sub proj" master &&
+ git fetch ./"sub proj" HEAD &&
git subtree add --prefix="sub dir" FETCH_HEAD &&
echo "You must provide the --prefix option." > expected &&
test_must_fail git subtree split > actual 2>&1 &&
test_create_commit "$subtree_test_count/sub proj" sub1 &&
(
cd "$subtree_test_count" &&
- git fetch ./"sub proj" master &&
+ git fetch ./"sub proj" HEAD &&
git subtree add --prefix="sub dir" FETCH_HEAD &&
echo "'\''non-existent-directory'\'' does not exist; use '\''git subtree add'\''" > expected &&
test_must_fail git subtree split --prefix=non-existent-directory > actual 2>&1 &&
test_create_commit "$subtree_test_count/sub proj" sub1 &&
(
cd "$subtree_test_count" &&
- git fetch ./"sub proj" master &&
+ git fetch ./"sub proj" HEAD &&
git subtree add --prefix="sub dir" FETCH_HEAD
) &&
test_create_commit "$subtree_test_count" "sub dir"/main-sub1 &&
test_create_commit "$subtree_test_count" "sub dir"/main-sub2 &&
(
cd "$subtree_test_count" &&
- git fetch ./"sub proj" master &&
+ git fetch ./"sub proj" HEAD &&
git subtree merge --prefix="sub dir" FETCH_HEAD &&
split_hash=$(git subtree split --prefix="sub dir" --annotate="*") &&
git subtree split --prefix="sub dir" --annotate="*" --rejoin &&
test_create_commit "$subtree_test_count/sub proj" sub1 &&
(
cd "$subtree_test_count" &&
- git fetch ./"sub proj" master &&
+ git fetch ./"sub proj" HEAD &&
git subtree add --prefix="sub dir" FETCH_HEAD
) &&
test_create_commit "$subtree_test_count" "sub dir"/main-sub1 &&
test_create_commit "$subtree_test_count" "sub dir"/main-sub2 &&
(
cd "$subtree_test_count" &&
- git fetch ./"sub proj" master &&
+ git fetch ./"sub proj" HEAD &&
git subtree merge --prefix="sub dir" FETCH_HEAD &&
git subtree split --prefix="sub dir" --message="Split & rejoin" --annotate="*" --rejoin &&
check_equal "$(last_commit_message)" "Split & rejoin"
test_create_commit "$subtree_test_count/sub proj" sub1 &&
(
cd "$subtree_test_count" &&
- git fetch ./"sub proj" master &&
+ git fetch ./"sub proj" HEAD &&
git subtree add --prefix="sub dir" FETCH_HEAD
) &&
test_create_commit "$subtree_test_count" "sub dir"/main-sub1 &&
test_create_commit "$subtree_test_count" "sub dir"/main-sub2 &&
(
cd "$subtree_test_count" &&
- git fetch ./"sub proj" master &&
+ git fetch ./"sub proj" HEAD &&
git subtree merge --prefix="sub dir" FETCH_HEAD &&
split_hash=$(git subtree split --prefix="sub dir" --annotate="*") &&
git subtree split --prefix="sub dir" --annotate="*" --branch subproj-br &&
test_create_commit "$subtree_test_count/sub proj" sub1 &&
(
cd "$subtree_test_count" &&
- git fetch ./"sub proj" master &&
+ git fetch ./"sub proj" HEAD &&
git subtree add --prefix="sub dir" FETCH_HEAD
) &&
test_create_commit "$subtree_test_count" "sub dir"/main-sub1 &&
test_create_commit "$subtree_test_count" "sub dir"/main-sub2 &&
(
cd "$subtree_test_count" &&
- git fetch ./"sub proj" master &&
+ git fetch ./"sub proj" HEAD &&
git subtree merge --prefix="sub dir" FETCH_HEAD &&
split_hash=$(git subtree split --prefix="sub dir" --annotate="*") &&
git subtree split --prefix="sub dir" --annotate="*" --branch subproj-br &&
test_create_commit "$subtree_test_count/sub proj" sub1 &&
(
cd "$subtree_test_count" &&
- git fetch ./"sub proj" master &&
+ git fetch ./"sub proj" HEAD &&
git branch subproj-br FETCH_HEAD &&
git subtree add --prefix="sub dir" FETCH_HEAD
) &&
test_create_commit "$subtree_test_count" "sub dir"/main-sub2 &&
(
cd "$subtree_test_count" &&
- git fetch ./"sub proj" master &&
+ git fetch ./"sub proj" HEAD &&
git subtree merge --prefix="sub dir" FETCH_HEAD &&
split_hash=$(git subtree split --prefix="sub dir" --annotate="*") &&
git subtree split --prefix="sub dir" --annotate="*" --branch subproj-br &&
(
cd "$subtree_test_count" &&
git branch init HEAD &&
- git fetch ./"sub proj" master &&
+ git fetch ./"sub proj" HEAD &&
git subtree add --prefix="sub dir" FETCH_HEAD
) &&
test_create_commit "$subtree_test_count" "sub dir"/main-sub1 &&
test_create_commit "$subtree_test_count" "sub dir"/main-sub2 &&
(
cd "$subtree_test_count" &&
- git fetch ./"sub proj" master &&
+ git fetch ./"sub proj" HEAD &&
git subtree merge --prefix="sub dir" FETCH_HEAD &&
test_must_fail git subtree split --prefix="sub dir" --branch init
)
test_create_commit "$subtree_test_count/sub proj" sub1 &&
(
cd "$subtree_test_count" &&
- git fetch ./"sub proj" master &&
+ git fetch ./"sub proj" HEAD &&
git subtree add --prefix="sub dir" FETCH_HEAD
) &&
test_create_commit "$subtree_test_count" "sub dir"/main-sub1 &&
test_create_commit "$subtree_test_count" "sub dir"/main-sub2 &&
(
cd "$subtree_test_count" &&
- git fetch ./"sub proj" master &&
+ git fetch ./"sub proj" HEAD &&
git subtree merge --prefix="sub dir" FETCH_HEAD &&
git subtree split --prefix="sub dir" --annotate="*" --branch subproj-br --rejoin
) &&
test_create_commit "$subtree_test_count/sub proj" sub1 &&
(
cd "$subtree_test_count" &&
- git fetch ./"sub proj" master &&
+ git fetch ./"sub proj" HEAD &&
git subtree add --prefix="sub dir" FETCH_HEAD
) &&
test_create_commit "$subtree_test_count" "sub dir"/main-sub1 &&
test_create_commit "$subtree_test_count" "sub dir"/main-sub2 &&
(
cd "$subtree_test_count" &&
- git fetch ./"sub proj" master &&
+ git fetch ./"sub proj" HEAD &&
git subtree merge --prefix="sub dir" FETCH_HEAD &&
git subtree split --prefix="sub dir" --annotate="*" --branch subproj-br --rejoin
) &&
test_create_commit "$subtree_test_count/sub proj" sub1 &&
(
cd "$subtree_test_count" &&
- git fetch ./"sub proj" master &&
+ git fetch ./"sub proj" HEAD &&
git subtree add --prefix="sub dir" FETCH_HEAD
) &&
test_create_commit "$subtree_test_count" "sub dir"/main-sub1 &&
test_create_commit "$subtree_test_count" "sub dir"/main-sub2 &&
(
cd "$subtree_test_count" &&
- git fetch ./"sub proj" master &&
+ git fetch ./"sub proj" HEAD &&
git subtree merge --prefix="sub dir" FETCH_HEAD &&
git subtree split --prefix="sub dir" --annotate="*" --branch subproj-br --rejoin
) &&
) &&
(
cd "$subtree_test_count" &&
- git subtree pull --prefix="sub dir" ./"sub proj" master &&
+ git subtree pull --prefix="sub dir" ./"sub proj" HEAD &&
test_write_lines main1 main2 >chkm &&
test_write_lines main-sub1 main-sub2 main-sub3 main-sub4 >chkms &&
(
cd "$subtree_test_count" &&
git config log.date relative &&
- git fetch ./"sub proj" master &&
+ git fetch ./"sub proj" HEAD &&
git subtree add --prefix="sub dir" FETCH_HEAD
) &&
test_create_commit "$subtree_test_count" "sub dir"/main-sub1 &&
test_create_commit "$subtree_test_count" "sub dir"/main-sub2 &&
(
cd "$subtree_test_count" &&
- git fetch ./"sub proj" master &&
+ git fetch ./"sub proj" HEAD &&
git subtree merge --prefix="sub dir" FETCH_HEAD &&
git subtree split --prefix="sub dir" --annotate="*" --branch subproj-br --rejoin
) &&
) &&
(
cd "$subtree_test_count" &&
- git subtree pull --prefix="sub dir" ./"sub proj" master &&
+ git subtree pull --prefix="sub dir" ./"sub proj" HEAD &&
test_write_lines main1 main2 >chkm &&
test_write_lines sub1 sub2 sub3 sub4 >chks &&
test_create_commit "$subtree_test_count/sub proj" sub1 &&
(
cd "$subtree_test_count" &&
- git fetch ./"sub proj" master &&
+ git fetch ./"sub proj" HEAD &&
git subtree add --prefix="sub dir" FETCH_HEAD
) &&
test_create_commit "$subtree_test_count" "sub dir"/main-sub1 &&
test_create_commit "$subtree_test_count" "sub dir"/main-sub2 &&
(
cd "$subtree_test_count" &&
- git fetch ./"sub proj" master &&
+ git fetch ./"sub proj" HEAD &&
git subtree merge --prefix="sub dir" FETCH_HEAD &&
git subtree split --prefix="sub dir" --annotate="*" --branch subproj-br --rejoin
) &&
) &&
(
cd "$subtree_test_count" &&
- git subtree pull --prefix="sub dir" ./"sub proj" master &&
+ git subtree pull --prefix="sub dir" ./"sub proj" HEAD &&
check_equal "$(git log --pretty=format:"%s" HEAD^2 | grep -i split)" ""
)
'
test_create_commit "$subtree_test_count/sub proj" sub1 &&
(
cd "$subtree_test_count" &&
- git fetch ./"sub proj" master &&
+ git fetch ./"sub proj" HEAD &&
git subtree add --prefix="sub dir" FETCH_HEAD
) &&
test_create_commit "$subtree_test_count" "sub dir"/main-sub1 &&
test_create_commit "$subtree_test_count" "sub dir"/main-sub2 &&
(
cd "$subtree_test_count" &&
- git fetch ./"sub proj" master &&
+ git fetch ./"sub proj" HEAD &&
git subtree merge --prefix="sub dir" FETCH_HEAD &&
git subtree split --prefix="sub dir" --annotate="*" --branch subproj-br --rejoin
) &&
) &&
(
cd "$subtree_test_count" &&
- git subtree pull --prefix="sub dir" ./"sub proj" master &&
+ git subtree pull --prefix="sub dir" ./"sub proj" HEAD &&
# They are meaningless to subproj since one side of the merge refers to the mainline
check_equal "$(git log --pretty=format:"%s%n%b" HEAD^2 | grep "git-subtree.*:")" ""
test_create_commit "$subtree_test_count/sub proj" sub1 &&
(
cd "$subtree_test_count" &&
- git fetch ./"sub proj" master &&
+ git fetch ./"sub proj" HEAD &&
git subtree add --prefix="sub dir" FETCH_HEAD
) &&
test_create_commit "$subtree_test_count/sub proj" sub2 &&
(
cd "$subtree_test_count" &&
- git fetch ./"sub proj" master &&
+ git fetch ./"sub proj" HEAD &&
git branch subproj-ref FETCH_HEAD &&
git subtree merge --prefix="sub dir" FETCH_HEAD
) &&
git subtree split --prefix="sub dir" --branch subproj-br &&
# at this point, the new commit parent should be subproj-ref, if it is
- # not, something went wrong (the "newparent" of "master~" commit should
+ # not, something went wrong (the "newparent" of "HEAD~" commit should
# have been sub2, but it was not, because its cache was not set to
# itself)
check_equal "$(git log --pretty=format:%P -1 subproj-br)" "$(git rev-parse subproj-ref)"
test_create_commit "$subtree_test_count/sub proj" sub1 &&
(
cd "$subtree_test_count" &&
- git fetch ./"sub proj" master &&
+ git fetch ./"sub proj" HEAD &&
git subtree add --prefix="sub dir" FETCH_HEAD
) &&
test_create_commit "$subtree_test_count/sub proj" sub2 &&
(
cd "$subtree_test_count" &&
- git fetch ./"sub proj" master &&
+ git fetch ./"sub proj" HEAD &&
git subtree merge --prefix="sub dir" FETCH_HEAD
) &&
test_create_commit "$subtree_test_count" "sub dir"/main-sub1 &&
test_create_commit "$subtree_test_count/sub proj" sub1 &&
(
cd "$subtree_test_count" &&
- git fetch ./"sub proj" master &&
+ git fetch ./"sub proj" HEAD &&
git branch sub1 FETCH_HEAD &&
git subtree add --prefix="sub dir" sub1
) &&
test_create_commit "$subtree_test_count/sub proj" sub2 &&
(
cd "$subtree_test_count" &&
- git fetch ./"sub proj" master &&
+ git fetch ./"sub proj" HEAD &&
git subtree merge --prefix="sub dir" FETCH_HEAD
) &&
test_create_commit "$subtree_test_count" "sub dir"/main-sub1 &&
test_create_commit "$subtree_test_count/sub proj" sub1 &&
(
cd "$subtree_test_count" &&
- git fetch ./"sub proj" master &&
+ git fetch ./"sub proj" HEAD &&
git subtree add --prefix="sub dir" FETCH_HEAD
) &&
test_create_commit "$subtree_test_count" "sub dir"/main-sub1 &&
cd $subtree_test_count/"sub proj" &&
git branch sub-branch-1 &&
cd .. &&
- git fetch ./"sub proj" master &&
+ git fetch ./"sub proj" HEAD &&
git subtree merge --prefix="sub dir" FETCH_HEAD
) &&
test_create_commit "$subtree_test_count" "sub dir"/main-sub3 &&
next_test
test_expect_success 'subtree descendant check' '
subtree_test_create_repo "$subtree_test_count" &&
+ defaultBranch=$(sed "s,ref: refs/heads/,," "$subtree_test_count/.git/HEAD") &&
test_create_commit "$subtree_test_count" folder_subtree/a &&
(
cd "$subtree_test_count" &&
(
cd "$subtree_test_count" &&
git cherry-pick $cherry &&
- git checkout master &&
+ git checkout $defaultBranch &&
git merge -m "merge should be kept on subtree" branch &&
git branch no_subtree_work_branch
) &&
test_create_commit "$subtree_test_count" not_a_subtree_change &&
(
cd "$subtree_test_count" &&
- git checkout master &&
+ git checkout $defaultBranch &&
git merge -m "merge should be skipped on subtree" no_subtree_work_branch &&
- git subtree split --prefix folder_subtree/ --branch subtree_tip master &&
+ git subtree split --prefix folder_subtree/ --branch subtree_tip $defaultBranch &&
git subtree split --prefix folder_subtree/ --branch subtree_branch branch &&
check_equal $(git rev-list --count subtree_tip..subtree_branch) 0
)