From: Avery Pennarun Date: Mon, 8 Feb 2010 20:00:42 +0000 (-0500) Subject: Improve checking for existence of the --prefix directory. X-Git-Url: https://git.tokkee.org/?a=commitdiff_plain;h=77ba30585213ee8e2be21841ba38786fd5bb26a5;p=git.git Improve checking for existence of the --prefix directory. For add, the prefix must *not* already exist. For all the other commands, it *must* already exist. --- diff --git a/git-subtree.sh b/git-subtree.sh index 52d4c0aeb..e76b45c2d 100755 --- a/git-subtree.sh +++ b/git-subtree.sh @@ -106,9 +106,12 @@ 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 +case "$command" in + add) [ -e "$prefix" ] && + die "prefix '$prefix' already exists." ;; + *) [ -e "$prefix" ] || + die "'$prefix' does not exist; use 'git subtree add'" ;; +esac dir="$(dirname "$prefix/.")" diff --git a/test.sh b/test.sh index d0a2c86c2..1446cfeed 100755 --- a/test.sh +++ b/test.sh @@ -21,6 +21,19 @@ check() fi } +check_not() +{ + echo + echo "check: NOT " "$@" + if "$@"; then + echo FAILED + exit 1 + else + echo ok + return 0 + fi +} + check_equal() { echo @@ -94,6 +107,8 @@ git fetch ../subproj sub1 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