Merge branch 'sb/submodule-deinit-all'
Correct faulty recommendation to use "git submodule deinit ." when de-initialising all submodules, which would result in a strange error message in a pathological corner case. * sb/submodule-deinit-all: submodule deinit: require '--all' instead of '.' for all submodules
This commit is contained in:
commit
21b2e60400
@ -13,7 +13,7 @@ SYNOPSIS
|
|||||||
[--reference <repository>] [--depth <depth>] [--] <repository> [<path>]
|
[--reference <repository>] [--depth <depth>] [--] <repository> [<path>]
|
||||||
'git submodule' [--quiet] status [--cached] [--recursive] [--] [<path>...]
|
'git submodule' [--quiet] status [--cached] [--recursive] [--] [<path>...]
|
||||||
'git submodule' [--quiet] init [--] [<path>...]
|
'git submodule' [--quiet] init [--] [<path>...]
|
||||||
'git submodule' [--quiet] deinit [-f|--force] [--] <path>...
|
'git submodule' [--quiet] deinit [-f|--force] (--all|[--] <path>...)
|
||||||
'git submodule' [--quiet] update [--init] [--remote] [-N|--no-fetch]
|
'git submodule' [--quiet] update [--init] [--remote] [-N|--no-fetch]
|
||||||
[-f|--force] [--rebase|--merge] [--reference <repository>]
|
[-f|--force] [--rebase|--merge] [--reference <repository>]
|
||||||
[--depth <depth>] [--recursive] [--jobs <n>] [--] [<path>...]
|
[--depth <depth>] [--recursive] [--jobs <n>] [--] [<path>...]
|
||||||
@ -140,12 +140,15 @@ deinit::
|
|||||||
tree. Further calls to `git submodule update`, `git submodule foreach`
|
tree. Further calls to `git submodule update`, `git submodule foreach`
|
||||||
and `git submodule sync` will skip any unregistered submodules until
|
and `git submodule sync` will skip any unregistered submodules until
|
||||||
they are initialized again, so use this command if you don't want to
|
they are initialized again, so use this command if you don't want to
|
||||||
have a local checkout of the submodule in your work tree anymore. If
|
have a local checkout of the submodule in your working tree anymore. If
|
||||||
you really want to remove a submodule from the repository and commit
|
you really want to remove a submodule from the repository and commit
|
||||||
that use linkgit:git-rm[1] instead.
|
that use linkgit:git-rm[1] instead.
|
||||||
+
|
+
|
||||||
If `--force` is specified, the submodule's work tree will be removed even if
|
When the command is run without pathspec, it errors out,
|
||||||
it contains local modifications.
|
instead of deinit-ing everything, to prevent mistakes.
|
||||||
|
+
|
||||||
|
If `--force` is specified, the submodule's working tree will
|
||||||
|
be removed even if it contains local modifications.
|
||||||
|
|
||||||
update::
|
update::
|
||||||
+
|
+
|
||||||
@ -247,6 +250,10 @@ OPTIONS
|
|||||||
--quiet::
|
--quiet::
|
||||||
Only print error messages.
|
Only print error messages.
|
||||||
|
|
||||||
|
--all::
|
||||||
|
This option is only valid for the deinit command. Unregister all
|
||||||
|
submodules in the working tree.
|
||||||
|
|
||||||
-b::
|
-b::
|
||||||
--branch::
|
--branch::
|
||||||
Branch of repository to add as submodule.
|
Branch of repository to add as submodule.
|
||||||
@ -257,8 +264,8 @@ OPTIONS
|
|||||||
--force::
|
--force::
|
||||||
This option is only valid for add, deinit and update commands.
|
This option is only valid for add, deinit and update commands.
|
||||||
When running add, allow adding an otherwise ignored submodule path.
|
When running add, allow adding an otherwise ignored submodule path.
|
||||||
When running deinit the submodule work trees will be removed even if
|
When running deinit the submodule working trees will be removed even
|
||||||
they contain local changes.
|
if they contain local changes.
|
||||||
When running update (only effective with the checkout procedure),
|
When running update (only effective with the checkout procedure),
|
||||||
throw away local changes in submodules when switching to a
|
throw away local changes in submodules when switching to a
|
||||||
different commit; and always run a checkout operation in the
|
different commit; and always run a checkout operation in the
|
||||||
|
@ -8,7 +8,7 @@ dashless=$(basename "$0" | sed -e 's/-/ /')
|
|||||||
USAGE="[--quiet] add [-b <branch>] [-f|--force] [--name <name>] [--reference <repository>] [--] <repository> [<path>]
|
USAGE="[--quiet] add [-b <branch>] [-f|--force] [--name <name>] [--reference <repository>] [--] <repository> [<path>]
|
||||||
or: $dashless [--quiet] status [--cached] [--recursive] [--] [<path>...]
|
or: $dashless [--quiet] status [--cached] [--recursive] [--] [<path>...]
|
||||||
or: $dashless [--quiet] init [--] [<path>...]
|
or: $dashless [--quiet] init [--] [<path>...]
|
||||||
or: $dashless [--quiet] deinit [-f|--force] [--] <path>...
|
or: $dashless [--quiet] deinit [-f|--force] (--all| [--] <path>...)
|
||||||
or: $dashless [--quiet] update [--init] [--remote] [-N|--no-fetch] [-f|--force] [--checkout|--merge|--rebase] [--reference <repository>] [--recursive] [--] [<path>...]
|
or: $dashless [--quiet] update [--init] [--remote] [-N|--no-fetch] [-f|--force] [--checkout|--merge|--rebase] [--reference <repository>] [--recursive] [--] [<path>...]
|
||||||
or: $dashless [--quiet] summary [--cached|--files] [--summary-limit <n>] [commit] [--] [<path>...]
|
or: $dashless [--quiet] summary [--cached|--files] [--summary-limit <n>] [commit] [--] [<path>...]
|
||||||
or: $dashless [--quiet] foreach [--recursive] <command>
|
or: $dashless [--quiet] foreach [--recursive] <command>
|
||||||
@ -415,6 +415,7 @@ cmd_init()
|
|||||||
cmd_deinit()
|
cmd_deinit()
|
||||||
{
|
{
|
||||||
# parse $args after "submodule ... deinit".
|
# parse $args after "submodule ... deinit".
|
||||||
|
deinit_all=
|
||||||
while test $# -ne 0
|
while test $# -ne 0
|
||||||
do
|
do
|
||||||
case "$1" in
|
case "$1" in
|
||||||
@ -424,6 +425,9 @@ cmd_deinit()
|
|||||||
-q|--quiet)
|
-q|--quiet)
|
||||||
GIT_QUIET=1
|
GIT_QUIET=1
|
||||||
;;
|
;;
|
||||||
|
--all)
|
||||||
|
deinit_all=t
|
||||||
|
;;
|
||||||
--)
|
--)
|
||||||
shift
|
shift
|
||||||
break
|
break
|
||||||
@ -438,9 +442,14 @@ cmd_deinit()
|
|||||||
shift
|
shift
|
||||||
done
|
done
|
||||||
|
|
||||||
if test $# = 0
|
if test -n "$deinit_all" && test "$#" -ne 0
|
||||||
then
|
then
|
||||||
die "$(eval_gettext "Use '.' if you really want to deinitialize all submodules")"
|
echo >&2 "$(eval_gettext "pathspec and --all are incompatible")"
|
||||||
|
usage
|
||||||
|
fi
|
||||||
|
if test $# = 0 && test -z "$deinit_all"
|
||||||
|
then
|
||||||
|
die "$(eval_gettext "Use '--all' if you really want to deinitialize all submodules")"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
git submodule--helper list --prefix "$wt_prefix" "$@" |
|
git submodule--helper list --prefix "$wt_prefix" "$@" |
|
||||||
|
@ -11,6 +11,10 @@ subcommands of git submodule.
|
|||||||
|
|
||||||
. ./test-lib.sh
|
. ./test-lib.sh
|
||||||
|
|
||||||
|
test_expect_success 'submodule deinit works on empty repository' '
|
||||||
|
git submodule deinit --all
|
||||||
|
'
|
||||||
|
|
||||||
test_expect_success 'setup - initial commit' '
|
test_expect_success 'setup - initial commit' '
|
||||||
>t &&
|
>t &&
|
||||||
git add t &&
|
git add t &&
|
||||||
@ -915,7 +919,8 @@ test_expect_success 'submodule deinit works on repository without submodules' '
|
|||||||
>file &&
|
>file &&
|
||||||
git add file &&
|
git add file &&
|
||||||
git commit -m "repo should not be empty" &&
|
git commit -m "repo should not be empty" &&
|
||||||
git submodule deinit .
|
git submodule deinit . &&
|
||||||
|
git submodule deinit --all
|
||||||
)
|
)
|
||||||
'
|
'
|
||||||
|
|
||||||
@ -957,6 +962,19 @@ test_expect_success 'submodule deinit . deinits all initialized submodules' '
|
|||||||
rmdir init example2
|
rmdir init example2
|
||||||
'
|
'
|
||||||
|
|
||||||
|
test_expect_success 'submodule deinit --all deinits all initialized submodules' '
|
||||||
|
git submodule update --init &&
|
||||||
|
git config submodule.example.foo bar &&
|
||||||
|
git config submodule.example2.frotz nitfol &&
|
||||||
|
test_must_fail git submodule deinit &&
|
||||||
|
git submodule deinit --all >actual &&
|
||||||
|
test -z "$(git config --get-regexp "submodule\.example\.")" &&
|
||||||
|
test -z "$(git config --get-regexp "submodule\.example2\.")" &&
|
||||||
|
test_i18ngrep "Cleared directory .init" actual &&
|
||||||
|
test_i18ngrep "Cleared directory .example2" actual &&
|
||||||
|
rmdir init example2
|
||||||
|
'
|
||||||
|
|
||||||
test_expect_success 'submodule deinit deinits a submodule when its work tree is missing or empty' '
|
test_expect_success 'submodule deinit deinits a submodule when its work tree is missing or empty' '
|
||||||
git submodule update --init &&
|
git submodule update --init &&
|
||||||
rm -rf init example2/* example2/.git &&
|
rm -rf init example2/* example2/.git &&
|
||||||
@ -1023,6 +1041,10 @@ test_expect_success 'submodule deinit is silent when used on an uninitialized su
|
|||||||
test_i18ngrep ! "Submodule .example. (.*) unregistered for path .init" actual &&
|
test_i18ngrep ! "Submodule .example. (.*) unregistered for path .init" actual &&
|
||||||
test_i18ngrep ! "Submodule .example2. (.*) unregistered for path .example2" actual &&
|
test_i18ngrep ! "Submodule .example2. (.*) unregistered for path .example2" actual &&
|
||||||
test_i18ngrep "Cleared directory .init" actual &&
|
test_i18ngrep "Cleared directory .init" actual &&
|
||||||
|
git submodule deinit --all >actual &&
|
||||||
|
test_i18ngrep ! "Submodule .example. (.*) unregistered for path .init" actual &&
|
||||||
|
test_i18ngrep ! "Submodule .example2. (.*) unregistered for path .example2" actual &&
|
||||||
|
test_i18ngrep "Cleared directory .init" actual &&
|
||||||
rmdir init example2
|
rmdir init example2
|
||||||
'
|
'
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user