summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJunio C Hamano <gitster@pobox.com>2011-01-19 16:25:41 (GMT)
committerJunio C Hamano <gitster@pobox.com>2011-01-19 16:25:41 (GMT)
commitf326a06497c6609b109c35bab6d8187b02dad81f (patch)
tree05a09b6a6871ad436e4a5ab05a4d6b19565ddac1
parentd84f28093719ce499e701f646f20ee62755147ad (diff)
parent69e7236c6df44bfcde8913972b75a6ccb360d58f (diff)
downloadgit-f326a06497c6609b109c35bab6d8187b02dad81f.zip
git-f326a06497c6609b109c35bab6d8187b02dad81f.tar.gz
git-f326a06497c6609b109c35bab6d8187b02dad81f.tar.bz2
Merge branch 'jn/submodule-b-current' into maint
* jn/submodule-b-current: git submodule: Remove now obsolete tests before cloning a repo git submodule -b ... of current HEAD fails
-rwxr-xr-xgit-submodule.sh16
-rwxr-xr-xt/t7400-submodule-basic.sh28
2 files changed, 24 insertions, 20 deletions
diff --git a/git-submodule.sh b/git-submodule.sh
index c291eed..6af1f7e 100755
--- a/git-submodule.sh
+++ b/git-submodule.sh
@@ -93,20 +93,6 @@ module_clone()
url=$2
reference="$3"
- # If there already is a directory at the submodule path,
- # expect it to be empty (since that is the default checkout
- # action) and try to remove it.
- # Note: if $path is a symlink to a directory the test will
- # succeed but the rmdir will fail. We might want to fix this.
- if test -d "$path"
- then
- rmdir "$path" 2>/dev/null ||
- die "Directory '$path' exists, but is neither empty nor a git repository"
- fi
-
- test -e "$path" &&
- die "A file already exist at path '$path'"
-
if test -n "$reference"
then
git-clone "$reference" -n "$url" "$path"
@@ -241,7 +227,7 @@ cmd_add()
# ash fails to wordsplit ${branch:+-b "$branch"...}
case "$branch" in
'') git checkout -f -q ;;
- ?*) git checkout -f -q -b "$branch" "origin/$branch" ;;
+ ?*) git checkout -f -q -B "$branch" "origin/$branch" ;;
esac
) || die "Unable to checkout submodule '$path'"
fi
diff --git a/t/t7400-submodule-basic.sh b/t/t7400-submodule-basic.sh
index 782b0a3..2c49db9 100755
--- a/t/t7400-submodule-basic.sh
+++ b/t/t7400-submodule-basic.sh
@@ -421,11 +421,29 @@ test_expect_success 'add submodules without specifying an explicit path' '
git commit -m "repo commit 1"
) &&
git clone --bare repo/ bare.git &&
- cd addtest &&
- git submodule add "$submodurl/repo" &&
- git config -f .gitmodules submodule.repo.path repo &&
- git submodule add "$submodurl/bare.git" &&
- git config -f .gitmodules submodule.bare.path bare
+ (
+ cd addtest &&
+ git submodule add "$submodurl/repo" &&
+ git config -f .gitmodules submodule.repo.path repo &&
+ git submodule add "$submodurl/bare.git" &&
+ git config -f .gitmodules submodule.bare.path bare
+ )
+'
+
+test_expect_success 'add should fail when path is used by a file' '
+ (
+ cd addtest &&
+ touch file &&
+ test_must_fail git submodule add "$submodurl/repo" file
+ )
+'
+
+test_expect_success 'add should fail when path is used by an existing directory' '
+ (
+ cd addtest &&
+ mkdir empty-dir &&
+ test_must_fail git submodule add "$submodurl/repo" empty-dir
+ )
'
test_done