@matheusbsbs / matheus-bagliano / commits / be4d2c83b6
Fork 0

submodule update: add convenience option --init

When a submodule is not initialized and you do not want to change the defaults from .gitmodules anyway, you can now say $ git submodule update --init <name> When "update" is called without --init on an uninitialized submodule, a hint to use --init is printed. Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de> Signed-off-by: Junio C Hamano <gitster@pobox.com>

Johannes Schindelin committed May 16, 2008 at 11:23 UTC be4d2c83b68a96285cc05036add4d64d324e52d9
3 files changed +25 -2
Documentation/git-submodule.txt
+6 -1
@@ -11,7 +11,8 @@ SYNOPSIS
11 [verse]
12 'git-submodule' [--quiet] add [-b branch] [--] <repository> [<path>]
13 'git-submodule' [--quiet] status [--cached] [--] [<path>...]
14 -'git-submodule' [--quiet] [init|update] [--] [<path>...]
14 +'git-submodule' [--quiet] init [--] [<path>...]
15 +'git-submodule' [--quiet] update [--init] [--] [<path>...]
16 'git-submodule' [--quiet] summary [--summary-limit <n>] [commit] [--] [<path>...]
17
18
@@ -47,6 +48,10 @@ update::
48 Update the registered submodules, i.e. clone missing submodules and
49 checkout the commit specified in the index of the containing repository.
50 This will make the submodules HEAD be detached.
51 ++
52 +If the submodule is not yet initialized, and you just want to use the
53 +setting as stored in .gitmodules, you can automatically initialize the
54 +submodule with the --init option.
55
56 summary::
57 Show commit summary between the given commit (defaults to HEAD) and
git-submodule.sh
+6 -1
@@ -5,7 +5,7 @@
5 # Copyright (c) 2007 Lars Hjemli
6
7 USAGE="[--quiet] [--cached] \
8 -[add <repo> [-b branch]|status|init|update|summary [-n|--summary-limit <n>] [<commit>]] \
8 +[add <repo> [-b branch]|status|init|update [-i|--init]|summary [-n|--summary-limit <n>] [<commit>]] \
9 [--] [<path>...]"
10 OPTIONS_SPEC=
11 . git-sh-setup
@@ -271,6 +271,10 @@ cmd_update()
271 -q|--quiet)
272 quiet=1
273 ;;
274 + -i|--init)
275 + shift
276 + cmd_init "$@" || return
277 + ;;
278 --)
279 shift
280 break
@@ -296,6 +300,7 @@ cmd_update()
300 # path have been specified
301 test "$#" != "0" &&
302 say "Submodule path '$path' not initialized"
303 + say "Maybe you want to use 'update --init'?"
304 continue
305 fi
306
t/t7400-submodule-basic.sh
+13
@@ -196,4 +196,17 @@ test_expect_success 'apply submodule diff' '
196 test -z "$D"
197 '
198
199 +test_expect_success 'update --init' '
200 +
201 + mv init init2 &&
202 + git config -f .gitmodules submodule.example.url "$(pwd)/init2" &&
203 + git config --remove-section submodule.example
204 + git submodule update init > update.out &&
205 + grep "not initialized" update.out &&
206 + test ! -d init/.git &&
207 + git submodule update --init init &&
208 + test -d init/.git
209 +
210 +'
211 +
212 test_done