* [PATCH] submodule update: add convenience option --init
@ 2008-05-16 10:23 Johannes Schindelin
2008-05-16 10:55 ` Imran M Yousuf
0 siblings, 1 reply; 2+ messages in thread
From: Johannes Schindelin @ 2008-05-16 10:23 UTC (permalink / raw)
To: git, gitster
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>
---
I know this is relatively late in the cycle, but this patch was
done on users' requests, and I think it is unobtrusive, yet
helpful.
Documentation/git-submodule.txt | 7 ++++++-
git-submodule.sh | 7 ++++++-
t/t7400-submodule-basic.sh | 13 +++++++++++++
3 files changed, 25 insertions(+), 2 deletions(-)
diff --git a/Documentation/git-submodule.txt b/Documentation/git-submodule.txt
index 6ffd896..0668f29 100644
--- a/Documentation/git-submodule.txt
+++ b/Documentation/git-submodule.txt
@@ -11,7 +11,8 @@ SYNOPSIS
[verse]
'git-submodule' [--quiet] add [-b branch] [--] <repository> [<path>]
'git-submodule' [--quiet] status [--cached] [--] [<path>...]
-'git-submodule' [--quiet] [init|update] [--] [<path>...]
+'git-submodule' [--quiet] init [--] [<path>...]
+'git-submodule' [--quiet] update [--init] [--] [<path>...]
'git-submodule' [--quiet] summary [--summary-limit <n>] [commit] [--] [<path>...]
@@ -47,6 +48,10 @@ update::
Update the registered submodules, i.e. clone missing submodules and
checkout the commit specified in the index of the containing repository.
This will make the submodules HEAD be detached.
++
+If the submodule is not yet initialized, and you just want to use the
+setting as stored in .gitmodules, you can automatically initialize the
+submodule with the --init option.
summary::
Show commit summary between the given commit (defaults to HEAD) and
diff --git a/git-submodule.sh b/git-submodule.sh
index 67f7a28..e681818 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]|status|init|update|summary [-n|--summary-limit <n>] [<commit>]] \
+[add <repo> [-b branch]|status|init|update [-i|--init]|summary [-n|--summary-limit <n>] [<commit>]] \
[--] [<path>...]"
OPTIONS_SPEC=
. git-sh-setup
@@ -272,6 +272,10 @@ cmd_update()
-q|--quiet)
quiet=1
;;
+ -i|--init)
+ shift
+ cmd_init "$@" || return
+ ;;
--)
shift
break
@@ -297,6 +301,7 @@ cmd_update()
# path have been specified
test "$#" != "0" &&
say "Submodule path '$path' not initialized"
+ say "Maybe you want to use 'update --init'?"
continue
fi
diff --git a/t/t7400-submodule-basic.sh b/t/t7400-submodule-basic.sh
index 2ef85a8..6c7b902 100755
--- a/t/t7400-submodule-basic.sh
+++ b/t/t7400-submodule-basic.sh
@@ -196,4 +196,17 @@ test_expect_success 'apply submodule diff' '
test -z "$D"
'
+test_expect_success 'update --init' '
+
+ mv init init2 &&
+ git config -f .gitmodules submodule.example.url "$(pwd)/init2" &&
+ git config --remove-section submodule.example
+ git submodule update init > update.out &&
+ grep "not initialized" update.out &&
+ test ! -d init/.git &&
+ git submodule update --init init &&
+ test -d init/.git
+
+'
+
test_done
--
1.5.5.1.425.g5f464.dirty
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH] submodule update: add convenience option --init
2008-05-16 10:23 [PATCH] submodule update: add convenience option --init Johannes Schindelin
@ 2008-05-16 10:55 ` Imran M Yousuf
0 siblings, 0 replies; 2+ messages in thread
From: Imran M Yousuf @ 2008-05-16 10:55 UTC (permalink / raw)
To: Johannes Schindelin; +Cc: git, gitster
On Fri, May 16, 2008 at 4:23 PM, Johannes Schindelin
<Johannes.Schindelin@gmx.de> wrote:
>
> 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>
This seems to be quite useful, I always wanted to do it in one step.
>
> 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>
> ---
>
> I know this is relatively late in the cycle, but this patch was
> done on users' requests, and I think it is unobtrusive, yet
> helpful.
>
> Documentation/git-submodule.txt | 7 ++++++-
> git-submodule.sh | 7 ++++++-
> t/t7400-submodule-basic.sh | 13 +++++++++++++
> 3 files changed, 25 insertions(+), 2 deletions(-)
>
> diff --git a/Documentation/git-submodule.txt b/Documentation/git-submodule.txt
> index 6ffd896..0668f29 100644
> --- a/Documentation/git-submodule.txt
> +++ b/Documentation/git-submodule.txt
> @@ -11,7 +11,8 @@ SYNOPSIS
> [verse]
> 'git-submodule' [--quiet] add [-b branch] [--] <repository> [<path>]
> 'git-submodule' [--quiet] status [--cached] [--] [<path>...]
> -'git-submodule' [--quiet] [init|update] [--] [<path>...]
> +'git-submodule' [--quiet] init [--] [<path>...]
> +'git-submodule' [--quiet] update [--init] [--] [<path>...]
> 'git-submodule' [--quiet] summary [--summary-limit <n>] [commit] [--] [<path>...]
>
>
> @@ -47,6 +48,10 @@ update::
> Update the registered submodules, i.e. clone missing submodules and
> checkout the commit specified in the index of the containing repository.
> This will make the submodules HEAD be detached.
> ++
> +If the submodule is not yet initialized, and you just want to use the
> +setting as stored in .gitmodules, you can automatically initialize the
> +submodule with the --init option.
>
> summary::
> Show commit summary between the given commit (defaults to HEAD) and
> diff --git a/git-submodule.sh b/git-submodule.sh
> index 67f7a28..e681818 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]|status|init|update|summary [-n|--summary-limit <n>] [<commit>]] \
> +[add <repo> [-b branch]|status|init|update [-i|--init]|summary [-n|--summary-limit <n>] [<commit>]] \
> [--] [<path>...]"
> OPTIONS_SPEC=
> . git-sh-setup
> @@ -272,6 +272,10 @@ cmd_update()
> -q|--quiet)
> quiet=1
> ;;
> + -i|--init)
> + shift
> + cmd_init "$@" || return
> + ;;
> --)
> shift
> break
> @@ -297,6 +301,7 @@ cmd_update()
> # path have been specified
> test "$#" != "0" &&
> say "Submodule path '$path' not initialized"
> + say "Maybe you want to use 'update --init'?"
> continue
> fi
>
> diff --git a/t/t7400-submodule-basic.sh b/t/t7400-submodule-basic.sh
> index 2ef85a8..6c7b902 100755
> --- a/t/t7400-submodule-basic.sh
> +++ b/t/t7400-submodule-basic.sh
> @@ -196,4 +196,17 @@ test_expect_success 'apply submodule diff' '
> test -z "$D"
> '
>
> +test_expect_success 'update --init' '
> +
> + mv init init2 &&
> + git config -f .gitmodules submodule.example.url "$(pwd)/init2" &&
> + git config --remove-section submodule.example
> + git submodule update init > update.out &&
> + grep "not initialized" update.out &&
> + test ! -d init/.git &&
> + git submodule update --init init &&
> + test -d init/.git
> +
> +'
> +
> test_done
> --
> 1.5.5.1.425.g5f464.dirty
>
> --
> To unsubscribe from this list: send the line "unsubscribe git" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at http://vger.kernel.org/majordomo-info.html
>
--
Imran M Yousuf
Entrepreneur & Software Engineer
Smart IT Engineering
Dhaka, Bangladesh
Email: imran@smartitengineering.com
Mobile: +880-1711402557
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2008-05-16 10:56 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2008-05-16 10:23 [PATCH] submodule update: add convenience option --init Johannes Schindelin
2008-05-16 10:55 ` Imran M Yousuf
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).