fi
}
+check_not()
+{
+ echo
+ echo "check: NOT " "$@"
+ if "$@"; then
+ echo FAILED
+ exit 1
+ else
+ echo ok
+ return 0
+ fi
+}
+
check_equal()
{
echo
last_commit_message()
{
- git log --format=%s -1
+ git log --pretty=format:%s -1
}
rm -rf mainline subproj
git branch sub1 FETCH_HEAD
# check if --message works for add
+check_not git subtree merge --prefix=subdir sub1
+check_not git subtree pull --prefix=subdir ../subproj sub1
git subtree add --prefix=subdir --message="Added subproject" sub1
check_equal "$(last_commit_message)" "Added subproject"
undo
# Check that the <prefix> exists for a split.
! result=$(git subtree split --prefix=non-existent-directory 2>&1)
-check_equal "non-existent-directory does not exist." "$result"
+check_equal "'non-existent-directory' does not exist; use 'git subtree add'" \
+ "$result"
# check if --message works for split+rejoin
spl1=$(git subtree split --annotate='*' --prefix subdir --onto FETCH_HEAD --message "Split & rejoin" --rejoin)
# at this point, the new commit's parent should be sub3
# if it's not, something went wrong (the "newparent" of "master~" commit should have been sub3,
# but it wasn't, because it's cache was not set to itself)
-check_equal "$(git log --format=%P -1 mainsub4)" "$(git rev-parse sub3)"
+check_equal "$(git log --pretty=format:%P -1 mainsub4)" "$(git rev-parse sub3)"
+
+mkdir subdir2
+create subdir2/main-sub5
+git commit -m "main-sub5"
+git subtree split --prefix subdir2 --branch mainsub5
+# also test that we still can split out an entirely new subtree
+# if the parent of the first commit in the tree isn't empty,
+# then the new subtree has accidently been attached to something
+check_equal "$(git log --pretty=format:%P -1 mainsub5)" ""
# make sure no patch changes more than one file. The original set of commits