submodule: add --no-fetch parameter to update command
git submodule update --no-fetch makes it possible to use git submodule update in complete offline mode by not fetching new revisions. This does make sense in the following setup: * There is an unstable and a stable branch in the super/master repository. * The submodules might be at different revisions in the branches. * You are at some place without internet connection ;) With this patch it is now possible to change branches and update the submodules to be at the recorded revision without online access. Another advantage is that with -N the update operation is faster, because fetch is checking for new updates even if there was no fetch/pull on the super/master repository since the last update. Signed-off-by: Fabian Franz <git@fabian-franz.de> Signed-off-by: Junio C Hamano <gitster@pobox.com>
This commit is contained in:
parent
ba743d1b0c
commit
31ca3ac30f
@ -12,7 +12,7 @@ SYNOPSIS
|
|||||||
'git submodule' [--quiet] add [-b branch] [--] <repository> <path>
|
'git submodule' [--quiet] add [-b branch] [--] <repository> <path>
|
||||||
'git submodule' [--quiet] status [--cached] [--] [<path>...]
|
'git submodule' [--quiet] status [--cached] [--] [<path>...]
|
||||||
'git submodule' [--quiet] init [--] [<path>...]
|
'git submodule' [--quiet] init [--] [<path>...]
|
||||||
'git submodule' [--quiet] update [--init] [--] [<path>...]
|
'git submodule' [--quiet] update [--init] [-N|--no-fetch] [--] [<path>...]
|
||||||
'git submodule' [--quiet] summary [--summary-limit <n>] [commit] [--] [<path>...]
|
'git submodule' [--quiet] summary [--summary-limit <n>] [commit] [--] [<path>...]
|
||||||
'git submodule' [--quiet] foreach <command>
|
'git submodule' [--quiet] foreach <command>
|
||||||
'git submodule' [--quiet] sync [--] [<path>...]
|
'git submodule' [--quiet] sync [--] [<path>...]
|
||||||
@ -172,6 +172,11 @@ OPTIONS
|
|||||||
(the default). This limit only applies to modified submodules. The
|
(the default). This limit only applies to modified submodules. The
|
||||||
size is always limited to 1 for added/deleted/typechanged submodules.
|
size is always limited to 1 for added/deleted/typechanged submodules.
|
||||||
|
|
||||||
|
-N::
|
||||||
|
--no-fetch::
|
||||||
|
This option is only valid for the update command.
|
||||||
|
Don't fetch new objects from the remote site.
|
||||||
|
|
||||||
<path>...::
|
<path>...::
|
||||||
Paths to submodule(s). When specified this will restrict the command
|
Paths to submodule(s). When specified this will restrict the command
|
||||||
to only operate on the submodules found at the specified paths.
|
to only operate on the submodules found at the specified paths.
|
||||||
|
@ -5,7 +5,7 @@
|
|||||||
# Copyright (c) 2007 Lars Hjemli
|
# Copyright (c) 2007 Lars Hjemli
|
||||||
|
|
||||||
USAGE="[--quiet] [--cached] \
|
USAGE="[--quiet] [--cached] \
|
||||||
[add <repo> [-b branch] <path>]|[status|init|update [-i|--init]|summary [-n|--summary-limit <n>] [<commit>]] \
|
[add <repo> [-b branch] <path>]|[status|init|update [-i|--init] [-N|--no-fetch]|summary [-n|--summary-limit <n>] [<commit>]] \
|
||||||
[--] [<path>...]|[foreach <command>]|[sync [--] [<path>...]]"
|
[--] [<path>...]|[foreach <command>]|[sync [--] [<path>...]]"
|
||||||
OPTIONS_SPEC=
|
OPTIONS_SPEC=
|
||||||
. git-sh-setup
|
. git-sh-setup
|
||||||
@ -16,6 +16,7 @@ command=
|
|||||||
branch=
|
branch=
|
||||||
quiet=
|
quiet=
|
||||||
cached=
|
cached=
|
||||||
|
nofetch=
|
||||||
|
|
||||||
#
|
#
|
||||||
# print stuff on stdout unless -q was specified
|
# print stuff on stdout unless -q was specified
|
||||||
@ -300,6 +301,10 @@ cmd_update()
|
|||||||
shift
|
shift
|
||||||
cmd_init "$@" || return
|
cmd_init "$@" || return
|
||||||
;;
|
;;
|
||||||
|
-N|--no-fetch)
|
||||||
|
shift
|
||||||
|
nofetch=1
|
||||||
|
;;
|
||||||
--)
|
--)
|
||||||
shift
|
shift
|
||||||
break
|
break
|
||||||
@ -345,8 +350,16 @@ cmd_update()
|
|||||||
then
|
then
|
||||||
force="-f"
|
force="-f"
|
||||||
fi
|
fi
|
||||||
(unset GIT_DIR; cd "$path" && git-fetch &&
|
|
||||||
git-checkout $force -q "$sha1") ||
|
if test -z "$nofetch"
|
||||||
|
then
|
||||||
|
(unset GIT_DIR; cd "$path" &&
|
||||||
|
git-fetch) ||
|
||||||
|
die "Unable to fetch in submodule path '$path'"
|
||||||
|
fi
|
||||||
|
|
||||||
|
(unset GIT_DIR; cd "$path" &&
|
||||||
|
git-checkout $force -q "$sha1") ||
|
||||||
die "Unable to checkout '$sha1' in submodule path '$path'"
|
die "Unable to checkout '$sha1' in submodule path '$path'"
|
||||||
|
|
||||||
say "Submodule path '$path': checked out '$sha1'"
|
say "Submodule path '$path': checked out '$sha1'"
|
||||||
|
Loading…
Reference in New Issue
Block a user