diff options
author | Fabian Franz <git@fabian-franz.de> | 2009-02-05 20:18:32 -0200 |
---|---|---|
committer | Junio C Hamano <gitster@pobox.com> | 2009-02-07 00:44:49 -0800 |
commit | 31ca3ac30fe3c2583881a74ef346911c8fba478f (patch) | |
tree | 4b2289617ba6a9645d007084af65d46ffd45b69f /git-submodule.sh | |
parent | ba743d1b0ce0b44c797c0de06c9db2781e4d1fdd (diff) | |
download | git-31ca3ac30fe3c2583881a74ef346911c8fba478f.tar.gz |
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>
Diffstat (limited to 'git-submodule.sh')
-rwxr-xr-x | git-submodule.sh | 19 |
1 files changed, 16 insertions, 3 deletions
diff --git a/git-submodule.sh b/git-submodule.sh index 2f47e065fe..af8d10ca83 100755 --- a/git-submodule.sh +++ b/git-submodule.sh @@ -5,7 +5,7 @@ # Copyright (c) 2007 Lars Hjemli 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>...]]" OPTIONS_SPEC= . git-sh-setup @@ -16,6 +16,7 @@ command= branch= quiet= cached= +nofetch= # # print stuff on stdout unless -q was specified @@ -300,6 +301,10 @@ cmd_update() shift cmd_init "$@" || return ;; + -N|--no-fetch) + shift + nofetch=1 + ;; --) shift break @@ -345,8 +350,16 @@ cmd_update() then force="-f" 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'" say "Submodule path '$path': checked out '$sha1'" |