File tree Expand file tree Collapse file tree 3 files changed +28
-3
lines changed Expand file tree Collapse file tree 3 files changed +28
-3
lines changed Original file line number Diff line number Diff line change @@ -10,7 +10,7 @@ SYNOPSIS
10
10
--------
11
11
[verse]
12
12
'git submodule' [--quiet] add [-b branch]
13
- [--reference <repository>] [--] <repository> <path>
13
+ [--reference <repository>] [--] <repository> [ <path>]
14
14
'git submodule' [--quiet] status [--cached] [--recursive] [--] [<path>...]
15
15
'git submodule' [--quiet] init [--] [<path>...]
16
16
'git submodule' [--quiet] update [--init] [-N|--no-fetch] [--rebase]
69
69
to the changeset to be committed next to the current
70
70
project: the current project is termed the "superproject".
71
71
+
72
- This requires two arguments: <repository> and <path>.
72
+ This requires at least one argument: <repository>. The optional
73
+ argument <path> is the relative location for the cloned submodule
74
+ to exist in the superproject. If <path> is not given, the
75
+ "humanish" part of the source repository is used ("repo" for
76
+ "/path/to/repo.git" and "foo" for "host.xz:foo/.git").
73
77
+
74
78
<repository> is the URL of the new submodule's origin repository.
75
79
This may be either an absolute URL, or (if it begins with ./
Original file line number Diff line number Diff line change 5
5
# Copyright (c) 2007 Lars Hjemli
6
6
7
7
dashless=$( basename " $0 " | sed -e ' s/-/ /' )
8
- USAGE=" [--quiet] add [-b branch] [--reference <repository>] [--] <repository> <path>
8
+ USAGE=" [--quiet] add [-b branch] [--reference <repository>] [--] <repository> [ <path>]
9
9
or: $dashless [--quiet] status [--cached] [--recursive] [--] [<path>...]
10
10
or: $dashless [--quiet] init [--] [<path>...]
11
11
or: $dashless [--quiet] update [--init] [-N|--no-fetch] [--rebase] [--reference <repository>] [--merge] [--recursive] [--] [<path>...]
@@ -160,6 +160,11 @@ cmd_add()
160
160
repo=$1
161
161
path=$2
162
162
163
+ if test -z " $path " ; then
164
+ path=$( echo " $repo " |
165
+ sed -e ' s|/$||' -e ' s|:*/*\.git$||' -e ' s|.*[/:]||g' )
166
+ fi
167
+
163
168
if test -z " $repo " -o -z " $path " ; then
164
169
usage
165
170
fi
Original file line number Diff line number Diff line change @@ -306,4 +306,20 @@ test_expect_success 'submodule <invalid-path> warns' '
306
306
307
307
'
308
308
309
+ test_expect_success ' add submodules without specifying an explicit path' '
310
+ mkdir repo &&
311
+ cd repo &&
312
+ git init &&
313
+ echo r >r &&
314
+ git add r &&
315
+ git commit -m "repo commit 1" &&
316
+ cd .. &&
317
+ git clone --bare repo/ bare.git &&
318
+ cd addtest &&
319
+ git submodule add "$submodurl/repo" &&
320
+ git config -f .gitmodules submodule.repo.path repo &&
321
+ git submodule add "$submodurl/bare.git" &&
322
+ git config -f .gitmodules submodule.bare.path bare
323
+ '
324
+
309
325
test_done
You can’t perform that action at this time.
0 commit comments