File tree Expand file tree Collapse file tree 2 files changed +24
-20
lines changed Expand file tree Collapse file tree 2 files changed +24
-20
lines changed Original file line number Diff line number Diff line change @@ -93,20 +93,6 @@ module_clone()
93
93
url=$2
94
94
reference=" $3 "
95
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
-
110
96
if test -n " $reference "
111
97
then
112
98
git-clone " $reference " -n " $url " " $path "
@@ -241,7 +227,7 @@ cmd_add()
241
227
# ash fails to wordsplit ${branch:+-b "$branch"...}
242
228
case " $branch " in
243
229
' ' ) git checkout -f -q ;;
244
- ?* ) git checkout -f -q -b " $branch " " origin/$branch " ;;
230
+ ?* ) git checkout -f -q -B " $branch " " origin/$branch " ;;
245
231
esac
246
232
) || die " Unable to checkout submodule '$path '"
247
233
fi
Original file line number Diff line number Diff line change @@ -421,11 +421,29 @@ test_expect_success 'add submodules without specifying an explicit path' '
421
421
git commit -m "repo commit 1"
422
422
) &&
423
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
+ )
429
447
'
430
448
431
449
test_done
You can’t perform that action at this time.
0 commit comments