{"thread":{"id":"48404","subject":"[PATCH v4 0/3] Add --progress and --dissociate to git submodule","startedAt":"2018-05-03T11:05:04Z","lastAt":"2018-05-17T02:48:49Z","messageCount":5,"participants":["Casey Fitzpatrick","Junio C Hamano"],"isPatch":true,"patchVersion":4,"patchTotal":3},"messages":[{"id":"346507","messageId":"20180503105346.1758-1-kcghost@gmail.com","threadId":"48404","inReplyTo":null,"subject":"[PATCH v4 0/3] Add --progress and --dissociate to git submodule","fromName":"Casey Fitzpatrick","fromEmail":"kcghost@gmail.com","sentAt":"2018-05-03T10:53:43Z","receivedAt":"2018-05-03T11:05:04Z","isPatch":true,"sender":{"key":"kcghost@gmail.com","avatar":"https://avatars.githubusercontent.com/u/7506642?v=4"},"body":"These patches add --progress and --dissociate options to git submodule.\n\nThe --progress option existed beforehand, but only for the update command and\nit was left undocumented.\n\nBoth add and update submodule commands supported --reference, but not its pair\noption --dissociate which allows for independent clones rather than depending\non the reference.\n\nThis is a resubmission with comments from Stefan Beller, Eric Sunshine, and\nJunio C Hamano addressed.\n\n\nCasey Fitzpatrick (3):\n  submodule: clean up subsititions in script\n  submodule: add --progress option to add command\n  submodule: add --dissociate option to add/update commands\n\n Documentation/git-submodule.txt | 17 ++++++++++++++++-\n builtin/submodule--helper.c     | 16 +++++++++++++---\n git-submodule.sh                | 21 ++++++++++++++++-----\n t/t7400-submodule-basic.sh      | 16 ++++++++++++++++\n t/t7408-submodule-reference.sh  | 17 +++++++++++++++++\n 5 files changed, 78 insertions(+), 9 deletions(-)\n\n-- \n2.17.0.1.ge0414f29c.dirty\n\n"},{"id":"346508","messageId":"20180503105346.1758-2-kcghost@gmail.com","threadId":"48404","inReplyTo":"20180503105346.1758-1-kcghost@gmail.com","subject":"[PATCH v4 1/3] submodule: clean up subsititions in script","fromName":"Casey Fitzpatrick","fromEmail":"kcghost@gmail.com","sentAt":"2018-05-03T10:53:44Z","receivedAt":"2018-05-03T11:05:06Z","isPatch":true,"sender":{"key":"kcghost@gmail.com","avatar":"https://avatars.githubusercontent.com/u/7506642?v=4"},"body":"'recommend_shallow' and 'jobs' variables do not need quotes. They only hold a\nsingle token value, and even if they were multi-token it is likely we would want\nthem split at IFS rather than pass a single string.\n\n'progress' is a boolean value. Treat it like the other boolean values in the\nscript by using a substitution.\n\nSigned-off-by: Casey Fitzpatrick <kcghost@gmail.com>\n---\n git-submodule.sh | 8 ++++----\n 1 file changed, 4 insertions(+), 4 deletions(-)\n\ndiff --git a/git-submodule.sh b/git-submodule.sh\nindex 24914963c..262547968 100755\n--- a/git-submodule.sh\n+++ b/git-submodule.sh\n@@ -465,7 +465,7 @@ cmd_update()\n \t\t\tGIT_QUIET=1\n \t\t\t;;\n \t\t--progress)\n-\t\t\tprogress=\"--progress\"\n+\t\t\tprogress=1\n \t\t\t;;\n \t\t-i|--init)\n \t\t\tinit=1\n@@ -542,14 +542,14 @@ cmd_update()\n \n \t{\n \tgit submodule--helper update-clone ${GIT_QUIET:+--quiet} \\\n-\t\t${progress:+\"$progress\"} \\\n+\t\t${progress:+\"--progress\"} \\\n \t\t${wt_prefix:+--prefix \"$wt_prefix\"} \\\n \t\t${prefix:+--recursive-prefix \"$prefix\"} \\\n \t\t${update:+--update \"$update\"} \\\n \t\t${reference:+\"$reference\"} \\\n \t\t${depth:+--depth \"$depth\"} \\\n-\t\t${recommend_shallow:+\"$recommend_shallow\"} \\\n-\t\t${jobs:+$jobs} \\\n+\t\t$recommend_shallow \\\n+\t\t$jobs \\\n \t\t\"$@\" || echo \"#unmatched\" $?\n \t} | {\n \terr=\n-- \n2.17.0.1.ge0414f29c.dirty\n\n"},{"id":"346509","messageId":"20180503105346.1758-3-kcghost@gmail.com","threadId":"48404","inReplyTo":"20180503105346.1758-1-kcghost@gmail.com","subject":"[PATCH v4 2/3] submodule: add --progress option to add command","fromName":"Casey Fitzpatrick","fromEmail":"kcghost@gmail.com","sentAt":"2018-05-03T10:53:45Z","receivedAt":"2018-05-03T11:05:09Z","isPatch":true,"sender":{"key":"kcghost@gmail.com","avatar":"https://avatars.githubusercontent.com/u/7506642?v=4"},"body":"The '--progress' was introduced in 72c5f88311d (clone: pass --progress\ndecision to recursive submodules, 2016-09-22) to fix the progress reporting\nof the clone command. Also add the progress option to the 'submodule add'\ncommand. The update command already supports the progress flag, but it\nis not documented.\n\nSigned-off-by: Casey Fitzpatrick <kcghost@gmail.com>\n---\n Documentation/git-submodule.txt |  7 +++++++\n git-submodule.sh                |  5 ++++-\n t/t7400-submodule-basic.sh      | 16 ++++++++++++++++\n 3 files changed, 27 insertions(+), 1 deletion(-)\n\ndiff --git a/Documentation/git-submodule.txt b/Documentation/git-submodule.txt\nindex 71c5618e8..d1ebe32e8 100644\n--- a/Documentation/git-submodule.txt\n+++ b/Documentation/git-submodule.txt\n@@ -239,6 +239,13 @@ OPTIONS\n --quiet::\n \tOnly print error messages.\n \n+--progress::\n+\tThis option is only valid for add and update commands.\n+\tProgress status is reported on the standard error stream\n+\tby default when it is attached to a terminal, unless -q\n+\tis specified. This flag forces progress status even if the\n+\tstandard error stream is not directed to a terminal.\n+\n --all::\n \tThis option is only valid for the deinit command. Unregister all\n \tsubmodules in the working tree.\ndiff --git a/git-submodule.sh b/git-submodule.sh\nindex 262547968..39c241a1d 100755\n--- a/git-submodule.sh\n+++ b/git-submodule.sh\n@@ -117,6 +117,9 @@ cmd_add()\n \t\t-q|--quiet)\n \t\t\tGIT_QUIET=1\n \t\t\t;;\n+\t\t--progress)\n+\t\t\tprogress=1\n+\t\t\t;;\n \t\t--reference)\n \t\t\tcase \"$2\" in '') usage ;; esac\n \t\t\treference_path=$2\n@@ -255,7 +258,7 @@ or you are unsure what this means choose another name with the '--name' option.\"\n \t\t\t\teval_gettextln \"Reactivating local git directory for submodule '\\$sm_name'.\"\n \t\t\tfi\n \t\tfi\n-\t\tgit submodule--helper clone ${GIT_QUIET:+--quiet} --prefix \"$wt_prefix\" --path \"$sm_path\" --name \"$sm_name\" --url \"$realrepo\" ${reference:+\"$reference\"} ${depth:+\"$depth\"} || exit\n+\t\tgit submodule--helper clone ${GIT_QUIET:+--quiet} ${progress:+\"--progress\"} --prefix \"$wt_prefix\" --path \"$sm_path\" --name \"$sm_name\" --url \"$realrepo\" ${reference:+\"$reference\"} ${depth:+\"$depth\"} || exit\n \t\t(\n \t\t\tsanitize_submodule_env\n \t\t\tcd \"$sm_path\" &&\ndiff --git a/t/t7400-submodule-basic.sh b/t/t7400-submodule-basic.sh\nindex a39e69a3e..b5b4922ab 100755\n--- a/t/t7400-submodule-basic.sh\n+++ b/t/t7400-submodule-basic.sh\n@@ -126,6 +126,22 @@ test_expect_success 'submodule add' '\n \ttest_cmp empty untracked\n '\n \n+test_create_repo parent &&\n+test_commit -C parent one\n+\n+test_expect_success 'redirected submodule add does not show progress' '\n+\tgit -C addtest submodule add \"file://$submodurl/parent\" submod-redirected \\\n+\t\t2>err &&\n+\t! grep % err &&\n+\ttest_i18ngrep ! \"Checking connectivity\" err\n+'\n+\n+test_expect_success 'redirected submodule add --progress does show progress' '\n+\tgit -C addtest submodule add --progress \"file://$submodurl/parent\" \\\n+\t\tsubmod-redirected-progress 2>err && \\\n+\tgrep % err\n+'\n+\n test_expect_success 'submodule add to .gitignored path fails' '\n \t(\n \t\tcd addtest-ignore &&\n-- \n2.17.0.1.ge0414f29c.dirty\n\n"},{"id":"346510","messageId":"20180503105346.1758-4-kcghost@gmail.com","threadId":"48404","inReplyTo":"20180503105346.1758-1-kcghost@gmail.com","subject":"[PATCH v4 3/3] submodule: add --dissociate option to add/update commands","fromName":"Casey Fitzpatrick","fromEmail":"kcghost@gmail.com","sentAt":"2018-05-03T10:53:46Z","receivedAt":"2018-05-03T11:05:12Z","isPatch":true,"sender":{"key":"kcghost@gmail.com","avatar":"https://avatars.githubusercontent.com/u/7506642?v=4"},"body":"Add --dissociate option to add and update commands, both clone helper commands\nthat already have the --reference option --dissociate pairs with.\n\nSigned-off-by: Casey Fitzpatrick <kcghost@gmail.com>\n---\n Documentation/git-submodule.txt | 10 +++++++++-\n builtin/submodule--helper.c     | 16 +++++++++++++---\n git-submodule.sh                | 10 +++++++++-\n t/t7408-submodule-reference.sh  | 17 +++++++++++++++++\n 4 files changed, 48 insertions(+), 5 deletions(-)\n\ndiff --git a/Documentation/git-submodule.txt b/Documentation/git-submodule.txt\nindex d1ebe32e8..a75b95043 100644\n--- a/Documentation/git-submodule.txt\n+++ b/Documentation/git-submodule.txt\n@@ -369,7 +369,15 @@ the submodule itself.\n \tthis option will be passed to the linkgit:git-clone[1] command.\n +\n *NOTE*: Do *not* use this option unless you have read the note\n-for linkgit:git-clone[1]'s `--reference` and `--shared` options carefully.\n+for linkgit:git-clone[1]'s `--reference`, `--shared`, and `--dissociate`\n+options carefully.\n+\n+--dissociate::\n+\tThis option is only valid for add and update commands.  These\n+\tcommands sometimes need to clone a remote repository. In this case,\n+\tthis option will be passed to the linkgit:git-clone[1] command.\n++\n+*NOTE*: see the NOTE for the `--reference` option.\n \n --recursive::\n \tThis option is only valid for foreach, update, status and sync commands.\ndiff --git a/builtin/submodule--helper.c b/builtin/submodule--helper.c\nindex 6ba8587b6..a85b30419 100644\n--- a/builtin/submodule--helper.c\n+++ b/builtin/submodule--helper.c\n@@ -1056,7 +1056,7 @@ static int module_deinit(int argc, const char **argv, const char *prefix)\n }\n \n static int clone_submodule(const char *path, const char *gitdir, const char *url,\n-\t\t\t   const char *depth, struct string_list *reference,\n+\t\t\t   const char *depth, struct string_list *reference, int dissociate,\n \t\t\t   int quiet, int progress)\n {\n \tstruct child_process cp = CHILD_PROCESS_INIT;\n@@ -1075,6 +1075,8 @@ static int clone_submodule(const char *path, const char *gitdir, const char *url\n \t\t\targv_array_pushl(&cp.args, \"--reference\",\n \t\t\t\t\t item->string, NULL);\n \t}\n+\tif (dissociate)\n+\t\targv_array_push(&cp.args, \"--dissociate\");\n \tif (gitdir && *gitdir)\n \t\targv_array_pushl(&cp.args, \"--separate-git-dir\", gitdir, NULL);\n \n@@ -1190,6 +1192,7 @@ static int module_clone(int argc, const char **argv, const char *prefix)\n \tchar *p, *path = NULL, *sm_gitdir;\n \tstruct strbuf sb = STRBUF_INIT;\n \tstruct string_list reference = STRING_LIST_INIT_NODUP;\n+\tint dissociate = 0;\n \tchar *sm_alternate = NULL, *error_strategy = NULL;\n \n \tstruct option module_clone_options[] = {\n@@ -1208,6 +1211,8 @@ static int module_clone(int argc, const char **argv, const char *prefix)\n \t\tOPT_STRING_LIST(0, \"reference\", &reference,\n \t\t\t   N_(\"repo\"),\n \t\t\t   N_(\"reference repository\")),\n+\t\tOPT_BOOL(0, \"dissociate\", &dissociate,\n+\t\t\t   N_(\"use --reference only while cloning\")),\n \t\tOPT_STRING(0, \"depth\", &depth,\n \t\t\t   N_(\"string\"),\n \t\t\t   N_(\"depth for shallow clones\")),\n@@ -1247,7 +1252,7 @@ static int module_clone(int argc, const char **argv, const char *prefix)\n \n \t\tprepare_possible_alternates(name, &reference);\n \n-\t\tif (clone_submodule(path, sm_gitdir, url, depth, &reference,\n+\t\tif (clone_submodule(path, sm_gitdir, url, depth, &reference, dissociate,\n \t\t\t\t    quiet, progress))\n \t\t\tdie(_(\"clone of '%s' into submodule path '%s' failed\"),\n \t\t\t    url, path);\n@@ -1300,6 +1305,7 @@ struct submodule_update_clone {\n \tint quiet;\n \tint recommend_shallow;\n \tstruct string_list references;\n+\tint dissociate;\n \tconst char *depth;\n \tconst char *recursive_prefix;\n \tconst char *prefix;\n@@ -1315,7 +1321,7 @@ struct submodule_update_clone {\n \tint failed_clones_nr, failed_clones_alloc;\n };\n #define SUBMODULE_UPDATE_CLONE_INIT {0, MODULE_LIST_INIT, 0, \\\n-\tSUBMODULE_UPDATE_STRATEGY_INIT, 0, 0, -1, STRING_LIST_INIT_DUP, \\\n+\tSUBMODULE_UPDATE_STRATEGY_INIT, 0, 0, -1, STRING_LIST_INIT_DUP, 0, \\\n \tNULL, NULL, NULL, \\\n \tSTRING_LIST_INIT_DUP, 0, NULL, 0, 0}\n \n@@ -1442,6 +1448,8 @@ static int prepare_to_clone_next_submodule(const struct cache_entry *ce,\n \t\tfor_each_string_list_item(item, &suc->references)\n \t\t\targv_array_pushl(&child->args, \"--reference\", item->string, NULL);\n \t}\n+\tif (suc->dissociate)\n+\t\targv_array_push(&child->args, \"--dissociate\");\n \tif (suc->depth)\n \t\targv_array_push(&child->args, suc->depth);\n \n@@ -1575,6 +1583,8 @@ static int update_clone(int argc, const char **argv, const char *prefix)\n \t\t\t   N_(\"rebase, merge, checkout or none\")),\n \t\tOPT_STRING_LIST(0, \"reference\", &suc.references, N_(\"repo\"),\n \t\t\t   N_(\"reference repository\")),\n+\t\tOPT_BOOL(0, \"dissociate\", &suc.dissociate,\n+\t\t\t   N_(\"use --reference only while cloning\")),\n \t\tOPT_STRING(0, \"depth\", &suc.depth, \"<depth>\",\n \t\t\t   N_(\"Create a shallow clone truncated to the \"\n \t\t\t      \"specified number of revisions\")),\ndiff --git a/git-submodule.sh b/git-submodule.sh\nindex 39c241a1d..1fddc098f 100755\n--- a/git-submodule.sh\n+++ b/git-submodule.sh\n@@ -42,6 +42,7 @@ prefix=\n custom_name=\n depth=\n progress=\n+dissociate=\n \n die_if_unmatched ()\n {\n@@ -128,6 +129,9 @@ cmd_add()\n \t\t--reference=*)\n \t\t\treference_path=\"${1#--reference=}\"\n \t\t\t;;\n+\t\t--dissociate)\n+\t\t\tdissociate=1\n+\t\t\t;;\n \t\t--name)\n \t\t\tcase \"$2\" in '') usage ;; esac\n \t\t\tcustom_name=$2\n@@ -258,7 +262,7 @@ or you are unsure what this means choose another name with the '--name' option.\"\n \t\t\t\teval_gettextln \"Reactivating local git directory for submodule '\\$sm_name'.\"\n \t\t\tfi\n \t\tfi\n-\t\tgit submodule--helper clone ${GIT_QUIET:+--quiet} ${progress:+\"--progress\"} --prefix \"$wt_prefix\" --path \"$sm_path\" --name \"$sm_name\" --url \"$realrepo\" ${reference:+\"$reference\"} ${depth:+\"$depth\"} || exit\n+\t\tgit submodule--helper clone ${GIT_QUIET:+--quiet} ${progress:+\"--progress\"} --prefix \"$wt_prefix\" --path \"$sm_path\" --name \"$sm_name\" --url \"$realrepo\" ${reference:+\"$reference\"} ${dissociate:+\"--dissociate\"} ${depth:+\"$depth\"} || exit\n \t\t(\n \t\t\tsanitize_submodule_env\n \t\t\tcd \"$sm_path\" &&\n@@ -493,6 +497,9 @@ cmd_update()\n \t\t--reference=*)\n \t\t\treference=\"$1\"\n \t\t\t;;\n+\t\t--dissociate)\n+\t\t\tdissociate=1\n+\t\t\t;;\n \t\t-m|--merge)\n \t\t\tupdate=\"merge\"\n \t\t\t;;\n@@ -550,6 +557,7 @@ cmd_update()\n \t\t${prefix:+--recursive-prefix \"$prefix\"} \\\n \t\t${update:+--update \"$update\"} \\\n \t\t${reference:+\"$reference\"} \\\n+\t\t${dissociate:+\"--dissociate\"} \\\n \t\t${depth:+--depth \"$depth\"} \\\n \t\t$recommend_shallow \\\n \t\t$jobs \\\ndiff --git a/t/t7408-submodule-reference.sh b/t/t7408-submodule-reference.sh\nindex e159fc503..82656747f 100755\n--- a/t/t7408-submodule-reference.sh\n+++ b/t/t7408-submodule-reference.sh\n@@ -59,6 +59,16 @@ test_expect_success 'submodule add --reference uses alternates' '\n \ttest_alternate_is_used super/.git/modules/sub/objects/info/alternates super/sub\n '\n \n+test_expect_success 'submodule add --reference with --dissociate doesnt use alternates' '\n+\t(\n+\t\tcd super &&\n+\t\tgit submodule add --reference ../B --dissociate \"file://$base_dir/A\" sub-dissociate &&\n+\t\tgit commit -m B-super-added &&\n+\t\tgit repack -ad\n+\t) &&\n+\ttest_path_is_missing super/.git/modules/sub-dissociate/objects/info/alternates\n+'\n+\n test_expect_success 'that reference gets used with add' '\n \t(\n \t\tcd super/sub &&\n@@ -82,6 +92,13 @@ test_expect_success 'updating superproject keeps alternates' '\n \ttest_alternate_is_used super-clone/.git/modules/sub/objects/info/alternates super-clone/sub\n '\n \n+test_expect_success 'updating superproject with --dissociate doesnt keep alternates' '\n+\ttest_when_finished \"rm -rf super-clone\" &&\n+\tgit clone super super-clone &&\n+\tgit -C super-clone submodule update --init --reference ../B --dissociate &&\n+\ttest_path_is_missing super-clone/.git/modules/sub/objects/info/alternates\n+'\n+\n test_expect_success 'submodules use alternates when cloning a superproject' '\n \ttest_when_finished \"rm -rf super-clone\" &&\n \tgit clone --reference super --recursive super super-clone &&\n-- \n2.17.0.1.ge0414f29c.dirty\n\n"},{"id":"347894","messageId":"xmqq7eo36lpw.fsf@gitster-ct.c.googlers.com","threadId":"48404","inReplyTo":"20180503105346.1758-1-kcghost@gmail.com","subject":"Re: [PATCH v4 0/3] Add --progress and --dissociate to git submodule","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2018-05-17T02:48:43Z","receivedAt":"2018-05-17T02:48:49Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Casey Fitzpatrick <kcghost@gmail.com> writes:\n\n> These patches add --progress and --dissociate options to git submodule.\n>\n> The --progress option existed beforehand, but only for the update command and\n> it was left undocumented.\n>\n> Both add and update submodule commands supported --reference, but not its pair\n> option --dissociate which allows for independent clones rather than depending\n> on the reference.\n\nThis round hasn't seen any further comment, and I think all the\npreviously raised issues have been resolved in this version, so\nI am tempted to merge it to 'next'.\n\nOne thing that I noticed is that \"git submodule -h\" does not give\nany hint about --dissociate even though it talks about --reference\nwith these patches applied, and I think it probably should [*1*].\n\nWe can make such an update as incremental patch on top of these, if\npeople cared enough about this, without a further reroll of these\nthree patches.\n\nThanks.\n\n\n[Footnote]\n\n*1* It's not like we must list each and every option available---it\nis perfectly fine to omit less common ones to keep the \"-h\" output\nmanageably short.  But I have a feeling that \"--reference\" and\n\"--dissociate\" should probably be at a similar level of importance,\nand if we list one we probably should show the other, too.\n\n\n\n\n"}]}