@matheusbsbs / matheus-bagliano / commits / 31ca3ac30f
Fork 0

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>

Fabian Franz committed Feb 5, 2009 at 20:18 UTC 31ca3ac30fe3c2583881a74ef346911c8fba478f
2 files changed +22 -4
Documentation/git-submodule.txt
+6 -1
@@ -12,7 +12,7 @@ SYNOPSIS
12 'git submodule' [--quiet] add [-b branch] [--] <repository> <path>
13 'git submodule' [--quiet] status [--cached] [--] [<path>...]
14 'git submodule' [--quiet] init [--] [<path>...]
15 -'git submodule' [--quiet] update [--init] [--] [<path>...]
15 +'git submodule' [--quiet] update [--init] [-N|--no-fetch] [--] [<path>...]
16 'git submodule' [--quiet] summary [--summary-limit <n>] [commit] [--] [<path>...]
17 'git submodule' [--quiet] foreach <command>
18 'git submodule' [--quiet] sync [--] [<path>...]
@@ -172,6 +172,11 @@ OPTIONS
172 (the default). This limit only applies to modified submodules. The
173 size is always limited to 1 for added/deleted/typechanged submodules.
174
175 +-N::
176 +--no-fetch::
177 + This option is only valid for the update command.
178 + Don't fetch new objects from the remote site.
179 +
180 <path>...::
181 Paths to submodule(s). When specified this will restrict the command
182 to only operate on the submodules found at the specified paths.
git-submodule.sh
+16 -3
@@ -5,7 +5,7 @@
5 # Copyright (c) 2007 Lars Hjemli
6
7 USAGE="[--quiet] [--cached] \
8 -[add <repo> [-b branch] <path>]|[status|init|update [-i|--init]|summary [-n|--summary-limit <n>] [<commit>]] \
8 +[add <repo> [-b branch] <path>]|[status|init|update [-i|--init] [-N|--no-fetch]|summary [-n|--summary-limit <n>] [<commit>]] \
9 [--] [<path>...]|[foreach <command>]|[sync [--] [<path>...]]"
10 OPTIONS_SPEC=
11 . git-sh-setup
@@ -16,6 +16,7 @@ command=
16 branch=
17 quiet=
18 cached=
19 +nofetch=
20
21 #
22 # print stuff on stdout unless -q was specified
@@ -300,6 +301,10 @@ cmd_update()
301 shift
302 cmd_init "$@" || return
303 ;;
304 + -N|--no-fetch)
305 + shift
306 + nofetch=1
307 + ;;
308 --)
309 shift
310 break
@@ -345,8 +350,16 @@ cmd_update()
350 then
351 force="-f"
352 fi
348 - (unset GIT_DIR; cd "$path" && git-fetch &&
349 - git-checkout $force -q "$sha1") ||
353 +
354 + if test -z "$nofetch"
355 + then
356 + (unset GIT_DIR; cd "$path" &&
357 + git-fetch) ||
358 + die "Unable to fetch in submodule path '$path'"
359 + fi
360 +
361 + (unset GIT_DIR; cd "$path" &&
362 + git-checkout $force -q "$sha1") ||
363 die "Unable to checkout '$sha1' in submodule path '$path'"
364
365 say "Submodule path '$path': checked out '$sha1'"