@matheusbsbs / matheus-bagliano / commits / ec54f0d9ad
Fork 0

Make sure that <prefix> exists when splitting.

And test cases for that check, as well as for an error if no prefix is specified at all.

Win Treese committed Feb 5, 2010 at 22:02 UTC ec54f0d9adb50baa14eae44a1b8c410f794d32de
2 files changed +13
git-subtree.sh
+5
@@ -105,6 +105,11 @@ esac
105 if [ -z "$prefix" ]; then
106 die "You must provide the --prefix option."
107 fi
108 +
109 +if [ "$command" = "split" -a """"! -e "$prefix" ]; then
110 + die "$prefix does not exist."
111 +fi
112 +
113 dir="$(dirname "$prefix/.")"
114
115 if [ "$command" != "pull" ]; then
test.sh
+8
@@ -140,6 +140,14 @@ git subtree merge --prefix=subdir FETCH_HEAD
140 git branch pre-split
141 check_equal "$(last_commit_message)" "Merge commit '$(git rev-parse sub2)' into mainline"
142
143 +# Check that prefix argument is required for split (exits with warning and exit status = 1)
144 +! result=$(git subtree split 2>&1)
145 +check_equal "You must provide the --prefix option." "$result"
146 +
147 +# Check that the <prefix> exists for a split.
148 +! result=$(git subtree split --prefix=non-existent-directory 2>&1)
149 +check_equal "non-existent-directory does not exist." "$result"
150 +
151 # check if --message works for split+rejoin
152 spl1=$(git subtree split --annotate='*' --prefix subdir --onto FETCH_HEAD --message "Split & rejoin" --rejoin)
153 echo "spl1={$spl1}"