Andrew's git
/
gitweb.git
/ diff
summary
|
log
|
commit
| diff |
tree
commit
grep
author
committer
pickaxe
?
re
Make sure that <prefix> exists when splitting.
author
Win Treese
<treese@acm.org>
Sat, 6 Feb 2010 03:02:43 +0000
(22:02 -0500)
committer
Avery Pennarun
<apenwarr@gmail.com>
Sat, 6 Feb 2010 20:06:45 +0000
(15:06 -0500)
And test cases for that check, as well as for an error if no prefix is
specified at all.
git-subtree.sh
patch
|
blob
|
history
test.sh
patch
|
blob
|
history
raw
|
patch
|
inline
| side by side (parent:
349a70d
)
diff --git
a/git-subtree.sh
b/git-subtree.sh
index 009c0db9bc3c92607d942f5fe858eeee0603b039..52d4c0aeb135d0e760516e38640d11229c66ca42 100755
(executable)
--- 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 [ -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
dir="$(dirname "$prefix/.")"
if [ "$command" != "pull" ]; then
diff --git
a/test.sh
b/test.sh
index cfe3a3c2585ea67a432e7e90b0ed131499270846..d0a2c86c243ae6e68b4c6cb76f60d61339be859c 100755
(executable)
--- 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"
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 <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 if --message works for split+rejoin
spl1=$(git subtree split --annotate='*' --prefix subdir --onto FETCH_HEAD --message "Split & rejoin" --rejoin)
echo "spl1={$spl1}"
# check if --message works for split+rejoin
spl1=$(git subtree split --annotate='*' --prefix subdir --onto FETCH_HEAD --message "Split & rejoin" --rejoin)
echo "spl1={$spl1}"