git submodule: Remove now obsolete tests before cloning a repo
Since 55892d23 "git clone" itself checks that the destination path is not a file but an empty directory if it exists, so there is no need anymore for module_clone() to check that too. Two tests have been added to test the behavior of "git submodule add" when path is a file or a directory (A subshell had to be added to the former last test to stay in the right directory). Signed-off-by: Jens Lehmann <Jens.Lehmann@web.de> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Jens Lehmann committed
Dec 5, 2010 at 00:27 UTC
69e7236c6df44bfcde8913972b75a6ccb360d58f
2 files changed
+23
-19
git-submodule.sh
-14
@@ -93,20 +93,6 @@ module_clone()
93
url=$2
94
reference="$3"
95
96
- # If there already is a directory at the submodule path,
97
- # expect it to be empty (since that is the default checkout
98
- # action) and try to remove it.
99
- # Note: if $path is a symlink to a directory the test will
100
- # succeed but the rmdir will fail. We might want to fix this.
101
- if test -d "$path"
102
- then
103
- rmdir "$path" 2>/dev/null ||
104
- die "Directory '$path' exists, but is neither empty nor a git repository"
105
- fi
106
-
107
- test -e "$path" &&
108
- die "A file already exist at path '$path'"
109
-
96
if test -n "$reference"
97
then
98
git-clone "$reference" -n "$url" "$path"
t/t7400-submodule-basic.sh
+23
-5
@@ -421,11 +421,29 @@ test_expect_success 'add submodules without specifying an explicit path' '
421
git commit -m "repo commit 1"
422
) &&
423
git clone --bare repo/ bare.git &&
424
- cd addtest &&
425
- git submodule add "$submodurl/repo" &&
426
- git config -f .gitmodules submodule.repo.path repo &&
427
- git submodule add "$submodurl/bare.git" &&
428
- git config -f .gitmodules submodule.bare.path bare
424
+ (
425
+ cd addtest &&
426
+ git submodule add "$submodurl/repo" &&
427
+ git config -f .gitmodules submodule.repo.path repo &&
428
+ git submodule add "$submodurl/bare.git" &&
429
+ git config -f .gitmodules submodule.bare.path bare
430
+ )
431
+'
432
+
433
+test_expect_success 'add should fail when path is used by a file' '
434
+ (
435
+ cd addtest &&
436
+ touch file &&
437
+ test_must_fail git submodule add "$submodurl/repo" file
438
+ )
439
+'
440
+
441
+test_expect_success 'add should fail when path is used by an existing directory' '
442
+ (
443
+ cd addtest &&
444
+ mkdir empty-dir &&
445
+ test_must_fail git submodule add "$submodurl/repo" empty-dir
446
+ )
447
'
448
449
test_done