From ec54f0d9adb50baa14eae44a1b8c410f794d32de Mon Sep 17 00:00:00 2001 From: Win Treese Date: Fri, 5 Feb 2010 22:02:43 -0500 Subject: [PATCH] Make sure that exists when splitting. And test cases for that check, as well as for an error if no prefix is specified at all. --- git-subtree.sh | 5 +++++ test.sh | 8 ++++++++ 2 files changed, 13 insertions(+) diff --git a/git-subtree.sh b/git-subtree.sh index 009c0db9b..52d4c0aeb 100755 --- a/git-subtree.sh +++ b/git-subtree.sh @@ -105,6 +105,11 @@ esac if [ -z "$prefix" ]; then die "You must provide the --prefix option." fi + +if [ "$command" = "split" -a """"! -e "$prefix" ]; then + die "$prefix does not exist." +fi + dir="$(dirname "$prefix/.")" if [ "$command" != "pull" ]; then diff --git a/test.sh b/test.sh index cfe3a3c25..d0a2c86c2 100755 --- a/test.sh +++ b/test.sh @@ -140,6 +140,14 @@ git subtree merge --prefix=subdir FETCH_HEAD git branch pre-split check_equal "$(last_commit_message)" "Merge commit '$(git rev-parse sub2)' into mainline" +# Check that prefix argument is required for split (exits with warning and exit status = 1) +! result=$(git subtree split 2>&1) +check_equal "You must provide the --prefix option." "$result" + +# Check that the exists for a split. +! result=$(git subtree split --prefix=non-existent-directory 2>&1) +check_equal "non-existent-directory does not exist." "$result" + # check if --message works for split+rejoin spl1=$(git subtree split --annotate='*' --prefix subdir --onto FETCH_HEAD --message "Split & rejoin" --rejoin) echo "spl1={$spl1}" -- 2.26.2