{"thread":{"id":"13543","subject":"[PATCH] submodule update: add convenience option --init","startedAt":"2008-05-16T10:23:03Z","lastAt":"2008-05-16T10:55:56Z","messageCount":2,"participants":["Johannes Schindelin","Imran M Yousuf"],"isPatch":true,"patchVersion":1,"patchTotal":null},"messages":[{"id":"77109","messageId":"alpine.DEB.1.00.0805161122110.30431@racer","threadId":"13543","inReplyTo":null,"subject":"[PATCH] submodule update: add convenience option --init","fromName":"Johannes Schindelin","fromEmail":"johannes.schindelin@gmx.de","sentAt":"2008-05-16T10:23:03Z","receivedAt":"2008-05-16T10:23:03Z","isPatch":true,"sender":{"key":"johannes.schindelin@gmx.de","avatar":"https://avatars.githubusercontent.com/u/127790?v=4"},"body":"\nWhen a submodule is not initialized and you do not want to change the\ndefaults from .gitmodules anyway, you can now say\n\n\t$ git submodule update --init <name>\n\nWhen \"update\" is called without --init on an uninitialized submodule,\na hint to use --init is printed.\n\nSigned-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>\n---\n\n\tI know this is relatively late in the cycle, but this patch was \n\tdone on users' requests, and I think it is unobtrusive, yet \n\thelpful.\n\n Documentation/git-submodule.txt |    7 ++++++-\n git-submodule.sh                |    7 ++++++-\n t/t7400-submodule-basic.sh      |   13 +++++++++++++\n 3 files changed, 25 insertions(+), 2 deletions(-)\n\ndiff --git a/Documentation/git-submodule.txt b/Documentation/git-submodule.txt\nindex 6ffd896..0668f29 100644\n--- a/Documentation/git-submodule.txt\n+++ b/Documentation/git-submodule.txt\n@@ -11,7 +11,8 @@ SYNOPSIS\n [verse]\n 'git-submodule' [--quiet] add [-b branch] [--] <repository> [<path>]\n 'git-submodule' [--quiet] status [--cached] [--] [<path>...]\n-'git-submodule' [--quiet] [init|update] [--] [<path>...]\n+'git-submodule' [--quiet] init [--] [<path>...]\n+'git-submodule' [--quiet] update [--init] [--] [<path>...]\n 'git-submodule' [--quiet] summary [--summary-limit <n>] [commit] [--] [<path>...]\n \n \n@@ -47,6 +48,10 @@ update::\n \tUpdate the registered submodules, i.e. clone missing submodules and\n \tcheckout the commit specified in the index of the containing repository.\n \tThis will make the submodules HEAD be detached.\n++\n+If the submodule is not yet initialized, and you just want to use the\n+setting as stored in .gitmodules, you can automatically initialize the\n+submodule with the --init option.\n \n summary::\n \tShow commit summary between the given commit (defaults to HEAD) and\ndiff --git a/git-submodule.sh b/git-submodule.sh\nindex 67f7a28..e681818 100755\n--- a/git-submodule.sh\n+++ b/git-submodule.sh\n@@ -5,7 +5,7 @@\n # Copyright (c) 2007 Lars Hjemli\n \n USAGE=\"[--quiet] [--cached] \\\n-[add <repo> [-b branch]|status|init|update|summary [-n|--summary-limit <n>] [<commit>]] \\\n+[add <repo> [-b branch]|status|init|update [-i|--init]|summary [-n|--summary-limit <n>] [<commit>]] \\\n [--] [<path>...]\"\n OPTIONS_SPEC=\n . git-sh-setup\n@@ -272,6 +272,10 @@ cmd_update()\n \t\t-q|--quiet)\n \t\t\tquiet=1\n \t\t\t;;\n+\t\t-i|--init)\n+\t\t\tshift\n+\t\t\tcmd_init \"$@\" || return\n+\t\t\t;;\n \t\t--)\n \t\t\tshift\n \t\t\tbreak\n@@ -297,6 +301,7 @@ cmd_update()\n \t\t\t# path have been specified\n \t\t\ttest \"$#\" != \"0\" &&\n \t\t\tsay \"Submodule path '$path' not initialized\"\n+\t\t\tsay \"Maybe you want to use 'update --init'?\"\n \t\t\tcontinue\n \t\tfi\n \ndiff --git a/t/t7400-submodule-basic.sh b/t/t7400-submodule-basic.sh\nindex 2ef85a8..6c7b902 100755\n--- a/t/t7400-submodule-basic.sh\n+++ b/t/t7400-submodule-basic.sh\n@@ -196,4 +196,17 @@ test_expect_success 'apply submodule diff' '\n \ttest -z \"$D\"\n '\n \n+test_expect_success 'update --init' '\n+\n+\tmv init init2 &&\n+\tgit config -f .gitmodules submodule.example.url \"$(pwd)/init2\" &&\n+\tgit config --remove-section submodule.example\n+\tgit submodule update init > update.out &&\n+\tgrep \"not initialized\" update.out &&\n+\ttest ! -d init/.git &&\n+\tgit submodule update --init init &&\n+\ttest -d init/.git\n+\n+'\n+\n test_done\n-- \n1.5.5.1.425.g5f464.dirty\n"},{"id":"77114","messageId":"7bfdc29a0805160355x4120a425qaa947dd75bf60303@mail.gmail.com","threadId":"13543","inReplyTo":"alpine.DEB.1.00.0805161122110.30431@racer","subject":"Re: [PATCH] submodule update: add convenience option --init","fromName":"Imran M Yousuf","fromEmail":"imyousuf@gmail.com","sentAt":"2008-05-16T10:55:56Z","receivedAt":"2008-05-16T10:55:56Z","isPatch":true,"sender":{"key":"imyousuf@gmail.com","avatar":"https://gravatar.com/avatar/fda3c870262849d03c7b9c4d288842e128d6d80769fa7bc2d22731b7597928be?d=mp&s=160"},"body":"On Fri, May 16, 2008 at 4:23 PM, Johannes Schindelin\n<Johannes.Schindelin@gmx.de> wrote:\n>\n>  When a submodule is not initialized and you do not want to change the\n>  defaults from .gitmodules anyway, you can now say\n>\n>         $ git submodule update --init <name>\n\nThis seems to be quite useful, I always wanted to do it in one step.\n\n>\n>  When \"update\" is called without --init on an uninitialized submodule,\n>  a hint to use --init is printed.\n>\n>  Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>\n>  ---\n>\n>         I know this is relatively late in the cycle, but this patch was\n>         done on users' requests, and I think it is unobtrusive, yet\n>         helpful.\n>\n>   Documentation/git-submodule.txt |    7 ++++++-\n>   git-submodule.sh                |    7 ++++++-\n>   t/t7400-submodule-basic.sh      |   13 +++++++++++++\n>   3 files changed, 25 insertions(+), 2 deletions(-)\n>\n>  diff --git a/Documentation/git-submodule.txt b/Documentation/git-submodule.txt\n>  index 6ffd896..0668f29 100644\n>  --- a/Documentation/git-submodule.txt\n>  +++ b/Documentation/git-submodule.txt\n>  @@ -11,7 +11,8 @@ SYNOPSIS\n>   [verse]\n>   'git-submodule' [--quiet] add [-b branch] [--] <repository> [<path>]\n>   'git-submodule' [--quiet] status [--cached] [--] [<path>...]\n>  -'git-submodule' [--quiet] [init|update] [--] [<path>...]\n>  +'git-submodule' [--quiet] init [--] [<path>...]\n>  +'git-submodule' [--quiet] update [--init] [--] [<path>...]\n>   'git-submodule' [--quiet] summary [--summary-limit <n>] [commit] [--] [<path>...]\n>\n>\n>  @@ -47,6 +48,10 @@ update::\n>         Update the registered submodules, i.e. clone missing submodules and\n>         checkout the commit specified in the index of the containing repository.\n>         This will make the submodules HEAD be detached.\n>  ++\n>  +If the submodule is not yet initialized, and you just want to use the\n>  +setting as stored in .gitmodules, you can automatically initialize the\n>  +submodule with the --init option.\n>\n>   summary::\n>         Show commit summary between the given commit (defaults to HEAD) and\n>  diff --git a/git-submodule.sh b/git-submodule.sh\n>  index 67f7a28..e681818 100755\n>  --- a/git-submodule.sh\n>  +++ b/git-submodule.sh\n>  @@ -5,7 +5,7 @@\n>   # Copyright (c) 2007 Lars Hjemli\n>\n>   USAGE=\"[--quiet] [--cached] \\\n>  -[add <repo> [-b branch]|status|init|update|summary [-n|--summary-limit <n>] [<commit>]] \\\n>  +[add <repo> [-b branch]|status|init|update [-i|--init]|summary [-n|--summary-limit <n>] [<commit>]] \\\n>   [--] [<path>...]\"\n>   OPTIONS_SPEC=\n>   . git-sh-setup\n>  @@ -272,6 +272,10 @@ cmd_update()\n>                 -q|--quiet)\n>                         quiet=1\n>                         ;;\n>  +               -i|--init)\n>  +                       shift\n>  +                       cmd_init \"$@\" || return\n>  +                       ;;\n>                 --)\n>                         shift\n>                         break\n>  @@ -297,6 +301,7 @@ cmd_update()\n>                         # path have been specified\n>                         test \"$#\" != \"0\" &&\n>                         say \"Submodule path '$path' not initialized\"\n>  +                       say \"Maybe you want to use 'update --init'?\"\n>                         continue\n>                 fi\n>\n>  diff --git a/t/t7400-submodule-basic.sh b/t/t7400-submodule-basic.sh\n>  index 2ef85a8..6c7b902 100755\n>  --- a/t/t7400-submodule-basic.sh\n>  +++ b/t/t7400-submodule-basic.sh\n>  @@ -196,4 +196,17 @@ test_expect_success 'apply submodule diff' '\n>         test -z \"$D\"\n>   '\n>\n>  +test_expect_success 'update --init' '\n>  +\n>  +       mv init init2 &&\n>  +       git config -f .gitmodules submodule.example.url \"$(pwd)/init2\" &&\n>  +       git config --remove-section submodule.example\n>  +       git submodule update init > update.out &&\n>  +       grep \"not initialized\" update.out &&\n>  +       test ! -d init/.git &&\n>  +       git submodule update --init init &&\n>  +       test -d init/.git\n>  +\n>  +'\n>  +\n>   test_done\n>  --\n>  1.5.5.1.425.g5f464.dirty\n>\n>  --\n>  To unsubscribe from this list: send the line \"unsubscribe git\" in\n>  the body of a message to majordomo@vger.kernel.org\n>  More majordomo info at  http://vger.kernel.org/majordomo-info.html\n>\n\n\n\n-- \nImran M Yousuf\nEntrepreneur & Software Engineer\nSmart IT Engineering\nDhaka, Bangladesh\nEmail: imran@smartitengineering.com\nMobile: +880-1711402557\n"}]}