{"thread":{"id":"57979","subject":"[PATCH 1/8] submodule update: remove intermediate parsing","startedAt":"2022-06-10T00:26:30Z","lastAt":"2022-06-28T16:54:55Z","messageCount":90,"participants":["Glen Choo via GitGitGadget","Ævar Arnfjörð Bjarmason","Glen Choo"],"isPatch":true,"patchVersion":1,"patchTotal":8},"messages":[{"id":"456972","messageId":"0eec4debd0498b22a2279e53f3b9548ae3d673da.1654820781.git.gitgitgadget@gmail.com","threadId":"57979","inReplyTo":"pull.1275.git.git.1654820781.gitgitgadget@gmail.com","subject":"[PATCH 1/8] submodule update: remove intermediate parsing","fromName":"Glen Choo via GitGitGadget","fromEmail":"gitgitgadget@gmail.com","sentAt":"2022-06-10T00:26:14Z","receivedAt":"2022-06-10T00:26:30Z","isPatch":true,"sender":{"key":"glencbz@gmail.com","avatar":"https://avatars.githubusercontent.com/u/58092771?v=4"},"body":"From: Glen Choo <chooglen@google.com>\n\nWhen the cmd_*() functions in git-submodule.sh parse options, they\nsometimes set an intermediate variable to \"1\", check if the variable is\nset, and if so, pass a string option to \"git submodule--helper\".\n\nIn many cases, this parsing and unparsing is unnecessary because the\n\"git submodule--helper\" command already understands the literal options\npassed to \"git submodule\", e.g. when we see \"--init\", we don't need to\nset \"init=1\" only to pass \"${init:+--init}\" again.\n\nIn cmd_update(), remove unnecessary \"${variable+option}\" expressions by\npassing the literal option to \"git submodule--helper update\". Do this by\nappending the string option into a catch-all \"opts\", so that the\nintermediate variable becomes unused and can be removed.\n\nThis slightly changes the options we pass to \"git submodule--helper\nupdate\" because we now pass every instance of the option instead of only\npassing it once. This is probably a good thing though, because it's more\nconsistent to handle this in C instead of custom shell code.\n\nSigned-off-by: Glen Choo <chooglen@google.com>\n---\n git-submodule.sh | 25 ++++++++-----------------\n 1 file changed, 8 insertions(+), 17 deletions(-)\n\ndiff --git a/git-submodule.sh b/git-submodule.sh\nindex fd0b4a2c947..f4679e0db80 100755\n--- a/git-submodule.sh\n+++ b/git-submodule.sh\n@@ -38,17 +38,13 @@ recursive=\n init=\n require_init=\n files=\n-remote=\n-nofetch=\n update=\n prefix=\n custom_name=\n depth=\n progress=\n dissociate=\n-single_branch=\n jobs=\n-recommend_shallow=\n filter=\n \n isnumber()\n@@ -246,6 +242,7 @@ cmd_deinit()\n #\n cmd_update()\n {\n+\topts=\n \t# parse $args after \"submodule ... update\".\n \twhile test $# -ne 0\n \tdo\n@@ -257,7 +254,7 @@ cmd_update()\n \t\t\tunset GIT_QUIET\n \t\t\t;;\n \t\t--progress)\n-\t\t\tprogress=1\n+\t\t\topts=\"$opts $1\"\n \t\t\t;;\n \t\t-i|--init)\n \t\t\tinit=1\n@@ -267,13 +264,13 @@ cmd_update()\n \t\t\trequire_init=1\n \t\t\t;;\n \t\t--remote)\n-\t\t\tremote=1\n+\t\t\topts=\"$opts $1\"\n \t\t\t;;\n \t\t-N|--no-fetch)\n-\t\t\tnofetch=1\n+\t\t\topts=\"$opts $1\"\n \t\t\t;;\n \t\t-f|--force)\n-\t\t\tforce=$1\n+\t\t\topts=\"$opts $1\"\n \t\t\t;;\n \t\t-r|--rebase)\n \t\t\tupdate=\"rebase\"\n@@ -287,13 +284,13 @@ cmd_update()\n \t\t\treference=\"$1\"\n \t\t\t;;\n \t\t--dissociate)\n-\t\t\tdissociate=1\n+\t\t\topts=\"$opts $1\"\n \t\t\t;;\n \t\t-m|--merge)\n \t\t\tupdate=\"merge\"\n \t\t\t;;\n \t\t--recursive)\n-\t\t\trecursive=1\n+\t\t\topts=\"$opts $1\"\n \t\t\t;;\n \t\t--checkout)\n \t\t\tupdate=\"checkout\"\n@@ -350,24 +347,18 @@ cmd_update()\n \n \tgit ${wt_prefix:+-C \"$wt_prefix\"} submodule--helper update \\\n \t\t${GIT_QUIET:+--quiet} \\\n-\t\t${force:+--force} \\\n-\t\t${progress:+\"--progress\"} \\\n-\t\t${remote:+--remote} \\\n-\t\t${recursive:+--recursive} \\\n \t\t${init:+--init} \\\n-\t\t${nofetch:+--no-fetch} \\\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${dissociate:+\"--dissociate\"} \\\n \t\t${depth:+\"$depth\"} \\\n \t\t${require_init:+--require-init} \\\n-\t\t${dissociate:+\"--dissociate\"} \\\n \t\t$single_branch \\\n \t\t$recommend_shallow \\\n \t\t$jobs \\\n \t\t$filter \\\n+\t\t$opts \\\n \t\t-- \\\n \t\t\"$@\"\n }\n-- \ngitgitgadget\n\n"},{"id":"456973","messageId":"pull.1275.git.git.1654820781.gitgitgadget@gmail.com","threadId":"57979","inReplyTo":null,"subject":"[PATCH 0/8] [RFC] submodule update: parse all options in C","fromName":"Glen Choo via GitGitGadget","fromEmail":"gitgitgadget@gmail.com","sentAt":"2022-06-10T00:26:13Z","receivedAt":"2022-06-10T00:26:32Z","isPatch":true,"sender":{"key":"glencbz@gmail.com","avatar":"https://avatars.githubusercontent.com/u/58092771?v=4"},"body":"As a follow up to ar/submodule-update [1] and its successors\ngc/submodule-update-part* [2] [3], this series converts the last remaining\npiece of \"git submodule update\" into C, namely, the option parsing in\ngit-submodule.sh.\n\nAs a result, git-submodule.sh::cmd_update() is now an (almost) one-liner:\n\ncmd_update() { git ${wt_prefix:+-C \"$wt_prefix\"} submodule--helper update\n${wt_prefix:+--prefix \"$wt_prefix\"}\n\"$@\" }\n\nand best of all, \"git submodule update\" now shows a usage string for its own\nsubcommand instead of a giant usage string for all of \"git submodule\" :)\n\nGiven how many options \"git submodule update\" accepts, this series takes a\ngradual approach:\n\n 1. Create a variable opts, which holds the literal options we want to pass\n    to \"git submodule--helper update\". Then, for each option...\n 2. If \"git submodule--helper update\" already understands the string option,\n    append it to opts and remove any special handling (1-3/8).\n 3. Otherwise, if the option makes sense, teach \"git submodule--helper\n    update\" to understand the option. Goto 2. (4-5/8).\n 4. Otherwise, if the option makes no sense, drop it (6/8).\n 5. When we've processed all options, delete all the option parsing code\n    (7/8) and clean up (8/8).\n\nI read over the other \"git submodule\" subcommands very briefly to see how\nmuch work this would be if we were to repeat the process for all\nsubcommands. It should be relatively simple - most \"git submodule--helper\"\ncommands already understand every CLI option that they need to, so we can\nskip step 3 (i.e. the tedious one).\n\nI'm sending this as an RFC because even though this series is pretty\nlow-risk, the previous topics [1] [2] [3] had their fair share of\nregressions (even when the conversions seemed 'obviously correct') and\nshowed that the test coverage of \"git submodule \"update\" is quite poor. I'd\nlike to get feedback on the general approach before I invest more time into\nimproving the test coverage and/or checking the before/after output for\nregressions [4].\n\n[1] https://lore.kernel.org/git/20210907115932.36068-1-raykar.ath@gmail.com/\n[2] Part 1\nhttps://lore.kernel.org/git/20220305001401.20888-1-chooglen@google.com/ [3]\nPart 2\nhttps://lore.kernel.org/git/20220315210925.79289-1-chooglen@google.com/ [4]\nÆvar suggested a way to do this using the test suite and \"--tee\" in\nhttps://lore.kernel.org/git/220214.86h791xsza.gmgdl@evledraar.gmail.com/\n\nGlen Choo (8):\n  submodule update: remove intermediate parsing\n  submodule update: pass options containing \"[no-]\"\n  submodule update: pass options with stuck forms\n  submodule update: pass --require-init and --init\n  submodule--helper update: use one param per type\n  submodule update: remove -v, pass --quiet\n  submodule update: stop parsing options in .sh\n  submodule update: remove never-used expansion\n\n builtin/submodule--helper.c |  41 +++++++----\n git-submodule.sh            | 131 ------------------------------------\n t/t7406-submodule-update.sh |   2 +-\n 3 files changed, 29 insertions(+), 145 deletions(-)\n\n\nbase-commit: 1e59178e3f65880188caedb965e70db5ceeb2d64\nPublished-As: https://github.com/gitgitgadget/git/releases/tag/pr-git-1275%2Fchooglen%2Fsubmodule%2Fparse-update-opts-in-c-v1\nFetch-It-Via: git fetch https://github.com/gitgitgadget/git pr-git-1275/chooglen/submodule/parse-update-opts-in-c-v1\nPull-Request: https://github.com/git/git/pull/1275\n-- \ngitgitgadget\n"},{"id":"456974","messageId":"058d84864120844e70f3a2dc65432d6327d63bea.1654820781.git.gitgitgadget@gmail.com","threadId":"57979","inReplyTo":"pull.1275.git.git.1654820781.gitgitgadget@gmail.com","subject":"[PATCH 2/8] submodule update: pass options containing \"[no-]\"","fromName":"Glen Choo via GitGitGadget","fromEmail":"gitgitgadget@gmail.com","sentAt":"2022-06-10T00:26:15Z","receivedAt":"2022-06-10T00:26:34Z","isPatch":true,"sender":{"key":"glencbz@gmail.com","avatar":"https://avatars.githubusercontent.com/u/58092771?v=4"},"body":"From: Glen Choo <chooglen@google.com>\n\n\"git submodule--helper update\" understands these options, so append them\nto `opts` and remove their intermediate variables.\n\nAs a result, we now pass every instance of the option and its \"no-\"\nvariant to \"git submodule--helper update\" instead of only passing the\nlast instance. As we noted in the previous commit, this is good because\nthis makes our options parsing consistent.\n\nSigned-off-by: Glen Choo <chooglen@google.com>\n---\n git-submodule.sh | 10 ++++------\n 1 file changed, 4 insertions(+), 6 deletions(-)\n\ndiff --git a/git-submodule.sh b/git-submodule.sh\nindex f4679e0db80..8c46eac22e8 100755\n--- a/git-submodule.sh\n+++ b/git-submodule.sh\n@@ -296,10 +296,10 @@ cmd_update()\n \t\t\tupdate=\"checkout\"\n \t\t\t;;\n \t\t--recommend-shallow)\n-\t\t\trecommend_shallow=\"--recommend-shallow\"\n+\t\t\topts=\"$opts $1\"\n \t\t\t;;\n \t\t--no-recommend-shallow)\n-\t\t\trecommend_shallow=\"--no-recommend-shallow\"\n+\t\t\topts=\"$opts $1\"\n \t\t\t;;\n \t\t--depth)\n \t\t\tcase \"$2\" in '') usage ;; esac\n@@ -318,10 +318,10 @@ cmd_update()\n \t\t\tjobs=$1\n \t\t\t;;\n \t\t--single-branch)\n-\t\t\tsingle_branch=\"--single-branch\"\n+\t\t\topts=\"$opts $1\"\n \t\t\t;;\n \t\t--no-single-branch)\n-\t\t\tsingle_branch=\"--no-single-branch\"\n+\t\t\topts=\"$opts $1\"\n \t\t\t;;\n \t\t--filter)\n \t\t\tcase \"$2\" in '') usage ;; esac\n@@ -354,8 +354,6 @@ cmd_update()\n \t\t${reference:+\"$reference\"} \\\n \t\t${depth:+\"$depth\"} \\\n \t\t${require_init:+--require-init} \\\n-\t\t$single_branch \\\n-\t\t$recommend_shallow \\\n \t\t$jobs \\\n \t\t$filter \\\n \t\t$opts \\\n-- \ngitgitgadget\n\n"},{"id":"456975","messageId":"cad906fda44133963cae92dabbbf9290e8356df1.1654820781.git.gitgitgadget@gmail.com","threadId":"57979","inReplyTo":"pull.1275.git.git.1654820781.gitgitgadget@gmail.com","subject":"[PATCH 3/8] submodule update: pass options with stuck forms","fromName":"Glen Choo via GitGitGadget","fromEmail":"gitgitgadget@gmail.com","sentAt":"2022-06-10T00:26:16Z","receivedAt":"2022-06-10T00:26:37Z","isPatch":true,"sender":{"key":"glencbz@gmail.com","avatar":"https://avatars.githubusercontent.com/u/58092771?v=4"},"body":"From: Glen Choo <chooglen@google.com>\n\ngit-submodule.sh::cmd_update() converts 'unstuck' forms of options into\ntheir 'stuck' forms before passing them to \"git submodule--helper\nupdate\". Remove this special handling of 'unstuck' options and append\nthe options to `opts`.\n\nSigned-off-by: Glen Choo <chooglen@google.com>\n---\n git-submodule.sh | 23 ++++++++---------------\n 1 file changed, 8 insertions(+), 15 deletions(-)\n\ndiff --git a/git-submodule.sh b/git-submodule.sh\nindex 8c46eac22e8..7418fd5bf51 100755\n--- a/git-submodule.sh\n+++ b/git-submodule.sh\n@@ -32,7 +32,6 @@ export GIT_PROTOCOL_FROM_USER\n command=\n branch=\n force=\n-reference=\n cached=\n recursive=\n init=\n@@ -44,8 +43,6 @@ custom_name=\n depth=\n progress=\n dissociate=\n-jobs=\n-filter=\n \n isnumber()\n {\n@@ -277,11 +274,11 @@ cmd_update()\n \t\t\t;;\n \t\t--reference)\n \t\t\tcase \"$2\" in '') usage ;; esac\n-\t\t\treference=\"--reference=$2\"\n+\t\t\topts=\"$opts $1 $2\"\n \t\t\tshift\n \t\t\t;;\n \t\t--reference=*)\n-\t\t\treference=\"$1\"\n+\t\t\topts=\"$opts $1\"\n \t\t\t;;\n \t\t--dissociate)\n \t\t\topts=\"$opts $1\"\n@@ -303,19 +300,19 @@ cmd_update()\n \t\t\t;;\n \t\t--depth)\n \t\t\tcase \"$2\" in '') usage ;; esac\n-\t\t\tdepth=\"--depth=$2\"\n+\t\t\topts=\"$opts $1 $2\"\n \t\t\tshift\n \t\t\t;;\n \t\t--depth=*)\n-\t\t\tdepth=$1\n+\t\t\topts=\"$opts $1\"\n \t\t\t;;\n \t\t-j|--jobs)\n \t\t\tcase \"$2\" in '') usage ;; esac\n-\t\t\tjobs=\"--jobs=$2\"\n+\t\t\topts=\"$opts $1 $2\"\n \t\t\tshift\n \t\t\t;;\n \t\t--jobs=*)\n-\t\t\tjobs=$1\n+\t\t\topts=\"$opts $1\"\n \t\t\t;;\n \t\t--single-branch)\n \t\t\topts=\"$opts $1\"\n@@ -325,11 +322,11 @@ cmd_update()\n \t\t\t;;\n \t\t--filter)\n \t\t\tcase \"$2\" in '') usage ;; esac\n-\t\t\tfilter=\"--filter=$2\"\n+\t\t\topts=\"$opts $1 $2\"\n \t\t\tshift\n \t\t\t;;\n \t\t--filter=*)\n-\t\t\tfilter=\"$1\"\n+\t\t\topts=\"$opts $1\"\n \t\t\t;;\n \t\t--)\n \t\t\tshift\n@@ -351,11 +348,7 @@ cmd_update()\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\"} \\\n \t\t${require_init:+--require-init} \\\n-\t\t$jobs \\\n-\t\t$filter \\\n \t\t$opts \\\n \t\t-- \\\n \t\t\"$@\"\n-- \ngitgitgadget\n\n"},{"id":"456976","messageId":"0b3d419be665186536a7350682834542647800dd.1654820781.git.gitgitgadget@gmail.com","threadId":"57979","inReplyTo":"pull.1275.git.git.1654820781.gitgitgadget@gmail.com","subject":"[PATCH 4/8] submodule update: pass --require-init and --init","fromName":"Glen Choo via GitGitGadget","fromEmail":"gitgitgadget@gmail.com","sentAt":"2022-06-10T00:26:17Z","receivedAt":"2022-06-10T00:26:40Z","isPatch":true,"sender":{"key":"glencbz@gmail.com","avatar":"https://avatars.githubusercontent.com/u/58092771?v=4"},"body":"From: Glen Choo <chooglen@google.com>\n\ngit-submodule.sh::cmd_update() makes \"--require-init\" imply \"--init\".\nMove this logic into \"git submodule--helper update\" instead, and append\nboth options to `opts`.\n\nSigned-off-by: Glen Choo <chooglen@google.com>\n---\n builtin/submodule--helper.c | 4 ++++\n git-submodule.sh            | 9 ++-------\n 2 files changed, 6 insertions(+), 7 deletions(-)\n\ndiff --git a/builtin/submodule--helper.c b/builtin/submodule--helper.c\nindex c6c2ba1b6dc..a40f9f143e8 100644\n--- a/builtin/submodule--helper.c\n+++ b/builtin/submodule--helper.c\n@@ -2642,6 +2642,10 @@ static int module_update(int argc, const char **argv, const char *prefix)\n \targc = parse_options(argc, argv, prefix, module_update_options,\n \t\t\t     git_submodule_helper_usage, 0);\n \n+\tif (opt.require_init) {\n+\t\topt.init = 1;\n+\t}\n+\n \tif (filter_options.choice && !opt.init) {\n \t\tusage_with_options(git_submodule_helper_usage,\n \t\t\t\t   module_update_options);\ndiff --git a/git-submodule.sh b/git-submodule.sh\nindex 7418fd5bf51..f61d12ccd21 100755\n--- a/git-submodule.sh\n+++ b/git-submodule.sh\n@@ -34,8 +34,6 @@ branch=\n force=\n cached=\n recursive=\n-init=\n-require_init=\n files=\n update=\n prefix=\n@@ -254,11 +252,10 @@ cmd_update()\n \t\t\topts=\"$opts $1\"\n \t\t\t;;\n \t\t-i|--init)\n-\t\t\tinit=1\n+\t\t\topts=\"$opts $1\"\n \t\t\t;;\n \t\t--require-init)\n-\t\t\tinit=1\n-\t\t\trequire_init=1\n+\t\t\topts=\"$opts $1\"\n \t\t\t;;\n \t\t--remote)\n \t\t\topts=\"$opts $1\"\n@@ -344,11 +341,9 @@ cmd_update()\n \n \tgit ${wt_prefix:+-C \"$wt_prefix\"} submodule--helper update \\\n \t\t${GIT_QUIET:+--quiet} \\\n-\t\t${init:+--init} \\\n \t\t${wt_prefix:+--prefix \"$wt_prefix\"} \\\n \t\t${prefix:+--recursive-prefix \"$prefix\"} \\\n \t\t${update:+--update \"$update\"} \\\n-\t\t${require_init:+--require-init} \\\n \t\t$opts \\\n \t\t-- \\\n \t\t\"$@\"\n-- \ngitgitgadget\n\n"},{"id":"456977","messageId":"1bed100c12e851bf5697af6cb96275510ae52b2f.1654820781.git.gitgitgadget@gmail.com","threadId":"57979","inReplyTo":"pull.1275.git.git.1654820781.gitgitgadget@gmail.com","subject":"[PATCH 5/8] submodule--helper update: use one param per type","fromName":"Glen Choo via GitGitGadget","fromEmail":"gitgitgadget@gmail.com","sentAt":"2022-06-10T00:26:18Z","receivedAt":"2022-06-10T00:26:42Z","isPatch":true,"sender":{"key":"glencbz@gmail.com","avatar":"https://avatars.githubusercontent.com/u/58092771?v=4"},"body":"From: Glen Choo <chooglen@google.com>\n\ngit-submodule.sh accepts literal 'update types' as options, but parses\nthem into a \"--update\" option for \"git submodule--helper update\", e.g.\n\"--checkout\" becomes \"--update=checkout\".\n\nTeach the 'update type' options to \"git submodule--helper update\" so\nthat we no longer have to do this parsing in git-submodule.sh, and\nappend them to `opts`.\n\nSigned-off-by: Glen Choo <chooglen@google.com>\n---\n builtin/submodule--helper.c | 37 ++++++++++++++++++++++++-------------\n git-submodule.sh            |  8 +++-----\n 2 files changed, 27 insertions(+), 18 deletions(-)\n\ndiff --git a/builtin/submodule--helper.c b/builtin/submodule--helper.c\nindex a40f9f143e8..09510ebc026 100644\n--- a/builtin/submodule--helper.c\n+++ b/builtin/submodule--helper.c\n@@ -1818,7 +1818,7 @@ static int module_clone(int argc, const char **argv, const char *prefix)\n static void determine_submodule_update_strategy(struct repository *r,\n \t\t\t\t\t\tint just_cloned,\n \t\t\t\t\t\tconst char *path,\n-\t\t\t\t\t\tconst char *update,\n+\t\t\t\t\t\tenum submodule_update_type update,\n \t\t\t\t\t\tstruct submodule_update_strategy *out)\n {\n \tconst struct submodule *sub = submodule_from_path(r, null_oid(), path);\n@@ -1828,9 +1828,7 @@ static void determine_submodule_update_strategy(struct repository *r,\n \tkey = xstrfmt(\"submodule.%s.update\", sub->name);\n \n \tif (update) {\n-\t\tif (parse_submodule_update_strategy(update, out) < 0)\n-\t\t\tdie(_(\"Invalid update mode '%s' for submodule path '%s'\"),\n-\t\t\t\tupdate, path);\n+\t\tout->type = update;\n \t} else if (!repo_config_get_string_tmp(r, key, &val)) {\n \t\tif (parse_submodule_update_strategy(val, out) < 0)\n \t\t\tdie(_(\"Invalid update mode '%s' configured for submodule path '%s'\"),\n@@ -1882,7 +1880,6 @@ struct update_data {\n \tconst char *prefix;\n \tconst char *recursive_prefix;\n \tconst char *displaypath;\n-\tconst char *update_default;\n \tstruct object_id suboid;\n \tstruct string_list references;\n \tstruct submodule_update_strategy update_strategy;\n@@ -1892,6 +1889,7 @@ struct update_data {\n \tint max_jobs;\n \tint single_branch;\n \tint recommend_shallow;\n+\tenum submodule_update_type update_default;\n \tunsigned int require_init;\n \tunsigned int force;\n \tunsigned int quiet;\n@@ -2429,8 +2427,20 @@ static void update_data_to_args(struct update_data *update_data, struct strvec *\n \t\tstrvec_push(args, \"--require-init\");\n \tif (update_data->depth)\n \t\tstrvec_pushf(args, \"--depth=%d\", update_data->depth);\n-\tif (update_data->update_default)\n-\t\tstrvec_pushl(args, \"--update\", update_data->update_default, NULL);\n+\tswitch (update_data->update_default) {\n+\tcase SM_UPDATE_MERGE:\n+\t\tstrvec_push(args, \"--merge\");\n+\t\tbreak;\n+\tcase SM_UPDATE_CHECKOUT:\n+\t\tstrvec_push(args, \"--checkout\");\n+\t\tbreak;\n+\tcase SM_UPDATE_REBASE:\n+\t\tstrvec_push(args, \"--rebase\");\n+\t\tbreak;\n+\tdefault:\n+\t\tbreak;\n+\t}\n+\n \tif (update_data->references.nr) {\n \t\tstruct string_list_item *item;\n \t\tfor_each_string_list_item(item, &update_data->references)\n@@ -2600,9 +2610,12 @@ static int module_update(int argc, const char **argv, const char *prefix)\n \t\t\t   N_(\"path\"),\n \t\t\t   N_(\"path into the working tree, across nested \"\n \t\t\t      \"submodule boundaries\")),\n-\t\tOPT_STRING(0, \"update\", &opt.update_default,\n-\t\t\t   N_(\"string\"),\n-\t\t\t   N_(\"rebase, merge, checkout or none\")),\n+\t\tOPT_SET_INT(0, \"checkout\", &opt.update_default,\n+\t\t\t    N_(\"update using checkout\"), SM_UPDATE_CHECKOUT),\n+\t\tOPT_SET_INT('r', \"rebase\", &opt.update_default,\n+\t\t\t    N_(\"update using rebase\"), SM_UPDATE_REBASE),\n+\t\tOPT_SET_INT('m', \"merge\", &opt.update_default,\n+\t\t\t    N_(\"update using merge\"), SM_UPDATE_MERGE),\n \t\tOPT_STRING_LIST(0, \"reference\", &opt.references, N_(\"repo\"),\n \t\t\t   N_(\"reference repository\")),\n \t\tOPT_BOOL(0, \"dissociate\", &opt.dissociate,\n@@ -2654,9 +2667,7 @@ static int module_update(int argc, const char **argv, const char *prefix)\n \topt.filter_options = &filter_options;\n \n \tif (opt.update_default)\n-\t\tif (parse_submodule_update_strategy(opt.update_default,\n-\t\t\t\t\t\t    &opt.update_strategy) < 0)\n-\t\t\tdie(_(\"bad value for update parameter\"));\n+\t\topt.update_strategy.type = opt.update_default;\n \n \tif (module_list_compute(argc, argv, prefix, &pathspec, &opt.list) < 0) {\n \t\tlist_objects_filter_release(&filter_options);\ndiff --git a/git-submodule.sh b/git-submodule.sh\nindex f61d12ccd21..d93b6dfbbd7 100755\n--- a/git-submodule.sh\n+++ b/git-submodule.sh\n@@ -35,7 +35,6 @@ force=\n cached=\n recursive=\n files=\n-update=\n prefix=\n custom_name=\n depth=\n@@ -267,7 +266,7 @@ cmd_update()\n \t\t\topts=\"$opts $1\"\n \t\t\t;;\n \t\t-r|--rebase)\n-\t\t\tupdate=\"rebase\"\n+\t\t\topts=\"$opts $1\"\n \t\t\t;;\n \t\t--reference)\n \t\t\tcase \"$2\" in '') usage ;; esac\n@@ -281,13 +280,13 @@ cmd_update()\n \t\t\topts=\"$opts $1\"\n \t\t\t;;\n \t\t-m|--merge)\n-\t\t\tupdate=\"merge\"\n+\t\t\topts=\"$opts $1\"\n \t\t\t;;\n \t\t--recursive)\n \t\t\topts=\"$opts $1\"\n \t\t\t;;\n \t\t--checkout)\n-\t\t\tupdate=\"checkout\"\n+\t\t\topts=\"$opts $1\"\n \t\t\t;;\n \t\t--recommend-shallow)\n \t\t\topts=\"$opts $1\"\n@@ -343,7 +342,6 @@ cmd_update()\n \t\t${GIT_QUIET:+--quiet} \\\n \t\t${wt_prefix:+--prefix \"$wt_prefix\"} \\\n \t\t${prefix:+--recursive-prefix \"$prefix\"} \\\n-\t\t${update:+--update \"$update\"} \\\n \t\t$opts \\\n \t\t-- \\\n \t\t\"$@\"\n-- \ngitgitgadget\n\n"},{"id":"456978","messageId":"6c496ef31526c45686b0ac6e685f655bdbb003de.1654820781.git.gitgitgadget@gmail.com","threadId":"57979","inReplyTo":"pull.1275.git.git.1654820781.gitgitgadget@gmail.com","subject":"[PATCH 7/8] submodule update: stop parsing options in .sh","fromName":"Glen Choo via GitGitGadget","fromEmail":"gitgitgadget@gmail.com","sentAt":"2022-06-10T00:26:20Z","receivedAt":"2022-06-10T00:26:44Z","isPatch":true,"sender":{"key":"glencbz@gmail.com","avatar":"https://avatars.githubusercontent.com/u/58092771?v=4"},"body":"From: Glen Choo <chooglen@google.com>\n\ncmd_update()'s option parsing loop is now obsolete - it only\nappends options to `opts` without doing additional parsing. Remove it.\n\nSigned-off-by: Glen Choo <chooglen@google.com>\n---\n git-submodule.sh | 101 -----------------------------------------------\n 1 file changed, 101 deletions(-)\n\ndiff --git a/git-submodule.sh b/git-submodule.sh\nindex 6b3f161dc53..e9d93e91d21 100755\n--- a/git-submodule.sh\n+++ b/git-submodule.sh\n@@ -236,110 +236,9 @@ cmd_deinit()\n #\n cmd_update()\n {\n-\topts=\n-\t# parse $args after \"submodule ... update\".\n-\twhile test $# -ne 0\n-\tdo\n-\t\tcase \"$1\" in\n-\t\t-q|--quiet)\n-\t\t\topts=\"$opts $1\"\n-\t\t\t;;\n-\t\t--progress)\n-\t\t\topts=\"$opts $1\"\n-\t\t\t;;\n-\t\t-i|--init)\n-\t\t\topts=\"$opts $1\"\n-\t\t\t;;\n-\t\t--require-init)\n-\t\t\topts=\"$opts $1\"\n-\t\t\t;;\n-\t\t--remote)\n-\t\t\topts=\"$opts $1\"\n-\t\t\t;;\n-\t\t-N|--no-fetch)\n-\t\t\topts=\"$opts $1\"\n-\t\t\t;;\n-\t\t-f|--force)\n-\t\t\topts=\"$opts $1\"\n-\t\t\t;;\n-\t\t-r|--rebase)\n-\t\t\topts=\"$opts $1\"\n-\t\t\t;;\n-\t\t--reference)\n-\t\t\tcase \"$2\" in '') usage ;; esac\n-\t\t\topts=\"$opts $1 $2\"\n-\t\t\tshift\n-\t\t\t;;\n-\t\t--reference=*)\n-\t\t\topts=\"$opts $1\"\n-\t\t\t;;\n-\t\t--dissociate)\n-\t\t\topts=\"$opts $1\"\n-\t\t\t;;\n-\t\t-m|--merge)\n-\t\t\topts=\"$opts $1\"\n-\t\t\t;;\n-\t\t--recursive)\n-\t\t\topts=\"$opts $1\"\n-\t\t\t;;\n-\t\t--checkout)\n-\t\t\topts=\"$opts $1\"\n-\t\t\t;;\n-\t\t--recommend-shallow)\n-\t\t\topts=\"$opts $1\"\n-\t\t\t;;\n-\t\t--no-recommend-shallow)\n-\t\t\topts=\"$opts $1\"\n-\t\t\t;;\n-\t\t--depth)\n-\t\t\tcase \"$2\" in '') usage ;; esac\n-\t\t\topts=\"$opts $1 $2\"\n-\t\t\tshift\n-\t\t\t;;\n-\t\t--depth=*)\n-\t\t\topts=\"$opts $1\"\n-\t\t\t;;\n-\t\t-j|--jobs)\n-\t\t\tcase \"$2\" in '') usage ;; esac\n-\t\t\topts=\"$opts $1 $2\"\n-\t\t\tshift\n-\t\t\t;;\n-\t\t--jobs=*)\n-\t\t\topts=\"$opts $1\"\n-\t\t\t;;\n-\t\t--single-branch)\n-\t\t\topts=\"$opts $1\"\n-\t\t\t;;\n-\t\t--no-single-branch)\n-\t\t\topts=\"$opts $1\"\n-\t\t\t;;\n-\t\t--filter)\n-\t\t\tcase \"$2\" in '') usage ;; esac\n-\t\t\topts=\"$opts $1 $2\"\n-\t\t\tshift\n-\t\t\t;;\n-\t\t--filter=*)\n-\t\t\topts=\"$opts $1\"\n-\t\t\t;;\n-\t\t--)\n-\t\t\tshift\n-\t\t\tbreak\n-\t\t\t;;\n-\t\t-*)\n-\t\t\tusage\n-\t\t\t;;\n-\t\t*)\n-\t\t\tbreak\n-\t\t\t;;\n-\t\tesac\n-\t\tshift\n-\tdone\n-\n \tgit ${wt_prefix:+-C \"$wt_prefix\"} submodule--helper update \\\n \t\t${wt_prefix:+--prefix \"$wt_prefix\"} \\\n \t\t${prefix:+--recursive-prefix \"$prefix\"} \\\n-\t\t$opts \\\n-\t\t-- \\\n \t\t\"$@\"\n }\n \n-- \ngitgitgadget\n\n"},{"id":"456979","messageId":"242d3399dfb4fb533ca6cdca452af2717c316672.1654820781.git.gitgitgadget@gmail.com","threadId":"57979","inReplyTo":"pull.1275.git.git.1654820781.gitgitgadget@gmail.com","subject":"[PATCH 8/8] submodule update: remove never-used expansion","fromName":"Glen Choo via GitGitGadget","fromEmail":"gitgitgadget@gmail.com","sentAt":"2022-06-10T00:26:21Z","receivedAt":"2022-06-10T00:26:47Z","isPatch":true,"sender":{"key":"glencbz@gmail.com","avatar":"https://avatars.githubusercontent.com/u/58092771?v=4"},"body":"From: Glen Choo <chooglen@google.com>\n\nThe `prefix` variable is never set, so this conditional expansion is\nalways '' (which does nothing).\n\nSigned-off-by: Glen Choo <chooglen@google.com>\n---\n git-submodule.sh | 1 -\n 1 file changed, 1 deletion(-)\n\ndiff --git a/git-submodule.sh b/git-submodule.sh\nindex e9d93e91d21..2a6ffa8ac34 100755\n--- a/git-submodule.sh\n+++ b/git-submodule.sh\n@@ -238,7 +238,6 @@ cmd_update()\n {\n \tgit ${wt_prefix:+-C \"$wt_prefix\"} submodule--helper update \\\n \t\t${wt_prefix:+--prefix \"$wt_prefix\"} \\\n-\t\t${prefix:+--recursive-prefix \"$prefix\"} \\\n \t\t\"$@\"\n }\n \n-- \ngitgitgadget\n"},{"id":"456980","messageId":"fbdfab55f563c2a6dff8485d6870baf472b2e12f.1654820781.git.gitgitgadget@gmail.com","threadId":"57979","inReplyTo":"pull.1275.git.git.1654820781.gitgitgadget@gmail.com","subject":"[PATCH 6/8] submodule update: remove -v, pass --quiet","fromName":"Glen Choo via GitGitGadget","fromEmail":"gitgitgadget@gmail.com","sentAt":"2022-06-10T00:26:19Z","receivedAt":"2022-06-10T00:26:50Z","isPatch":true,"sender":{"key":"glencbz@gmail.com","avatar":"https://avatars.githubusercontent.com/u/58092771?v=4"},"body":"From: Glen Choo <chooglen@google.com>\n\nIn cmd_update(), \"-v\" unsets GIT_QUIET, but this does nothing because\nGIT_QUIET is only set when \"-q|--quiet\" is passed.\n\nRemove \"-v\", and since \"git submodule--helper update\" already\nunderstands 'quiet' options, append them to `opts`. This makes GIT_QUIET\nobsolete, so remove it.\n\nSigned-off-by: Glen Choo <chooglen@google.com>\n---\n git-submodule.sh            | 6 +-----\n t/t7406-submodule-update.sh | 2 +-\n 2 files changed, 2 insertions(+), 6 deletions(-)\n\ndiff --git a/git-submodule.sh b/git-submodule.sh\nindex d93b6dfbbd7..6b3f161dc53 100755\n--- a/git-submodule.sh\n+++ b/git-submodule.sh\n@@ -242,10 +242,7 @@ cmd_update()\n \tdo\n \t\tcase \"$1\" in\n \t\t-q|--quiet)\n-\t\t\tGIT_QUIET=1\n-\t\t\t;;\n-\t\t-v)\n-\t\t\tunset GIT_QUIET\n+\t\t\topts=\"$opts $1\"\n \t\t\t;;\n \t\t--progress)\n \t\t\topts=\"$opts $1\"\n@@ -339,7 +336,6 @@ cmd_update()\n \tdone\n \n \tgit ${wt_prefix:+-C \"$wt_prefix\"} submodule--helper update \\\n-\t\t${GIT_QUIET:+--quiet} \\\n \t\t${wt_prefix:+--prefix \"$wt_prefix\"} \\\n \t\t${prefix:+--recursive-prefix \"$prefix\"} \\\n \t\t$opts \\\ndiff --git a/t/t7406-submodule-update.sh b/t/t7406-submodule-update.sh\nindex 43f779d751c..06d804e2131 100755\n--- a/t/t7406-submodule-update.sh\n+++ b/t/t7406-submodule-update.sh\n@@ -1074,7 +1074,7 @@ test_expect_success 'submodule update --quiet passes quietness to merge/rebase'\n \t git submodule update --rebase --quiet >out 2>err &&\n \t test_must_be_empty out &&\n \t test_must_be_empty err &&\n-\t git submodule update --rebase -v >out 2>err &&\n+\t git submodule update --rebase >out 2>err &&\n \t test_file_not_empty out &&\n \t test_must_be_empty err\n \t)\n-- \ngitgitgadget\n\n"},{"id":"456984","messageId":"RFC-patch-01.20-0e9f13822ef-20220610T011725Z-avarab@gmail.com","threadId":"57979","inReplyTo":"RFC-cover-00.20-00000000000-20220610T011725Z-avarab@gmail.com","subject":"[RFC PATCH 01/20] git-submodule.sh: remove unused sanitize_submodule_env()","fromName":"Ævar Arnfjörð Bjarmason","fromEmail":"avarab@gmail.com","sentAt":"2022-06-10T02:01:13Z","receivedAt":"2022-06-10T02:01:54Z","isPatch":true,"sender":{"key":"avarab@gmail.com","avatar":"https://avatars.githubusercontent.com/u/45301?v=4"},"body":"The sanitize_submodule_env() function was last used in\nb3c5f5cb048 (submodule: move core cmd_update() logic to C,\n2022-03-15), let's remove it.\n\nThis also allows us to remove clear_local_git_env() from\ngit-sh-setup.sh. That function hasn't been documented in\nDocumentation/git-sh-setup.sh, and since 14111fc4927 (git: submodule\nhonor -c credential.* from command line, 2016-02-29) it had only been\nused in the sanitize_submodule_env() function being removed here.\n\nSigned-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>\n---\n git-sh-setup.sh  |  7 -------\n git-submodule.sh | 11 -----------\n 2 files changed, 18 deletions(-)\n\ndiff --git a/git-sh-setup.sh b/git-sh-setup.sh\nindex d92df37e992..ecb60d9e3cb 100644\n--- a/git-sh-setup.sh\n+++ b/git-sh-setup.sh\n@@ -285,13 +285,6 @@ get_author_ident_from_commit () {\n \tparse_ident_from_commit author AUTHOR\n }\n \n-# Clear repo-local GIT_* environment variables. Useful when switching to\n-# another repository (e.g. when entering a submodule). See also the env\n-# list in git_connect()\n-clear_local_git_env() {\n-\tunset $(git rev-parse --local-env-vars)\n-}\n-\n # Generate a virtual base file for a two-file merge. Uses git apply to\n # remove lines from $1 that are not in $2, leaving only common lines.\n create_virtual_base() {\ndiff --git a/git-submodule.sh b/git-submodule.sh\nindex fd0b4a2c947..bc436c4ca47 100755\n--- a/git-submodule.sh\n+++ b/git-submodule.sh\n@@ -56,17 +56,6 @@ isnumber()\n \tn=$(($1 + 0)) 2>/dev/null && test \"$n\" = \"$1\"\n }\n \n-# Sanitize the local git environment for use within a submodule. We\n-# can't simply use clear_local_git_env since we want to preserve some\n-# of the settings from GIT_CONFIG_PARAMETERS.\n-sanitize_submodule_env()\n-{\n-\tsave_config=$GIT_CONFIG_PARAMETERS\n-\tclear_local_git_env\n-\tGIT_CONFIG_PARAMETERS=$save_config\n-\texport GIT_CONFIG_PARAMETERS\n-}\n-\n #\n # Add a new submodule to the working tree, .gitmodules and the index\n #\n-- \n2.36.1.1178.gb5b1747c546\n\n"},{"id":"456985","messageId":"RFC-cover-00.20-00000000000-20220610T011725Z-avarab@gmail.com","threadId":"57979","inReplyTo":"pull.1275.git.git.1654820781.gitgitgadget@gmail.com","subject":"[RFC PATCH 00/20] submodule: remove git-submodule.sh, create bare builtin/submodule.c","fromName":"Ævar Arnfjörð Bjarmason","fromEmail":"avarab@gmail.com","sentAt":"2022-06-10T02:01:12Z","receivedAt":"2022-06-10T02:01:55Z","isPatch":true,"sender":{"key":"avarab@gmail.com","avatar":"https://avatars.githubusercontent.com/u/45301?v=4"},"body":"On Fri, Jun 10 2022, Glen Choo via GitGitGadget wrote:\n\n> As a follow up to ar/submodule-update [1] and its successors\n> gc/submodule-update-part* [2] [3], this series converts the last remaining\n> piece of \"git submodule update\" into C, namely, the option parsing in\n> git-submodule.sh.\n\nAside at the end at [2].\n\n> As a result, git-submodule.sh::cmd_update() is now an (almost) one-liner:\n>\n> cmd_update() { git ${wt_prefix:+-C \"$wt_prefix\"} submodule--helper update\n> ${wt_prefix:+--prefix \"$wt_prefix\"}\n> \"$@\" }\n>\n> and best of all, \"git submodule update\" now shows a usage string for its own\n> subcommand instead of a giant usage string for all of \"git submodule\" :)\n>\n> Given how many options \"git submodule update\" accepts, this series takes a\n> gradual approach:\n>\n>  1. Create a variable opts, which holds the literal options we want to pass\n>     to \"git submodule--helper update\". Then, for each option...\n>  2. If \"git submodule--helper update\" already understands the string option,\n>     append it to opts and remove any special handling (1-3/8).\n>  3. Otherwise, if the option makes sense, teach \"git submodule--helper\n>     update\" to understand the option. Goto 2. (4-5/8).\n>  4. Otherwise, if the option makes no sense, drop it (6/8).\n>  5. When we've processed all options, delete all the option parsing code\n>     (7/8) and clean up (8/8).\n\nThat's quite the timing coincidence. I hacked this up yesterday,\nthinking that the submodule topic had been too quiet for a while, and\nwondering how hard it was to convert the rest of git-submodule.sh.\n\nIt's more than 2x the length of yours, but gets to the point where we\ncan \"git rm git-submodule.sh\".\n\nSome brief comparison/commentary:\n\n> Glen Choo (8):\n>   submodule update: remove intermediate parsing\n>   submodule update: pass options containing \"[no-]\"\n>   submodule update: pass options with stuck forms\n\nYeah, this is the alternate approach I considered and ended up\ndiscarding. I.e. to make forward progress with migrating things away\nfrom the cmd_*() functions you either have to prepare things in\nadvance and then sweep the rug from under them in one go.\n\nOr, as you're doing here teaching them about the options they're\nnot-really-parsing anymore, but must know about because they're in a\nloop that ends with a \"if unknown option, usage\".\n\n>   submodule update: pass --require-init and --init\n\nAlmost the same as my 12/20.\n\n>   submodule--helper update: use one param per type\n\nSame as my 13/20, but I ended up doing it in a more narrow/smaller\nway. I tried your way and ran into some bug, then figured I'd do it\nmore narrowly instead of debugging it.\n\n>   submodule update: remove -v, pass --quiet\n\nHrm, so we don't need it at all then. Well, that's a bit simpler than\nmy 1[45]/20 and 17/20 :)\n\nSo yeah, definitely RFC-quality, but I ran into that one test that\nused -v, and then saw the missing docs etc. But no cheating, so I've\nleft it in :)\n\nI do wonder if we should leave it in anyway, we never documented -v,\nbut we *did* understand it, and if you look at:\n\n    git log -p -Gsay -- git-submodule.sh\n\nWe used to have a lot more code impacted by it, but looking at this\nagain now it would have only been for users of command-lines like:\n\n    git submodule --quiet update -v [...]\n\nI.e. where we already set the flag to the non-default quiet, and then\nused -v to flip it.\n\nI think at this point I've talked myself into \"let's just remove it\",\nbut maybe...\n\n>   submodule update: stop parsing options in .sh\n\nSame effect as my 16/20, but it's the last one I converted, the\ncmd_update() case being the trickiest.\n\n>   submodule update: remove never-used expansion\n\nSame as my 02/20, but as seen there I think you missed several\n\"prefix\" non-uses.\n\nBrief commentary on my patches, details in commit messages:\n\nÆvar Arnfjörð Bjarmason (20):\n  git-submodule.sh: remove unused sanitize_submodule_env()\n  git-submodule.sh: remove unused $prefix variable\n  git-submodule.sh: remove unused --super-prefix logic\n\nI removed a bit more dead code here than yours.\n\n  git-submodule.sh: normalize parsing of \"--branch\"\n  git-submodule.sh: normalize parsing of --cached\n\nThis & various other prep commits (hereafter \"easy prep\") make\nsubsequent one-time conversions of whole cmd_*() easier.\n\n  submodule--helper: rename \"absorb-git-dirs\" to \"absorbgitdirs\"\n  git-submodule.sh: create a \"case\" dispatch statement\n\neasy prep\n\n  submodule--helper: pretend to be \"git submodule\" in \"-h\" output\n\neasy prep & bug fix for existing (on master) output bugs.\n\n  git-submodule.sh: dispatch \"sync\" to helper\n  git-submodule.sh: dispatch directly to helper\n  git-submodule.sh: dispatch \"foreach\" to helper\n\nThese are easy conversions as the options 1=1 map after the above\nprep.\n\n  submodule--helper: have --require-init imply --init\n  submodule--helper: understand --checkout, --merge and --rebase\n    synonyms\n  git-submodule doc: document the -v\" option to \"update\"\n  submodule--helper: understand -v option for \"update\"\n\nnot-so-easy prep for \"cmd_update()\"\n\n  git-submodule.sh: dispatch \"update\" to helper\n\nFull cmd_update() migration in one go.\n\n  git-submodule.sh: use \"$quiet\", not \"$GIT_QUIET\"\n\n\"easy prep\", but this one is less overall churn if done at the end,\nbut as noted above could/should maybe be dropped entirely.\n\n  git-submodule.sh: simplify parsing loop\n\nNot really needed, but I wanted to get the code as close to minimal\nfor the next step, to eyeball the resulting sh v.s. C version.\n\n  submodule: make it a built-in, remove git-submodule.sh\n\nWe now have a builtin/submodule.c *and* the current\nbuiltin/submodule--helper.c, and we even dispatch to \"git\nsubmodule--helper\" via run_command()!\n\nThe idea is to be as close as possible to a bug-for-bug implementation\nof the shellscript, and that reviewers should be confident in being\nable to trace what commands we invoked before/after, we're invoking\nthe same \"git submodule--helper\" commands.\n\nOf course we eventually want to get to some full union of\nbuiltin/submodule{,--helper}.c, but that can wait.\n\n  submodule: add a subprocess-less submodule.useBuiltin setting\n\nWait, a useBuiltin setting to switch between two built-ins? Yeah,\nmaybe it makes little sense, but here we get rid of the run_command()\noverhead, and could generally use the built-in to experiment with\ndeeper integration between the two.\n\nPerformance is around ~2x faster with the \"real\" built-in than the\nrun_command() version, whic hin turn is more than 6x as fast on basic\noverhead than the shellscript version, to the extent that anyone cares\nabout \"git submodule\" overhead. See [1] at the end for a benchmark.\n\nThat last change adds a CI target for\nGIT_TEST_SUBMODULE_USE_BUILTIN=true, full CI run here:\nhttps://github.com/avar/git/actions/runs/2472131257\n\n Documentation/config/submodule.txt |   4 +\n Documentation/git-submodule.txt    |   8 +-\n Makefile                           |   2 +-\n builtin.h                          |   1 +\n builtin/submodule--helper.c        | 118 +++---\n builtin/submodule.c                | 169 ++++++++\n ci/run-build-and-tests.sh          |   1 +\n git-sh-setup.sh                    |   7 -\n git-submodule.sh                   | 637 -----------------------------\n git.c                              |   1 +\n submodule.c                        |   2 +-\n t/README                           |   4 +\n 12 files changed, 255 insertions(+), 699 deletions(-)\n create mode 100644 builtin/submodule.c\n delete mode 100755 git-submodule.sh\n\n1. GIT_TEST_SUBMODULE_USE_BUILTIN=true git hyperfine -L rev origin/master,HEAD~0 -L v false,true -s 'make CFLAGS=-O3' 'GIT_TEST_SUBMODULE_USE_BUILTIN={v} ./git --exec-path=$PWD submodule status' -r 20\nBenchmark 1: GIT_TEST_SUBMODULE_USE_BUILTIN=false ./git --exec-path=$PWD submodule status' in 'origin/master\n  Time (mean ± σ):      40.9 ms ±   0.3 ms    [User: 33.3 ms, System: 9.7 ms]\n  Range (min … max):    40.2 ms …  41.5 ms    20 runs\n\nBenchmark 2: GIT_TEST_SUBMODULE_USE_BUILTIN=false ./git --exec-path=$PWD submodule status' in 'HEAD~0\n  Time (mean ± σ):      12.4 ms ±   0.1 ms    [User: 9.9 ms, System: 2.5 ms]\n  Range (min … max):    12.2 ms …  12.7 ms    20 runs\n\nBenchmark 3: GIT_TEST_SUBMODULE_USE_BUILTIN=true ./git --exec-path=$PWD submodule status' in 'origin/master\n  Time (mean ± σ):      40.9 ms ±   0.5 ms    [User: 35.6 ms, System: 7.2 ms]\n  Range (min … max):    40.1 ms …  41.8 ms    20 runs\n\nBenchmark 4: GIT_TEST_SUBMODULE_USE_BUILTIN=true ./git --exec-path=$PWD submodule status' in 'HEAD~0\n  Time (mean ± σ):       6.4 ms ±   0.1 ms    [User: 3.9 ms, System: 2.5 ms]\n  Range (min … max):     6.3 ms …   6.6 ms    20 runs\n\nSummary\n  'GIT_TEST_SUBMODULE_USE_BUILTIN=true ./git --exec-path=$PWD submodule status' in 'HEAD~0' ran\n    1.94 ± 0.03 times faster than 'GIT_TEST_SUBMODULE_USE_BUILTIN=false ./git --exec-path=$PWD submodule status' in 'HEAD~0'\n    6.40 ± 0.11 times faster than 'GIT_TEST_SUBMODULE_USE_BUILTIN=true ./git --exec-path=$PWD submodule status' in 'origin/master'\n    6.40 ± 0.10 times faster than 'GIT_TEST_SUBMODULE_USE_BUILTIN=false ./git --exec-path=$PWD submodule status' in 'origin/master'\n\n2. Aside: I don't think these ever made it on-list but Atharva's\n   version of what we're trying to do here is at:\n   https://github.com/tfidfwastaken/git/tree/submodule-make-builtin-2\n\n   I'd looked those over at some distant point in the past, and\n   skimmed them again yesterday, but thought they were too much\n   all-at-once to be confident in testing it myself, hence coming up\n   with this alternate & smaller approach.\n\n-- \n2.36.1.1178.gb5b1747c546\n\n"},{"id":"456986","messageId":"RFC-patch-02.20-8fcd832e58f-20220610T011725Z-avarab@gmail.com","threadId":"57979","inReplyTo":"RFC-cover-00.20-00000000000-20220610T011725Z-avarab@gmail.com","subject":"[RFC PATCH 02/20] git-submodule.sh: remove unused $prefix variable","fromName":"Ævar Arnfjörð Bjarmason","fromEmail":"avarab@gmail.com","sentAt":"2022-06-10T02:01:14Z","receivedAt":"2022-06-10T02:01:57Z","isPatch":true,"sender":{"key":"avarab@gmail.com","avatar":"https://avatars.githubusercontent.com/u/45301?v=4"},"body":"Remove the $prefix variable which is never set, and never resulted in\nan option being passed to our \"git submodule--helper\". The\n--recursive-prefix option to \"git submodule--helper\" is still used,\nbut only when it invokes itself.\n\nSigned-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>\n---\n git-submodule.sh | 6 ++----\n 1 file changed, 2 insertions(+), 4 deletions(-)\n\ndiff --git a/git-submodule.sh b/git-submodule.sh\nindex bc436c4ca47..53847bbf6e2 100755\n--- a/git-submodule.sh\n+++ b/git-submodule.sh\n@@ -41,7 +41,6 @@ files=\n remote=\n nofetch=\n update=\n-prefix=\n custom_name=\n depth=\n progress=\n@@ -127,7 +126,7 @@ cmd_add()\n \t\tusage\n \tfi\n \n-\tgit ${wt_prefix:+-C \"$wt_prefix\"} ${prefix:+--super-prefix \"$prefix\"} submodule--helper add ${GIT_QUIET:+--quiet} ${force:+--force} ${progress:+\"--progress\"} ${branch:+--branch \"$branch\"} ${reference_path:+--reference \"$reference_path\"} ${dissociate:+--dissociate} ${custom_name:+--name \"$custom_name\"} ${depth:+\"$depth\"} -- \"$@\"\n+\tgit ${wt_prefix:+-C \"$wt_prefix\"} submodule--helper add ${GIT_QUIET:+--quiet} ${force:+--force} ${progress:+\"--progress\"} ${branch:+--branch \"$branch\"} ${reference_path:+--reference \"$reference_path\"} ${dissociate:+--dissociate} ${custom_name:+--name \"$custom_name\"} ${depth:+\"$depth\"} -- \"$@\"\n }\n \n #\n@@ -189,7 +188,7 @@ cmd_init()\n \t\tshift\n \tdone\n \n-\tgit ${wt_prefix:+-C \"$wt_prefix\"} ${prefix:+--super-prefix \"$prefix\"} submodule--helper init ${GIT_QUIET:+--quiet} -- \"$@\"\n+\tgit ${wt_prefix:+-C \"$wt_prefix\"} submodule--helper init ${GIT_QUIET:+--quiet} -- \"$@\"\n }\n \n #\n@@ -346,7 +345,6 @@ cmd_update()\n \t\t${init:+--init} \\\n \t\t${nofetch:+--no-fetch} \\\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${dissociate:+\"--dissociate\"} \\\n-- \n2.36.1.1178.gb5b1747c546\n\n"},{"id":"456987","messageId":"RFC-patch-04.20-f27723aa0a2-20220610T011725Z-avarab@gmail.com","threadId":"57979","inReplyTo":"RFC-cover-00.20-00000000000-20220610T011725Z-avarab@gmail.com","subject":"[RFC PATCH 04/20] git-submodule.sh: normalize parsing of \"--branch\"","fromName":"Ævar Arnfjörð Bjarmason","fromEmail":"avarab@gmail.com","sentAt":"2022-06-10T02:01:16Z","receivedAt":"2022-06-10T02:02:00Z","isPatch":true,"sender":{"key":"avarab@gmail.com","avatar":"https://avatars.githubusercontent.com/u/45301?v=4"},"body":"In 5c08dbbdf1a (git-submodule: fix subcommand parser, 2008-01-15) the\n\"--branch\" option was supported as an option to \"git submodule\"\nitself, i.e. \"git submodule --branch\" as a side-effect of its\nimplementation.\n\nThen in b57e8119e6e (submodule: teach set-branch subcommand,\n2019-02-08) when the \"set-branch\" subcommand was added the assertion\nthat we shouldn't have \"--branch\" anywhere except as an argument to\n\"add\" and \"set-branch\" was copy/pasted from the adjacent check for\n\"--cache\" added (or rather modified) in 496eeeb19b9 (git-submodule.sh:\navoid \"test <cond> -a/-o <cond>\", 2014-06-10).\n\nBut there's been a logic error in that check, this looked like it\nshould be supporting:\n\n    git submodule --branch <branch> (add | set-branch) [<options>]\n\nBut due to \"||\" in the condition (as opposed to \"&&\" for \"--cache\") if\nwe have \"--branch\" here already we'll emit usage, even for \"add\" and\n\"set-branch\".\n\nSince nobody's complained about \"--branch <branch>\" not being\nsupported as argument to \"git submodule\" itself, i.e. we want to\nsupport:\n\n    git submodule (add | set-branch) --branch <branch>  [<options>]\n\nBut not the first form noted above. Let's just remove this code, we've\nnever documented \"--branch\" as a top-level option (unlike \"--quiet\"),\nso this looks like it was an accident of the implementation, which we\nbroke v2.22.0, so we also know it must not have been important to\nanyone.\n\nSigned-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>\n---\n git-submodule.sh | 14 --------------\n 1 file changed, 14 deletions(-)\n\ndiff --git a/git-submodule.sh b/git-submodule.sh\nindex 53847bbf6e2..1b0a31b8383 100755\n--- a/git-submodule.sh\n+++ b/git-submodule.sh\n@@ -574,14 +574,6 @@ do\n \t-q|--quiet)\n \t\tGIT_QUIET=1\n \t\t;;\n-\t-b|--branch)\n-\t\tcase \"$2\" in\n-\t\t'')\n-\t\t\tusage\n-\t\t\t;;\n-\t\tesac\n-\t\tbranch=\"$2\"; shift\n-\t\t;;\n \t--cached)\n \t\tcached=\"$1\"\n \t\t;;\n@@ -609,12 +601,6 @@ then\n     fi\n fi\n \n-# \"-b branch\" is accepted only by \"add\" and \"set-branch\"\n-if test -n \"$branch\" && (test \"$command\" != add || test \"$command\" != set-branch)\n-then\n-\tusage\n-fi\n-\n # \"--cached\" is accepted only by \"status\" and \"summary\"\n if test -n \"$cached\" && test \"$command\" != status && test \"$command\" != summary\n then\n-- \n2.36.1.1178.gb5b1747c546\n\n"},{"id":"456988","messageId":"RFC-patch-03.20-6c774505ac5-20220610T011725Z-avarab@gmail.com","threadId":"57979","inReplyTo":"RFC-cover-00.20-00000000000-20220610T011725Z-avarab@gmail.com","subject":"[RFC PATCH 03/20] git-submodule.sh: remove unused --super-prefix logic","fromName":"Ævar Arnfjörð Bjarmason","fromEmail":"avarab@gmail.com","sentAt":"2022-06-10T02:01:15Z","receivedAt":"2022-06-10T02:02:06Z","isPatch":true,"sender":{"key":"avarab@gmail.com","avatar":"https://avatars.githubusercontent.com/u/45301?v=4"},"body":"The \"$prefix\" variable has not been set since b3c5f5cb048 (submodule:\nmove core cmd_update() logic to C, 2022-03-15), so we'd never pass the\n--super-prefix option to \"git submodule--helper\", and can therefore\nremove the handling of it from builtin/submodule--helper.c as well.\n\nSigned-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>\n---\n builtin/submodule--helper.c | 53 +++++++++++++++----------------------\n 1 file changed, 22 insertions(+), 31 deletions(-)\n\ndiff --git a/builtin/submodule--helper.c b/builtin/submodule--helper.c\nindex c6c2ba1b6dc..70693205764 100644\n--- a/builtin/submodule--helper.c\n+++ b/builtin/submodule--helper.c\n@@ -3364,35 +3364,32 @@ static int module_add(int argc, const char **argv, const char *prefix)\n \treturn 0;\n }\n \n-#define SUPPORT_SUPER_PREFIX (1<<0)\n-\n struct cmd_struct {\n \tconst char *cmd;\n \tint (*fn)(int, const char **, const char *);\n-\tunsigned option;\n };\n \n static struct cmd_struct commands[] = {\n-\t{\"list\", module_list, 0},\n-\t{\"name\", module_name, 0},\n-\t{\"clone\", module_clone, 0},\n-\t{\"add\", module_add, SUPPORT_SUPER_PREFIX},\n-\t{\"update\", module_update, 0},\n-\t{\"resolve-relative-url-test\", resolve_relative_url_test, 0},\n-\t{\"foreach\", module_foreach, SUPPORT_SUPER_PREFIX},\n-\t{\"init\", module_init, SUPPORT_SUPER_PREFIX},\n-\t{\"status\", module_status, SUPPORT_SUPER_PREFIX},\n-\t{\"sync\", module_sync, SUPPORT_SUPER_PREFIX},\n-\t{\"deinit\", module_deinit, 0},\n-\t{\"summary\", module_summary, SUPPORT_SUPER_PREFIX},\n-\t{\"push-check\", push_check, 0},\n-\t{\"absorb-git-dirs\", absorb_git_dirs, SUPPORT_SUPER_PREFIX},\n-\t{\"is-active\", is_active, 0},\n-\t{\"check-name\", check_name, 0},\n-\t{\"config\", module_config, 0},\n-\t{\"set-url\", module_set_url, 0},\n-\t{\"set-branch\", module_set_branch, 0},\n-\t{\"create-branch\", module_create_branch, 0},\n+\t{\"list\", module_list},\n+\t{\"name\", module_name},\n+\t{\"clone\", module_clone},\n+\t{\"add\", module_add},\n+\t{\"update\", module_update},\n+\t{\"resolve-relative-url-test\", resolve_relative_url_test},\n+\t{\"foreach\", module_foreach},\n+\t{\"init\", module_init},\n+\t{\"status\", module_status},\n+\t{\"sync\", module_sync},\n+\t{\"deinit\", module_deinit},\n+\t{\"summary\", module_summary},\n+\t{\"push-check\", push_check},\n+\t{\"absorb-git-dirs\", absorb_git_dirs},\n+\t{\"is-active\", is_active},\n+\t{\"check-name\", check_name},\n+\t{\"config\", module_config},\n+\t{\"set-url\", module_set_url},\n+\t{\"set-branch\", module_set_branch},\n+\t{\"create-branch\", module_create_branch},\n };\n \n int cmd_submodule__helper(int argc, const char **argv, const char *prefix)\n@@ -3401,15 +3398,9 @@ int cmd_submodule__helper(int argc, const char **argv, const char *prefix)\n \tif (argc < 2 || !strcmp(argv[1], \"-h\"))\n \t\tusage(\"git submodule--helper <command>\");\n \n-\tfor (i = 0; i < ARRAY_SIZE(commands); i++) {\n-\t\tif (!strcmp(argv[1], commands[i].cmd)) {\n-\t\t\tif (get_super_prefix() &&\n-\t\t\t    !(commands[i].option & SUPPORT_SUPER_PREFIX))\n-\t\t\t\tdie(_(\"%s doesn't support --super-prefix\"),\n-\t\t\t\t    commands[i].cmd);\n+\tfor (i = 0; i < ARRAY_SIZE(commands); i++)\n+\t\tif (!strcmp(argv[1], commands[i].cmd))\n \t\t\treturn commands[i].fn(argc - 1, argv + 1, prefix);\n-\t\t}\n-\t}\n \n \tdie(_(\"'%s' is not a valid submodule--helper \"\n \t      \"subcommand\"), argv[1]);\n-- \n2.36.1.1178.gb5b1747c546\n\n"},{"id":"456989","messageId":"RFC-patch-05.20-124c062e3a1-20220610T011725Z-avarab@gmail.com","threadId":"57979","inReplyTo":"RFC-cover-00.20-00000000000-20220610T011725Z-avarab@gmail.com","subject":"[RFC PATCH 05/20] git-submodule.sh: normalize parsing of --cached","fromName":"Ævar Arnfjörð Bjarmason","fromEmail":"avarab@gmail.com","sentAt":"2022-06-10T02:01:17Z","receivedAt":"2022-06-10T02:02:14Z","isPatch":true,"sender":{"key":"avarab@gmail.com","avatar":"https://avatars.githubusercontent.com/u/45301?v=4"},"body":"Remove the assignment of \"$1\" to the \"$cached\" variable. As seen in\nthe initial implementation in 70c7ac22de6 (Add git-submodule command,\n2007-05-26) we only need to keep track of if we've seen the --cached\noption. In 28f9af5d25e (git-submodule summary: code framework,\n2008-03-11) \"$1\" was assigned to it, but there was no reason to do\nso. Let's undo that.\n\nSigned-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>\n---\n git-submodule.sh | 4 ++--\n 1 file changed, 2 insertions(+), 2 deletions(-)\n\ndiff --git a/git-submodule.sh b/git-submodule.sh\nindex 1b0a31b8383..20fc1b620fa 100755\n--- a/git-submodule.sh\n+++ b/git-submodule.sh\n@@ -446,7 +446,7 @@ cmd_summary() {\n \tdo\n \t\tcase \"$1\" in\n \t\t--cached)\n-\t\t\tcached=\"$1\"\n+\t\t\tcached=1\n \t\t\t;;\n \t\t--files)\n \t\t\tfiles=\"$1\"\n@@ -575,7 +575,7 @@ do\n \t\tGIT_QUIET=1\n \t\t;;\n \t--cached)\n-\t\tcached=\"$1\"\n+\t\tcached=1\n \t\t;;\n \t--)\n \t\tbreak\n-- \n2.36.1.1178.gb5b1747c546\n\n"},{"id":"456990","messageId":"RFC-patch-06.20-b1ca1183885-20220610T011725Z-avarab@gmail.com","threadId":"57979","inReplyTo":"RFC-cover-00.20-00000000000-20220610T011725Z-avarab@gmail.com","subject":"[RFC PATCH 06/20] submodule--helper: rename \"absorb-git-dirs\" to \"absorbgitdirs\"","fromName":"Ævar Arnfjörð Bjarmason","fromEmail":"avarab@gmail.com","sentAt":"2022-06-10T02:01:18Z","receivedAt":"2022-06-10T02:02:17Z","isPatch":true,"sender":{"key":"avarab@gmail.com","avatar":"https://avatars.githubusercontent.com/u/45301?v=4"},"body":"Rename the \"absorb-git-dirs\" subcommand to \"absorbgitdirs\", which is\nwhat the \"git submodule\" command itself has called it since the\nsubcommand was implemented in f6f85861400 (submodule: add\nabsorb-git-dir function, 2016-12-12).\n\nHaving these two be different will make it more tedious to dispatch to\n\"git submodule--helper\" directly, so let's get rid of this needless\ninconsistency.\n\nSigned-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>\n---\n builtin/submodule--helper.c | 4 ++--\n git-submodule.sh            | 2 +-\n submodule.c                 | 2 +-\n 3 files changed, 4 insertions(+), 4 deletions(-)\n\ndiff --git a/builtin/submodule--helper.c b/builtin/submodule--helper.c\nindex 70693205764..8df1541baf8 100644\n--- a/builtin/submodule--helper.c\n+++ b/builtin/submodule--helper.c\n@@ -2784,7 +2784,7 @@ static int absorb_git_dirs(int argc, const char **argv, const char *prefix)\n \t};\n \n \tconst char *const git_submodule_helper_usage[] = {\n-\t\tN_(\"git submodule--helper absorb-git-dirs [<options>] [<path>...]\"),\n+\t\tN_(\"git submodule--helper absorbgitdirs [<options>] [<path>...]\"),\n \t\tNULL\n \t};\n \n@@ -3383,7 +3383,7 @@ static struct cmd_struct commands[] = {\n \t{\"deinit\", module_deinit},\n \t{\"summary\", module_summary},\n \t{\"push-check\", push_check},\n-\t{\"absorb-git-dirs\", absorb_git_dirs},\n+\t{\"absorbgitdirs\", absorb_git_dirs},\n \t{\"is-active\", is_active},\n \t{\"check-name\", check_name},\n \t{\"config\", module_config},\ndiff --git a/git-submodule.sh b/git-submodule.sh\nindex 20fc1b620fa..70258eaf38e 100755\n--- a/git-submodule.sh\n+++ b/git-submodule.sh\n@@ -556,7 +556,7 @@ cmd_sync()\n \n cmd_absorbgitdirs()\n {\n-\tgit submodule--helper absorb-git-dirs --prefix \"$wt_prefix\" \"$@\"\n+\tgit submodule--helper absorbgitdirs --prefix \"$wt_prefix\" \"$@\"\n }\n \n # This loop parses the command line arguments to find the\ndiff --git a/submodule.c b/submodule.c\nindex 7923e951e1c..9129cd564c8 100644\n--- a/submodule.c\n+++ b/submodule.c\n@@ -2374,7 +2374,7 @@ void absorb_git_dir_into_superproject(const char *path,\n \t\tcp.no_stdin = 1;\n \t\tstrvec_pushl(&cp.args, \"--super-prefix\", sb.buf,\n \t\t\t     \"submodule--helper\",\n-\t\t\t     \"absorb-git-dirs\", NULL);\n+\t\t\t     \"absorbgitdirs\", NULL);\n \t\tprepare_submodule_repo_env(&cp.env_array);\n \t\tif (run_command(&cp))\n \t\t\tdie(_(\"could not recurse into submodule '%s'\"), path);\n-- \n2.36.1.1178.gb5b1747c546\n\n"},{"id":"456991","messageId":"RFC-patch-07.20-9f5cfbb864a-20220610T011725Z-avarab@gmail.com","threadId":"57979","inReplyTo":"RFC-cover-00.20-00000000000-20220610T011725Z-avarab@gmail.com","subject":"[RFC PATCH 07/20] git-submodule.sh: create a \"case\" dispatch statement","fromName":"Ævar Arnfjörð Bjarmason","fromEmail":"avarab@gmail.com","sentAt":"2022-06-10T02:01:19Z","receivedAt":"2022-06-10T02:02:20Z","isPatch":true,"sender":{"key":"avarab@gmail.com","avatar":"https://avatars.githubusercontent.com/u/45301?v=4"},"body":"Create a \"case/esac\" dispatch statement at the end of git-submodule.sh\nand move the contents of the trivial cmd_absorbgitdirs() function to\nit.\n\nThis template will be expanded on in subsequent commits, but for now\nwe're moving the trivial \"git submodule absorb-git-dirs\" to it.\n\nSigned-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>\n---\n git-submodule.sh | 14 ++++++++------\n 1 file changed, 8 insertions(+), 6 deletions(-)\n\ndiff --git a/git-submodule.sh b/git-submodule.sh\nindex 70258eaf38e..fb13f818c63 100755\n--- a/git-submodule.sh\n+++ b/git-submodule.sh\n@@ -554,11 +554,6 @@ cmd_sync()\n \tgit ${wt_prefix:+-C \"$wt_prefix\"} submodule--helper sync ${GIT_QUIET:+--quiet} ${recursive:+--recursive} -- \"$@\"\n }\n \n-cmd_absorbgitdirs()\n-{\n-\tgit submodule--helper absorbgitdirs --prefix \"$wt_prefix\" \"$@\"\n-}\n-\n # This loop parses the command line arguments to find the\n # subcommand name to dispatch.  Parsing of the subcommand specific\n # options are primarily done by the subcommand implementations.\n@@ -607,4 +602,11 @@ then\n \tusage\n fi\n \n-\"cmd_$(echo $command | sed -e s/-/_/g)\" \"$@\"\n+case \"$command\" in\n+absorbgitdirs)\n+\tgit submodule--helper \"$command\" --prefix \"$wt_prefix\" \"$@\"\n+\t;;\n+*)\n+\t\"cmd_$(echo $command | sed -e s/-/_/g)\" \"$@\"\n+\t;;\n+esac\n-- \n2.36.1.1178.gb5b1747c546\n\n"},{"id":"456992","messageId":"RFC-patch-09.20-bd0e4a4f8b8-20220610T011725Z-avarab@gmail.com","threadId":"57979","inReplyTo":"RFC-cover-00.20-00000000000-20220610T011725Z-avarab@gmail.com","subject":"[RFC PATCH 09/20] git-submodule.sh: dispatch \"sync\" to helper","fromName":"Ævar Arnfjörð Bjarmason","fromEmail":"avarab@gmail.com","sentAt":"2022-06-10T02:01:21Z","receivedAt":"2022-06-10T02:02:23Z","isPatch":true,"sender":{"key":"avarab@gmail.com","avatar":"https://avatars.githubusercontent.com/u/45301?v=4"},"body":"Remove the cmd_sync() wrapper for \"git submodule--helper sync\" in\nfavor of dispatching the raw command-line directly to the helper.\n\nAt this point we've already parsed out the optional \"--quiet\" flag\nthat we need to support for \"git submodule --quiet\" (as opposed to\n\"git submodule <subcommand> --quiet\").\n\nThis changes the output we'll display on invalid usage for the better,\nbefore this we'd emit e.g.:\n\n\t$ git submodule sync --blah\n\tusage: git submodule [--quiet] [--cached]\n\t   or: [...many lines of \"or\" usage omitted...]\n\nBut now we'll emit the much more useful:\n\n\t$ git submodule sync --blah\n\terror: unknown option `blah'\n\tusage: git submodule sync [--quiet] [--recursive] [<path>]\n\n\t    -q, --quiet           suppress output of synchronizing submodule url\n\t    --recursive           recurse into nested submodules\n\nThis is because we'll now get as far as module_sync()'s failing call\nto parse_options() when we have invalid usage.\n\nSigned-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>\n---\n git-submodule.sh | 37 ++++---------------------------------\n 1 file changed, 4 insertions(+), 33 deletions(-)\n\ndiff --git a/git-submodule.sh b/git-submodule.sh\nindex fb13f818c63..ddc2e4e4032 100755\n--- a/git-submodule.sh\n+++ b/git-submodule.sh\n@@ -520,39 +520,6 @@ cmd_status()\n \n \tgit ${wt_prefix:+-C \"$wt_prefix\"} submodule--helper status ${GIT_QUIET:+--quiet} ${cached:+--cached} ${recursive:+--recursive} -- \"$@\"\n }\n-#\n-# Sync remote urls for submodules\n-# This makes the value for remote.$remote.url match the value\n-# specified in .gitmodules.\n-#\n-cmd_sync()\n-{\n-\twhile test $# -ne 0\n-\tdo\n-\t\tcase \"$1\" in\n-\t\t-q|--quiet)\n-\t\t\tGIT_QUIET=1\n-\t\t\tshift\n-\t\t\t;;\n-\t\t--recursive)\n-\t\t\trecursive=1\n-\t\t\tshift\n-\t\t\t;;\n-\t\t--)\n-\t\t\tshift\n-\t\t\tbreak\n-\t\t\t;;\n-\t\t-*)\n-\t\t\tusage\n-\t\t\t;;\n-\t\t*)\n-\t\t\tbreak\n-\t\t\t;;\n-\t\tesac\n-\tdone\n-\n-\tgit ${wt_prefix:+-C \"$wt_prefix\"} submodule--helper sync ${GIT_QUIET:+--quiet} ${recursive:+--recursive} -- \"$@\"\n-}\n \n # This loop parses the command line arguments to find the\n # subcommand name to dispatch.  Parsing of the subcommand specific\n@@ -606,6 +573,10 @@ case \"$command\" in\n absorbgitdirs)\n \tgit submodule--helper \"$command\" --prefix \"$wt_prefix\" \"$@\"\n \t;;\n+sync)\n+\tgit ${wt_prefix:+-C \"$wt_prefix\"} submodule--helper \"$command\" \\\n+\t\t${GIT_QUIET:+--quiet} \"$@\"\n+\t;;\n *)\n \t\"cmd_$(echo $command | sed -e s/-/_/g)\" \"$@\"\n \t;;\n-- \n2.36.1.1178.gb5b1747c546\n\n"},{"id":"456993","messageId":"RFC-patch-08.20-0c1a5063653-20220610T011725Z-avarab@gmail.com","threadId":"57979","inReplyTo":"RFC-cover-00.20-00000000000-20220610T011725Z-avarab@gmail.com","subject":"[RFC PATCH 08/20] submodule--helper: pretend to be \"git submodule\" in \"-h\" output","fromName":"Ævar Arnfjörð Bjarmason","fromEmail":"avarab@gmail.com","sentAt":"2022-06-10T02:01:20Z","receivedAt":"2022-06-10T02:02:27Z","isPatch":true,"sender":{"key":"avarab@gmail.com","avatar":"https://avatars.githubusercontent.com/u/45301?v=4"},"body":"Change the usage output for \"git submodule--helper\" so that it will\npretend to be named \"git submodule\". This will allow us to dispatch\nfurther into \"git submodule--helper\" from git-submodule.sh while\nemitting the correct usage output.\n\nThis fixes a bug that's been there ever since \"git submodule\nabsorbgitdirs\" was added in f6f85861400 (submodule: add absorb-git-dir\nfunction, 2016-12-12). Before this we'd emit e.g. this on invalid\nusage:\n\n\t$ git submodule absorbgitdirs --blah\n\terror: unknown option `blah'\n\tusage: git submodule--helper absorbgitdirs [<options>] [<path>...]\n\nNow we'll emit the same, except that the usage line is now referring\nto the correct command run by the user:\n\n\tusage: git submodule absorbgitdirs [<options>] [<path>...]\n\t[.. same usage output ...]\n\nNote that in the case of \"status\", \"deinit\" and \"update\" we were\nalready referring to ourselves as \"git submodule\" in\nbuiltin/submodule--helper.c.\n\nSigned-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>\n---\n builtin/submodule--helper.c | 32 ++++++++++++++++----------------\n 1 file changed, 16 insertions(+), 16 deletions(-)\n\ndiff --git a/builtin/submodule--helper.c b/builtin/submodule--helper.c\nindex 8df1541baf8..3173295ed8e 100644\n--- a/builtin/submodule--helper.c\n+++ b/builtin/submodule--helper.c\n@@ -286,7 +286,7 @@ static int module_list(int argc, const char **argv, const char *prefix)\n \t};\n \n \tconst char *const git_submodule_helper_usage[] = {\n-\t\tN_(\"git submodule--helper list [--prefix=<path>] [<path>...]\"),\n+\t\tN_(\"git submodule list [--prefix=<path>] [<path>...]\"),\n \t\tNULL\n \t};\n \n@@ -444,7 +444,7 @@ static int module_foreach(int argc, const char **argv, const char *prefix)\n \t};\n \n \tconst char *const git_submodule_helper_usage[] = {\n-\t\tN_(\"git submodule--helper foreach [--quiet] [--recursive] [--] <command>\"),\n+\t\tN_(\"git submodule foreach [--quiet] [--recursive] [--] <command>\"),\n \t\tNULL\n \t};\n \n@@ -582,7 +582,7 @@ static int module_init(int argc, const char **argv, const char *prefix)\n \t};\n \n \tconst char *const git_submodule_helper_usage[] = {\n-\t\tN_(\"git submodule--helper init [<options>] [<path>]\"),\n+\t\tN_(\"git submodule init [<options>] [<path>]\"),\n \t\tNULL\n \t};\n \n@@ -786,7 +786,7 @@ static int module_name(int argc, const char **argv, const char *prefix)\n \tconst struct submodule *sub;\n \n \tif (argc != 2)\n-\t\tusage(_(\"git submodule--helper name <path>\"));\n+\t\tusage(_(\"git submodule name <path>\"));\n \n \tsub = submodule_from_path(the_repository, null_oid(), argv[1]);\n \n@@ -1185,7 +1185,7 @@ static int module_summary(int argc, const char **argv, const char *prefix)\n \t};\n \n \tconst char *const git_submodule_helper_usage[] = {\n-\t\tN_(\"git submodule--helper summary [<options>] [<commit>] [--] [<path>]\"),\n+\t\tN_(\"git submodule summary [<options>] [<commit>] [--] [<path>]\"),\n \t\tNULL\n \t};\n \n@@ -1349,7 +1349,7 @@ static int module_sync(int argc, const char **argv, const char *prefix)\n \t};\n \n \tconst char *const git_submodule_helper_usage[] = {\n-\t\tN_(\"git submodule--helper sync [--quiet] [--recursive] [<path>]\"),\n+\t\tN_(\"git submodule sync [--quiet] [--recursive] [<path>]\"),\n \t\tNULL\n \t};\n \n@@ -1789,7 +1789,7 @@ static int module_clone(int argc, const char **argv, const char *prefix)\n \t};\n \n \tconst char *const git_submodule_helper_usage[] = {\n-\t\tN_(\"git submodule--helper clone [--prefix=<path>] [--quiet] \"\n+\t\tN_(\"git submodule clone [--prefix=<path>] [--quiet] \"\n \t\t   \"[--reference <repository>] [--name <name>] [--depth <depth>] \"\n \t\t   \"[--single-branch] [--filter <filter-spec>] \"\n \t\t   \"--url <url> --path <path>\"),\n@@ -2784,7 +2784,7 @@ static int absorb_git_dirs(int argc, const char **argv, const char *prefix)\n \t};\n \n \tconst char *const git_submodule_helper_usage[] = {\n-\t\tN_(\"git submodule--helper absorbgitdirs [<options>] [<path>...]\"),\n+\t\tN_(\"git submodule absorbgitdirs [<options>] [<path>...]\"),\n \t\tNULL\n \t};\n \n@@ -2848,9 +2848,9 @@ static int module_config(int argc, const char **argv, const char *prefix)\n \t\tOPT_END()\n \t};\n \tconst char *const git_submodule_helper_usage[] = {\n-\t\tN_(\"git submodule--helper config <name> [<value>]\"),\n-\t\tN_(\"git submodule--helper config --unset <name>\"),\n-\t\t\"git submodule--helper config --check-writeable\",\n+\t\tN_(\"git submodule config <name> [<value>]\"),\n+\t\tN_(\"git submodule config --unset <name>\"),\n+\t\t\"git submodule config --check-writeable\",\n \t\tNULL\n \t};\n \n@@ -2889,7 +2889,7 @@ static int module_set_url(int argc, const char **argv, const char *prefix)\n \t\tOPT_END()\n \t};\n \tconst char *const usage[] = {\n-\t\tN_(\"git submodule--helper set-url [--quiet] <path> <newurl>\"),\n+\t\tN_(\"git submodule set-url [--quiet] <path> <newurl>\"),\n \t\tNULL\n \t};\n \n@@ -2928,8 +2928,8 @@ static int module_set_branch(int argc, const char **argv, const char *prefix)\n \t\tOPT_END()\n \t};\n \tconst char *const usage[] = {\n-\t\tN_(\"git submodule--helper set-branch [-q|--quiet] (-d|--default) <path>\"),\n-\t\tN_(\"git submodule--helper set-branch [-q|--quiet] (-b|--branch) <branch> <path>\"),\n+\t\tN_(\"git submodule set-branch [-q|--quiet] (-d|--default) <path>\"),\n+\t\tN_(\"git submodule set-branch [-q|--quiet] (-b|--branch) <branch> <path>\"),\n \t\tNULL\n \t};\n \n@@ -2970,7 +2970,7 @@ static int module_create_branch(int argc, const char **argv, const char *prefix)\n \t\tOPT_END()\n \t};\n \tconst char *const usage[] = {\n-\t\tN_(\"git submodule--helper create-branch [-f|--force] [--create-reflog] [-q|--quiet] [-t|--track] [-n|--dry-run] <name> <start-oid> <start-name>\"),\n+\t\tN_(\"git submodule create-branch [-f|--force] [--create-reflog] [-q|--quiet] [-t|--track] [-n|--dry-run] <name> <start-oid> <start-name>\"),\n \t\tNULL\n \t};\n \n@@ -3273,7 +3273,7 @@ static int module_add(int argc, const char **argv, const char *prefix)\n \t};\n \n \tconst char *const usage[] = {\n-\t\tN_(\"git submodule--helper add [<options>] [--] <repository> [<path>]\"),\n+\t\tN_(\"git submodule add [<options>] [--] <repository> [<path>]\"),\n \t\tNULL\n \t};\n \n-- \n2.36.1.1178.gb5b1747c546\n\n"},{"id":"456994","messageId":"RFC-patch-10.20-498a1fd275b-20220610T011725Z-avarab@gmail.com","threadId":"57979","inReplyTo":"RFC-cover-00.20-00000000000-20220610T011725Z-avarab@gmail.com","subject":"[RFC PATCH 10/20] git-submodule.sh: dispatch directly to helper","fromName":"Ævar Arnfjörð Bjarmason","fromEmail":"avarab@gmail.com","sentAt":"2022-06-10T02:01:22Z","receivedAt":"2022-06-10T02:02:29Z","isPatch":true,"sender":{"key":"avarab@gmail.com","avatar":"https://avatars.githubusercontent.com/u/45301?v=4"},"body":"Change the dispatching logic in \"git-submodule.sh\" for the \"add\",\n\"init\", \"deinit\", \"set-branch\", \"set-url\", \"summary\" and \"status\"\nsub-commands to do away with the argument parsing in git-submodule.sh,\nand instead dispatch directly to \"git submodule--helper\".\n\nAs in a preceding commit the only functional change here should be\nthat on invalid options we'll now emit more targeted \"-h\" output.\n\nThe isnumber() helper function was only used in the now-removed\ncmd_summary(), the same goes for the $files variable. The $custom_name\nand $branch variables were only used in cmd_add().\n\nSince there are no dashed commands anymore in git-submodule.sh we can\nget rid of the \"$(echo | sed ...)\" one-liner to change e.g. \"set-url\"\nto \"set_url\".\n\nSigned-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>\n---\n git-submodule.sh | 321 +----------------------------------------------\n 1 file changed, 5 insertions(+), 316 deletions(-)\n\ndiff --git a/git-submodule.sh b/git-submodule.sh\nindex ddc2e4e4032..61e4f17b805 100755\n--- a/git-submodule.sh\n+++ b/git-submodule.sh\n@@ -30,18 +30,15 @@ GIT_PROTOCOL_FROM_USER=0\n export GIT_PROTOCOL_FROM_USER\n \n command=\n-branch=\n force=\n reference=\n cached=\n recursive=\n init=\n require_init=\n-files=\n remote=\n nofetch=\n update=\n-custom_name=\n depth=\n progress=\n dissociate=\n@@ -50,86 +47,7 @@ jobs=\n recommend_shallow=\n filter=\n \n-isnumber()\n-{\n-\tn=$(($1 + 0)) 2>/dev/null && test \"$n\" = \"$1\"\n-}\n-\n-#\n-# Add a new submodule to the working tree, .gitmodules and the index\n-#\n-# $@ = repo path\n-#\n-# optional branch is stored in global branch variable\n-#\n-cmd_add()\n-{\n-\t# parse $args after \"submodule ... add\".\n-\treference_path=\n-\twhile test $# -ne 0\n-\tdo\n-\t\tcase \"$1\" in\n-\t\t-b | --branch)\n-\t\t\tcase \"$2\" in '') usage ;; esac\n-\t\t\tbranch=$2\n-\t\t\tshift\n-\t\t\t;;\n-\t\t-f | --force)\n-\t\t\tforce=$1\n-\t\t\t;;\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-\t\t\tshift\n-\t\t\t;;\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-\t\t\tshift\n-\t\t\t;;\n-\t\t--depth)\n-\t\t\tcase \"$2\" in '') usage ;; esac\n-\t\t\tdepth=\"--depth=$2\"\n-\t\t\tshift\n-\t\t\t;;\n-\t\t--depth=*)\n-\t\t\tdepth=$1\n-\t\t\t;;\n-\t\t--)\n-\t\t\tshift\n-\t\t\tbreak\n-\t\t\t;;\n-\t\t-*)\n-\t\t\tusage\n-\t\t\t;;\n-\t\t*)\n-\t\t\tbreak\n-\t\t\t;;\n-\t\tesac\n-\t\tshift\n-\tdone\n-\n-\tif test -z \"$1\"\n-\tthen\n-\t\tusage\n-\tfi\n-\n-\tgit ${wt_prefix:+-C \"$wt_prefix\"} submodule--helper add ${GIT_QUIET:+--quiet} ${force:+--force} ${progress:+\"--progress\"} ${branch:+--branch \"$branch\"} ${reference_path:+--reference \"$reference_path\"} ${dissociate:+--dissociate} ${custom_name:+--name \"$custom_name\"} ${depth:+\"$depth\"} -- \"$@\"\n-}\n \n-#\n # Execute an arbitrary command sequence in each checked out\n # submodule\n #\n@@ -160,73 +78,6 @@ cmd_foreach()\n \tgit ${wt_prefix:+-C \"$wt_prefix\"} submodule--helper foreach ${GIT_QUIET:+--quiet} ${recursive:+--recursive} -- \"$@\"\n }\n \n-#\n-# Register submodules in .git/config\n-#\n-# $@ = requested paths (default to all)\n-#\n-cmd_init()\n-{\n-\t# parse $args after \"submodule ... init\".\n-\twhile test $# -ne 0\n-\tdo\n-\t\tcase \"$1\" in\n-\t\t-q|--quiet)\n-\t\t\tGIT_QUIET=1\n-\t\t\t;;\n-\t\t--)\n-\t\t\tshift\n-\t\t\tbreak\n-\t\t\t;;\n-\t\t-*)\n-\t\t\tusage\n-\t\t\t;;\n-\t\t*)\n-\t\t\tbreak\n-\t\t\t;;\n-\t\tesac\n-\t\tshift\n-\tdone\n-\n-\tgit ${wt_prefix:+-C \"$wt_prefix\"} submodule--helper init ${GIT_QUIET:+--quiet} -- \"$@\"\n-}\n-\n-#\n-# Unregister submodules from .git/config and remove their work tree\n-#\n-cmd_deinit()\n-{\n-\t# parse $args after \"submodule ... deinit\".\n-\tdeinit_all=\n-\twhile test $# -ne 0\n-\tdo\n-\t\tcase \"$1\" in\n-\t\t-f|--force)\n-\t\t\tforce=$1\n-\t\t\t;;\n-\t\t-q|--quiet)\n-\t\t\tGIT_QUIET=1\n-\t\t\t;;\n-\t\t--all)\n-\t\t\tdeinit_all=t\n-\t\t\t;;\n-\t\t--)\n-\t\t\tshift\n-\t\t\tbreak\n-\t\t\t;;\n-\t\t-*)\n-\t\t\tusage\n-\t\t\t;;\n-\t\t*)\n-\t\t\tbreak\n-\t\t\t;;\n-\t\tesac\n-\t\tshift\n-\tdone\n-\n-\tgit ${wt_prefix:+-C \"$wt_prefix\"} submodule--helper deinit ${GIT_QUIET:+--quiet} ${force:+--force} ${deinit_all:+--all} -- \"$@\"\n-}\n-\n #\n # Update each submodule path to correct revision, using clone and checkout as needed\n #\n@@ -359,168 +210,6 @@ cmd_update()\n \t\t\"$@\"\n }\n \n-#\n-# Configures a submodule's default branch\n-#\n-# $@ = requested path\n-#\n-cmd_set_branch() {\n-\tdefault=\n-\tbranch=\n-\n-\twhile test $# -ne 0\n-\tdo\n-\t\tcase \"$1\" in\n-\t\t-q|--quiet)\n-\t\t\t# we don't do anything with this but we need to accept it\n-\t\t\t;;\n-\t\t-d|--default)\n-\t\t\tdefault=1\n-\t\t\t;;\n-\t\t-b|--branch)\n-\t\t\tcase \"$2\" in '') usage ;; esac\n-\t\t\tbranch=$2\n-\t\t\tshift\n-\t\t\t;;\n-\t\t--)\n-\t\t\tshift\n-\t\t\tbreak\n-\t\t\t;;\n-\t\t-*)\n-\t\t\tusage\n-\t\t\t;;\n-\t\t*)\n-\t\t\tbreak\n-\t\t\t;;\n-\t\tesac\n-\t\tshift\n-\tdone\n-\n-\tgit ${wt_prefix:+-C \"$wt_prefix\"} submodule--helper set-branch ${GIT_QUIET:+--quiet} ${branch:+--branch \"$branch\"} ${default:+--default} -- \"$@\"\n-}\n-\n-#\n-# Configures a submodule's remote url\n-#\n-# $@ = requested path, requested url\n-#\n-cmd_set_url() {\n-\twhile test $# -ne 0\n-\tdo\n-\t\tcase \"$1\" in\n-\t\t-q|--quiet)\n-\t\t\tGIT_QUIET=1\n-\t\t\t;;\n-\t\t--)\n-\t\t\tshift\n-\t\t\tbreak\n-\t\t\t;;\n-\t\t-*)\n-\t\t\tusage\n-\t\t\t;;\n-\t\t*)\n-\t\t\tbreak\n-\t\t\t;;\n-\t\tesac\n-\t\tshift\n-\tdone\n-\n-\tgit ${wt_prefix:+-C \"$wt_prefix\"} submodule--helper set-url ${GIT_QUIET:+--quiet} -- \"$@\"\n-}\n-\n-#\n-# Show commit summary for submodules in index or working tree\n-#\n-# If '--cached' is given, show summary between index and given commit,\n-# or between working tree and given commit\n-#\n-# $@ = [commit (default 'HEAD'),] requested paths (default all)\n-#\n-cmd_summary() {\n-\tsummary_limit=-1\n-\tfor_status=\n-\tdiff_cmd=diff-index\n-\n-\t# parse $args after \"submodule ... summary\".\n-\twhile test $# -ne 0\n-\tdo\n-\t\tcase \"$1\" in\n-\t\t--cached)\n-\t\t\tcached=1\n-\t\t\t;;\n-\t\t--files)\n-\t\t\tfiles=\"$1\"\n-\t\t\t;;\n-\t\t--for-status)\n-\t\t\tfor_status=\"$1\"\n-\t\t\t;;\n-\t\t-n|--summary-limit)\n-\t\t\tsummary_limit=\"$2\"\n-\t\t\tisnumber \"$summary_limit\" || usage\n-\t\t\tshift\n-\t\t\t;;\n-\t\t--summary-limit=*)\n-\t\t\tsummary_limit=\"${1#--summary-limit=}\"\n-\t\t\tisnumber \"$summary_limit\" || usage\n-\t\t\t;;\n-\t\t--)\n-\t\t\tshift\n-\t\t\tbreak\n-\t\t\t;;\n-\t\t-*)\n-\t\t\tusage\n-\t\t\t;;\n-\t\t*)\n-\t\t\tbreak\n-\t\t\t;;\n-\t\tesac\n-\t\tshift\n-\tdone\n-\n-\tgit ${wt_prefix:+-C \"$wt_prefix\"} submodule--helper summary ${files:+--files} ${cached:+--cached} ${for_status:+--for-status} ${summary_limit:+-n $summary_limit} -- \"$@\"\n-}\n-#\n-# List all submodules, prefixed with:\n-#  - submodule not initialized\n-#  + different revision checked out\n-#\n-# If --cached was specified the revision in the index will be printed\n-# instead of the currently checked out revision.\n-#\n-# $@ = requested paths (default to all)\n-#\n-cmd_status()\n-{\n-\t# parse $args after \"submodule ... status\".\n-\twhile test $# -ne 0\n-\tdo\n-\t\tcase \"$1\" in\n-\t\t-q|--quiet)\n-\t\t\tGIT_QUIET=1\n-\t\t\t;;\n-\t\t--cached)\n-\t\t\tcached=1\n-\t\t\t;;\n-\t\t--recursive)\n-\t\t\trecursive=1\n-\t\t\t;;\n-\t\t--)\n-\t\t\tshift\n-\t\t\tbreak\n-\t\t\t;;\n-\t\t-*)\n-\t\t\tusage\n-\t\t\t;;\n-\t\t*)\n-\t\t\tbreak\n-\t\t\t;;\n-\t\tesac\n-\t\tshift\n-\tdone\n-\n-\tgit ${wt_prefix:+-C \"$wt_prefix\"} submodule--helper status ${GIT_QUIET:+--quiet} ${cached:+--cached} ${recursive:+--recursive} -- \"$@\"\n-}\n-\n # This loop parses the command line arguments to find the\n # subcommand name to dispatch.  Parsing of the subcommand specific\n # options are primarily done by the subcommand implementations.\n@@ -573,11 +262,11 @@ case \"$command\" in\n absorbgitdirs)\n \tgit submodule--helper \"$command\" --prefix \"$wt_prefix\" \"$@\"\n \t;;\n-sync)\n-\tgit ${wt_prefix:+-C \"$wt_prefix\"} submodule--helper \"$command\" \\\n-\t\t${GIT_QUIET:+--quiet} \"$@\"\n+foreach | update)\n+\t\"cmd_$command\" \"$@\"\n \t;;\n-*)\n-\t\"cmd_$(echo $command | sed -e s/-/_/g)\" \"$@\"\n+add | init | deinit | set-branch | set-url | status | summary | sync)\n+\tgit ${wt_prefix:+-C \"$wt_prefix\"} submodule--helper \"$command\" \\\n+\t\t${GIT_QUIET:+--quiet} ${cached:+--cached} \"$@\"\n \t;;\n esac\n-- \n2.36.1.1178.gb5b1747c546\n\n"},{"id":"456995","messageId":"RFC-patch-12.20-57b9df29ea6-20220610T011725Z-avarab@gmail.com","threadId":"57979","inReplyTo":"RFC-cover-00.20-00000000000-20220610T011725Z-avarab@gmail.com","subject":"[RFC PATCH 12/20] submodule--helper: have --require-init imply --init","fromName":"Ævar Arnfjörð Bjarmason","fromEmail":"avarab@gmail.com","sentAt":"2022-06-10T02:01:24Z","receivedAt":"2022-06-10T02:02:31Z","isPatch":true,"sender":{"key":"avarab@gmail.com","avatar":"https://avatars.githubusercontent.com/u/45301?v=4"},"body":"Adjust code added in 0060fd1511b (clone --recurse-submodules: prevent\nname squatting on Windows, 2019-09-12) to have the internal\n--require-init option imply --init, rather than having\n\"git-submodule.sh\" add it implicitly.\n\nSigned-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>\n---\n builtin/submodule--helper.c | 5 ++++-\n git-submodule.sh            | 1 -\n 2 files changed, 4 insertions(+), 2 deletions(-)\n\ndiff --git a/builtin/submodule--helper.c b/builtin/submodule--helper.c\nindex 459260efc65..f1f5c6b84c6 100644\n--- a/builtin/submodule--helper.c\n+++ b/builtin/submodule--helper.c\n@@ -2619,7 +2619,7 @@ static int module_update(int argc, const char **argv, const char *prefix)\n \t\tOPT_BOOL(0, \"progress\", &opt.progress,\n \t\t\t    N_(\"force cloning progress\")),\n \t\tOPT_BOOL(0, \"require-init\", &opt.require_init,\n-\t\t\t   N_(\"disallow cloning into non-empty directory\")),\n+\t\t\t   N_(\"disallow cloning into non-empty directory, implies --init\")),\n \t\tOPT_BOOL(0, \"single-branch\", &opt.single_branch,\n \t\t\t N_(\"clone only one branch, HEAD or --branch\")),\n \t\tOPT_PARSE_LIST_OBJECTS_FILTER(&filter_options),\n@@ -2643,6 +2643,9 @@ static int module_update(int argc, const char **argv, const char *prefix)\n \targc = parse_options(argc, argv, prefix, module_update_options,\n \t\t\t     git_submodule_helper_usage, 0);\n \n+\tif (opt.require_init)\n+\t\topt.init = 1;\n+\n \tif (filter_options.choice && !opt.init) {\n \t\tusage_with_options(git_submodule_helper_usage,\n \t\t\t\t   module_update_options);\ndiff --git a/git-submodule.sh b/git-submodule.sh\nindex de6c71d6bd5..43fe3bcb00b 100755\n--- a/git-submodule.sh\n+++ b/git-submodule.sh\n@@ -71,7 +71,6 @@ cmd_update()\n \t\t\tinit=1\n \t\t\t;;\n \t\t--require-init)\n-\t\t\tinit=1\n \t\t\trequire_init=1\n \t\t\t;;\n \t\t--remote)\n-- \n2.36.1.1178.gb5b1747c546\n\n"},{"id":"456996","messageId":"RFC-patch-11.20-625320e13b9-20220610T011725Z-avarab@gmail.com","threadId":"57979","inReplyTo":"RFC-cover-00.20-00000000000-20220610T011725Z-avarab@gmail.com","subject":"[RFC PATCH 11/20] git-submodule.sh: dispatch \"foreach\" to helper","fromName":"Ævar Arnfjörð Bjarmason","fromEmail":"avarab@gmail.com","sentAt":"2022-06-10T02:01:23Z","receivedAt":"2022-06-10T02:02:34Z","isPatch":true,"sender":{"key":"avarab@gmail.com","avatar":"https://avatars.githubusercontent.com/u/45301?v=4"},"body":"Dispatch the \"git submodule foreach\" command directly to \"git\nsubmodule--helper foreach\". This case requires the addition of the\nPARSE_OPT_STOP_AT_NON_OPTION flag, since the shellscript was\nunconditionally adding \"--\" to the \"git submodule--helper\"\ncommand-line.\n\nSigned-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>\n---\n builtin/submodule--helper.c |  3 ++-\n git-submodule.sh            | 37 +++----------------------------------\n 2 files changed, 5 insertions(+), 35 deletions(-)\n\ndiff --git a/builtin/submodule--helper.c b/builtin/submodule--helper.c\nindex 3173295ed8e..459260efc65 100644\n--- a/builtin/submodule--helper.c\n+++ b/builtin/submodule--helper.c\n@@ -449,7 +449,8 @@ static int module_foreach(int argc, const char **argv, const char *prefix)\n \t};\n \n \targc = parse_options(argc, argv, prefix, module_foreach_options,\n-\t\t\t     git_submodule_helper_usage, 0);\n+\t\t\t     git_submodule_helper_usage,\n+\t\t\t     PARSE_OPT_STOP_AT_NON_OPTION);\n \n \tif (module_list_compute(0, NULL, prefix, &pathspec, &list) < 0)\n \t\treturn 1;\ndiff --git a/git-submodule.sh b/git-submodule.sh\nindex 61e4f17b805..de6c71d6bd5 100755\n--- a/git-submodule.sh\n+++ b/git-submodule.sh\n@@ -47,37 +47,6 @@ jobs=\n recommend_shallow=\n filter=\n \n-\n-# Execute an arbitrary command sequence in each checked out\n-# submodule\n-#\n-# $@ = command to execute\n-#\n-cmd_foreach()\n-{\n-\t# parse $args after \"submodule ... foreach\".\n-\twhile test $# -ne 0\n-\tdo\n-\t\tcase \"$1\" in\n-\t\t-q|--quiet)\n-\t\t\tGIT_QUIET=1\n-\t\t\t;;\n-\t\t--recursive)\n-\t\t\trecursive=1\n-\t\t\t;;\n-\t\t-*)\n-\t\t\tusage\n-\t\t\t;;\n-\t\t*)\n-\t\t\tbreak\n-\t\t\t;;\n-\t\tesac\n-\t\tshift\n-\tdone\n-\n-\tgit ${wt_prefix:+-C \"$wt_prefix\"} submodule--helper foreach ${GIT_QUIET:+--quiet} ${recursive:+--recursive} -- \"$@\"\n-}\n-\n #\n # Update each submodule path to correct revision, using clone and checkout as needed\n #\n@@ -262,10 +231,10 @@ case \"$command\" in\n absorbgitdirs)\n \tgit submodule--helper \"$command\" --prefix \"$wt_prefix\" \"$@\"\n \t;;\n-foreach | update)\n-\t\"cmd_$command\" \"$@\"\n+update)\n+\tcmd_update \"$@\"\n \t;;\n-add | init | deinit | set-branch | set-url | status | summary | sync)\n+add | foreach | init | deinit | set-branch | set-url | status | summary | sync)\n \tgit ${wt_prefix:+-C \"$wt_prefix\"} submodule--helper \"$command\" \\\n \t\t${GIT_QUIET:+--quiet} ${cached:+--cached} \"$@\"\n \t;;\n-- \n2.36.1.1178.gb5b1747c546\n\n"},{"id":"456997","messageId":"RFC-patch-15.20-0c388eed1d1-20220610T011725Z-avarab@gmail.com","threadId":"57979","inReplyTo":"RFC-cover-00.20-00000000000-20220610T011725Z-avarab@gmail.com","subject":"[RFC PATCH 15/20] submodule--helper: understand -v option for \"update\"","fromName":"Ævar Arnfjörð Bjarmason","fromEmail":"avarab@gmail.com","sentAt":"2022-06-10T02:01:27Z","receivedAt":"2022-06-10T02:02:36Z","isPatch":true,"sender":{"key":"avarab@gmail.com","avatar":"https://avatars.githubusercontent.com/u/45301?v=4"},"body":"Change the \"OPT__QUIET()\" in module_update() to use OPT__VERBOSITY()\ninstead. This is in preparation for passing the command in\n\"git-submodule.sh\" to \"git submodule update\" directly.\n\nNote that this implementation supports the \"--verbose\" synonym for\n\"-v\", but \"git-submodule.sh\" does not. Once we make the switch to\ncalling \"git submodule--helper update\" directly we should update the\ndocumentation to reflect that.\n\nSigned-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>\n---\n builtin/submodule--helper.c | 8 ++++++--\n 1 file changed, 6 insertions(+), 2 deletions(-)\n\ndiff --git a/builtin/submodule--helper.c b/builtin/submodule--helper.c\nindex 64d7c5d7ba4..94126bcca07 100644\n--- a/builtin/submodule--helper.c\n+++ b/builtin/submodule--helper.c\n@@ -2584,6 +2584,7 @@ static int module_update(int argc, const char **argv, const char *prefix)\n \tstruct list_objects_filter_options filter_options;\n \tint ret;\n \tenum submodule_update_type update_type = SM_UPDATE_UNSPECIFIED;\n+\tint verbosity = 0;\n \n \tstruct option module_update_options[] = {\n \t\tOPT__FORCE(&opt.force, N_(\"force checkout updates\"), 0),\n@@ -2625,7 +2626,7 @@ static int module_update(int argc, const char **argv, const char *prefix)\n \t\t\t    N_(\"parallel jobs\")),\n \t\tOPT_BOOL(0, \"recommend-shallow\", &opt.recommend_shallow,\n \t\t\t    N_(\"whether the initial clone should follow the shallow recommendation\")),\n-\t\tOPT__QUIET(&opt.quiet, N_(\"don't print cloning progress\")),\n+\t\tOPT__VERBOSITY(&verbosity),\n \t\tOPT_BOOL(0, \"progress\", &opt.progress,\n \t\t\t    N_(\"force cloning progress\")),\n \t\tOPT_BOOL(0, \"require-init\", &opt.require_init,\n@@ -2637,7 +2638,7 @@ static int module_update(int argc, const char **argv, const char *prefix)\n \t};\n \n \tconst char *const git_submodule_helper_usage[] = {\n-\t\tN_(\"git submodule [--quiet] update\"\n+\t\tN_(\"git submodule [--quiet] update [-v | --verbose]\"\n \t\t\" [--init [--filter=<filter-spec>]] [--remote]\"\n \t\t\" [-N|--no-fetch] [-f|--force]\"\n \t\t\" [--checkout|--merge|--rebase]\"\n@@ -2656,6 +2657,9 @@ static int module_update(int argc, const char **argv, const char *prefix)\n \tif (opt.require_init)\n \t\topt.init = 1;\n \n+\tif (verbosity < 0)\n+\t\topt.quiet = 1;\n+\n \tif (filter_options.choice && !opt.init) {\n \t\tusage_with_options(git_submodule_helper_usage,\n \t\t\t\t   module_update_options);\n-- \n2.36.1.1178.gb5b1747c546\n\n"},{"id":"456998","messageId":"RFC-patch-14.20-1cb40a5f42e-20220610T011725Z-avarab@gmail.com","threadId":"57979","inReplyTo":"RFC-cover-00.20-00000000000-20220610T011725Z-avarab@gmail.com","subject":"[RFC PATCH 14/20] git-submodule doc: document the -v\" option to \"update\"","fromName":"Ævar Arnfjörð Bjarmason","fromEmail":"avarab@gmail.com","sentAt":"2022-06-10T02:01:26Z","receivedAt":"2022-06-10T02:02:37Z","isPatch":true,"sender":{"key":"avarab@gmail.com","avatar":"https://avatars.githubusercontent.com/u/45301?v=4"},"body":"In e84c3cf3dc3 (git-submodule.sh: accept verbose flag in cmd_update to\nbe non-quiet, 2018-08-14) the \"git submodule update\" sub-command was\nmade to understand \"-v\" for \"don't be quiet\" (but not\n\"--verbose\"). Let's update the documentation to reflect this.\n\nSigned-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>\n---\n Documentation/git-submodule.txt | 7 +++++--\n git-submodule.sh                | 2 +-\n 2 files changed, 6 insertions(+), 3 deletions(-)\n\ndiff --git a/Documentation/git-submodule.txt b/Documentation/git-submodule.txt\nindex 4d3ab6b9f92..5f1c552110e 100644\n--- a/Documentation/git-submodule.txt\n+++ b/Documentation/git-submodule.txt\n@@ -14,7 +14,7 @@ SYNOPSIS\n 'git submodule' [--quiet] status [--cached] [--recursive] [--] [<path>...]\n 'git submodule' [--quiet] init [--] [<path>...]\n 'git submodule' [--quiet] deinit [-f|--force] (--all|[--] <path>...)\n-'git submodule' [--quiet] update [<options>] [--] [<path>...]\n+'git submodule' [--quiet] update [-v] [<options>] [--] [<path>...]\n 'git submodule' [--quiet] set-branch [<options>] [--] <path>\n 'git submodule' [--quiet] set-url [--] <path> <newurl>\n 'git submodule' [--quiet] summary [<options>] [--] [<path>...]\n@@ -133,7 +133,7 @@ If you really want to remove a submodule from the repository and commit\n that use linkgit:git-rm[1] instead. See linkgit:gitsubmodules[7] for removal\n options.\n \n-update [--init] [--remote] [-N|--no-fetch] [--[no-]recommend-shallow] [-f|--force] [--checkout|--rebase|--merge] [--reference <repository>] [--depth <depth>] [--recursive] [--jobs <n>] [--[no-]single-branch] [--filter <filter spec>] [--] [<path>...]::\n+update [-v] [--init] [--remote] [-N|--no-fetch] [--[no-]recommend-shallow] [-f|--force] [--checkout|--rebase|--merge] [--reference <repository>] [--depth <depth>] [--recursive] [--jobs <n>] [--[no-]single-branch] [--filter <filter spec>] [--] [<path>...]::\n +\n --\n Update the registered submodules to match what the superproject\n@@ -270,6 +270,9 @@ OPTIONS\n --quiet::\n \tOnly print error messages.\n \n+-v::\n+\tDon't be quiet. This option is only valid for the update command.\n+\n --progress::\n \tThis option is only valid for add and update commands.\n \tProgress status is reported on the standard error stream\ndiff --git a/git-submodule.sh b/git-submodule.sh\nindex d8abdd8e8ad..1929c34ae8b 100755\n--- a/git-submodule.sh\n+++ b/git-submodule.sh\n@@ -10,7 +10,7 @@ USAGE=\"[--quiet] [--cached]\n    or: $dashless [--quiet] status [--cached] [--recursive] [--] [<path>...]\n    or: $dashless [--quiet] init [--] [<path>...]\n    or: $dashless [--quiet] deinit [-f|--force] (--all| [--] <path>...)\n-   or: $dashless [--quiet] update [--init [--filter=<filter-spec>]] [--remote] [-N|--no-fetch] [-f|--force] [--checkout|--merge|--rebase] [--[no-]recommend-shallow] [--reference <repository>] [--recursive] [--[no-]single-branch] [--] [<path>...]\n+   or: $dashless [--quiet] update [-v] [--init [--filter=<filter-spec>]] [--remote] [-N|--no-fetch] [-f|--force] [--checkout|--merge|--rebase] [--[no-]recommend-shallow] [--reference <repository>] [--recursive] [--[no-]single-branch] [--] [<path>...]\n    or: $dashless [--quiet] set-branch (--default|--branch <branch>) [--] <path>\n    or: $dashless [--quiet] set-url [--] <path> <newurl>\n    or: $dashless [--quiet] summary [--cached|--files] [--summary-limit <n>] [commit] [--] [<path>...]\n-- \n2.36.1.1178.gb5b1747c546\n\n"},{"id":"456999","messageId":"RFC-patch-18.20-c5796878f0b-20220610T011725Z-avarab@gmail.com","threadId":"57979","inReplyTo":"RFC-cover-00.20-00000000000-20220610T011725Z-avarab@gmail.com","subject":"[RFC PATCH 18/20] git-submodule.sh: simplify parsing loop","fromName":"Ævar Arnfjörð Bjarmason","fromEmail":"avarab@gmail.com","sentAt":"2022-06-10T02:01:30Z","receivedAt":"2022-06-10T02:02:39Z","isPatch":true,"sender":{"key":"avarab@gmail.com","avatar":"https://avatars.githubusercontent.com/u/45301?v=4"},"body":"Simplify the parsing loop so that we don't try to find out the\n\"$command\" when looping over arguments initially, we'll only look for\nthe --quiet and --cached options.\n\nThen if we have no more arguments we default to \"status\", otherwise we\nemit our usage info. Most importantly we don't need to give --cache to\nonly \"status\" and \"summary\", instead we trust that \"submodule--helper\"\nis checking those arguments, if some subcommands don't them they can\nemit their own errors.\n\nSigned-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>\n---\n git-submodule.sh | 44 +++++++++++++++++---------------------------\n 1 file changed, 17 insertions(+), 27 deletions(-)\n\ndiff --git a/git-submodule.sh b/git-submodule.sh\nindex cad9948c047..0274b253297 100755\n--- a/git-submodule.sh\n+++ b/git-submodule.sh\n@@ -29,50 +29,40 @@ cd_to_toplevel\n GIT_PROTOCOL_FROM_USER=0\n export GIT_PROTOCOL_FROM_USER\n \n-command=\n quiet=\n cached=\n \n-while test $# != 0 && test -z \"$command\"\n+while test $# != 0\n do\n \tcase \"$1\" in\n-\tadd | foreach | init | deinit | update | set-branch | set-url | status | summary | sync | absorbgitdirs)\n-\t\tcommand=$1\n-\t\t;;\n \t-q|--quiet)\n-\t\tquiet=1\n+\t\tquiet=1 &&\n+\t\tshift\n \t\t;;\n \t--cached)\n-\t\tcached=1\n-\t\t;;\n-\t--)\n-\t\tbreak\n-\t\t;;\n-\t-*)\n-\t\tusage\n+\t\tcached=1 &&\n+\t\tshift\n \t\t;;\n \t*)\n \t\tbreak\n \t\t;;\n \tesac\n-\tshift\n done\n \n # No command word defaults to \"status\"\n-if test -z \"$command\"\n+command=\n+if test $# = 0\n then\n-    if test $# = 0\n-    then\n \tcommand=status\n-    else\n-\tusage\n-    fi\n-fi\n-\n-# \"--cached\" is accepted only by \"status\" and \"summary\"\n-if test -n \"$cached\" && test \"$command\" != status && test \"$command\" != summary\n-then\n-\tusage\n+else\n+\tcase \"$1\" in\n+\tadd | foreach | init | deinit | update | set-branch | set-url | status | summary | sync | absorbgitdirs)\n+\t\tcommand=$1 &&\n+\t\tshift\n+\t\t;;\n+\t*)\n+\t\tusage\n+\tesac\n fi\n \n case \"$command\" in\n@@ -83,7 +73,7 @@ update)\n \tgit ${wt_prefix:+-C \"$wt_prefix\"} submodule--helper \"$command\" \\\n \t\t${quiet:+--quiet} ${wt_prefix:+--prefix \"$wt_prefix\"} \"$@\"\n \t;;\n-add | foreach | init | deinit | set-branch | set-url | status | summary | sync)\n+*)\n \tgit ${wt_prefix:+-C \"$wt_prefix\"} submodule--helper \"$command\" \\\n \t\t${quiet:+--quiet} ${cached:+--cached} \"$@\"\n \t;;\n-- \n2.36.1.1178.gb5b1747c546\n\n"},{"id":"457000","messageId":"RFC-patch-20.20-b2aaad5c008-20220610T011725Z-avarab@gmail.com","threadId":"57979","inReplyTo":"RFC-cover-00.20-00000000000-20220610T011725Z-avarab@gmail.com","subject":"[RFC PATCH 20/20] submodule: add a subprocess-less submodule.useBuiltin setting","fromName":"Ævar Arnfjörð Bjarmason","fromEmail":"avarab@gmail.com","sentAt":"2022-06-10T02:01:32Z","receivedAt":"2022-06-10T02:02:42Z","isPatch":true,"sender":{"key":"avarab@gmail.com","avatar":"https://avatars.githubusercontent.com/u/45301?v=4"},"body":"Add an experimental setting to avoid the subprocess invocation of \"git\nsubmodule--helper\", instead we'll call cmd_submodule__helper()\ndirectly.\n\nSigned-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>\n---\n Documentation/config/submodule.txt |  4 ++++\n builtin/submodule.c                | 35 ++++++++++++++++++++++++++++--\n ci/run-build-and-tests.sh          |  1 +\n t/README                           |  4 ++++\n 4 files changed, 42 insertions(+), 2 deletions(-)\n\ndiff --git a/Documentation/config/submodule.txt b/Documentation/config/submodule.txt\nindex 6490527b45b..aa761f331c9 100644\n--- a/Documentation/config/submodule.txt\n+++ b/Documentation/config/submodule.txt\n@@ -79,6 +79,10 @@ setting.\n * `branch` is supported only if `submodule.propagateBranches` is\n enabled\n \n+submodule.useBuiltin::\n+\tSet to `true` to use a faster but possibly less stable subprocess-less\n+\timplementation of linkgit:git-submodule[1]. Is `false` by default.\n+\n submodule.propagateBranches::\n \t[EXPERIMENTAL] A boolean that enables branching support when\n \tusing `--recurse-submodules` or `submodule.recurse=true`.\ndiff --git a/builtin/submodule.c b/builtin/submodule.c\nindex b777787169e..9bb731ce87a 100644\n--- a/builtin/submodule.c\n+++ b/builtin/submodule.c\n@@ -6,6 +6,7 @@\n #include \"parse-options.h\"\n #include \"run-command.h\"\n #include \"strvec.h\"\n+#include \"config.h\"\n \n #define BUILTIN_SUBMODULE_USAGE \\\n \t\"git submodule [--quiet] [--cached]\"\n@@ -105,17 +106,33 @@ static void setup_helper_args(int argc, const char **argv, const char *prefix,\n \tstrvec_pushv(args, argv);\n }\n \n+static int get_use_builtin(void)\n+{\n+\tint v;\n+\n+\tif (git_env_bool(\"GIT_TEST_SUBMODULE_USE_BUILTIN\", 0))\n+\t\tv = 1;\n+\telse if (!git_config_get_bool(\"submodule.usebuiltin\", &v))\n+\t\t;\n+\telse if (!git_config_get_bool(\"feature.experimental\", &v))\n+\t      ;\n+\n+\treturn v;\n+}\n+\n int cmd_submodule(int argc, const char **argv, const char *prefix)\n {\n \tint opt_quiet = 0;\n \tint opt_cached = 0;\n \tstruct child_process cp = CHILD_PROCESS_INIT;\n+\tstruct strvec args = STRVEC_INIT;\n \tstruct option options[] = {\n \t\tOPT__QUIET(&opt_quiet, N_(\"be quiet\")),\n \t\tOPT_BOOL(0, \"cached\", &opt_cached,\n \t\t\t N_(\"print the OID of submodules\")),\n \t\tOPT_END()\n \t};\n+\tconst int use_builtin = get_use_builtin();\n \tint ret;\n \n \targc = parse_options(argc, argv, prefix, options, git_submodule_usage,\n@@ -125,14 +142,28 @@ int cmd_submodule(int argc, const char **argv, const char *prefix)\n \t * Tell the rest of git that any URLs we get don't come\n \t * directly from the user, so it can apply policy as appropriate.\n \t */\n-\tstrvec_push(&cp.env_array, \"GIT_PROTOCOL_FROM_USER=0\");\n+\tif (use_builtin)\n+\t\txsetenv(\"GIT_PROTOCOL_FROM_USER\", \"0\", 1);\n+\telse\n+\t\tstrvec_push(&cp.env_array, \"GIT_PROTOCOL_FROM_USER=0\");\n+\n \tsetup_helper_args(argc, argv, prefix, opt_quiet, opt_cached,\n-\t\t\t  &cp.args);\n+\t\t\t  use_builtin ? &args : &cp.args);\n+\n+\tif (use_builtin) {\n+\t\tret = cmd_submodule__helper(args.nr, args.v, prefix);\n+\t\tgoto cleanup;\n+\t}\n \n \tcp.git_cmd = 1;\n \tcp.no_stdin = 0; /* for git submodule foreach */\n \tcp.dir = startup_info->original_cwd;\n \tret = run_command(&cp);\n \n+cleanup:\n+\tif (!use_builtin)\n+\t\t/* TODO: Double free? */\n+\t\tstrvec_clear(&args);\n+\n \treturn ret;\n }\ndiff --git a/ci/run-build-and-tests.sh b/ci/run-build-and-tests.sh\nindex 8ebff425967..06d40fc94aa 100755\n--- a/ci/run-build-and-tests.sh\n+++ b/ci/run-build-and-tests.sh\n@@ -27,6 +27,7 @@ linux-TEST-vars)\n \texport GIT_TEST_MULTI_PACK_INDEX=1\n \texport GIT_TEST_MULTI_PACK_INDEX_WRITE_BITMAP=1\n \texport GIT_TEST_ADD_I_USE_BUILTIN=0\n+\texport GIT_TEST_SUBMODULE_USE_BUILTIN=1\n \texport GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME=master\n \texport GIT_TEST_WRITE_REV_INDEX=1\n \texport GIT_TEST_CHECKOUT_WORKERS=2\ndiff --git a/t/README b/t/README\nindex 309a31133c6..20c2e74723d 100644\n--- a/t/README\n+++ b/t/README\n@@ -423,6 +423,10 @@ GIT_TEST_ADD_I_USE_BUILTIN=<boolean>, when false, disables the\n built-in version of git add -i. See 'add.interactive.useBuiltin' in\n git-config(1).\n \n+GIT_TEST_SUBMODULE_USE_BUILTIN=<boolean>, when true, enables the\n+built-in subprocess-less invocation of \"git submodule--helper\".\n+See 'submodule.useBuiltin' in git-config(1).\n+\n GIT_TEST_INDEX_THREADS=<n> enables exercising the multi-threaded loading\n of the index for the whole test suite by bypassing the default number of\n cache entries and thread minimums. Setting this to 1 will make the\n-- \n2.36.1.1178.gb5b1747c546\n\n"},{"id":"457001","messageId":"RFC-patch-19.20-1423950de08-20220610T011725Z-avarab@gmail.com","threadId":"57979","inReplyTo":"RFC-cover-00.20-00000000000-20220610T011725Z-avarab@gmail.com","subject":"[RFC PATCH 19/20] submodule: make it a built-in, remove git-submodule.sh","fromName":"Ævar Arnfjörð Bjarmason","fromEmail":"avarab@gmail.com","sentAt":"2022-06-10T02:01:31Z","receivedAt":"2022-06-10T02:02:57Z","isPatch":true,"sender":{"key":"avarab@gmail.com","avatar":"https://avatars.githubusercontent.com/u/45301?v=4"},"body":"Replace the now-trivial git-submodule.sh script with a built-in\nbuiltin/submodule.c. For now this new command is only a dumb\ndispatcher that uses run-command.c to invoke \"git submodule--helper\",\njust as \"git-submodule.sh\" used to do.\n\nThis is obviously not ideal, and we should follow-up and merge the\nbuiltin/submodule--helper.c code into builtin/submodule.c, but doing it\nthis way makes it easy to review that this new C implementation isn't\ndoing anything more clever than the old shellscript implementation.\n\nThe \"define BUILTIN_\" macros will help with that, i.e. the usage\ninformation we emit can be merged with what\nbuiltin/submodule--helper.c is now emitting. See\n8757b35d443 (commit-graph: define common usage with a macro,\n2021-08-23) and 1e91d3faf6c (reflog: move \"usage\" variables and use\nmacros, 2022-03-17) for prior art using this pattern.\n\nThe \"(argc < 2 || !strcmp(argv[1], \"-h\"))\" path at the top of\ncmd_submodule__helper() could now be a \"(argc < 2)\" if not for\nt0012-help.sh (which invokes all built-ins manually with \"-h\"). Let's\nleave it for now, eventually we'll consolidate the two.\n\nSigned-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>\n---\n Makefile            |   2 +-\n builtin.h           |   1 +\n builtin/submodule.c | 138 ++++++++++++++++++++++++++++++++++++++++++++\n git-submodule.sh    |  80 -------------------------\n git.c               |   1 +\n 5 files changed, 141 insertions(+), 81 deletions(-)\n create mode 100644 builtin/submodule.c\n delete mode 100755 git-submodule.sh\n\ndiff --git a/Makefile b/Makefile\nindex 790382bd1e3..635ab791a8a 100644\n--- a/Makefile\n+++ b/Makefile\n@@ -622,7 +622,6 @@ SCRIPT_SH += git-merge-resolve.sh\n SCRIPT_SH += git-mergetool.sh\n SCRIPT_SH += git-quiltimport.sh\n SCRIPT_SH += git-request-pull.sh\n-SCRIPT_SH += git-submodule.sh\n SCRIPT_SH += git-web--browse.sh\n \n SCRIPT_LIB += git-mergetool--lib\n@@ -1213,6 +1212,7 @@ BUILTIN_OBJS += builtin/show-ref.o\n BUILTIN_OBJS += builtin/sparse-checkout.o\n BUILTIN_OBJS += builtin/stash.o\n BUILTIN_OBJS += builtin/stripspace.o\n+BUILTIN_OBJS += builtin/submodule.o\n BUILTIN_OBJS += builtin/submodule--helper.o\n BUILTIN_OBJS += builtin/symbolic-ref.o\n BUILTIN_OBJS += builtin/tag.o\ndiff --git a/builtin.h b/builtin.h\nindex 40e9ecc8485..c8cf4a2ae3b 100644\n--- a/builtin.h\n+++ b/builtin.h\n@@ -223,6 +223,7 @@ int cmd_sparse_checkout(int argc, const char **argv, const char *prefix);\n int cmd_status(int argc, const char **argv, const char *prefix);\n int cmd_stash(int argc, const char **argv, const char *prefix);\n int cmd_stripspace(int argc, const char **argv, const char *prefix);\n+int cmd_submodule(int argc, const char **argv, const char *prefix);\n int cmd_submodule__helper(int argc, const char **argv, const char *prefix);\n int cmd_switch(int argc, const char **argv, const char *prefix);\n int cmd_symbolic_ref(int argc, const char **argv, const char *prefix);\ndiff --git a/builtin/submodule.c b/builtin/submodule.c\nnew file mode 100644\nindex 00000000000..b777787169e\n--- /dev/null\n+++ b/builtin/submodule.c\n@@ -0,0 +1,138 @@\n+/*\n+ * Copyright (c) 2007-2022 Lars Hjemli & others\n+ * Copyright(c) 2022 Ævar Arnfjörð Bjarmason\n+ */\n+#include \"builtin.h\"\n+#include \"parse-options.h\"\n+#include \"run-command.h\"\n+#include \"strvec.h\"\n+\n+#define BUILTIN_SUBMODULE_USAGE \\\n+\t\"git submodule [--quiet] [--cached]\"\n+\n+#define BUILTIN_SUBMODULE_ADD_USAGE \\\n+\tN_(\"git submodule [--quiet] add [-b <branch>] [-f | --force] [--name <name>]\\n\" \\\n+\t   \"              [--reference <repository>] [--] <repository> [<path>]\")\n+\n+#define BUILTIN_SUBMODULE_STATUS_USAGE \\\n+\tN_(\"git submodule [--quiet] status [--cached] [--recursive] [--] [<path>...]\")\n+\n+#define BUILTIN_SUBMODULE_INIT_USAGE \\\n+\tN_(\"git submodule [--quiet] init [--] [<path>...]\")\n+\n+#define BUILTIN_SUBMODULE_DEINIT_USAGE \\\n+\tN_(\"git submodule [--quiet] deinit [-f | --force] (--all | [--] <path>...)\")\n+\n+#define BUILTIN_SUBMODULE_UPDATE_USAGE \\\n+\tN_(\"git submodule [--quiet] update [-v] [--init [--filter=<filter-spec>]]\\n\" \\\n+\t   \"              [--remote] [-N | --no-fetch] [-f | --force] [--checkout |--merge | --rebase]\\n\" \\\n+\t   \"              [--[no-]recommend-shallow] [--reference <repository>] [--recursive]\\n\" \\\n+\t   \"              [--[no-]single-branch] [--] [<path>...]\")\n+\n+#define BUILTIN_SUBMODULE_SET_BRANCH_USAGE \\\n+\tN_(\"git submodule [--quiet] set-branch (--default | --branch <branch>) [--] <path>\")\n+\n+#define BUILTIN_SUBMODULE_SET_URL_USAGE \\\n+\tN_(\"git submodule [--quiet] set-url [--] <path> <newurl>\")\n+\n+#define BUILTIN_SUBMODULE_SUMMARY_USAGE \\\n+\tN_(\"git submodule [--quiet] summary [--cached | --files] [--summary-limit <n>]\\n\"  \\\n+\t   \"              [commit] [--] [<path>...]\")\n+#define BUILTIN_SUBMODULE_FOREACH_USAGE \\\n+\tN_(\"git submodule [--quiet] foreach [--recursive] <command>\")\n+\n+#define BUILTIN_SUBMODULE_SYNC_USAGE \\\n+\tN_(\"git submodule [--quiet] sync [--recursive] [--] [<path>...]\")\n+\n+#define BUILTIN_SUBMODULE_ABSORBGITDIRS_USAGE \\\n+\tN_(\"git submodule [--quiet] absorbgitdirs [--] [<path>...]\")\n+\n+static const char * const git_submodule_usage[] = {\n+\tBUILTIN_SUBMODULE_USAGE,\n+\tBUILTIN_SUBMODULE_ADD_USAGE,\n+\tBUILTIN_SUBMODULE_STATUS_USAGE,\n+\tBUILTIN_SUBMODULE_INIT_USAGE,\n+\tBUILTIN_SUBMODULE_DEINIT_USAGE,\n+\tBUILTIN_SUBMODULE_UPDATE_USAGE,\n+\tBUILTIN_SUBMODULE_SET_BRANCH_USAGE,\n+\tBUILTIN_SUBMODULE_SET_URL_USAGE,\n+\tBUILTIN_SUBMODULE_SUMMARY_USAGE,\n+\tBUILTIN_SUBMODULE_FOREACH_USAGE,\n+\tBUILTIN_SUBMODULE_SYNC_USAGE,\n+\tBUILTIN_SUBMODULE_ABSORBGITDIRS_USAGE,\n+\tNULL,\n+};\n+\n+static void setup_helper_args(int argc, const char **argv, const char *prefix,\n+\t\t\t      int quiet, int cached, struct strvec *args)\n+{\n+\tconst char *cmd;\n+\tint do_quiet_cache = 1;\n+\tint do_prefix = 1;\n+\n+\tstrvec_push(args, \"submodule--helper\");\n+\n+\t/* No command word defaults to \"status\" */\n+\tif (!argc) {\n+\t\tstrvec_push(args, \"status\");\n+\t\treturn;\n+\t}\n+\n+\t/* Either a valid command, or submodule--helper will barf! */\n+\tcmd = argv[0];\n+\tstrvec_push(args, cmd);\n+\targv++;\n+\targc--;\n+\n+\t/* Options that need to go before user-supplied options */\n+\tif (!strcmp(cmd, \"absorbgitdirs\"))\n+\t\tdo_quiet_cache = 0;\n+\telse if (!strcmp(cmd, \"update\"))\n+\t\t;\n+\telse\n+\t\tdo_prefix = 0;\n+\tif (do_quiet_cache) {\n+\t\tif (quiet)\n+\t\t\tstrvec_push(args, \"--quiet\");\n+\t\tif (cached)\n+\t\t\tstrvec_push(args, \"--cached\");\n+\n+\t\tif (prefix && do_prefix)\n+\t\t\tstrvec_pushl(args, \"--prefix\", prefix, NULL);\n+\t}\n+\n+\t/* All commands get argv, including a \"--\", if any */\n+\tstrvec_pushv(args, argv);\n+}\n+\n+int cmd_submodule(int argc, const char **argv, const char *prefix)\n+{\n+\tint opt_quiet = 0;\n+\tint opt_cached = 0;\n+\tstruct child_process cp = CHILD_PROCESS_INIT;\n+\tstruct option options[] = {\n+\t\tOPT__QUIET(&opt_quiet, N_(\"be quiet\")),\n+\t\tOPT_BOOL(0, \"cached\", &opt_cached,\n+\t\t\t N_(\"print the OID of submodules\")),\n+\t\tOPT_END()\n+\t};\n+\tint ret;\n+\n+\targc = parse_options(argc, argv, prefix, options, git_submodule_usage,\n+\t\t\t     PARSE_OPT_STOP_AT_NON_OPTION);\n+\n+\t/*\n+\t * Tell the rest of git that any URLs we get don't come\n+\t * directly from the user, so it can apply policy as appropriate.\n+\t */\n+\tstrvec_push(&cp.env_array, \"GIT_PROTOCOL_FROM_USER=0\");\n+\tsetup_helper_args(argc, argv, prefix, opt_quiet, opt_cached,\n+\t\t\t  &cp.args);\n+\n+\tcp.git_cmd = 1;\n+\tcp.no_stdin = 0; /* for git submodule foreach */\n+\tcp.dir = startup_info->original_cwd;\n+\tret = run_command(&cp);\n+\n+\treturn ret;\n+}\ndiff --git a/git-submodule.sh b/git-submodule.sh\ndeleted file mode 100755\nindex 0274b253297..00000000000\n--- a/git-submodule.sh\n+++ /dev/null\n@@ -1,80 +0,0 @@\n-#!/bin/sh\n-#\n-# git-submodule.sh: add, init, update or list git submodules\n-#\n-# Copyright (c) 2007 Lars Hjemli\n-\n-dashless=$(basename \"$0\" | sed -e 's/-/ /')\n-USAGE=\"[--quiet] [--cached]\n-   or: $dashless [--quiet] add [-b <branch>] [-f|--force] [--name <name>] [--reference <repository>] [--] <repository> [<path>]\n-   or: $dashless [--quiet] status [--cached] [--recursive] [--] [<path>...]\n-   or: $dashless [--quiet] init [--] [<path>...]\n-   or: $dashless [--quiet] deinit [-f|--force] (--all| [--] <path>...)\n-   or: $dashless [--quiet] update [-v] [--init [--filter=<filter-spec>]] [--remote] [-N|--no-fetch] [-f|--force] [--checkout|--merge|--rebase] [--[no-]recommend-shallow] [--reference <repository>] [--recursive] [--[no-]single-branch] [--] [<path>...]\n-   or: $dashless [--quiet] set-branch (--default|--branch <branch>) [--] <path>\n-   or: $dashless [--quiet] set-url [--] <path> <newurl>\n-   or: $dashless [--quiet] summary [--cached|--files] [--summary-limit <n>] [commit] [--] [<path>...]\n-   or: $dashless [--quiet] foreach [--recursive] <command>\n-   or: $dashless [--quiet] sync [--recursive] [--] [<path>...]\n-   or: $dashless [--quiet] absorbgitdirs [--] [<path>...]\"\n-OPTIONS_SPEC=\n-SUBDIRECTORY_OK=Yes\n-. git-sh-setup\n-require_work_tree\n-wt_prefix=$(git rev-parse --show-prefix)\n-cd_to_toplevel\n-\n-# Tell the rest of git that any URLs we get don't come\n-# directly from the user, so it can apply policy as appropriate.\n-GIT_PROTOCOL_FROM_USER=0\n-export GIT_PROTOCOL_FROM_USER\n-\n-quiet=\n-cached=\n-\n-while test $# != 0\n-do\n-\tcase \"$1\" in\n-\t-q|--quiet)\n-\t\tquiet=1 &&\n-\t\tshift\n-\t\t;;\n-\t--cached)\n-\t\tcached=1 &&\n-\t\tshift\n-\t\t;;\n-\t*)\n-\t\tbreak\n-\t\t;;\n-\tesac\n-done\n-\n-# No command word defaults to \"status\"\n-command=\n-if test $# = 0\n-then\n-\tcommand=status\n-else\n-\tcase \"$1\" in\n-\tadd | foreach | init | deinit | update | set-branch | set-url | status | summary | sync | absorbgitdirs)\n-\t\tcommand=$1 &&\n-\t\tshift\n-\t\t;;\n-\t*)\n-\t\tusage\n-\tesac\n-fi\n-\n-case \"$command\" in\n-absorbgitdirs)\n-\tgit submodule--helper \"$command\" --prefix \"$wt_prefix\" \"$@\"\n-\t;;\n-update)\n-\tgit ${wt_prefix:+-C \"$wt_prefix\"} submodule--helper \"$command\" \\\n-\t\t${quiet:+--quiet} ${wt_prefix:+--prefix \"$wt_prefix\"} \"$@\"\n-\t;;\n-*)\n-\tgit ${wt_prefix:+-C \"$wt_prefix\"} submodule--helper \"$command\" \\\n-\t\t${quiet:+--quiet} ${cached:+--cached} \"$@\"\n-\t;;\n-esac\ndiff --git a/git.c b/git.c\nindex 5ff4f3e25b7..047fc262cd2 100644\n--- a/git.c\n+++ b/git.c\n@@ -609,6 +609,7 @@ static struct cmd_struct commands[] = {\n \t{ \"stash\", cmd_stash, RUN_SETUP | NEED_WORK_TREE },\n \t{ \"status\", cmd_status, RUN_SETUP | NEED_WORK_TREE },\n \t{ \"stripspace\", cmd_stripspace },\n+\t{ \"submodule\", cmd_submodule, RUN_SETUP | NEED_WORK_TREE },\n \t{ \"submodule--helper\", cmd_submodule__helper, RUN_SETUP | SUPPORT_SUPER_PREFIX | NO_PARSEOPT },\n \t{ \"switch\", cmd_switch, RUN_SETUP | NEED_WORK_TREE },\n \t{ \"symbolic-ref\", cmd_symbolic_ref, RUN_SETUP },\n-- \n2.36.1.1178.gb5b1747c546\n\n"},{"id":"457002","messageId":"RFC-patch-17.20-59a72296967-20220610T011725Z-avarab@gmail.com","threadId":"57979","inReplyTo":"RFC-cover-00.20-00000000000-20220610T011725Z-avarab@gmail.com","subject":"[RFC PATCH 17/20] git-submodule.sh: use \"$quiet\", not \"$GIT_QUIET\"","fromName":"Ævar Arnfjörð Bjarmason","fromEmail":"avarab@gmail.com","sentAt":"2022-06-10T02:01:29Z","receivedAt":"2022-06-10T02:03:01Z","isPatch":true,"sender":{"key":"avarab@gmail.com","avatar":"https://avatars.githubusercontent.com/u/45301?v=4"},"body":"Remove the use of the \"$GIT_QUIET\" variable in favor of our own\n\"$quiet\", ever since b3c5f5cb048 (submodule: move core cmd_update()\nlogic to C, 2022-03-15) we have not used the \"say\" function in\ngit-sh-setup.sh, which is the only thing that's affected by using\n\"GIT_QUIET\".\n\nWe still want to support --quiet for our own use though, but let's use\nour own variable for that.\n\nThis change could have come before the preceding commits which removed\ncmd_*() functions from this file, but that would have been a much more\nverbose change. Since we were removing most of the uses of\n\"$GIT_QUIET\" this change comes after those.\n\nSigned-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>\n---\n git-submodule.sh | 7 ++++---\n 1 file changed, 4 insertions(+), 3 deletions(-)\n\ndiff --git a/git-submodule.sh b/git-submodule.sh\nindex e245b7fbaca..cad9948c047 100755\n--- a/git-submodule.sh\n+++ b/git-submodule.sh\n@@ -30,6 +30,7 @@ GIT_PROTOCOL_FROM_USER=0\n export GIT_PROTOCOL_FROM_USER\n \n command=\n+quiet=\n cached=\n \n while test $# != 0 && test -z \"$command\"\n@@ -39,7 +40,7 @@ do\n \t\tcommand=$1\n \t\t;;\n \t-q|--quiet)\n-\t\tGIT_QUIET=1\n+\t\tquiet=1\n \t\t;;\n \t--cached)\n \t\tcached=1\n@@ -80,10 +81,10 @@ absorbgitdirs)\n \t;;\n update)\n \tgit ${wt_prefix:+-C \"$wt_prefix\"} submodule--helper \"$command\" \\\n-\t\t${GIT_QUIET:+--quiet} ${wt_prefix:+--prefix \"$wt_prefix\"} \"$@\"\n+\t\t${quiet:+--quiet} ${wt_prefix:+--prefix \"$wt_prefix\"} \"$@\"\n \t;;\n add | foreach | init | deinit | set-branch | set-url | status | summary | sync)\n \tgit ${wt_prefix:+-C \"$wt_prefix\"} submodule--helper \"$command\" \\\n-\t\t${GIT_QUIET:+--quiet} ${cached:+--cached} \"$@\"\n+\t\t${quiet:+--quiet} ${cached:+--cached} \"$@\"\n \t;;\n esac\n-- \n2.36.1.1178.gb5b1747c546\n\n"},{"id":"457003","messageId":"RFC-patch-13.20-20db979a094-20220610T011725Z-avarab@gmail.com","threadId":"57979","inReplyTo":"RFC-cover-00.20-00000000000-20220610T011725Z-avarab@gmail.com","subject":"[RFC PATCH 13/20] submodule--helper: understand --checkout, --merge and --rebase synonyms","fromName":"Ævar Arnfjörð Bjarmason","fromEmail":"avarab@gmail.com","sentAt":"2022-06-10T02:01:25Z","receivedAt":"2022-06-10T02:03:04Z","isPatch":true,"sender":{"key":"avarab@gmail.com","avatar":"https://avatars.githubusercontent.com/u/45301?v=4"},"body":"Understand --checkout, --merge and --rebase synonyms for\n--update={checkout,merge,rebase}, as well as the short options that\n'git submodule' itself understands.\n\nThis removes a difference between the CLI API of \"git submodule\" and\n\"git submodule--helper\", making it easier to make the latter an alias\nfor the former. See 48308681b07 (git submodule update: have a\ndedicated helper for cloning, 2016-02-29) for the initial addition of\n--update.\n\nSigned-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>\n---\n builtin/submodule--helper.c | 17 +++++++++++++++++\n git-submodule.sh            | 14 +++++++++-----\n 2 files changed, 26 insertions(+), 5 deletions(-)\n\ndiff --git a/builtin/submodule--helper.c b/builtin/submodule--helper.c\nindex f1f5c6b84c6..64d7c5d7ba4 100644\n--- a/builtin/submodule--helper.c\n+++ b/builtin/submodule--helper.c\n@@ -2583,6 +2583,7 @@ static int module_update(int argc, const char **argv, const char *prefix)\n \tstruct update_data opt = UPDATE_DATA_INIT;\n \tstruct list_objects_filter_options filter_options;\n \tint ret;\n+\tenum submodule_update_type update_type = SM_UPDATE_UNSPECIFIED;\n \n \tstruct option module_update_options[] = {\n \t\tOPT__FORCE(&opt.force, N_(\"force checkout updates\"), 0),\n@@ -2604,6 +2605,15 @@ static int module_update(int argc, const char **argv, const char *prefix)\n \t\tOPT_STRING(0, \"update\", &opt.update_default,\n \t\t\t   N_(\"string\"),\n \t\t\t   N_(\"rebase, merge, checkout or none\")),\n+\t\tOPT_SET_INT(0, \"checkout\", &update_type,\n+\t\t\tN_(\"use the 'checkout' update strategy (default)\"),\n+\t\t\tSM_UPDATE_CHECKOUT),\n+\t\tOPT_SET_INT('m', \"merge\", &update_type,\n+\t\t\tN_(\"use the 'merge' update strategy\"),\n+\t\t\tSM_UPDATE_MERGE),\n+\t\tOPT_SET_INT('r', \"rebase\", &update_type,\n+\t\t\tN_(\"use the 'rebase' update strategy\"),\n+\t\t\tSM_UPDATE_MERGE),\n \t\tOPT_STRING_LIST(0, \"reference\", &opt.references, N_(\"repo\"),\n \t\t\t   N_(\"reference repository\")),\n \t\tOPT_BOOL(0, \"dissociate\", &opt.dissociate,\n@@ -2653,6 +2663,13 @@ static int module_update(int argc, const char **argv, const char *prefix)\n \n \topt.filter_options = &filter_options;\n \n+\tif (update_type == SM_UPDATE_CHECKOUT)\n+\t\topt.update_default = \"checkout\";\n+\telse if (update_type == SM_UPDATE_MERGE)\n+\t\topt.update_default = \"merge\";\n+\telse if (update_type == SM_UPDATE_REBASE)\n+\t\topt.update_default = \"rebase\";\n+\n \tif (opt.update_default)\n \t\tif (parse_submodule_update_strategy(opt.update_default,\n \t\t\t\t\t\t    &opt.update_strategy) < 0)\ndiff --git a/git-submodule.sh b/git-submodule.sh\nindex 43fe3bcb00b..d8abdd8e8ad 100755\n--- a/git-submodule.sh\n+++ b/git-submodule.sh\n@@ -38,7 +38,9 @@ init=\n require_init=\n remote=\n nofetch=\n-update=\n+rebase=\n+merge=\n+checkout=\n depth=\n progress=\n dissociate=\n@@ -83,7 +85,7 @@ cmd_update()\n \t\t\tforce=$1\n \t\t\t;;\n \t\t-r|--rebase)\n-\t\t\tupdate=\"rebase\"\n+\t\t\trebase=1\n \t\t\t;;\n \t\t--reference)\n \t\t\tcase \"$2\" in '') usage ;; esac\n@@ -97,13 +99,13 @@ cmd_update()\n \t\t\tdissociate=1\n \t\t\t;;\n \t\t-m|--merge)\n-\t\t\tupdate=\"merge\"\n+\t\t\tmerge=1\n \t\t\t;;\n \t\t--recursive)\n \t\t\trecursive=1\n \t\t\t;;\n \t\t--checkout)\n-\t\t\tupdate=\"checkout\"\n+\t\t\tcheckout=1\n \t\t\t;;\n \t\t--recommend-shallow)\n \t\t\trecommend_shallow=\"--recommend-shallow\"\n@@ -164,7 +166,9 @@ cmd_update()\n \t\t${init:+--init} \\\n \t\t${nofetch:+--no-fetch} \\\n \t\t${wt_prefix:+--prefix \"$wt_prefix\"} \\\n-\t\t${update:+--update \"$update\"} \\\n+\t\t${rebase:+--rebase} \\\n+\t\t${merge:+--merge} \\\n+\t\t${checkout:+--checkout} \\\n \t\t${reference:+\"$reference\"} \\\n \t\t${dissociate:+\"--dissociate\"} \\\n \t\t${depth:+\"$depth\"} \\\n-- \n2.36.1.1178.gb5b1747c546\n\n"},{"id":"457004","messageId":"RFC-patch-16.20-08abadda7c3-20220610T011725Z-avarab@gmail.com","threadId":"57979","inReplyTo":"RFC-cover-00.20-00000000000-20220610T011725Z-avarab@gmail.com","subject":"[RFC PATCH 16/20] git-submodule.sh: dispatch \"update\" to helper","fromName":"Ævar Arnfjörð Bjarmason","fromEmail":"avarab@gmail.com","sentAt":"2022-06-10T02:01:28Z","receivedAt":"2022-06-10T02:03:06Z","isPatch":true,"sender":{"key":"avarab@gmail.com","avatar":"https://avatars.githubusercontent.com/u/45301?v=4"},"body":"Dispatch the \"update\" command directly to \"git submodule--helper\nupdate\", rather than doing our own argument parsing in\ngit-submodule.sh. As this is the last cmd_*() function to be removed\nfrom git-submodule.sh we can do some larger cleanup of that file as a\nresult.\n\nAs noted in a preceding commit the only behavior change here should be\nthe desirable change of better \"-h\" output, and that this\nimplementation understands the \"--verbose\" synonym for \"-v\". Let's\nupdate the documentation to reflect the new \"--verbose\" synonym.\n\nSigned-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>\n---\n Documentation/git-submodule.txt |   5 +-\n git-submodule.sh                | 159 +-------------------------------\n 2 files changed, 5 insertions(+), 159 deletions(-)\n\ndiff --git a/Documentation/git-submodule.txt b/Documentation/git-submodule.txt\nindex 5f1c552110e..95685ac4f1c 100644\n--- a/Documentation/git-submodule.txt\n+++ b/Documentation/git-submodule.txt\n@@ -14,7 +14,7 @@ SYNOPSIS\n 'git submodule' [--quiet] status [--cached] [--recursive] [--] [<path>...]\n 'git submodule' [--quiet] init [--] [<path>...]\n 'git submodule' [--quiet] deinit [-f|--force] (--all|[--] <path>...)\n-'git submodule' [--quiet] update [-v] [<options>] [--] [<path>...]\n+'git submodule' [--quiet] update [-v | --verbose] [<options>] [--] [<path>...]\n 'git submodule' [--quiet] set-branch [<options>] [--] <path>\n 'git submodule' [--quiet] set-url [--] <path> <newurl>\n 'git submodule' [--quiet] summary [<options>] [--] [<path>...]\n@@ -133,7 +133,7 @@ If you really want to remove a submodule from the repository and commit\n that use linkgit:git-rm[1] instead. See linkgit:gitsubmodules[7] for removal\n options.\n \n-update [-v] [--init] [--remote] [-N|--no-fetch] [--[no-]recommend-shallow] [-f|--force] [--checkout|--rebase|--merge] [--reference <repository>] [--depth <depth>] [--recursive] [--jobs <n>] [--[no-]single-branch] [--filter <filter spec>] [--] [<path>...]::\n+update [-v | --verbose] [--init] [--remote] [-N|--no-fetch] [--[no-]recommend-shallow] [-f|--force] [--checkout|--rebase|--merge] [--reference <repository>] [--depth <depth>] [--recursive] [--jobs <n>] [--[no-]single-branch] [--filter <filter spec>] [--] [<path>...]::\n +\n --\n Update the registered submodules to match what the superproject\n@@ -271,6 +271,7 @@ OPTIONS\n \tOnly print error messages.\n \n -v::\n+--verbose::\n \tDon't be quiet. This option is only valid for the update command.\n \n --progress::\ndiff --git a/git-submodule.sh b/git-submodule.sh\nindex 1929c34ae8b..e245b7fbaca 100755\n--- a/git-submodule.sh\n+++ b/git-submodule.sh\n@@ -30,163 +30,7 @@ GIT_PROTOCOL_FROM_USER=0\n export GIT_PROTOCOL_FROM_USER\n \n command=\n-force=\n-reference=\n cached=\n-recursive=\n-init=\n-require_init=\n-remote=\n-nofetch=\n-rebase=\n-merge=\n-checkout=\n-depth=\n-progress=\n-dissociate=\n-single_branch=\n-jobs=\n-recommend_shallow=\n-filter=\n-\n-#\n-# Update each submodule path to correct revision, using clone and checkout as needed\n-#\n-# $@ = requested paths (default to all)\n-#\n-cmd_update()\n-{\n-\t# parse $args after \"submodule ... update\".\n-\twhile test $# -ne 0\n-\tdo\n-\t\tcase \"$1\" in\n-\t\t-q|--quiet)\n-\t\t\tGIT_QUIET=1\n-\t\t\t;;\n-\t\t-v)\n-\t\t\tunset GIT_QUIET\n-\t\t\t;;\n-\t\t--progress)\n-\t\t\tprogress=1\n-\t\t\t;;\n-\t\t-i|--init)\n-\t\t\tinit=1\n-\t\t\t;;\n-\t\t--require-init)\n-\t\t\trequire_init=1\n-\t\t\t;;\n-\t\t--remote)\n-\t\t\tremote=1\n-\t\t\t;;\n-\t\t-N|--no-fetch)\n-\t\t\tnofetch=1\n-\t\t\t;;\n-\t\t-f|--force)\n-\t\t\tforce=$1\n-\t\t\t;;\n-\t\t-r|--rebase)\n-\t\t\trebase=1\n-\t\t\t;;\n-\t\t--reference)\n-\t\t\tcase \"$2\" in '') usage ;; esac\n-\t\t\treference=\"--reference=$2\"\n-\t\t\tshift\n-\t\t\t;;\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\tmerge=1\n-\t\t\t;;\n-\t\t--recursive)\n-\t\t\trecursive=1\n-\t\t\t;;\n-\t\t--checkout)\n-\t\t\tcheckout=1\n-\t\t\t;;\n-\t\t--recommend-shallow)\n-\t\t\trecommend_shallow=\"--recommend-shallow\"\n-\t\t\t;;\n-\t\t--no-recommend-shallow)\n-\t\t\trecommend_shallow=\"--no-recommend-shallow\"\n-\t\t\t;;\n-\t\t--depth)\n-\t\t\tcase \"$2\" in '') usage ;; esac\n-\t\t\tdepth=\"--depth=$2\"\n-\t\t\tshift\n-\t\t\t;;\n-\t\t--depth=*)\n-\t\t\tdepth=$1\n-\t\t\t;;\n-\t\t-j|--jobs)\n-\t\t\tcase \"$2\" in '') usage ;; esac\n-\t\t\tjobs=\"--jobs=$2\"\n-\t\t\tshift\n-\t\t\t;;\n-\t\t--jobs=*)\n-\t\t\tjobs=$1\n-\t\t\t;;\n-\t\t--single-branch)\n-\t\t\tsingle_branch=\"--single-branch\"\n-\t\t\t;;\n-\t\t--no-single-branch)\n-\t\t\tsingle_branch=\"--no-single-branch\"\n-\t\t\t;;\n-\t\t--filter)\n-\t\t\tcase \"$2\" in '') usage ;; esac\n-\t\t\tfilter=\"--filter=$2\"\n-\t\t\tshift\n-\t\t\t;;\n-\t\t--filter=*)\n-\t\t\tfilter=\"$1\"\n-\t\t\t;;\n-\t\t--)\n-\t\t\tshift\n-\t\t\tbreak\n-\t\t\t;;\n-\t\t-*)\n-\t\t\tusage\n-\t\t\t;;\n-\t\t*)\n-\t\t\tbreak\n-\t\t\t;;\n-\t\tesac\n-\t\tshift\n-\tdone\n-\n-\tgit ${wt_prefix:+-C \"$wt_prefix\"} submodule--helper update \\\n-\t\t${GIT_QUIET:+--quiet} \\\n-\t\t${force:+--force} \\\n-\t\t${progress:+\"--progress\"} \\\n-\t\t${remote:+--remote} \\\n-\t\t${recursive:+--recursive} \\\n-\t\t${init:+--init} \\\n-\t\t${nofetch:+--no-fetch} \\\n-\t\t${wt_prefix:+--prefix \"$wt_prefix\"} \\\n-\t\t${rebase:+--rebase} \\\n-\t\t${merge:+--merge} \\\n-\t\t${checkout:+--checkout} \\\n-\t\t${reference:+\"$reference\"} \\\n-\t\t${dissociate:+\"--dissociate\"} \\\n-\t\t${depth:+\"$depth\"} \\\n-\t\t${require_init:+--require-init} \\\n-\t\t${dissociate:+\"--dissociate\"} \\\n-\t\t$single_branch \\\n-\t\t$recommend_shallow \\\n-\t\t$jobs \\\n-\t\t$filter \\\n-\t\t-- \\\n-\t\t\"$@\"\n-}\n-\n-# This loop parses the command line arguments to find the\n-# subcommand name to dispatch.  Parsing of the subcommand specific\n-# options are primarily done by the subcommand implementations.\n-# Subcommand specific options such as --branch and --cached are\n-# parsed here as well, for backward compatibility.\n \n while test $# != 0 && test -z \"$command\"\n do\n@@ -235,7 +79,8 @@ absorbgitdirs)\n \tgit submodule--helper \"$command\" --prefix \"$wt_prefix\" \"$@\"\n \t;;\n update)\n-\tcmd_update \"$@\"\n+\tgit ${wt_prefix:+-C \"$wt_prefix\"} submodule--helper \"$command\" \\\n+\t\t${GIT_QUIET:+--quiet} ${wt_prefix:+--prefix \"$wt_prefix\"} \"$@\"\n \t;;\n add | foreach | init | deinit | set-branch | set-url | status | summary | sync)\n \tgit ${wt_prefix:+-C \"$wt_prefix\"} submodule--helper \"$command\" \\\n-- \n2.36.1.1178.gb5b1747c546\n\n"},{"id":"457118","messageId":"kl6lzgig5qmc.fsf@chooglen-macbookpro.roam.corp.google.com","threadId":"57979","inReplyTo":"RFC-cover-00.20-00000000000-20220610T011725Z-avarab@gmail.com","subject":"Re: [RFC PATCH 00/20] submodule: remove git-submodule.sh, create bare builtin/submodule.c","fromName":"Glen Choo","fromEmail":"chooglen@google.com","sentAt":"2022-06-13T19:07:39Z","receivedAt":"2022-06-13T20:25:36Z","isPatch":true,"sender":{"key":"glencbz@gmail.com","avatar":"https://avatars.githubusercontent.com/u/58092771?v=4"},"body":"Ævar Arnfjörð Bjarmason <avarab@gmail.com> writes:\n\n>> As a result, git-submodule.sh::cmd_update() is now an (almost) one-liner:\n>>\n>> cmd_update() { git ${wt_prefix:+-C \"$wt_prefix\"} submodule--helper update\n>> ${wt_prefix:+--prefix \"$wt_prefix\"}\n>> \"$@\" }\n>>\n>> and best of all, \"git submodule update\" now shows a usage string for its own\n>> subcommand instead of a giant usage string for all of \"git submodule\" :)\n>>\n>> Given how many options \"git submodule update\" accepts, this series takes a\n>> gradual approach:\n>>\n>>  1. Create a variable opts, which holds the literal options we want to pass\n>>     to \"git submodule--helper update\". Then, for each option...\n>>  2. If \"git submodule--helper update\" already understands the string option,\n>>     append it to opts and remove any special handling (1-3/8).\n>>  3. Otherwise, if the option makes sense, teach \"git submodule--helper\n>>     update\" to understand the option. Goto 2. (4-5/8).\n>>  4. Otherwise, if the option makes no sense, drop it (6/8).\n>>  5. When we've processed all options, delete all the option parsing code\n>>     (7/8) and clean up (8/8).\n>\n> That's quite the timing coincidence. I hacked this up yesterday,\n> thinking that the submodule topic had been too quiet for a while, and\n> wondering how hard it was to convert the rest of git-submodule.sh.\n>\n> It's more than 2x the length of yours, but gets to the point where we\n> can \"git rm git-submodule.sh\".\n\nVery cool. I've skimmed through all of the patches, which mostly look\ngood except for ~1-2 things.\n\nYour series shows that there isn't any prohibitively difficult work left\nto finish the conversion, which is great! The real problem IMO is the\npotential for mechanical errors given how many lines this touches.\n\nHere's a way of breaking apart the work that makes sense to me:\n\n- Reuse the patches that prepare git-submodule.sh for the conversion,\n  particularly 1-7/20 (create a \"case\" dispatch statement and its\n  preceding patches).\n- Keep my series that prepares \"update\", since that's the most tedious\n  one to convert. If I don't dispatch to the \"case\" statement, I don't\n  think it will even conflict with the preparatory series.\n\n  Some of your patches make more sense than mine, and I'll incorporate\n  them as necessary :)\n- Dispatch subcommands using the \"case\" dispatch, including \"update\". We\n  might have to do this slowly if we want things to be easy to eyeball.\n- \"git rm git-submodule.sh\"!\n\n>> Glen Choo (8):\n>>   submodule update: remove intermediate parsing\n>>   submodule update: pass options containing \"[no-]\"\n>>   submodule update: pass options with stuck forms\n>\n> Yeah, this is the alternate approach I considered and ended up\n> discarding. I.e. to make forward progress with migrating things away\n> from the cmd_*() functions you either have to prepare things in\n> advance and then sweep the rug from under them in one go.\n>\n> Or, as you're doing here teaching them about the options they're\n> not-really-parsing anymore, but must know about because they're in a\n> loop that ends with a \"if unknown option, usage\".\n\nYes, if you took as many steps as I did, your series would be way too\nlong :P\n\nTo convert \"update\", I don't think this many steps is necessary; I\nprepared it this way primarily to make it easier for everyone to spot\nhow the options changed so that they can give feedback. Some of these\ncan be squashed in my reroll\n\n>>   submodule--helper update: use one param per type\n>\n> Same as my 13/20, but I ended up doing it in a more narrow/smaller\n> way. I tried your way and ran into some bug, then figured I'd do it\n> more narrowly instead of debugging it.\n\nYeah your approach is easier to eyeball, so I'll do this instead.\n\n>>   submodule update: remove -v, pass --quiet\n>\n> Hrm, so we don't need it at all then. Well, that's a bit simpler than\n> my 1[45]/20 and 17/20 :)\n>\n> So yeah, definitely RFC-quality, but I ran into that one test that\n> used -v, and then saw the missing docs etc. But no cheating, so I've\n> left it in :)\n>\n> I do wonder if we should leave it in anyway, we never documented -v,\n> but we *did* understand it, and if you look at:\n>\n>     git log -p -Gsay -- git-submodule.sh\n>\n> We used to have a lot more code impacted by it, but looking at this\n> again now it would have only been for users of command-lines like:\n>\n>     git submodule --quiet update -v [...]\n>\n> I.e. where we already set the flag to the non-default quiet, and then\n> used -v to flip it.\n>\n> I think at this point I've talked myself into \"let's just remove it\",\n> but maybe...\n\nOn hindsight, what I did is definitely cheating ;)\n\nMy series also breaks the way we'd handle --quiet in \"git submodule\",\ni.e.\n\n   git submodule --quiet update\n\nshould be quiet, but isn't.\n\nYour approach actually handles --quiet as per the original shell script,\nwhich is a good enough reason to do it your way. We can think about\nremoving it later.\n\n> Brief commentary on my patches, details in commit messages:\n>\n> Ævar Arnfjörð Bjarmason (20):\n>   git-submodule.sh: remove unused sanitize_submodule_env()\n>   git-submodule.sh: remove unused $prefix variable\n>   git-submodule.sh: remove unused --super-prefix logic\n>\n> I removed a bit more dead code here than yours.\n>\n>   git-submodule.sh: normalize parsing of \"--branch\"\n>   git-submodule.sh: normalize parsing of --cached\n>\n> This & various other prep commits (hereafter \"easy prep\") make\n> subsequent one-time conversions of whole cmd_*() easier.\n>\n>   submodule--helper: rename \"absorb-git-dirs\" to \"absorbgitdirs\"\n>   git-submodule.sh: create a \"case\" dispatch statement\n>\n> easy prep\n\nThis would all make sense in a preparatory series, with the exception of \n3/20 git-submodule.sh: remove unused --super-prefix logic.\n\nWe have several instances where we invoke submodule--helper directly\nwith --super-prefix, e.g. inside sync_submodule():\n    \n    if (flags & OPT_RECURSIVE) {\n      struct child_process cpr = CHILD_PROCESS_INIT;\n\n      cpr.git_cmd = 1;\n      cpr.dir = path;\n      prepare_submodule_repo_env(&cpr.env_array);\n\n      strvec_push(&cpr.args, \"--super-prefix\"); /* Here */\n\nI even have a (as of now private) patch that replaces \"update\"'s\n--recursive-prefix with --super-prefix.\n\nThis probably wasn't caught in the tests because this only affects how\nwe calculate the submodule 'displayname'.\n\n>   submodule--helper: pretend to be \"git submodule\" in \"-h\" output\n>\n> easy prep & bug fix for existing (on master) output bugs.\n>\n>   git-submodule.sh: dispatch \"sync\" to helper\n>   git-submodule.sh: dispatch directly to helper\n>   git-submodule.sh: dispatch \"foreach\" to helper\n>\n> These are easy conversions as the options 1=1 map after the above\n> prep.\n\nYes, these are pretty easy. I'm worried about the number of lines\nchanged and the potential for mechanical errors, but we can roll these\nmore slowly if necessary.\n\n>   submodule--helper: have --require-init imply --init\n>   submodule--helper: understand --checkout, --merge and --rebase\n>     synonyms\n>   git-submodule doc: document the -v\" option to \"update\"\n>   submodule--helper: understand -v option for \"update\"\n>\n> not-so-easy prep for \"cmd_update()\"\n>\n>   git-submodule.sh: dispatch \"update\" to helper\n>\n> Full cmd_update() migration in one go.\n\nYeah, and since it's not-so-easy, it probably makes sense to continue to\nkeep my series around. I'll borrow some of these patches if that's ok :)\n\n>   git-submodule.sh: use \"$quiet\", not \"$GIT_QUIET\"\n>\n> \"easy prep\", but this one is less overall churn if done at the end,\n> but as noted above could/should maybe be dropped entirely.\n>\n>   git-submodule.sh: simplify parsing loop\n>\n> Not really needed, but I wanted to get the code as close to minimal\n> for the next step, to eyeball the resulting sh v.s. C version.\n>\n>   submodule: make it a built-in, remove git-submodule.sh\n>\n> We now have a builtin/submodule.c *and* the current\n> builtin/submodule--helper.c, and we even dispatch to \"git\n> submodule--helper\" via run_command()!\n>\n> The idea is to be as close as possible to a bug-for-bug implementation\n> of the shellscript, and that reviewers should be confident in being\n> able to trace what commands we invoked before/after, we're invoking\n> the same \"git submodule--helper\" commands.\n>\n> Of course we eventually want to get to some full union of\n> builtin/submodule{,--helper}.c, but that can wait.\n>\n>   submodule: add a subprocess-less submodule.useBuiltin setting\n>\n> Wait, a useBuiltin setting to switch between two built-ins? Yeah,\n> maybe it makes little sense, but here we get rid of the run_command()\n> overhead, and could generally use the built-in to experiment with\n> deeper integration between the two.\n>\n> ...\n\nInteresting approach. It looks ok to me, but if we break up this series,\nmaybe this will be stale by the time we integrate the rest of the\nchanges?\n"},{"id":"457135","messageId":"patch-v2-01.12-c5afc72e075-20220613T220150Z-avarab@gmail.com","threadId":"57979","inReplyTo":"cover-v2-00.12-00000000000-20220613T220150Z-avarab@gmail.com","subject":"[PATCH v2 01/12] git-submodule.sh: remove unused sanitize_submodule_env()","fromName":"Ævar Arnfjörð Bjarmason","fromEmail":"avarab@gmail.com","sentAt":"2022-06-13T22:38:52Z","receivedAt":"2022-06-13T22:39:12Z","isPatch":true,"sender":{"key":"avarab@gmail.com","avatar":"https://avatars.githubusercontent.com/u/45301?v=4"},"body":"The sanitize_submodule_env() function was last used before\nb3c5f5cb048 (submodule: move core cmd_update() logic to C,\n2022-03-15), let's remove it.\n\nThis also allows us to remove clear_local_git_env() from\ngit-sh-setup.sh. That function hasn't been documented in\nDocumentation/git-sh-setup.sh, and since 14111fc4927 (git: submodule\nhonor -c credential.* from command line, 2016-02-29) it had only been\nused in the sanitize_submodule_env() function being removed here.\n\nSigned-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>\n---\n git-sh-setup.sh  |  7 -------\n git-submodule.sh | 11 -----------\n 2 files changed, 18 deletions(-)\n\ndiff --git a/git-sh-setup.sh b/git-sh-setup.sh\nindex d92df37e992..ecb60d9e3cb 100644\n--- a/git-sh-setup.sh\n+++ b/git-sh-setup.sh\n@@ -285,13 +285,6 @@ get_author_ident_from_commit () {\n \tparse_ident_from_commit author AUTHOR\n }\n \n-# Clear repo-local GIT_* environment variables. Useful when switching to\n-# another repository (e.g. when entering a submodule). See also the env\n-# list in git_connect()\n-clear_local_git_env() {\n-\tunset $(git rev-parse --local-env-vars)\n-}\n-\n # Generate a virtual base file for a two-file merge. Uses git apply to\n # remove lines from $1 that are not in $2, leaving only common lines.\n create_virtual_base() {\ndiff --git a/git-submodule.sh b/git-submodule.sh\nindex fd0b4a2c947..bc436c4ca47 100755\n--- a/git-submodule.sh\n+++ b/git-submodule.sh\n@@ -56,17 +56,6 @@ isnumber()\n \tn=$(($1 + 0)) 2>/dev/null && test \"$n\" = \"$1\"\n }\n \n-# Sanitize the local git environment for use within a submodule. We\n-# can't simply use clear_local_git_env since we want to preserve some\n-# of the settings from GIT_CONFIG_PARAMETERS.\n-sanitize_submodule_env()\n-{\n-\tsave_config=$GIT_CONFIG_PARAMETERS\n-\tclear_local_git_env\n-\tGIT_CONFIG_PARAMETERS=$save_config\n-\texport GIT_CONFIG_PARAMETERS\n-}\n-\n #\n # Add a new submodule to the working tree, .gitmodules and the index\n #\n-- \n2.36.1.1239.gfba91521d90\n\n"},{"id":"457136","messageId":"patch-v2-02.12-e127803d59d-20220613T220150Z-avarab@gmail.com","threadId":"57979","inReplyTo":"cover-v2-00.12-00000000000-20220613T220150Z-avarab@gmail.com","subject":"[PATCH v2 02/12] git-submodule.sh: remove unused $prefix var and --super-prefix","fromName":"Ævar Arnfjörð Bjarmason","fromEmail":"avarab@gmail.com","sentAt":"2022-06-13T22:38:53Z","receivedAt":"2022-06-13T22:39:13Z","isPatch":true,"sender":{"key":"avarab@gmail.com","avatar":"https://avatars.githubusercontent.com/u/45301?v=4"},"body":"Remove the $prefix variable which isn't used anymore, and hasn't been\nsince b3c5f5cb048 (submodule: move core cmd_update() logic to C,\n2022-03-15).\n\nBefore that we'd use it to invoke \"git submodule--helper\" with the\n\"--recursive-prefix\" option, but since b3c5f5cb048 that \"git\nsubmodule--helper\" option is only used when it invokes itself.\n\nSince we haven't used it since then we haven't been passing the\n--super-prefix option to \"git submodule--helper\", and can therefore\nremove the handling of it from builtin/submodule--helper.c as well.\n\nNote also that the still-existing code in builtin/submodule--helper.c\nto invoke other \"git submodule--helper\" processes with\n\"--super-prefix\" is not passing the option to\n\"cmd_submodule__helper()\", rather it's an argument to \"git\" itself.\n\nSigned-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>\n---\n builtin/submodule--helper.c | 53 +++++++++++++++----------------------\n git-submodule.sh            |  6 ++---\n 2 files changed, 24 insertions(+), 35 deletions(-)\n\ndiff --git a/builtin/submodule--helper.c b/builtin/submodule--helper.c\nindex 5c77dfcffee..9d3642290f3 100644\n--- a/builtin/submodule--helper.c\n+++ b/builtin/submodule--helper.c\n@@ -3364,35 +3364,32 @@ static int module_add(int argc, const char **argv, const char *prefix)\n \treturn 0;\n }\n \n-#define SUPPORT_SUPER_PREFIX (1<<0)\n-\n struct cmd_struct {\n \tconst char *cmd;\n \tint (*fn)(int, const char **, const char *);\n-\tunsigned option;\n };\n \n static struct cmd_struct commands[] = {\n-\t{\"list\", module_list, 0},\n-\t{\"name\", module_name, 0},\n-\t{\"clone\", module_clone, 0},\n-\t{\"add\", module_add, SUPPORT_SUPER_PREFIX},\n-\t{\"update\", module_update, 0},\n-\t{\"resolve-relative-url-test\", resolve_relative_url_test, 0},\n-\t{\"foreach\", module_foreach, SUPPORT_SUPER_PREFIX},\n-\t{\"init\", module_init, SUPPORT_SUPER_PREFIX},\n-\t{\"status\", module_status, SUPPORT_SUPER_PREFIX},\n-\t{\"sync\", module_sync, SUPPORT_SUPER_PREFIX},\n-\t{\"deinit\", module_deinit, 0},\n-\t{\"summary\", module_summary, SUPPORT_SUPER_PREFIX},\n-\t{\"push-check\", push_check, 0},\n-\t{\"absorb-git-dirs\", absorb_git_dirs, SUPPORT_SUPER_PREFIX},\n-\t{\"is-active\", is_active, 0},\n-\t{\"check-name\", check_name, 0},\n-\t{\"config\", module_config, 0},\n-\t{\"set-url\", module_set_url, 0},\n-\t{\"set-branch\", module_set_branch, 0},\n-\t{\"create-branch\", module_create_branch, 0},\n+\t{\"list\", module_list},\n+\t{\"name\", module_name},\n+\t{\"clone\", module_clone},\n+\t{\"add\", module_add},\n+\t{\"update\", module_update},\n+\t{\"resolve-relative-url-test\", resolve_relative_url_test},\n+\t{\"foreach\", module_foreach},\n+\t{\"init\", module_init},\n+\t{\"status\", module_status},\n+\t{\"sync\", module_sync},\n+\t{\"deinit\", module_deinit},\n+\t{\"summary\", module_summary},\n+\t{\"push-check\", push_check},\n+\t{\"absorb-git-dirs\", absorb_git_dirs},\n+\t{\"is-active\", is_active},\n+\t{\"check-name\", check_name},\n+\t{\"config\", module_config},\n+\t{\"set-url\", module_set_url},\n+\t{\"set-branch\", module_set_branch},\n+\t{\"create-branch\", module_create_branch},\n };\n \n int cmd_submodule__helper(int argc, const char **argv, const char *prefix)\n@@ -3401,15 +3398,9 @@ int cmd_submodule__helper(int argc, const char **argv, const char *prefix)\n \tif (argc < 2 || !strcmp(argv[1], \"-h\"))\n \t\tusage(\"git submodule--helper <command>\");\n \n-\tfor (i = 0; i < ARRAY_SIZE(commands); i++) {\n-\t\tif (!strcmp(argv[1], commands[i].cmd)) {\n-\t\t\tif (get_super_prefix() &&\n-\t\t\t    !(commands[i].option & SUPPORT_SUPER_PREFIX))\n-\t\t\t\tdie(_(\"%s doesn't support --super-prefix\"),\n-\t\t\t\t    commands[i].cmd);\n+\tfor (i = 0; i < ARRAY_SIZE(commands); i++)\n+\t\tif (!strcmp(argv[1], commands[i].cmd))\n \t\t\treturn commands[i].fn(argc - 1, argv + 1, prefix);\n-\t\t}\n-\t}\n \n \tdie(_(\"'%s' is not a valid submodule--helper \"\n \t      \"subcommand\"), argv[1]);\ndiff --git a/git-submodule.sh b/git-submodule.sh\nindex bc436c4ca47..53847bbf6e2 100755\n--- a/git-submodule.sh\n+++ b/git-submodule.sh\n@@ -41,7 +41,6 @@ files=\n remote=\n nofetch=\n update=\n-prefix=\n custom_name=\n depth=\n progress=\n@@ -127,7 +126,7 @@ cmd_add()\n \t\tusage\n \tfi\n \n-\tgit ${wt_prefix:+-C \"$wt_prefix\"} ${prefix:+--super-prefix \"$prefix\"} submodule--helper add ${GIT_QUIET:+--quiet} ${force:+--force} ${progress:+\"--progress\"} ${branch:+--branch \"$branch\"} ${reference_path:+--reference \"$reference_path\"} ${dissociate:+--dissociate} ${custom_name:+--name \"$custom_name\"} ${depth:+\"$depth\"} -- \"$@\"\n+\tgit ${wt_prefix:+-C \"$wt_prefix\"} submodule--helper add ${GIT_QUIET:+--quiet} ${force:+--force} ${progress:+\"--progress\"} ${branch:+--branch \"$branch\"} ${reference_path:+--reference \"$reference_path\"} ${dissociate:+--dissociate} ${custom_name:+--name \"$custom_name\"} ${depth:+\"$depth\"} -- \"$@\"\n }\n \n #\n@@ -189,7 +188,7 @@ cmd_init()\n \t\tshift\n \tdone\n \n-\tgit ${wt_prefix:+-C \"$wt_prefix\"} ${prefix:+--super-prefix \"$prefix\"} submodule--helper init ${GIT_QUIET:+--quiet} -- \"$@\"\n+\tgit ${wt_prefix:+-C \"$wt_prefix\"} submodule--helper init ${GIT_QUIET:+--quiet} -- \"$@\"\n }\n \n #\n@@ -346,7 +345,6 @@ cmd_update()\n \t\t${init:+--init} \\\n \t\t${nofetch:+--no-fetch} \\\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${dissociate:+\"--dissociate\"} \\\n-- \n2.36.1.1239.gfba91521d90\n\n"},{"id":"457137","messageId":"cover-v2-00.12-00000000000-20220613T220150Z-avarab@gmail.com","threadId":"57979","inReplyTo":"kl6lzgig5qmc.fsf@chooglen-macbookpro.roam.corp.google.com","subject":"[PATCH v2 00/12] submodule: make \"git submodule--helper\" behave like \"git submodule\"","fromName":"Ævar Arnfjörð Bjarmason","fromEmail":"avarab@gmail.com","sentAt":"2022-06-13T22:38:51Z","receivedAt":"2022-06-13T22:39:14Z","isPatch":true,"sender":{"key":"avarab@gmail.com","avatar":"https://avatars.githubusercontent.com/u/45301?v=4"},"body":"This series:\n\n * Removes dead code from git-submodule.sh, or dead code where it was\n   the last user.\n\n * Simplifies CLI parsing in git-submodule.sh, where it was doing\n   something overly complex for no reason.\n\n * Brings \"git submodule--helper\" in line with the CLI interface of\n   \"git-submodule.sh\", for a follow-up series to remove the latter, as\n   we'll be able to make a new \"git submodule\" in C dispatch directly\n   to our new \"git submodule--helper\" code.\n\n * Removes the \"-v\" option to \"git submodule\", which has been\n   supported, but was a) never documented b) never did anything\n   anyway, except as a way to negate an earlier \"--quiet\" option, as\n   \"verbose\" was always the default.\n\n * The last couple of patches are cleanup that isn't strictly\n   neccesary for the end-goal of \"git submodule\" in C, but cleans up\n   some more shellscript code.\n\n   The \"say\" function is removed from \"git-sh-setup.sh\", now that\n   \"git-submodule.sh\" doesn't use it anymore (which happened before\n   this series) we can replace the couple of remaining uses with\n   \"echo\", and by having \"git-subtree.sh\" own the code that used to\n   live in \"git-sh-setup.sh\".\n\nThe approach here was to combine bits of the two RFC series' Glen and\nI sent out:\n\n - https://lore.kernel.org/git/pull.1275.git.git.1654820781.gitgitgadget@gmail.com/\n - https://lore.kernel.org/git/RFC-cover-00.20-00000000000-20220610T011725Z-avarab@gmail.com/\n\nMy branch for this (and passing CI) are at:\nhttps://github.com/avar/git/tree/avar/submodule-sh-dispatch-to-helper-directly-prep\n\nThe rest here is a reply to\nhttps://lore.kernel.org/git/kl6lzgig5qmc.fsf@chooglen-macbookpro.roam.corp.google.com/:\n\nOn Mon, Jun 13 2022, Glen Choo wrote:\n\n> Ævar Arnfjörð Bjarmason <avarab@gmail.com> writes:\n>\n>>> [...]\n>> That's quite the timing coincidence. I hacked this up yesterday,\n>> thinking that the submodule topic had been too quiet for a while, and\n>> wondering how hard it was to convert the rest of git-submodule.sh.\n>>\n>> It's more than 2x the length of yours, but gets to the point where we\n>> can \"git rm git-submodule.sh\".\n>\n> Very cool. I've skimmed through all of the patches, which mostly look\n> good except for ~1-2 things.\n>\n> Your series shows that there isn't any prohibitively difficult work left\n> to finish the conversion, which is great! The real problem IMO is the\n> potential for mechanical errors given how many lines this touches.\n\nYes, and as I've discovered in some further poking at the follow-up\nwork (not included here) we again lack quite a bit of testing.\n\n> Here's a way of breaking apart the work that makes sense to me:\n>\n> - Reuse the patches that prepare git-submodule.sh for the conversion,\n>   particularly 1-7/20 (create a \"case\" dispatch statement and its\n>   preceding patches).\n> - Keep my series that prepares \"update\", since that's the most tedious\n>   one to convert. If I don't dispatch to the \"case\" statement, I don't\n>   think it will even conflict with the preparatory series.\n>\n>   Some of your patches make more sense than mine, and I'll incorporate\n>   them as necessary :)\n> - Dispatch subcommands using the \"case\" dispatch, including \"update\". We\n>   might have to do this slowly if we want things to be easy to eyeball.\n> - \"git rm git-submodule.sh\"!\n\nHopefully there's no stepping on toes here, but I thought I'd send\nthis out now (I went back to the laptop) to avoid the duplicate work,\nsince I'd already attempted combining the two, and this is the result.\n\nObviously you may have different ideas about it, and I wouldn't at all\nmind a v3 that goes in a different direction if you think it's needed.\n\nAs noted in the CL above I think this is more palatable for an initial\niteration, i.e. it's not doing any of the migration work yet, but\nmerely doing small changes to bring git-submodule.sh and \"git\nsubmodule--helper\" in line with one another.\n\n>>>   submodule--helper update: use one param per type\n>>\n>> Same as my 13/20, but I ended up doing it in a more narrow/smaller\n>> way. I tried your way and ran into some bug, then figured I'd do it\n>> more narrowly instead of debugging it.\n>\n> Yeah your approach is easier to eyeball, so I'll do this instead.\n\nHopefully you'll like the change I made here, I kept my commit which\nnarrowlry changes it so that we pass --checkout, --merge and --rebase\nfrom git-submodule.sh.\n\nThen after that comes a commit extracted from your change where we\nmake \"git submodule--helper\" use the same interface for passing\noptions to itself.\n\nBoth are good changes to make, but I think it makes sense to split\nthem up. One is needed for \"git submodule\" in C, the other is just\njanitorial work in the \"git submodule--helper\" code.\n\nI think it makes sense to do both, but splitting up the concerns makes\nit a lot easier to review them IMO.\n\n>>>   submodule update: remove -v, pass --quiet\n>> [...]\n>> I think at this point I've talked myself into \"let's just remove it\",\n>> but maybe...\n>\n> On hindsight, what I did is definitely cheating ;)\n\nYour removal of \"-v\" is in this series. I rewrote the commit message\nto note exactly what we're changing, why it's thought to be OK etc.\n\n> My series also breaks the way we'd handle --quiet in \"git submodule\",\n> i.e.\n>\n>    git submodule --quiet update\n>\n> should be quiet, but isn't.\n>\n> Your approach actually handles --quiet as per the original shell script,\n> which is a good enough reason to do it your way. We can think about\n> removing it later.\n\nWe have some of these unfortunate \"top-level\" CLI options in other\nplaces, e.g. \"git commit-graph\", it's probably not worth it to remove\nthem, as they're easy enough to support, and have been documented for\na long time.\n\n>> Brief commentary on my patches, details in commit messages:\n>>\n>> Ævar Arnfjörð Bjarmason (20):\n>>   git-submodule.sh: remove unused sanitize_submodule_env()\n>>   git-submodule.sh: remove unused $prefix variable\n>>   git-submodule.sh: remove unused --super-prefix logic\n>>\n>> I removed a bit more dead code here than yours.\n>>\n>>   git-submodule.sh: normalize parsing of \"--branch\"\n>>   git-submodule.sh: normalize parsing of --cached\n>>\n>> This & various other prep commits (hereafter \"easy prep\") make\n>> subsequent one-time conversions of whole cmd_*() easier.\n>>\n>>   submodule--helper: rename \"absorb-git-dirs\" to \"absorbgitdirs\"\n>>   git-submodule.sh: create a \"case\" dispatch statement\n>>\n>> easy prep\n>\n> This would all make sense in a preparatory series, with the exception of \n> 3/20 git-submodule.sh: remove unused --super-prefix logic.\n>\n> We have several instances where we invoke submodule--helper directly\n> with --super-prefix, e.g. inside sync_submodule():\n>     \n>     if (flags & OPT_RECURSIVE) {\n>       struct child_process cpr = CHILD_PROCESS_INIT;\n>\n>       cpr.git_cmd = 1;\n>       cpr.dir = path;\n>       prepare_submodule_repo_env(&cpr.env_array);\n>\n>       strvec_push(&cpr.args, \"--super-prefix\"); /* Here */\n>\n> I even have a (as of now private) patch that replaces \"update\"'s\n> --recursive-prefix with --super-prefix.\n>\n> This probably wasn't caught in the tests because this only affects how\n> we calculate the submodule 'displayname'.\n\nThis is still in this series as 02/12. I think you've misunderstood\nthat code, it *is* invoking \"git submodule--helper\" with\n\"--super-prefix\", but the option is passed as:\n\n    git --super-prefix <path> submodule--helper\n\nAnd not as:\n\n    git submodule--helper --super-prefix <path>\n\nThis is thus handled by other code before builtin/submodule--helper.c,\nand it doesn't need to handle it.\n\nBut anyway, this is confusing, so I updated the commit message (seen\nin the range-diff below)>\n\n>>   submodule--helper: pretend to be \"git submodule\" in \"-h\" output\n>>\n>> easy prep & bug fix for existing (on master) output bugs.\n>>\n>>   git-submodule.sh: dispatch \"sync\" to helper\n>>   git-submodule.sh: dispatch directly to helper\n>>   git-submodule.sh: dispatch \"foreach\" to helper\n>>\n>> These are easy conversions as the options 1=1 map after the above\n>> prep.\n>\n> Yes, these are pretty easy. I'm worried about the number of lines\n> changed and the potential for mechanical errors, but we can roll these\n> more slowly if necessary.\n\nAll of this is left out here for now. FWIW I don't think it's hard to\nreview due to the line count, yes e.g. the 2nd patch there is ~300\nlines changed, but it's just 5 lines removed/added if we omit the\nmechanical deletion of the now-unused functions.\n\nMaybe it would be better to omit that and do just one \"git rm\" at the\nend? FWIW I thought doing it atomically so that we were left with no\ndead code after each step made it easier to review.\n\n>>   submodule--helper: have --require-init imply --init\n>>   submodule--helper: understand --checkout, --merge and --rebase\n>>     synonyms\n>>   git-submodule doc: document the -v\" option to \"update\"\n>>   submodule--helper: understand -v option for \"update\"\n>>\n>> not-so-easy prep for \"cmd_update()\"\n>>\n>>   git-submodule.sh: dispatch \"update\" to helper\n>>\n>> Full cmd_update() migration in one go.\n>\n> Yeah, and since it's not-so-easy, it probably makes sense to continue to\n> keep my series around. I'll borrow some of these patches if that's ok :)\n\nThe proposal in *this series* is to leave this aside for now, but\ngenerally I wonder what part of it you find not-so-easy.\n\nPersonally I find it much harder to carefully review the way you\nproposed to do it, i.e. to \"buffer up\" options that we \"don't handle\",\nbut actually need to sort-of handle, as we'd still like to die if we\nhave unknown options.\n\nParticularly since shellscript quoting etc. is a pain with that sort\nof thing, as it doesn't have any real list or key-value\ndatastructures.\n\nWhereas getting it to the point where we're clearly just passing\noptions as-is through beforehand, and then simply dropping the wrapper\nis, I think, much easier to review. You only need to trust or check\nthat e.g. \"git submodule--helper update\" also supports a \"--progress\"\noption or whatever, and/or that we've got coverage for it.\n\n>> [...]\n>> Wait, a useBuiltin setting to switch between two built-ins? Yeah,\n>> maybe it makes little sense, but here we get rid of the run_command()\n>> overhead, and could generally use the built-in to experiment with\n>> deeper integration between the two.\n>>\n>> ...\n>\n> Interesting approach. It looks ok to me, but if we break up this series,\n> maybe this will be stale by the time we integrate the rest of the\n> changes?\n\nYes, I think it's probably best to drop this idea of a useBuiltin\nsetting in this case entirely.\n\nThe reason we did it for \"stash\", \"git add --interactive\" etc. is that\nwe were (or are) dispatching to drastically different code, i.e. we\nhad or have an entire all-at-once re-implementation of the command or\nfeature.\n\nWhereas for \"git submodule\" we've been doing it incrementally already,\nand complexity-wise I think previous rounds to migrate to \"git\nsubmodule--helper\" were much more likely have subtle breakages than\nthe relatively straightforward migration we've got left.\n\nB.t.w. here is my WIP re-roll of the full thing, on top of these\npatches:\nhttps://github.com/avar/git/tree/avar/submodule-sh-dispatch-to-helper-directly-2\n\nAs covered in amended commits & tests there the v1 RFC (but not the\nparts re-rolled here, just the later stuff) had some subtle behavior\nchanges. See the new \"submodule tests: test usage behavior\" commit\nthere & follow-ups to that.\n\nI haven't found any bad bugs yet, but just obscure edge cases in\ne.g. how we handle \"git submodule --\" before/after.\n\nGlen Choo (2):\n  submodule update: remove \"-v\" option\n  submodule--helper: eliminate internal \"--update\" option\n\nÆvar Arnfjörð Bjarmason (10):\n  git-submodule.sh: remove unused sanitize_submodule_env()\n  git-submodule.sh: remove unused $prefix var and --super-prefix\n  git-submodule.sh: make \"$cached\" variable a boolean\n  git-submodule.sh: remove unused top-level \"--branch\" argument\n  submodule--helper: have --require-init imply --init\n  submodule--helper: rename \"absorb-git-dirs\" to \"absorbgitdirs\"\n  submodule--helper: report \"submodule\" as our name in \"-h\" output\n  submodule--helper: understand --checkout, --merge and --rebase\n    synonyms\n  git-submodule.sh: use \"$quiet\", not \"$GIT_QUIET\"\n  git-sh-setup.sh: remove \"say\" function, change last users\n\n builtin/submodule--helper.c    | 127 +++++++++++++++++----------------\n contrib/subtree/git-subtree.sh |  15 +++-\n git-instaweb.sh                |   2 +-\n git-sh-setup.sh                |  16 -----\n git-submodule.sh               |  88 ++++++++---------------\n submodule.c                    |   2 +-\n t/t7406-submodule-update.sh    |   2 +-\n 7 files changed, 112 insertions(+), 140 deletions(-)\n\nRange-diff against v1:\n 1:  0e9f13822ef !  1:  c5afc72e075 git-submodule.sh: remove unused sanitize_submodule_env()\n    @@ Metadata\n      ## Commit message ##\n         git-submodule.sh: remove unused sanitize_submodule_env()\n     \n    -    The sanitize_submodule_env() function was last used in\n    +    The sanitize_submodule_env() function was last used before\n         b3c5f5cb048 (submodule: move core cmd_update() logic to C,\n         2022-03-15), let's remove it.\n     \n 2:  8fcd832e58f <  -:  ----------- git-submodule.sh: remove unused $prefix variable\n 3:  6c774505ac5 !  2:  e127803d59d git-submodule.sh: remove unused --super-prefix logic\n    @@ Metadata\n     Author: Ævar Arnfjörð Bjarmason <avarab@gmail.com>\n     \n      ## Commit message ##\n    -    git-submodule.sh: remove unused --super-prefix logic\n    +    git-submodule.sh: remove unused $prefix var and --super-prefix\n     \n    -    The \"$prefix\" variable has not been set since b3c5f5cb048 (submodule:\n    -    move core cmd_update() logic to C, 2022-03-15), so we'd never pass the\n    +    Remove the $prefix variable which isn't used anymore, and hasn't been\n    +    since b3c5f5cb048 (submodule: move core cmd_update() logic to C,\n    +    2022-03-15).\n    +\n    +    Before that we'd use it to invoke \"git submodule--helper\" with the\n    +    \"--recursive-prefix\" option, but since b3c5f5cb048 that \"git\n    +    submodule--helper\" option is only used when it invokes itself.\n    +\n    +    Since we haven't used it since then we haven't been passing the\n         --super-prefix option to \"git submodule--helper\", and can therefore\n         remove the handling of it from builtin/submodule--helper.c as well.\n     \n    +    Note also that the still-existing code in builtin/submodule--helper.c\n    +    to invoke other \"git submodule--helper\" processes with\n    +    \"--super-prefix\" is not passing the option to\n    +    \"cmd_submodule__helper()\", rather it's an argument to \"git\" itself.\n    +\n         Signed-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>\n     \n      ## builtin/submodule--helper.c ##\n    @@ builtin/submodule--helper.c: int cmd_submodule__helper(int argc, const char **ar\n      \n      \tdie(_(\"'%s' is not a valid submodule--helper \"\n      \t      \"subcommand\"), argv[1]);\n    +\n    + ## git-submodule.sh ##\n    +@@ git-submodule.sh: files=\n    + remote=\n    + nofetch=\n    + update=\n    +-prefix=\n    + custom_name=\n    + depth=\n    + progress=\n    +@@ git-submodule.sh: cmd_add()\n    + \t\tusage\n    + \tfi\n    + \n    +-\tgit ${wt_prefix:+-C \"$wt_prefix\"} ${prefix:+--super-prefix \"$prefix\"} submodule--helper add ${GIT_QUIET:+--quiet} ${force:+--force} ${progress:+\"--progress\"} ${branch:+--branch \"$branch\"} ${reference_path:+--reference \"$reference_path\"} ${dissociate:+--dissociate} ${custom_name:+--name \"$custom_name\"} ${depth:+\"$depth\"} -- \"$@\"\n    ++\tgit ${wt_prefix:+-C \"$wt_prefix\"} submodule--helper add ${GIT_QUIET:+--quiet} ${force:+--force} ${progress:+\"--progress\"} ${branch:+--branch \"$branch\"} ${reference_path:+--reference \"$reference_path\"} ${dissociate:+--dissociate} ${custom_name:+--name \"$custom_name\"} ${depth:+\"$depth\"} -- \"$@\"\n    + }\n    + \n    + #\n    +@@ git-submodule.sh: cmd_init()\n    + \t\tshift\n    + \tdone\n    + \n    +-\tgit ${wt_prefix:+-C \"$wt_prefix\"} ${prefix:+--super-prefix \"$prefix\"} submodule--helper init ${GIT_QUIET:+--quiet} -- \"$@\"\n    ++\tgit ${wt_prefix:+-C \"$wt_prefix\"} submodule--helper init ${GIT_QUIET:+--quiet} -- \"$@\"\n    + }\n    + \n    + #\n    +@@ git-submodule.sh: cmd_update()\n    + \t\t${init:+--init} \\\n    + \t\t${nofetch:+--no-fetch} \\\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${dissociate:+\"--dissociate\"} \\\n 5:  124c062e3a1 !  3:  d5c8613c654 git-submodule.sh: normalize parsing of --cached\n    @@ Metadata\n     Author: Ævar Arnfjörð Bjarmason <avarab@gmail.com>\n     \n      ## Commit message ##\n    -    git-submodule.sh: normalize parsing of --cached\n    +    git-submodule.sh: make \"$cached\" variable a boolean\n     \n         Remove the assignment of \"$1\" to the \"$cached\" variable. As seen in\n         the initial implementation in 70c7ac22de6 (Add git-submodule command,\n         2007-05-26) we only need to keep track of if we've seen the --cached\n    -    option. In 28f9af5d25e (git-submodule summary: code framework,\n    -    2008-03-11) \"$1\" was assigned to it, but there was no reason to do\n    -    so. Let's undo that.\n    +    option, not save the \"--cached\" string for later use.\n    +\n    +    In 28f9af5d25e (git-submodule summary: code framework, 2008-03-11)\n    +    \"$1\" was assigned to it, but since there was no reason to do so let's\n    +    stop doing it. This trivial change will make it easier to reason about\n    +    an eventual change that'll remove the cmd_summary() function in favor\n    +    of dispatching to \"git submodule--helper summary\" directly.\n     \n         Signed-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>\n     \n    @@ git-submodule.sh: cmd_summary() {\n      \t\t--files)\n      \t\t\tfiles=\"$1\"\n     @@ git-submodule.sh: do\n    - \t\tGIT_QUIET=1\n    + \t\tbranch=\"$2\"; shift\n      \t\t;;\n      \t--cached)\n     -\t\tcached=\"$1\"\n 4:  f27723aa0a2 !  4:  fd328329b68 git-submodule.sh: normalize parsing of \"--branch\"\n    @@ Metadata\n     Author: Ævar Arnfjörð Bjarmason <avarab@gmail.com>\n     \n      ## Commit message ##\n    -    git-submodule.sh: normalize parsing of \"--branch\"\n    +    git-submodule.sh: remove unused top-level \"--branch\" argument\n     \n         In 5c08dbbdf1a (git-submodule: fix subcommand parser, 2008-01-15) the\n         \"--branch\" option was supported as an option to \"git submodule\"\n    @@ Commit message\n         \"--cache\" added (or rather modified) in 496eeeb19b9 (git-submodule.sh:\n         avoid \"test <cond> -a/-o <cond>\", 2014-06-10).\n     \n    -    But there's been a logic error in that check, this looked like it\n    -    should be supporting:\n    +    But there's been a logic error in that check, which at a glance looked\n    +    like it should be supporting:\n     \n             git submodule --branch <branch> (add | set-branch) [<options>]\n     \n    @@ Commit message\n         we have \"--branch\" here already we'll emit usage, even for \"add\" and\n         \"set-branch\".\n     \n    -    Since nobody's complained about \"--branch <branch>\" not being\n    -    supported as argument to \"git submodule\" itself, i.e. we want to\n    -    support:\n    +    So in addition to never having documented this form it hasn't worked\n    +    since b57e8119e6e was released with v2.22.0 it's safe to remove this\n    +    code. I.e. we don't want to support the form noted above, but only:\n     \n    -        git submodule (add | set-branch) --branch <branch>  [<options>]\n    -\n    -    But not the first form noted above. Let's just remove this code, we've\n    -    never documented \"--branch\" as a top-level option (unlike \"--quiet\"),\n    -    so this looks like it was an accident of the implementation, which we\n    -    broke v2.22.0, so we also know it must not have been important to\n    -    anyone.\n    +        git submodule (add | set-branch) --branch <branch> [<options>]\n     \n         Signed-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>\n     \n    @@ git-submodule.sh: do\n     -\t\tbranch=\"$2\"; shift\n     -\t\t;;\n      \t--cached)\n    - \t\tcached=\"$1\"\n    + \t\tcached=1\n      \t\t;;\n     @@ git-submodule.sh: then\n          fi\n12:  57b9df29ea6 !  5:  ef3265a588e submodule--helper: have --require-init imply --init\n    @@ Commit message\n         --require-init option imply --init, rather than having\n         \"git-submodule.sh\" add it implicitly.\n     \n    +    This change doesn't make any difference now, but eliminates another\n    +    special-case where \"git submodule--helper update\"'s behavior was\n    +    different from \"git submodule update\". This will make it easier to\n    +    eventually replace the cmd_update() function in git-submodule.sh.\n    +\n    +    We'll still need to keep the distinction between \"--init\" and\n    +    \"--require-init\" in git-submodule.sh. Once cmd_update() gets\n    +    re-implemented in C we'll be able to variables and other code related\n    +    to that, but not yet.\n    +\n         Signed-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>\n     \n      ## builtin/submodule--helper.c ##\n -:  ----------- >  6:  025694644fc submodule update: remove \"-v\" option\n 6:  b1ca1183885 !  7:  63155ab5026 submodule--helper: rename \"absorb-git-dirs\" to \"absorbgitdirs\"\n    @@ Commit message\n         absorb-git-dir function, 2016-12-12).\n     \n         Having these two be different will make it more tedious to dispatch to\n    -    \"git submodule--helper\" directly, so let's get rid of this needless\n    +    eventually dispatch \"git submodule--helper\" directly, as we'd need to\n    +    retain this name mapping. So let's get rid of this needless\n         inconsistency.\n     \n         Signed-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>\n    @@ submodule.c: void absorb_git_dir_into_superproject(const char *path,\n      \t\t\t     \"submodule--helper\",\n     -\t\t\t     \"absorb-git-dirs\", NULL);\n     +\t\t\t     \"absorbgitdirs\", NULL);\n    - \t\tprepare_submodule_repo_env(&cp.env_array);\n    + \t\tprepare_submodule_repo_env(&cp.env);\n      \t\tif (run_command(&cp))\n      \t\t\tdie(_(\"could not recurse into submodule '%s'\"), path);\n 7:  9f5cfbb864a <  -:  ----------- git-submodule.sh: create a \"case\" dispatch statement\n 8:  0c1a5063653 !  8:  99ac52d810f submodule--helper: pretend to be \"git submodule\" in \"-h\" output\n    @@ Metadata\n     Author: Ævar Arnfjörð Bjarmason <avarab@gmail.com>\n     \n      ## Commit message ##\n    -    submodule--helper: pretend to be \"git submodule\" in \"-h\" output\n    +    submodule--helper: report \"submodule\" as our name in \"-h\" output\n     \n    -    Change the usage output for \"git submodule--helper\" so that it will\n    -    pretend to be named \"git submodule\". This will allow us to dispatch\n    -    further into \"git submodule--helper\" from git-submodule.sh while\n    -    emitting the correct usage output.\n    +    Change the rest of the usage output for \"git submodule--helper\" so\n    +    that it will pretend to be named \"git submodule\", which it already did\n    +    e.g. in the case of \"status\", \"deinit\" and \"update\".\n    +\n    +    This will allow us to eventually dispatch further into \"git\n    +    submodule--helper\" from git-submodule.sh, while emitting the correct\n    +    usage output.\n    +\n    +    This does make the usage output of \"git submodule--helper\" itself\n    +    \"incorrect\", but since nothing user-facing invokes it directly it\n    +    makes sense to continue to elide that difference entirely. A user\n    +    isn't served by us exposing this internal implementation detail.\n     \n         This fixes a bug that's been there ever since \"git submodule\n         absorbgitdirs\" was added in f6f85861400 (submodule: add absorb-git-dir\n    @@ Commit message\n                 usage: git submodule absorbgitdirs [<options>] [<path>...]\n                 [.. same usage output ...]\n     \n    -    Note that in the case of \"status\", \"deinit\" and \"update\" we were\n    -    already referring to ourselves as \"git submodule\" in\n    -    builtin/submodule--helper.c.\n    -\n         Signed-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>\n     \n      ## builtin/submodule--helper.c ##\n 9:  bd0e4a4f8b8 <  -:  ----------- git-submodule.sh: dispatch \"sync\" to helper\n10:  498a1fd275b <  -:  ----------- git-submodule.sh: dispatch directly to helper\n11:  625320e13b9 <  -:  ----------- git-submodule.sh: dispatch \"foreach\" to helper\n13:  20db979a094 !  9:  01c5eee67c7 submodule--helper: understand --checkout, --merge and --rebase synonyms\n    @@ builtin/submodule--helper.c: static int module_update(int argc, const char **arg\n     +\t\t\tSM_UPDATE_MERGE),\n     +\t\tOPT_SET_INT('r', \"rebase\", &update_type,\n     +\t\t\tN_(\"use the 'rebase' update strategy\"),\n    -+\t\t\tSM_UPDATE_MERGE),\n    ++\t\t\tSM_UPDATE_REBASE),\n      \t\tOPT_STRING_LIST(0, \"reference\", &opt.references, N_(\"repo\"),\n      \t\t\t   N_(\"reference repository\")),\n      \t\tOPT_BOOL(0, \"dissociate\", &opt.dissociate,\n    @@ builtin/submodule--helper.c: static int module_update(int argc, const char **arg\n      \t\t\t\t\t\t    &opt.update_strategy) < 0)\n     \n      ## git-submodule.sh ##\n    -@@ git-submodule.sh: init=\n    - require_init=\n    +@@ git-submodule.sh: require_init=\n    + files=\n      remote=\n      nofetch=\n     -update=\n     +rebase=\n     +merge=\n     +checkout=\n    + custom_name=\n      depth=\n      progress=\n    - dissociate=\n     @@ git-submodule.sh: cmd_update()\n      \t\t\tforce=$1\n      \t\t\t;;\n14:  1cb40a5f42e <  -:  ----------- git-submodule doc: document the -v\" option to \"update\"\n15:  0c388eed1d1 <  -:  ----------- submodule--helper: understand -v option for \"update\"\n16:  08abadda7c3 <  -:  ----------- git-submodule.sh: dispatch \"update\" to helper\n17:  59a72296967 <  -:  ----------- git-submodule.sh: use \"$quiet\", not \"$GIT_QUIET\"\n18:  c5796878f0b <  -:  ----------- git-submodule.sh: simplify parsing loop\n19:  1423950de08 <  -:  ----------- submodule: make it a built-in, remove git-submodule.sh\n20:  b2aaad5c008 <  -:  ----------- submodule: add a subprocess-less submodule.useBuiltin setting\n -:  ----------- > 10:  ac00a9599de submodule--helper: eliminate internal \"--update\" option\n -:  ----------- > 11:  875acae8550 git-submodule.sh: use \"$quiet\", not \"$GIT_QUIET\"\n -:  ----------- > 12:  31517345ae8 git-sh-setup.sh: remove \"say\" function, change last users\n-- \n2.36.1.1239.gfba91521d90\n\n"},{"id":"457138","messageId":"patch-v2-03.12-d5c8613c654-20220613T220150Z-avarab@gmail.com","threadId":"57979","inReplyTo":"cover-v2-00.12-00000000000-20220613T220150Z-avarab@gmail.com","subject":"[PATCH v2 03/12] git-submodule.sh: make \"$cached\" variable a boolean","fromName":"Ævar Arnfjörð Bjarmason","fromEmail":"avarab@gmail.com","sentAt":"2022-06-13T22:38:54Z","receivedAt":"2022-06-13T22:39:16Z","isPatch":true,"sender":{"key":"avarab@gmail.com","avatar":"https://avatars.githubusercontent.com/u/45301?v=4"},"body":"Remove the assignment of \"$1\" to the \"$cached\" variable. As seen in\nthe initial implementation in 70c7ac22de6 (Add git-submodule command,\n2007-05-26) we only need to keep track of if we've seen the --cached\noption, not save the \"--cached\" string for later use.\n\nIn 28f9af5d25e (git-submodule summary: code framework, 2008-03-11)\n\"$1\" was assigned to it, but since there was no reason to do so let's\nstop doing it. This trivial change will make it easier to reason about\nan eventual change that'll remove the cmd_summary() function in favor\nof dispatching to \"git submodule--helper summary\" directly.\n\nSigned-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>\n---\n git-submodule.sh | 4 ++--\n 1 file changed, 2 insertions(+), 2 deletions(-)\n\ndiff --git a/git-submodule.sh b/git-submodule.sh\nindex 53847bbf6e2..b99a00d9f84 100755\n--- a/git-submodule.sh\n+++ b/git-submodule.sh\n@@ -446,7 +446,7 @@ cmd_summary() {\n \tdo\n \t\tcase \"$1\" in\n \t\t--cached)\n-\t\t\tcached=\"$1\"\n+\t\t\tcached=1\n \t\t\t;;\n \t\t--files)\n \t\t\tfiles=\"$1\"\n@@ -583,7 +583,7 @@ do\n \t\tbranch=\"$2\"; shift\n \t\t;;\n \t--cached)\n-\t\tcached=\"$1\"\n+\t\tcached=1\n \t\t;;\n \t--)\n \t\tbreak\n-- \n2.36.1.1239.gfba91521d90\n\n"},{"id":"457139","messageId":"patch-v2-04.12-fd328329b68-20220613T220150Z-avarab@gmail.com","threadId":"57979","inReplyTo":"cover-v2-00.12-00000000000-20220613T220150Z-avarab@gmail.com","subject":"[PATCH v2 04/12] git-submodule.sh: remove unused top-level \"--branch\" argument","fromName":"Ævar Arnfjörð Bjarmason","fromEmail":"avarab@gmail.com","sentAt":"2022-06-13T22:38:55Z","receivedAt":"2022-06-13T22:39:17Z","isPatch":true,"sender":{"key":"avarab@gmail.com","avatar":"https://avatars.githubusercontent.com/u/45301?v=4"},"body":"In 5c08dbbdf1a (git-submodule: fix subcommand parser, 2008-01-15) the\n\"--branch\" option was supported as an option to \"git submodule\"\nitself, i.e. \"git submodule --branch\" as a side-effect of its\nimplementation.\n\nThen in b57e8119e6e (submodule: teach set-branch subcommand,\n2019-02-08) when the \"set-branch\" subcommand was added the assertion\nthat we shouldn't have \"--branch\" anywhere except as an argument to\n\"add\" and \"set-branch\" was copy/pasted from the adjacent check for\n\"--cache\" added (or rather modified) in 496eeeb19b9 (git-submodule.sh:\navoid \"test <cond> -a/-o <cond>\", 2014-06-10).\n\nBut there's been a logic error in that check, which at a glance looked\nlike it should be supporting:\n\n    git submodule --branch <branch> (add | set-branch) [<options>]\n\nBut due to \"||\" in the condition (as opposed to \"&&\" for \"--cache\") if\nwe have \"--branch\" here already we'll emit usage, even for \"add\" and\n\"set-branch\".\n\nSo in addition to never having documented this form it hasn't worked\nsince b57e8119e6e was released with v2.22.0 it's safe to remove this\ncode. I.e. we don't want to support the form noted above, but only:\n\n    git submodule (add | set-branch) --branch <branch> [<options>]\n\nSigned-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>\n---\n git-submodule.sh | 14 --------------\n 1 file changed, 14 deletions(-)\n\ndiff --git a/git-submodule.sh b/git-submodule.sh\nindex b99a00d9f84..20fc1b620fa 100755\n--- a/git-submodule.sh\n+++ b/git-submodule.sh\n@@ -574,14 +574,6 @@ do\n \t-q|--quiet)\n \t\tGIT_QUIET=1\n \t\t;;\n-\t-b|--branch)\n-\t\tcase \"$2\" in\n-\t\t'')\n-\t\t\tusage\n-\t\t\t;;\n-\t\tesac\n-\t\tbranch=\"$2\"; shift\n-\t\t;;\n \t--cached)\n \t\tcached=1\n \t\t;;\n@@ -609,12 +601,6 @@ then\n     fi\n fi\n \n-# \"-b branch\" is accepted only by \"add\" and \"set-branch\"\n-if test -n \"$branch\" && (test \"$command\" != add || test \"$command\" != set-branch)\n-then\n-\tusage\n-fi\n-\n # \"--cached\" is accepted only by \"status\" and \"summary\"\n if test -n \"$cached\" && test \"$command\" != status && test \"$command\" != summary\n then\n-- \n2.36.1.1239.gfba91521d90\n\n"},{"id":"457140","messageId":"patch-v2-05.12-ef3265a588e-20220613T220150Z-avarab@gmail.com","threadId":"57979","inReplyTo":"cover-v2-00.12-00000000000-20220613T220150Z-avarab@gmail.com","subject":"[PATCH v2 05/12] submodule--helper: have --require-init imply --init","fromName":"Ævar Arnfjörð Bjarmason","fromEmail":"avarab@gmail.com","sentAt":"2022-06-13T22:38:56Z","receivedAt":"2022-06-13T22:39:35Z","isPatch":true,"sender":{"key":"avarab@gmail.com","avatar":"https://avatars.githubusercontent.com/u/45301?v=4"},"body":"Adjust code added in 0060fd1511b (clone --recurse-submodules: prevent\nname squatting on Windows, 2019-09-12) to have the internal\n--require-init option imply --init, rather than having\n\"git-submodule.sh\" add it implicitly.\n\nThis change doesn't make any difference now, but eliminates another\nspecial-case where \"git submodule--helper update\"'s behavior was\ndifferent from \"git submodule update\". This will make it easier to\neventually replace the cmd_update() function in git-submodule.sh.\n\nWe'll still need to keep the distinction between \"--init\" and\n\"--require-init\" in git-submodule.sh. Once cmd_update() gets\nre-implemented in C we'll be able to variables and other code related\nto that, but not yet.\n\nSigned-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>\n---\n builtin/submodule--helper.c | 5 ++++-\n git-submodule.sh            | 1 -\n 2 files changed, 4 insertions(+), 2 deletions(-)\n\ndiff --git a/builtin/submodule--helper.c b/builtin/submodule--helper.c\nindex 9d3642290f3..7bcb76cea6a 100644\n--- a/builtin/submodule--helper.c\n+++ b/builtin/submodule--helper.c\n@@ -2618,7 +2618,7 @@ static int module_update(int argc, const char **argv, const char *prefix)\n \t\tOPT_BOOL(0, \"progress\", &opt.progress,\n \t\t\t    N_(\"force cloning progress\")),\n \t\tOPT_BOOL(0, \"require-init\", &opt.require_init,\n-\t\t\t   N_(\"disallow cloning into non-empty directory\")),\n+\t\t\t   N_(\"disallow cloning into non-empty directory, implies --init\")),\n \t\tOPT_BOOL(0, \"single-branch\", &opt.single_branch,\n \t\t\t N_(\"clone only one branch, HEAD or --branch\")),\n \t\tOPT_PARSE_LIST_OBJECTS_FILTER(&filter_options),\n@@ -2642,6 +2642,9 @@ static int module_update(int argc, const char **argv, const char *prefix)\n \targc = parse_options(argc, argv, prefix, module_update_options,\n \t\t\t     git_submodule_helper_usage, 0);\n \n+\tif (opt.require_init)\n+\t\topt.init = 1;\n+\n \tif (filter_options.choice && !opt.init) {\n \t\tusage_with_options(git_submodule_helper_usage,\n \t\t\t\t   module_update_options);\ndiff --git a/git-submodule.sh b/git-submodule.sh\nindex 20fc1b620fa..5b9683bf766 100755\n--- a/git-submodule.sh\n+++ b/git-submodule.sh\n@@ -251,7 +251,6 @@ cmd_update()\n \t\t\tinit=1\n \t\t\t;;\n \t\t--require-init)\n-\t\t\tinit=1\n \t\t\trequire_init=1\n \t\t\t;;\n \t\t--remote)\n-- \n2.36.1.1239.gfba91521d90\n\n"},{"id":"457141","messageId":"patch-v2-06.12-025694644fc-20220613T220150Z-avarab@gmail.com","threadId":"57979","inReplyTo":"cover-v2-00.12-00000000000-20220613T220150Z-avarab@gmail.com","subject":"[PATCH v2 06/12] submodule update: remove \"-v\" option","fromName":"Ævar Arnfjörð Bjarmason","fromEmail":"avarab@gmail.com","sentAt":"2022-06-13T22:38:57Z","receivedAt":"2022-06-13T22:39:38Z","isPatch":true,"sender":{"key":"avarab@gmail.com","avatar":"https://avatars.githubusercontent.com/u/45301?v=4"},"body":"From: Glen Choo <chooglen@google.com>\n\nIn e84c3cf3dc3 (git-submodule.sh: accept verbose flag in cmd_update to\nbe non-quiet, 2018-08-14) the \"git submodule update\" sub-command was\nmade to understand \"-v\", but the option was never documented.\n\nThe only in-tree user has been this test added in\n3ad0401e9e6 (submodule update: silence underlying merge/rebase with\n\"--quiet\", 2020-09-30), it wasn't per-se testing --quiet, but fixing a\nbug in e84c3cf3dc3: It used to set \"GIT_QUIET=0\" instead of unsetting\nit on \"-v\", and thus we'd end up passing \"--quiet\" to \"git\nsubmodule--helper\" on \"-v\", since the \"--quiet\" option was passed sing\nthe ${parameter:+word} construct.\n\nFurthermore, even if someone had used the \"-v\" option they'd only be\ngetting the default output. Our default in both git-submodule.sh and\n\"git submodule--helper\" has been to be \"verbose\", so the only way this\noption could have matter is if it were used as e.g.:\n\n    git submodule --quiet update -v [...]\n\nI.e. to undo the effect of a previous \"--quiet\" on the command-line.\n\nSigned-off-by: Glen Choo <chooglen@google.com>\nSigned-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>\n---\n git-submodule.sh            | 3 ---\n t/t7406-submodule-update.sh | 2 +-\n 2 files changed, 1 insertion(+), 4 deletions(-)\n\ndiff --git a/git-submodule.sh b/git-submodule.sh\nindex 5b9683bf766..0df6b0fc974 100755\n--- a/git-submodule.sh\n+++ b/git-submodule.sh\n@@ -241,9 +241,6 @@ cmd_update()\n \t\t-q|--quiet)\n \t\t\tGIT_QUIET=1\n \t\t\t;;\n-\t\t-v)\n-\t\t\tunset GIT_QUIET\n-\t\t\t;;\n \t\t--progress)\n \t\t\tprogress=1\n \t\t\t;;\ndiff --git a/t/t7406-submodule-update.sh b/t/t7406-submodule-update.sh\nindex 43f779d751c..06d804e2131 100755\n--- a/t/t7406-submodule-update.sh\n+++ b/t/t7406-submodule-update.sh\n@@ -1074,7 +1074,7 @@ test_expect_success 'submodule update --quiet passes quietness to merge/rebase'\n \t git submodule update --rebase --quiet >out 2>err &&\n \t test_must_be_empty out &&\n \t test_must_be_empty err &&\n-\t git submodule update --rebase -v >out 2>err &&\n+\t git submodule update --rebase >out 2>err &&\n \t test_file_not_empty out &&\n \t test_must_be_empty err\n \t)\n-- \n2.36.1.1239.gfba91521d90\n\n"},{"id":"457142","messageId":"patch-v2-09.12-01c5eee67c7-20220613T220150Z-avarab@gmail.com","threadId":"57979","inReplyTo":"cover-v2-00.12-00000000000-20220613T220150Z-avarab@gmail.com","subject":"[PATCH v2 09/12] submodule--helper: understand --checkout, --merge and --rebase synonyms","fromName":"Ævar Arnfjörð Bjarmason","fromEmail":"avarab@gmail.com","sentAt":"2022-06-13T22:39:00Z","receivedAt":"2022-06-13T22:39:38Z","isPatch":true,"sender":{"key":"avarab@gmail.com","avatar":"https://avatars.githubusercontent.com/u/45301?v=4"},"body":"Understand --checkout, --merge and --rebase synonyms for\n--update={checkout,merge,rebase}, as well as the short options that\n'git submodule' itself understands.\n\nThis removes a difference between the CLI API of \"git submodule\" and\n\"git submodule--helper\", making it easier to make the latter an alias\nfor the former. See 48308681b07 (git submodule update: have a\ndedicated helper for cloning, 2016-02-29) for the initial addition of\n--update.\n\nSigned-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>\n---\n builtin/submodule--helper.c | 17 +++++++++++++++++\n git-submodule.sh            | 14 +++++++++-----\n 2 files changed, 26 insertions(+), 5 deletions(-)\n\ndiff --git a/builtin/submodule--helper.c b/builtin/submodule--helper.c\nindex c2f55779cb1..57f0237af23 100644\n--- a/builtin/submodule--helper.c\n+++ b/builtin/submodule--helper.c\n@@ -2582,6 +2582,7 @@ static int module_update(int argc, const char **argv, const char *prefix)\n \tstruct update_data opt = UPDATE_DATA_INIT;\n \tstruct list_objects_filter_options filter_options;\n \tint ret;\n+\tenum submodule_update_type update_type = SM_UPDATE_UNSPECIFIED;\n \n \tstruct option module_update_options[] = {\n \t\tOPT__FORCE(&opt.force, N_(\"force checkout updates\"), 0),\n@@ -2603,6 +2604,15 @@ static int module_update(int argc, const char **argv, const char *prefix)\n \t\tOPT_STRING(0, \"update\", &opt.update_default,\n \t\t\t   N_(\"string\"),\n \t\t\t   N_(\"rebase, merge, checkout or none\")),\n+\t\tOPT_SET_INT(0, \"checkout\", &update_type,\n+\t\t\tN_(\"use the 'checkout' update strategy (default)\"),\n+\t\t\tSM_UPDATE_CHECKOUT),\n+\t\tOPT_SET_INT('m', \"merge\", &update_type,\n+\t\t\tN_(\"use the 'merge' update strategy\"),\n+\t\t\tSM_UPDATE_MERGE),\n+\t\tOPT_SET_INT('r', \"rebase\", &update_type,\n+\t\t\tN_(\"use the 'rebase' update strategy\"),\n+\t\t\tSM_UPDATE_REBASE),\n \t\tOPT_STRING_LIST(0, \"reference\", &opt.references, N_(\"repo\"),\n \t\t\t   N_(\"reference repository\")),\n \t\tOPT_BOOL(0, \"dissociate\", &opt.dissociate,\n@@ -2652,6 +2662,13 @@ static int module_update(int argc, const char **argv, const char *prefix)\n \n \topt.filter_options = &filter_options;\n \n+\tif (update_type == SM_UPDATE_CHECKOUT)\n+\t\topt.update_default = \"checkout\";\n+\telse if (update_type == SM_UPDATE_MERGE)\n+\t\topt.update_default = \"merge\";\n+\telse if (update_type == SM_UPDATE_REBASE)\n+\t\topt.update_default = \"rebase\";\n+\n \tif (opt.update_default)\n \t\tif (parse_submodule_update_strategy(opt.update_default,\n \t\t\t\t\t\t    &opt.update_strategy) < 0)\ndiff --git a/git-submodule.sh b/git-submodule.sh\nindex 1c1dc320922..7fc7119fb21 100755\n--- a/git-submodule.sh\n+++ b/git-submodule.sh\n@@ -40,7 +40,9 @@ require_init=\n files=\n remote=\n nofetch=\n-update=\n+rebase=\n+merge=\n+checkout=\n custom_name=\n depth=\n progress=\n@@ -260,7 +262,7 @@ cmd_update()\n \t\t\tforce=$1\n \t\t\t;;\n \t\t-r|--rebase)\n-\t\t\tupdate=\"rebase\"\n+\t\t\trebase=1\n \t\t\t;;\n \t\t--reference)\n \t\t\tcase \"$2\" in '') usage ;; esac\n@@ -274,13 +276,13 @@ cmd_update()\n \t\t\tdissociate=1\n \t\t\t;;\n \t\t-m|--merge)\n-\t\t\tupdate=\"merge\"\n+\t\t\tmerge=1\n \t\t\t;;\n \t\t--recursive)\n \t\t\trecursive=1\n \t\t\t;;\n \t\t--checkout)\n-\t\t\tupdate=\"checkout\"\n+\t\t\tcheckout=1\n \t\t\t;;\n \t\t--recommend-shallow)\n \t\t\trecommend_shallow=\"--recommend-shallow\"\n@@ -341,7 +343,9 @@ cmd_update()\n \t\t${init:+--init} \\\n \t\t${nofetch:+--no-fetch} \\\n \t\t${wt_prefix:+--prefix \"$wt_prefix\"} \\\n-\t\t${update:+--update \"$update\"} \\\n+\t\t${rebase:+--rebase} \\\n+\t\t${merge:+--merge} \\\n+\t\t${checkout:+--checkout} \\\n \t\t${reference:+\"$reference\"} \\\n \t\t${dissociate:+\"--dissociate\"} \\\n \t\t${depth:+\"$depth\"} \\\n-- \n2.36.1.1239.gfba91521d90\n\n"},{"id":"457144","messageId":"patch-v2-08.12-99ac52d810f-20220613T220150Z-avarab@gmail.com","threadId":"57979","inReplyTo":"cover-v2-00.12-00000000000-20220613T220150Z-avarab@gmail.com","subject":"[PATCH v2 08/12] submodule--helper: report \"submodule\" as our name in \"-h\" output","fromName":"Ævar Arnfjörð Bjarmason","fromEmail":"avarab@gmail.com","sentAt":"2022-06-13T22:38:59Z","receivedAt":"2022-06-13T22:39:40Z","isPatch":true,"sender":{"key":"avarab@gmail.com","avatar":"https://avatars.githubusercontent.com/u/45301?v=4"},"body":"Change the rest of the usage output for \"git submodule--helper\" so\nthat it will pretend to be named \"git submodule\", which it already did\ne.g. in the case of \"status\", \"deinit\" and \"update\".\n\nThis will allow us to eventually dispatch further into \"git\nsubmodule--helper\" from git-submodule.sh, while emitting the correct\nusage output.\n\nThis does make the usage output of \"git submodule--helper\" itself\n\"incorrect\", but since nothing user-facing invokes it directly it\nmakes sense to continue to elide that difference entirely. A user\nisn't served by us exposing this internal implementation detail.\n\nThis fixes a bug that's been there ever since \"git submodule\nabsorbgitdirs\" was added in f6f85861400 (submodule: add absorb-git-dir\nfunction, 2016-12-12). Before this we'd emit e.g. this on invalid\nusage:\n\n\t$ git submodule absorbgitdirs --blah\n\terror: unknown option `blah'\n\tusage: git submodule--helper absorbgitdirs [<options>] [<path>...]\n\nNow we'll emit the same, except that the usage line is now referring\nto the correct command run by the user:\n\n\tusage: git submodule absorbgitdirs [<options>] [<path>...]\n\t[.. same usage output ...]\n\nSigned-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>\n---\n builtin/submodule--helper.c | 32 ++++++++++++++++----------------\n 1 file changed, 16 insertions(+), 16 deletions(-)\n\ndiff --git a/builtin/submodule--helper.c b/builtin/submodule--helper.c\nindex 574d6e0a79b..c2f55779cb1 100644\n--- a/builtin/submodule--helper.c\n+++ b/builtin/submodule--helper.c\n@@ -286,7 +286,7 @@ static int module_list(int argc, const char **argv, const char *prefix)\n \t};\n \n \tconst char *const git_submodule_helper_usage[] = {\n-\t\tN_(\"git submodule--helper list [--prefix=<path>] [<path>...]\"),\n+\t\tN_(\"git submodule list [--prefix=<path>] [<path>...]\"),\n \t\tNULL\n \t};\n \n@@ -444,7 +444,7 @@ static int module_foreach(int argc, const char **argv, const char *prefix)\n \t};\n \n \tconst char *const git_submodule_helper_usage[] = {\n-\t\tN_(\"git submodule--helper foreach [--quiet] [--recursive] [--] <command>\"),\n+\t\tN_(\"git submodule foreach [--quiet] [--recursive] [--] <command>\"),\n \t\tNULL\n \t};\n \n@@ -582,7 +582,7 @@ static int module_init(int argc, const char **argv, const char *prefix)\n \t};\n \n \tconst char *const git_submodule_helper_usage[] = {\n-\t\tN_(\"git submodule--helper init [<options>] [<path>]\"),\n+\t\tN_(\"git submodule init [<options>] [<path>]\"),\n \t\tNULL\n \t};\n \n@@ -786,7 +786,7 @@ static int module_name(int argc, const char **argv, const char *prefix)\n \tconst struct submodule *sub;\n \n \tif (argc != 2)\n-\t\tusage(_(\"git submodule--helper name <path>\"));\n+\t\tusage(_(\"git submodule name <path>\"));\n \n \tsub = submodule_from_path(the_repository, null_oid(), argv[1]);\n \n@@ -1185,7 +1185,7 @@ static int module_summary(int argc, const char **argv, const char *prefix)\n \t};\n \n \tconst char *const git_submodule_helper_usage[] = {\n-\t\tN_(\"git submodule--helper summary [<options>] [<commit>] [--] [<path>]\"),\n+\t\tN_(\"git submodule summary [<options>] [<commit>] [--] [<path>]\"),\n \t\tNULL\n \t};\n \n@@ -1349,7 +1349,7 @@ static int module_sync(int argc, const char **argv, const char *prefix)\n \t};\n \n \tconst char *const git_submodule_helper_usage[] = {\n-\t\tN_(\"git submodule--helper sync [--quiet] [--recursive] [<path>]\"),\n+\t\tN_(\"git submodule sync [--quiet] [--recursive] [<path>]\"),\n \t\tNULL\n \t};\n \n@@ -1789,7 +1789,7 @@ static int module_clone(int argc, const char **argv, const char *prefix)\n \t};\n \n \tconst char *const git_submodule_helper_usage[] = {\n-\t\tN_(\"git submodule--helper clone [--prefix=<path>] [--quiet] \"\n+\t\tN_(\"git submodule clone [--prefix=<path>] [--quiet] \"\n \t\t   \"[--reference <repository>] [--name <name>] [--depth <depth>] \"\n \t\t   \"[--single-branch] [--filter <filter-spec>] \"\n \t\t   \"--url <url> --path <path>\"),\n@@ -2787,7 +2787,7 @@ static int absorb_git_dirs(int argc, const char **argv, const char *prefix)\n \t};\n \n \tconst char *const git_submodule_helper_usage[] = {\n-\t\tN_(\"git submodule--helper absorbgitdirs [<options>] [<path>...]\"),\n+\t\tN_(\"git submodule absorbgitdirs [<options>] [<path>...]\"),\n \t\tNULL\n \t};\n \n@@ -2851,9 +2851,9 @@ static int module_config(int argc, const char **argv, const char *prefix)\n \t\tOPT_END()\n \t};\n \tconst char *const git_submodule_helper_usage[] = {\n-\t\tN_(\"git submodule--helper config <name> [<value>]\"),\n-\t\tN_(\"git submodule--helper config --unset <name>\"),\n-\t\t\"git submodule--helper config --check-writeable\",\n+\t\tN_(\"git submodule config <name> [<value>]\"),\n+\t\tN_(\"git submodule config --unset <name>\"),\n+\t\t\"git submodule config --check-writeable\",\n \t\tNULL\n \t};\n \n@@ -2892,7 +2892,7 @@ static int module_set_url(int argc, const char **argv, const char *prefix)\n \t\tOPT_END()\n \t};\n \tconst char *const usage[] = {\n-\t\tN_(\"git submodule--helper set-url [--quiet] <path> <newurl>\"),\n+\t\tN_(\"git submodule set-url [--quiet] <path> <newurl>\"),\n \t\tNULL\n \t};\n \n@@ -2931,8 +2931,8 @@ static int module_set_branch(int argc, const char **argv, const char *prefix)\n \t\tOPT_END()\n \t};\n \tconst char *const usage[] = {\n-\t\tN_(\"git submodule--helper set-branch [-q|--quiet] (-d|--default) <path>\"),\n-\t\tN_(\"git submodule--helper set-branch [-q|--quiet] (-b|--branch) <branch> <path>\"),\n+\t\tN_(\"git submodule set-branch [-q|--quiet] (-d|--default) <path>\"),\n+\t\tN_(\"git submodule set-branch [-q|--quiet] (-b|--branch) <branch> <path>\"),\n \t\tNULL\n \t};\n \n@@ -2973,7 +2973,7 @@ static int module_create_branch(int argc, const char **argv, const char *prefix)\n \t\tOPT_END()\n \t};\n \tconst char *const usage[] = {\n-\t\tN_(\"git submodule--helper create-branch [-f|--force] [--create-reflog] [-q|--quiet] [-t|--track] [-n|--dry-run] <name> <start-oid> <start-name>\"),\n+\t\tN_(\"git submodule create-branch [-f|--force] [--create-reflog] [-q|--quiet] [-t|--track] [-n|--dry-run] <name> <start-oid> <start-name>\"),\n \t\tNULL\n \t};\n \n@@ -3276,7 +3276,7 @@ static int module_add(int argc, const char **argv, const char *prefix)\n \t};\n \n \tconst char *const usage[] = {\n-\t\tN_(\"git submodule--helper add [<options>] [--] <repository> [<path>]\"),\n+\t\tN_(\"git submodule add [<options>] [--] <repository> [<path>]\"),\n \t\tNULL\n \t};\n \n-- \n2.36.1.1239.gfba91521d90\n\n"},{"id":"457143","messageId":"patch-v2-07.12-63155ab5026-20220613T220150Z-avarab@gmail.com","threadId":"57979","inReplyTo":"cover-v2-00.12-00000000000-20220613T220150Z-avarab@gmail.com","subject":"[PATCH v2 07/12] submodule--helper: rename \"absorb-git-dirs\" to \"absorbgitdirs\"","fromName":"Ævar Arnfjörð Bjarmason","fromEmail":"avarab@gmail.com","sentAt":"2022-06-13T22:38:58Z","receivedAt":"2022-06-13T22:39:43Z","isPatch":true,"sender":{"key":"avarab@gmail.com","avatar":"https://avatars.githubusercontent.com/u/45301?v=4"},"body":"Rename the \"absorb-git-dirs\" subcommand to \"absorbgitdirs\", which is\nwhat the \"git submodule\" command itself has called it since the\nsubcommand was implemented in f6f85861400 (submodule: add\nabsorb-git-dir function, 2016-12-12).\n\nHaving these two be different will make it more tedious to dispatch to\neventually dispatch \"git submodule--helper\" directly, as we'd need to\nretain this name mapping. So let's get rid of this needless\ninconsistency.\n\nSigned-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>\n---\n builtin/submodule--helper.c | 4 ++--\n git-submodule.sh            | 2 +-\n submodule.c                 | 2 +-\n 3 files changed, 4 insertions(+), 4 deletions(-)\n\ndiff --git a/builtin/submodule--helper.c b/builtin/submodule--helper.c\nindex 7bcb76cea6a..574d6e0a79b 100644\n--- a/builtin/submodule--helper.c\n+++ b/builtin/submodule--helper.c\n@@ -2787,7 +2787,7 @@ static int absorb_git_dirs(int argc, const char **argv, const char *prefix)\n \t};\n \n \tconst char *const git_submodule_helper_usage[] = {\n-\t\tN_(\"git submodule--helper absorb-git-dirs [<options>] [<path>...]\"),\n+\t\tN_(\"git submodule--helper absorbgitdirs [<options>] [<path>...]\"),\n \t\tNULL\n \t};\n \n@@ -3386,7 +3386,7 @@ static struct cmd_struct commands[] = {\n \t{\"deinit\", module_deinit},\n \t{\"summary\", module_summary},\n \t{\"push-check\", push_check},\n-\t{\"absorb-git-dirs\", absorb_git_dirs},\n+\t{\"absorbgitdirs\", absorb_git_dirs},\n \t{\"is-active\", is_active},\n \t{\"check-name\", check_name},\n \t{\"config\", module_config},\ndiff --git a/git-submodule.sh b/git-submodule.sh\nindex 0df6b0fc974..1c1dc320922 100755\n--- a/git-submodule.sh\n+++ b/git-submodule.sh\n@@ -552,7 +552,7 @@ cmd_sync()\n \n cmd_absorbgitdirs()\n {\n-\tgit submodule--helper absorb-git-dirs --prefix \"$wt_prefix\" \"$@\"\n+\tgit submodule--helper absorbgitdirs --prefix \"$wt_prefix\" \"$@\"\n }\n \n # This loop parses the command line arguments to find the\ndiff --git a/submodule.c b/submodule.c\nindex 4e299f578f9..2af16c647d5 100644\n--- a/submodule.c\n+++ b/submodule.c\n@@ -2374,7 +2374,7 @@ void absorb_git_dir_into_superproject(const char *path,\n \t\tcp.no_stdin = 1;\n \t\tstrvec_pushl(&cp.args, \"--super-prefix\", sb.buf,\n \t\t\t     \"submodule--helper\",\n-\t\t\t     \"absorb-git-dirs\", NULL);\n+\t\t\t     \"absorbgitdirs\", NULL);\n \t\tprepare_submodule_repo_env(&cp.env);\n \t\tif (run_command(&cp))\n \t\t\tdie(_(\"could not recurse into submodule '%s'\"), path);\n-- \n2.36.1.1239.gfba91521d90\n\n"},{"id":"457145","messageId":"patch-v2-11.12-875acae8550-20220613T220150Z-avarab@gmail.com","threadId":"57979","inReplyTo":"cover-v2-00.12-00000000000-20220613T220150Z-avarab@gmail.com","subject":"[PATCH v2 11/12] git-submodule.sh: use \"$quiet\", not \"$GIT_QUIET\"","fromName":"Ævar Arnfjörð Bjarmason","fromEmail":"avarab@gmail.com","sentAt":"2022-06-13T22:39:02Z","receivedAt":"2022-06-13T22:39:55Z","isPatch":true,"sender":{"key":"avarab@gmail.com","avatar":"https://avatars.githubusercontent.com/u/45301?v=4"},"body":"Remove the use of the \"$GIT_QUIET\" variable in favor of our own\n\"$quiet\", ever since b3c5f5cb048 (submodule: move core cmd_update()\nlogic to C, 2022-03-15) we have not used the \"say\" function in\ngit-sh-setup.sh, which is the only thing that's affected by using\n\"GIT_QUIET\".\n\nWe still want to support --quiet for our own use though, but let's use\nour own variable for that, but now it's obvious that we only care\nabout passing \"--quiet\" to \"git submodule--helper\", and not to change\nthe output of any \"say\" invocation.\n\nSigned-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>\n---\n git-submodule.sh | 37 +++++++++++++++++++------------------\n 1 file changed, 19 insertions(+), 18 deletions(-)\n\ndiff --git a/git-submodule.sh b/git-submodule.sh\nindex 7fc7119fb21..5e5d21c010f 100755\n--- a/git-submodule.sh\n+++ b/git-submodule.sh\n@@ -30,6 +30,7 @@ GIT_PROTOCOL_FROM_USER=0\n export GIT_PROTOCOL_FROM_USER\n \n command=\n+quiet=\n branch=\n force=\n reference=\n@@ -80,7 +81,7 @@ cmd_add()\n \t\t\tforce=$1\n \t\t\t;;\n \t\t-q|--quiet)\n-\t\t\tGIT_QUIET=1\n+\t\t\tquiet=1\n \t\t\t;;\n \t\t--progress)\n \t\t\tprogress=1\n@@ -128,7 +129,7 @@ cmd_add()\n \t\tusage\n \tfi\n \n-\tgit ${wt_prefix:+-C \"$wt_prefix\"} submodule--helper add ${GIT_QUIET:+--quiet} ${force:+--force} ${progress:+\"--progress\"} ${branch:+--branch \"$branch\"} ${reference_path:+--reference \"$reference_path\"} ${dissociate:+--dissociate} ${custom_name:+--name \"$custom_name\"} ${depth:+\"$depth\"} -- \"$@\"\n+\tgit ${wt_prefix:+-C \"$wt_prefix\"} submodule--helper add ${quiet:+--quiet} ${force:+--force} ${progress:+\"--progress\"} ${branch:+--branch \"$branch\"} ${reference_path:+--reference \"$reference_path\"} ${dissociate:+--dissociate} ${custom_name:+--name \"$custom_name\"} ${depth:+\"$depth\"} -- \"$@\"\n }\n \n #\n@@ -144,7 +145,7 @@ cmd_foreach()\n \tdo\n \t\tcase \"$1\" in\n \t\t-q|--quiet)\n-\t\t\tGIT_QUIET=1\n+\t\t\tquiet=1\n \t\t\t;;\n \t\t--recursive)\n \t\t\trecursive=1\n@@ -159,7 +160,7 @@ cmd_foreach()\n \t\tshift\n \tdone\n \n-\tgit ${wt_prefix:+-C \"$wt_prefix\"} submodule--helper foreach ${GIT_QUIET:+--quiet} ${recursive:+--recursive} -- \"$@\"\n+\tgit ${wt_prefix:+-C \"$wt_prefix\"} submodule--helper foreach ${quiet:+--quiet} ${recursive:+--recursive} -- \"$@\"\n }\n \n #\n@@ -174,7 +175,7 @@ cmd_init()\n \tdo\n \t\tcase \"$1\" in\n \t\t-q|--quiet)\n-\t\t\tGIT_QUIET=1\n+\t\t\tquiet=1\n \t\t\t;;\n \t\t--)\n \t\t\tshift\n@@ -190,7 +191,7 @@ cmd_init()\n \t\tshift\n \tdone\n \n-\tgit ${wt_prefix:+-C \"$wt_prefix\"} submodule--helper init ${GIT_QUIET:+--quiet} -- \"$@\"\n+\tgit ${wt_prefix:+-C \"$wt_prefix\"} submodule--helper init ${quiet:+--quiet} -- \"$@\"\n }\n \n #\n@@ -207,7 +208,7 @@ cmd_deinit()\n \t\t\tforce=$1\n \t\t\t;;\n \t\t-q|--quiet)\n-\t\t\tGIT_QUIET=1\n+\t\t\tquiet=1\n \t\t\t;;\n \t\t--all)\n \t\t\tdeinit_all=t\n@@ -226,7 +227,7 @@ cmd_deinit()\n \t\tshift\n \tdone\n \n-\tgit ${wt_prefix:+-C \"$wt_prefix\"} submodule--helper deinit ${GIT_QUIET:+--quiet} ${force:+--force} ${deinit_all:+--all} -- \"$@\"\n+\tgit ${wt_prefix:+-C \"$wt_prefix\"} submodule--helper deinit ${quiet:+--quiet} ${force:+--force} ${deinit_all:+--all} -- \"$@\"\n }\n \n #\n@@ -241,7 +242,7 @@ cmd_update()\n \tdo\n \t\tcase \"$1\" in\n \t\t-q|--quiet)\n-\t\t\tGIT_QUIET=1\n+\t\t\tquiet=1\n \t\t\t;;\n \t\t--progress)\n \t\t\tprogress=1\n@@ -335,7 +336,7 @@ cmd_update()\n \tdone\n \n \tgit ${wt_prefix:+-C \"$wt_prefix\"} submodule--helper update \\\n-\t\t${GIT_QUIET:+--quiet} \\\n+\t\t${quiet:+--quiet} \\\n \t\t${force:+--force} \\\n \t\t${progress:+\"--progress\"} \\\n \t\t${remote:+--remote} \\\n@@ -396,7 +397,7 @@ cmd_set_branch() {\n \t\tshift\n \tdone\n \n-\tgit ${wt_prefix:+-C \"$wt_prefix\"} submodule--helper set-branch ${GIT_QUIET:+--quiet} ${branch:+--branch \"$branch\"} ${default:+--default} -- \"$@\"\n+\tgit ${wt_prefix:+-C \"$wt_prefix\"} submodule--helper set-branch ${quiet:+--quiet} ${branch:+--branch \"$branch\"} ${default:+--default} -- \"$@\"\n }\n \n #\n@@ -409,7 +410,7 @@ cmd_set_url() {\n \tdo\n \t\tcase \"$1\" in\n \t\t-q|--quiet)\n-\t\t\tGIT_QUIET=1\n+\t\t\tquiet=1\n \t\t\t;;\n \t\t--)\n \t\t\tshift\n@@ -425,7 +426,7 @@ cmd_set_url() {\n \t\tshift\n \tdone\n \n-\tgit ${wt_prefix:+-C \"$wt_prefix\"} submodule--helper set-url ${GIT_QUIET:+--quiet} -- \"$@\"\n+\tgit ${wt_prefix:+-C \"$wt_prefix\"} submodule--helper set-url ${quiet:+--quiet} -- \"$@\"\n }\n \n #\n@@ -496,7 +497,7 @@ cmd_status()\n \tdo\n \t\tcase \"$1\" in\n \t\t-q|--quiet)\n-\t\t\tGIT_QUIET=1\n+\t\t\tquiet=1\n \t\t\t;;\n \t\t--cached)\n \t\t\tcached=1\n@@ -518,7 +519,7 @@ cmd_status()\n \t\tshift\n \tdone\n \n-\tgit ${wt_prefix:+-C \"$wt_prefix\"} submodule--helper status ${GIT_QUIET:+--quiet} ${cached:+--cached} ${recursive:+--recursive} -- \"$@\"\n+\tgit ${wt_prefix:+-C \"$wt_prefix\"} submodule--helper status ${quiet:+--quiet} ${cached:+--cached} ${recursive:+--recursive} -- \"$@\"\n }\n #\n # Sync remote urls for submodules\n@@ -531,7 +532,7 @@ cmd_sync()\n \tdo\n \t\tcase \"$1\" in\n \t\t-q|--quiet)\n-\t\t\tGIT_QUIET=1\n+\t\t\tquiet=1\n \t\t\tshift\n \t\t\t;;\n \t\t--recursive)\n@@ -551,7 +552,7 @@ cmd_sync()\n \t\tesac\n \tdone\n \n-\tgit ${wt_prefix:+-C \"$wt_prefix\"} submodule--helper sync ${GIT_QUIET:+--quiet} ${recursive:+--recursive} -- \"$@\"\n+\tgit ${wt_prefix:+-C \"$wt_prefix\"} submodule--helper sync ${quiet:+--quiet} ${recursive:+--recursive} -- \"$@\"\n }\n \n cmd_absorbgitdirs()\n@@ -572,7 +573,7 @@ do\n \t\tcommand=$1\n \t\t;;\n \t-q|--quiet)\n-\t\tGIT_QUIET=1\n+\t\tquiet=1\n \t\t;;\n \t--cached)\n \t\tcached=1\n-- \n2.36.1.1239.gfba91521d90\n\n"},{"id":"457146","messageId":"patch-v2-12.12-31517345ae8-20220613T220150Z-avarab@gmail.com","threadId":"57979","inReplyTo":"cover-v2-00.12-00000000000-20220613T220150Z-avarab@gmail.com","subject":"[PATCH v2 12/12] git-sh-setup.sh: remove \"say\" function, change last users","fromName":"Ævar Arnfjörð Bjarmason","fromEmail":"avarab@gmail.com","sentAt":"2022-06-13T22:39:03Z","receivedAt":"2022-06-13T22:39:58Z","isPatch":true,"sender":{"key":"avarab@gmail.com","avatar":"https://avatars.githubusercontent.com/u/45301?v=4"},"body":"Remove the \"say\" function, with various rewrites of the remaining\ngit-*.sh code to C and the preceding change to have git-submodule.sh\nstop using the GIT_QUIET variable there were only four uses in\ngit-subtree.sh. Let's have it use an \"arg_quiet\" variable instead, and\nmove the \"say\" function over to it.\n\nThe only other use was a trivial message in git-instaweb.sh, since it\nhas never supported the --quiet option (or similar) that code added in\n0b624b4ceee (instaweb: restart server if already running, 2009-11-22)\ncan simply use \"echo\" instead.\n\nThe remaining in-tree hits from \"say\" are all for the sibling function\ndefined in t/test-lib.sh. It's safe to remove this function since it\nhas never been documented in Documentation/git-sh-setup.txt.\n\nSigned-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>\n---\n contrib/subtree/git-subtree.sh | 15 ++++++++++++---\n git-instaweb.sh                |  2 +-\n git-sh-setup.sh                |  9 ---------\n 3 files changed, 13 insertions(+), 13 deletions(-)\n\ndiff --git a/contrib/subtree/git-subtree.sh b/contrib/subtree/git-subtree.sh\nindex 1af1d9653e9..7562a395c24 100755\n--- a/contrib/subtree/git-subtree.sh\n+++ b/contrib/subtree/git-subtree.sh\n@@ -50,6 +50,14 @@ m,message=    use the given message as the commit message for the merge commit\n \n indent=0\n \n+# Usage: say [MSG...]\n+say () {\n+\tif test -z \"$arg_quiet\"\n+\tthen\n+\t\tprintf '%s\\n' \"$*\"\n+\tfi\n+}\n+\n # Usage: debug [MSG...]\n debug () {\n \tif test -n \"$arg_debug\"\n@@ -60,7 +68,7 @@ debug () {\n \n # Usage: progress [MSG...]\n progress () {\n-\tif test -z \"$GIT_QUIET\"\n+\tif test -z \"$arg_quiet\"\n \tthen\n \t\tif test -z \"$arg_debug\"\n \t\tthen\n@@ -146,6 +154,7 @@ main () {\n \teval \"$set_args\"\n \n \t# Begin \"real\" flag parsing.\n+\targ_quiet=\n \targ_debug=\n \targ_prefix=\n \targ_split_branch=\n@@ -161,7 +170,7 @@ main () {\n \n \t\tcase \"$opt\" in\n \t\t-q)\n-\t\t\tGIT_QUIET=1\n+\t\t\targ_quiet=1\n \t\t\t;;\n \t\t-d)\n \t\t\targ_debug=1\n@@ -252,7 +261,7 @@ main () {\n \tdir=\"$(dirname \"$arg_prefix/.\")\"\n \n \tdebug \"command: {$arg_command}\"\n-\tdebug \"quiet: {$GIT_QUIET}\"\n+\tdebug \"quiet: {$arg_quiet}\"\n \tdebug \"dir: {$dir}\"\n \tdebug \"opts: {$*}\"\n \tdebug\ndiff --git a/git-instaweb.sh b/git-instaweb.sh\nindex 4349566c891..c68f49454cd 100755\n--- a/git-instaweb.sh\n+++ b/git-instaweb.sh\n@@ -102,7 +102,7 @@ resolve_full_httpd () {\n \n start_httpd () {\n \tif test -f \"$fqgitdir/pid\"; then\n-\t\tsay \"Instance already running. Restarting...\"\n+\t\techo \"Instance already running. Restarting...\"\n \t\tstop_httpd\n \tfi\n \ndiff --git a/git-sh-setup.sh b/git-sh-setup.sh\nindex ecb60d9e3cb..ce273fe0e48 100644\n--- a/git-sh-setup.sh\n+++ b/git-sh-setup.sh\n@@ -57,15 +57,6 @@ die_with_status () {\n \texit \"$status\"\n }\n \n-GIT_QUIET=\n-\n-say () {\n-\tif test -z \"$GIT_QUIET\"\n-\tthen\n-\t\tprintf '%s\\n' \"$*\"\n-\tfi\n-}\n-\n if test -n \"$OPTIONS_SPEC\"; then\n \tusage() {\n \t\t\"$0\" -h\n-- \n2.36.1.1239.gfba91521d90\n\n"},{"id":"457147","messageId":"patch-v2-10.12-ac00a9599de-20220613T220150Z-avarab@gmail.com","threadId":"57979","inReplyTo":"cover-v2-00.12-00000000000-20220613T220150Z-avarab@gmail.com","subject":"[PATCH v2 10/12] submodule--helper: eliminate internal \"--update\" option","fromName":"Ævar Arnfjörð Bjarmason","fromEmail":"avarab@gmail.com","sentAt":"2022-06-13T22:39:01Z","receivedAt":"2022-06-13T22:40:00Z","isPatch":true,"sender":{"key":"avarab@gmail.com","avatar":"https://avatars.githubusercontent.com/u/45301?v=4"},"body":"From: Glen Choo <chooglen@google.com>\n\nFollow-up on the preceding commit which taught \"git submodule--helper\nupdate\" to understand \"--merge\", \"--checkout\" and \"--rebase\" and use\nthose options instead of \"--update=(rebase|merge|checkout|none)\" when\nthe command invokes itself.\n\nUnlike the preceding change this isn't strictly necessary to\neventually change \"git-submodule.sh\" so that it invokes \"git\nsubmodule--helper update\" directly, but let's remove this\ninconsistency in the command-line interface. We shouldn't need to\ncarry special synonyms for existing options in \"git submodule--helper\"\nwhen that command can use the primary documented names instead.\n\nBut, as seen in the post-image this makes the control flow within\n\"builtin/submodule--helper.c\" simpler, we can now write directly to\nthe \"update_default\" member of \"struct update_data\" when parsing the\noptions in \"module_update()\".\n\nSigned-off-by: Glen Choo <chooglen@google.com>\nSigned-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>\n---\n builtin/submodule--helper.c | 42 ++++++++++++++++---------------------\n 1 file changed, 18 insertions(+), 24 deletions(-)\n\ndiff --git a/builtin/submodule--helper.c b/builtin/submodule--helper.c\nindex 57f0237af23..65cf4b915df 100644\n--- a/builtin/submodule--helper.c\n+++ b/builtin/submodule--helper.c\n@@ -1818,7 +1818,7 @@ static int module_clone(int argc, const char **argv, const char *prefix)\n static void determine_submodule_update_strategy(struct repository *r,\n \t\t\t\t\t\tint just_cloned,\n \t\t\t\t\t\tconst char *path,\n-\t\t\t\t\t\tconst char *update,\n+\t\t\t\t\t\tenum submodule_update_type update,\n \t\t\t\t\t\tstruct submodule_update_strategy *out)\n {\n \tconst struct submodule *sub = submodule_from_path(r, null_oid(), path);\n@@ -1828,9 +1828,7 @@ static void determine_submodule_update_strategy(struct repository *r,\n \tkey = xstrfmt(\"submodule.%s.update\", sub->name);\n \n \tif (update) {\n-\t\tif (parse_submodule_update_strategy(update, out) < 0)\n-\t\t\tdie(_(\"Invalid update mode '%s' for submodule path '%s'\"),\n-\t\t\t\tupdate, path);\n+\t\tout->type = update;\n \t} else if (!repo_config_get_string_tmp(r, key, &val)) {\n \t\tif (parse_submodule_update_strategy(val, out) < 0)\n \t\t\tdie(_(\"Invalid update mode '%s' configured for submodule path '%s'\"),\n@@ -1882,7 +1880,7 @@ struct update_data {\n \tconst char *prefix;\n \tconst char *recursive_prefix;\n \tconst char *displaypath;\n-\tconst char *update_default;\n+\tenum submodule_update_type update_default;\n \tstruct object_id suboid;\n \tstruct string_list references;\n \tstruct submodule_update_strategy update_strategy;\n@@ -2406,6 +2404,8 @@ static void ensure_core_worktree(const char *path)\n \n static void update_data_to_args(struct update_data *update_data, struct strvec *args)\n {\n+\tenum submodule_update_type ud = update_data->update_default;\n+\n \tstrvec_pushl(args, \"submodule--helper\", \"update\", \"--recursive\", NULL);\n \tstrvec_pushf(args, \"--jobs=%d\", update_data->max_jobs);\n \tif (update_data->recursive_prefix)\n@@ -2429,8 +2429,15 @@ static void update_data_to_args(struct update_data *update_data, struct strvec *\n \t\tstrvec_push(args, \"--require-init\");\n \tif (update_data->depth)\n \t\tstrvec_pushf(args, \"--depth=%d\", update_data->depth);\n-\tif (update_data->update_default)\n-\t\tstrvec_pushl(args, \"--update\", update_data->update_default, NULL);\n+\tif (ud == SM_UPDATE_MERGE)\n+\t\tstrvec_push(args, \"--merge\");\n+\telse if (ud == SM_UPDATE_CHECKOUT)\n+\t\tstrvec_push(args, \"--checkout\");\n+\telse if (ud == SM_UPDATE_REBASE)\n+\t\tstrvec_push(args, \"--rebase\");\n+\telse if (ud != SM_UPDATE_UNSPECIFIED)\n+\t\tBUG(\"cannot convert update_default=%d to args\", ud);\n+\n \tif (update_data->references.nr) {\n \t\tstruct string_list_item *item;\n \t\tfor_each_string_list_item(item, &update_data->references)\n@@ -2582,7 +2589,6 @@ static int module_update(int argc, const char **argv, const char *prefix)\n \tstruct update_data opt = UPDATE_DATA_INIT;\n \tstruct list_objects_filter_options filter_options;\n \tint ret;\n-\tenum submodule_update_type update_type = SM_UPDATE_UNSPECIFIED;\n \n \tstruct option module_update_options[] = {\n \t\tOPT__FORCE(&opt.force, N_(\"force checkout updates\"), 0),\n@@ -2601,16 +2607,13 @@ static int module_update(int argc, const char **argv, const char *prefix)\n \t\t\t   N_(\"path\"),\n \t\t\t   N_(\"path into the working tree, across nested \"\n \t\t\t      \"submodule boundaries\")),\n-\t\tOPT_STRING(0, \"update\", &opt.update_default,\n-\t\t\t   N_(\"string\"),\n-\t\t\t   N_(\"rebase, merge, checkout or none\")),\n-\t\tOPT_SET_INT(0, \"checkout\", &update_type,\n+\t\tOPT_SET_INT(0, \"checkout\", &opt.update_default,\n \t\t\tN_(\"use the 'checkout' update strategy (default)\"),\n \t\t\tSM_UPDATE_CHECKOUT),\n-\t\tOPT_SET_INT('m', \"merge\", &update_type,\n+\t\tOPT_SET_INT('m', \"merge\", &opt.update_default,\n \t\t\tN_(\"use the 'merge' update strategy\"),\n \t\t\tSM_UPDATE_MERGE),\n-\t\tOPT_SET_INT('r', \"rebase\", &update_type,\n+\t\tOPT_SET_INT('r', \"rebase\", &opt.update_default,\n \t\t\tN_(\"use the 'rebase' update strategy\"),\n \t\t\tSM_UPDATE_REBASE),\n \t\tOPT_STRING_LIST(0, \"reference\", &opt.references, N_(\"repo\"),\n@@ -2662,17 +2665,8 @@ static int module_update(int argc, const char **argv, const char *prefix)\n \n \topt.filter_options = &filter_options;\n \n-\tif (update_type == SM_UPDATE_CHECKOUT)\n-\t\topt.update_default = \"checkout\";\n-\telse if (update_type == SM_UPDATE_MERGE)\n-\t\topt.update_default = \"merge\";\n-\telse if (update_type == SM_UPDATE_REBASE)\n-\t\topt.update_default = \"rebase\";\n-\n \tif (opt.update_default)\n-\t\tif (parse_submodule_update_strategy(opt.update_default,\n-\t\t\t\t\t\t    &opt.update_strategy) < 0)\n-\t\t\tdie(_(\"bad value for update parameter\"));\n+\t\topt.update_strategy.type = opt.update_default;\n \n \tif (module_list_compute(argc, argv, prefix, &pathspec, &opt.list) < 0) {\n \t\tlist_objects_filter_release(&filter_options);\n-- \n2.36.1.1239.gfba91521d90\n\n"},{"id":"457151","messageId":"kl6lwndk5ffc.fsf@chooglen-macbookpro.roam.corp.google.com","threadId":"57979","inReplyTo":"cover-v2-00.12-00000000000-20220613T220150Z-avarab@gmail.com","subject":"Re: [PATCH v2 00/12] submodule: make \"git submodule--helper\" behave like \"git submodule\"","fromName":"Glen Choo","fromEmail":"chooglen@google.com","sentAt":"2022-06-13T23:09:27Z","receivedAt":"2022-06-13T23:09:36Z","isPatch":true,"sender":{"key":"glencbz@gmail.com","avatar":"https://avatars.githubusercontent.com/u/58092771?v=4"},"body":"\nThanks! I'm happy to see this happen regardless of whose patches we use\n:)\n\nReading the cover letter, I think it probably makes sense for this to\nsupersede gc/submodule-update. I haven't really looked at the changes\nyet though, but I will soon.\n\nÆvar Arnfjörð Bjarmason <avarab@gmail.com> writes:\n\n>> Here's a way of breaking apart the work that makes sense to me:\n>>\n>> - Reuse the patches that prepare git-submodule.sh for the conversion,\n>>   particularly 1-7/20 (create a \"case\" dispatch statement and its\n>>   preceding patches).\n>> - Keep my series that prepares \"update\", since that's the most tedious\n>>   one to convert. If I don't dispatch to the \"case\" statement, I don't\n>>   think it will even conflict with the preparatory series.\n>>\n>>   Some of your patches make more sense than mine, and I'll incorporate\n>>   them as necessary :)\n>> - Dispatch subcommands using the \"case\" dispatch, including \"update\". We\n>>   might have to do this slowly if we want things to be easy to eyeball.\n>> - \"git rm git-submodule.sh\"!\n>\n> Hopefully there's no stepping on toes here, but I thought I'd send\n> this out now (I went back to the laptop) to avoid the duplicate work,\n> since I'd already attempted combining the two, and this is the result.\n\nFortunately I hadn't resumed work on this yet, so it works out :)\n\n>>> Brief commentary on my patches, details in commit messages:\n>>>\n>>> Ævar Arnfjörð Bjarmason (20):\n>>>   git-submodule.sh: remove unused sanitize_submodule_env()\n>>>   git-submodule.sh: remove unused $prefix variable\n>>>   git-submodule.sh: remove unused --super-prefix logic\n>>>\n>>> I removed a bit more dead code here than yours.\n>>>\n>>>   git-submodule.sh: normalize parsing of \"--branch\"\n>>>   git-submodule.sh: normalize parsing of --cached\n>>>\n>>> This & various other prep commits (hereafter \"easy prep\") make\n>>> subsequent one-time conversions of whole cmd_*() easier.\n>>>\n>>>   submodule--helper: rename \"absorb-git-dirs\" to \"absorbgitdirs\"\n>>>   git-submodule.sh: create a \"case\" dispatch statement\n>>>\n>>> easy prep\n>>\n>> This would all make sense in a preparatory series, with the exception of \n>> 3/20 git-submodule.sh: remove unused --super-prefix logic.\n>>\n>> We have several instances where we invoke submodule--helper directly\n>> with --super-prefix, e.g. inside sync_submodule():\n>>     \n>>     if (flags & OPT_RECURSIVE) {\n>>       struct child_process cpr = CHILD_PROCESS_INIT;\n>>\n>>       cpr.git_cmd = 1;\n>>       cpr.dir = path;\n>>       prepare_submodule_repo_env(&cpr.env_array);\n>>\n>>       strvec_push(&cpr.args, \"--super-prefix\"); /* Here */\n>>\n>> I even have a (as of now private) patch that replaces \"update\"'s\n>> --recursive-prefix with --super-prefix.\n>>\n>> This probably wasn't caught in the tests because this only affects how\n>> we calculate the submodule 'displayname'.\n>\n> This is still in this series as 02/12. I think you've misunderstood\n> that code, it *is* invoking \"git submodule--helper\" with\n> \"--super-prefix\", but the option is passed as:\n>\n>     git --super-prefix <path> submodule--helper\n>\n> And not as:\n>\n>     git submodule--helper --super-prefix <path>\n>\n> This is thus handled by other code before builtin/submodule--helper.c,\n> and it doesn't need to handle it.\n>\n> But anyway, this is confusing, so I updated the commit message (seen\n> in the range-diff below)>\n\nAh that's right, I forgot that we have to pass it to \"git\" directly.\nThanks.\n\nI wonder why we ever needed this. 89c8626557 (submodule helper: support\nsuper prefix, 2016-12-08) doesn't really explain it, so it looks like\nI'll have to dig around the ML.\n\n>>>   submodule--helper: have --require-init imply --init\n>>>   submodule--helper: understand --checkout, --merge and --rebase\n>>>     synonyms\n>>>   git-submodule doc: document the -v\" option to \"update\"\n>>>   submodule--helper: understand -v option for \"update\"\n>>>\n>>> not-so-easy prep for \"cmd_update()\"\n>>>\n>>>   git-submodule.sh: dispatch \"update\" to helper\n>>>\n>>> Full cmd_update() migration in one go.\n>>\n>> Yeah, and since it's not-so-easy, it probably makes sense to continue to\n>> keep my series around. I'll borrow some of these patches if that's ok :)\n>\n> The proposal in *this series* is to leave this aside for now, but\n> generally I wonder what part of it you find not-so-easy.\n>\n> Personally I find it much harder to carefully review the way you\n> proposed to do it, i.e. to \"buffer up\" options that we \"don't handle\",\n> but actually need to sort-of handle, as we'd still like to die if we\n> have unknown options.\n>\n> Particularly since shellscript quoting etc. is a pain with that sort\n> of thing, as it doesn't have any real list or key-value\n> datastructures.\n>\n> Whereas getting it to the point where we're clearly just passing\n> options as-is through beforehand, and then simply dropping the wrapper\n> is, I think, much easier to review. You only need to trust or check\n> that e.g. \"git submodule--helper update\" also supports a \"--progress\"\n> option or whatever, and/or that we've got coverage for it.\n\nMakes sense. I suppose we don't have to overthink the conversion because\nwe will have to make the leap of faith to C at some point.\n\n"},{"id":"457153","messageId":"220614.86pmjcyv4u.gmgdl@evledraar.gmail.com","threadId":"57979","inReplyTo":"kl6lwndk5ffc.fsf@chooglen-macbookpro.roam.corp.google.com","subject":"Re: [PATCH v2 00/12] submodule: make \"git submodule--helper\" behave like \"git submodule\"","fromName":"Ævar Arnfjörð Bjarmason","fromEmail":"avarab@gmail.com","sentAt":"2022-06-13T23:31:10Z","receivedAt":"2022-06-13T23:57:28Z","isPatch":true,"sender":{"key":"avarab@gmail.com","avatar":"https://avatars.githubusercontent.com/u/45301?v=4"},"body":"\nOn Mon, Jun 13 2022, Glen Choo wrote:\n\n> Thanks! I'm happy to see this happen regardless of whose patches we use\n> :)\n\nI didn't set out to keep \"my side\", but just to see if we could come up\nwith something non-RFC that could be queued/integrated sooner than\nlater, and removing dead code & the smallish changes to unify the\ninterfaces for a subsequent conversion seemed like it would be more\npalatable.\n\nThus dropping 1-3/8 of yours, it's the \"real\" migration (or steps\ntowards it). Then your 4/8 was tangled up in that migration so I took my\nsmaller 12/20 over it.\n\nI then took your 5/8, but combined with my 13/20 as discussed in the\nCL. I.e. splitting up the external from internal interface change, which\nwe can do in two steps.\n\nYour 6/8 is then taken over my 14-15/20, 7/8 is another thing I dropped\nas the \"real\" migration to leave for later, and as discussed (see below)\nyour 8/8 is much smaller than the dead code removal we can do here in\n2/12, i.e. we can drop --super-prefix, and a lot of yarn falls out once\nwe pull on that thread...\n\nMost of the patches I dropped were my own :) I.e. the \"actual\nconversion\" bits, and then I picked up e.g. the\ns/absorb-git-dirs/absorbgitdirs/g etc., and other patches in my series\nthat unified the interfaces.\n\n> Reading the cover letter, I think it probably makes sense for this to\n> supersede gc/submodule-update. I haven't really looked at the changes\n> yet though, but I will soon.\n\nI hadn't noticed that Junio had picked your RFC patches up (I didn't\ncheck, figuring since it was RFC they wouldn't be...).\n\nAnyway, I'm fine with whatever gets us to the end goal most efficiently.\n\n> Ævar Arnfjörð Bjarmason <avarab@gmail.com> writes:\n>\n>>> Here's a way of breaking apart the work that makes sense to me:\n>>>\n>>> - Reuse the patches that prepare git-submodule.sh for the conversion,\n>>>   particularly 1-7/20 (create a \"case\" dispatch statement and its\n>>>   preceding patches).\n>>> - Keep my series that prepares \"update\", since that's the most tedious\n>>>   one to convert. If I don't dispatch to the \"case\" statement, I don't\n>>>   think it will even conflict with the preparatory series.\n>>>\n>>>   Some of your patches make more sense than mine, and I'll incorporate\n>>>   them as necessary :)\n>>> - Dispatch subcommands using the \"case\" dispatch, including \"update\". We\n>>>   might have to do this slowly if we want things to be easy to eyeball.\n>>> - \"git rm git-submodule.sh\"!\n>>\n>> Hopefully there's no stepping on toes here, but I thought I'd send\n>> this out now (I went back to the laptop) to avoid the duplicate work,\n>> since I'd already attempted combining the two, and this is the result.\n>\n> Fortunately I hadn't resumed work on this yet, so it works out :)\n\nHope it helped :)\n\n>> [...]\n>> This is still in this series as 02/12. I think you've misunderstood\n>> that code, it *is* invoking \"git submodule--helper\" with\n>> \"--super-prefix\", but the option is passed as:\n>>\n>>     git --super-prefix <path> submodule--helper\n>>\n>> And not as:\n>>\n>>     git submodule--helper --super-prefix <path>\n>>\n>> This is thus handled by other code before builtin/submodule--helper.c,\n>> and it doesn't need to handle it.\n>>\n>> But anyway, this is confusing, so I updated the commit message (seen\n>> in the range-diff below)>\n>\n> Ah that's right, I forgot that we have to pass it to \"git\" directly.\n> Thanks.\n>\n> I wonder why we ever needed this. 89c8626557 (submodule helper: support\n> super prefix, 2016-12-08) doesn't really explain it, so it looks like\n> I'll have to dig around the ML.\n\nIt was needed, but not after b3c5f5cb048 (submodule: move core\ncmd_update() logic to C, 2022-03-15) as my 02/12 discusses.\n\nAs a quick test try to check out b3c5f5cb048 and apply this change:\n\n    -#define SUPPORT_SUPER_PREFIX (1<<0)\n    +#define SUPPORT_SUPER_PREFIX 0\n\nYou'll find that t7406-submodule-update.sh passes, but check out its\nparent (which is a commit of yours) and it'll fail, as we'll then emit\noutput like:\n\n    -Submodule path '../super': checked out 'e1c658656b91df52a4634fbffeaa739807ce3521'\n    +Submodule path 'super': checked out 'e1c658656b91df52a4634fbffeaa739807ce3521'\n\nSo this is just one of the things that were overly complex in\ngit-submodule--helper because parts of it had to bridge the gap between\n*.sh and *.c land, but once we moved more parts to C we ended up getting\nthat for free.\n\n>>>>   submodule--helper: have --require-init imply --init\n>>>>   submodule--helper: understand --checkout, --merge and --rebase\n>>>>     synonyms\n>>>>   git-submodule doc: document the -v\" option to \"update\"\n>>>>   submodule--helper: understand -v option for \"update\"\n>>>>\n>>>> not-so-easy prep for \"cmd_update()\"\n>>>>\n>>>>   git-submodule.sh: dispatch \"update\" to helper\n>>>>\n>>>> Full cmd_update() migration in one go.\n>>>\n>>> Yeah, and since it's not-so-easy, it probably makes sense to continue to\n>>> keep my series around. I'll borrow some of these patches if that's ok :)\n>>\n>> The proposal in *this series* is to leave this aside for now, but\n>> generally I wonder what part of it you find not-so-easy.\n>>\n>> Personally I find it much harder to carefully review the way you\n>> proposed to do it, i.e. to \"buffer up\" options that we \"don't handle\",\n>> but actually need to sort-of handle, as we'd still like to die if we\n>> have unknown options.\n>>\n>> Particularly since shellscript quoting etc. is a pain with that sort\n>> of thing, as it doesn't have any real list or key-value\n>> datastructures.\n>>\n>> Whereas getting it to the point where we're clearly just passing\n>> options as-is through beforehand, and then simply dropping the wrapper\n>> is, I think, much easier to review. You only need to trust or check\n>> that e.g. \"git submodule--helper update\" also supports a \"--progress\"\n>> option or whatever, and/or that we've got coverage for it.\n>\n> Makes sense. I suppose we don't have to overthink the conversion because\n> we will have to make the leap of faith to C at some point.\n\nAnyway, that's something we can leave aside for now. I.e. maybe your way\nof doing it is better, maybe mine is. That's for later.\n\nFor now what do you think about focusing on initial smaller changes to\nget the two command-line interfaces as close to 1=1 as possible, and to\nremove dead code etc.\n\nI.e. to aim for small changes now to make reviewing the eventual *.sh\nv.s. *.c code as easy as possible, as the CLI for \"submodule\" and\n\"submodule--helper\" will behave the same at that point, there won't be\nany dead code etc.\n"},{"id":"457231","messageId":"kl6lsfo66bjr.fsf@chooglen-macbookpro.roam.corp.google.com","threadId":"57979","inReplyTo":"220614.86pmjcyv4u.gmgdl@evledraar.gmail.com","subject":"Re: [PATCH v2 00/12] submodule: make \"git submodule--helper\" behave like \"git submodule\"","fromName":"Glen Choo","fromEmail":"chooglen@google.com","sentAt":"2022-06-15T00:00:08Z","receivedAt":"2022-06-15T00:00:15Z","isPatch":true,"sender":{"key":"glencbz@gmail.com","avatar":"https://avatars.githubusercontent.com/u/58092771?v=4"},"body":"Ævar Arnfjörð Bjarmason <avarab@gmail.com> writes:\n\n>>> [...]\n>>> This is still in this series as 02/12. I think you've misunderstood\n>>> that code, it *is* invoking \"git submodule--helper\" with\n>>> \"--super-prefix\", but the option is passed as:\n>>>\n>>>     git --super-prefix <path> submodule--helper\n>>>\n>>> And not as:\n>>>\n>>>     git submodule--helper --super-prefix <path>\n>>>\n>>> This is thus handled by other code before builtin/submodule--helper.c,\n>>> and it doesn't need to handle it.\n>>>\n>>> But anyway, this is confusing, so I updated the commit message (seen\n>>> in the range-diff below)>\n>>\n>> Ah that's right, I forgot that we have to pass it to \"git\" directly.\n>> Thanks.\n>>\n>> I wonder why we ever needed this. 89c8626557 (submodule helper: support\n>> super prefix, 2016-12-08) doesn't really explain it, so it looks like\n>> I'll have to dig around the ML.\n>\n> It was needed, but not after b3c5f5cb048 (submodule: move core\n> cmd_update() logic to C, 2022-03-15) as my 02/12 discusses.\n>\n> As a quick test try to check out b3c5f5cb048 and apply this change:\n>\n>     -#define SUPPORT_SUPER_PREFIX (1<<0)\n>     +#define SUPPORT_SUPER_PREFIX 0\n>\n> You'll find that t7406-submodule-update.sh passes, but check out its\n> parent (which is a commit of yours) and it'll fail, as we'll then emit\n> output like:\n>\n>     -Submodule path '../super': checked out 'e1c658656b91df52a4634fbffeaa739807ce3521'\n>     +Submodule path 'super': checked out 'e1c658656b91df52a4634fbffeaa739807ce3521'\n>\n> So this is just one of the things that were overly complex in\n> git-submodule--helper because parts of it had to bridge the gap between\n> *.sh and *.c land, but once we moved more parts to C we ended up getting\n> that for free.\n\nAh yes you are right, as of b3c5f5cb048 we never pass `--super-prefix`\nto \"git submodule\" any more. Great!\n\nI also remember that when I was reading the patch that became\nb3c5f5cb048 (submodule: move core cmd_update() logic to C, 2022-03-15),\nI noted (internally) that we used `prefix` to set \"--recursive-prefix\",\nwhich was unusual because `prefix` is usually mapped to\n\"--super-prefix\".\n\nI have a patch to replace \"--recursive-prefix\" with \"--super-prefix\",\nbut it doesn't make sense for that patch to be included in this series\n(it's preparation for something else entirely, and it won't make this\nseries any cleaner.)\n"},{"id":"457232","messageId":"kl6lo7yu6b2g.fsf@chooglen-macbookpro.roam.corp.google.com","threadId":"57979","inReplyTo":"patch-v2-04.12-fd328329b68-20220613T220150Z-avarab@gmail.com","subject":"Re: [PATCH v2 04/12] git-submodule.sh: remove unused top-level \"--branch\" argument","fromName":"Glen Choo","fromEmail":"chooglen@google.com","sentAt":"2022-06-15T00:10:31Z","receivedAt":"2022-06-15T00:10:50Z","isPatch":true,"sender":{"key":"glencbz@gmail.com","avatar":"https://avatars.githubusercontent.com/u/58092771?v=4"},"body":"Ævar Arnfjörð Bjarmason <avarab@gmail.com> writes:\n\n> In 5c08dbbdf1a (git-submodule: fix subcommand parser, 2008-01-15) the\n> \"--branch\" option was supported as an option to \"git submodule\"\n> itself, i.e. \"git submodule --branch\" as a side-effect of its\n> implementation.\n>\n> Then in b57e8119e6e (submodule: teach set-branch subcommand,\n> 2019-02-08) when the \"set-branch\" subcommand was added the assertion\n> that we shouldn't have \"--branch\" anywhere except as an argument to\n> \"add\" and \"set-branch\" was copy/pasted from the adjacent check for\n> \"--cache\" added (or rather modified) in 496eeeb19b9 (git-submodule.sh:\n> avoid \"test <cond> -a/-o <cond>\", 2014-06-10).\n>\n> But there's been a logic error in that check, which at a glance looked\n> like it should be supporting:\n>\n>     git submodule --branch <branch> (add | set-branch) [<options>]\n>\n> But due to \"||\" in the condition (as opposed to \"&&\" for \"--cache\") if\n> we have \"--branch\" here already we'll emit usage, even for \"add\" and\n> \"set-branch\".\n>\n> So in addition to never having documented this form it hasn't worked\n> since b57e8119e6e was released with v2.22.0 it's safe to remove this\n> code. I.e. we don't want to support the form noted above, but only:\n>\n>     git submodule (add | set-branch) --branch <branch> [<options>]\n\nHm, that's suprising. But I guess the good news is that if it's been\nbroken for so long, nobody probably needs this.\n\n> Signed-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>\n> ---\n>  git-submodule.sh | 14 --------------\n>  1 file changed, 14 deletions(-)\n>\n> diff --git a/git-submodule.sh b/git-submodule.sh\n> index b99a00d9f84..20fc1b620fa 100755\n> --- a/git-submodule.sh\n> +++ b/git-submodule.sh\n> @@ -574,14 +574,6 @@ do\n>  \t-q|--quiet)\n>  \t\tGIT_QUIET=1\n>  \t\t;;\n> -\t-b|--branch)\n> -\t\tcase \"$2\" in\n> -\t\t'')\n> -\t\t\tusage\n> -\t\t\t;;\n> -\t\tesac\n> -\t\tbranch=\"$2\"; shift\n> -\t\t;;\n>  \t--cached)\n>  \t\tcached=1\n>  \t\t;;\n> @@ -609,12 +601,6 @@ then\n>      fi\n>  fi\n>  \n> -# \"-b branch\" is accepted only by \"add\" and \"set-branch\"\n> -if test -n \"$branch\" && (test \"$command\" != add || test \"$command\" != set-branch)\n> -then\n> -\tusage\n> -fi\n> -\n>  # \"--cached\" is accepted only by \"status\" and \"summary\"\n>  if test -n \"$cached\" && test \"$command\" != status && test \"$command\" != summary\n>  then\n\nLooks good.\n"},{"id":"457233","messageId":"kl6llety6amx.fsf@chooglen-macbookpro.roam.corp.google.com","threadId":"57979","inReplyTo":"patch-v2-05.12-ef3265a588e-20220613T220150Z-avarab@gmail.com","subject":"Re: [PATCH v2 05/12] submodule--helper: have --require-init imply --init","fromName":"Glen Choo","fromEmail":"chooglen@google.com","sentAt":"2022-06-15T00:19:50Z","receivedAt":"2022-06-15T00:19:56Z","isPatch":true,"sender":{"key":"glencbz@gmail.com","avatar":"https://avatars.githubusercontent.com/u/58092771?v=4"},"body":"Ævar Arnfjörð Bjarmason <avarab@gmail.com> writes:\n\n> [...]\n> We'll still need to keep the distinction between \"--init\" and\n> \"--require-init\" in git-submodule.sh. Once cmd_update() gets\n> re-implemented in C we'll be able to variables and other code related\n> to that, but not yet.\n\nSmall typo maybe?\n\n  re-implemented in C we'll be able to *change* variables and other code\n  related to that, but not yet.\n"},{"id":"457234","messageId":"kl6lilp26a79.fsf@chooglen-macbookpro.roam.corp.google.com","threadId":"57979","inReplyTo":"patch-v2-06.12-025694644fc-20220613T220150Z-avarab@gmail.com","subject":"Re: [PATCH v2 06/12] submodule update: remove \"-v\" option","fromName":"Glen Choo","fromEmail":"chooglen@google.com","sentAt":"2022-06-15T00:29:14Z","receivedAt":"2022-06-15T00:29:19Z","isPatch":true,"sender":{"key":"glencbz@gmail.com","avatar":"https://avatars.githubusercontent.com/u/58092771?v=4"},"body":"Ævar Arnfjörð Bjarmason <avarab@gmail.com> writes:\n\n> The only in-tree user has been this test added in\n> 3ad0401e9e6 (submodule update: silence underlying merge/rebase with\n> \"--quiet\", 2020-09-30), it wasn't per-se testing --quiet, but fixing a\n> bug in e84c3cf3dc3: It used to set \"GIT_QUIET=0\" instead of unsetting\n> it on \"-v\", and thus we'd end up passing \"--quiet\" to \"git\n> submodule--helper\" on \"-v\", since the \"--quiet\" option was passed sing\n> the ${parameter:+word} construct.\n\nAh, that explains why we have a test for something that seemed so\nunnecessary. Note to self to dig a little more in the future.\n\n> Furthermore, even if someone had used the \"-v\" option they'd only be\n> getting the default output. Our default in both git-submodule.sh and\n> \"git submodule--helper\" has been to be \"verbose\", so the only way this\n> option could have matter is if it were used as e.g.:\n>\n>     git submodule --quiet update -v [...]\n>\n> I.e. to undo the effect of a previous \"--quiet\" on the command-line.\n>\n> Signed-off-by: Glen Choo <chooglen@google.com>\n> Signed-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>\n\nThe additional motivation looks great, and I think it's changed\nsufficiently that you should be the author instead of me.\n"},{"id":"457245","messageId":"kl6lfsk661mr.fsf@chooglen-macbookpro.roam.corp.google.com","threadId":"57979","inReplyTo":"patch-v2-08.12-99ac52d810f-20220613T220150Z-avarab@gmail.com","subject":"Re: [PATCH v2 08/12] submodule--helper: report \"submodule\" as our name in \"-h\" output","fromName":"Glen Choo","fromEmail":"chooglen@google.com","sentAt":"2022-06-15T03:34:20Z","receivedAt":"2022-06-15T03:34:32Z","isPatch":true,"sender":{"key":"glencbz@gmail.com","avatar":"https://avatars.githubusercontent.com/u/58092771?v=4"},"body":"Ævar Arnfjörð Bjarmason <avarab@gmail.com> writes:\n\n> Change the rest of the usage output for \"git submodule--helper\" so\n> that it will pretend to be named \"git submodule\", which it already did\n> e.g. in the case of \"status\", \"deinit\" and \"update\".\n>\n> This will allow us to eventually dispatch further into \"git\n> submodule--helper\" from git-submodule.sh, while emitting the correct\n> usage output.\n>\n> This does make the usage output of \"git submodule--helper\" itself\n> \"incorrect\", but since nothing user-facing invokes it directly it\n> makes sense to continue to elide that difference entirely. A user\n> isn't served by us exposing this internal implementation detail.\n\nEverything up to here makes sense. I agree that \"git submodule--helper\"\nshould have been pretending to be \"git submodule\" wherever possible.\n\nBefore now, it probably didn't matter much because it's quite hard to\nget \"git submodule--helper\" to print usage without being first\nintercepted by \"git submodule\", but we'll need it now. Which brings us\nto..\n\n> This fixes a bug that's been there ever since \"git submodule\n> absorbgitdirs\" was added in f6f85861400 (submodule: add absorb-git-dir\n> function, 2016-12-12). Before this we'd emit e.g. this on invalid\n> usage:\n>\n> \t$ git submodule absorbgitdirs --blah\n> \terror: unknown option `blah'\n> \tusage: git submodule--helper absorbgitdirs [<options>] [<path>...]\n\nWe actually used to output the internal-only name of the\nsubmodule--helper subcommand, i.e.\n\n  git submodule--helper absorb-git-dirs\n\nwith the dashes.\n\n> Now we'll emit the same, except that the usage line is now referring\n> to the correct command run by the user:\n>\n> \tusage: git submodule absorbgitdirs [<options>] [<path>...]\n> \t[.. same usage output ...]\n\nI initially wondered why \"absorbgitdirs\" deserved a special shoutout\nwhen we are changing several other subcommands in the same patch, but\nit turns out that this usage string bug probably is\n\"absorbgitdirs\"-specific.\n\n\"absorbgitdirs\" is the only subcommand that doesn't have an options\nparsing loop that catches invalid options, it's just:\n\n  cmd_absorbgitdirs()\n  {\n    git submodule--helper absorb-git-dirs --prefix \"$wt_prefix\" \"$@\"\n  }\n\nwhereas in other subcommands, invalid usage would be caught by by the\noptions parsing loop and we never invoke \"git submodule--helper blah\".\nAs a result, \"git submodule--helper absorb-git-dirs\" is probably the\nonly subcommand that prints its usage string (instead of the generic\n\"git submodule\" usage string.)\n\nIt might be worth highlighting how absorbgitdirs is special in the\ncommit message, but I don't feel strongly either way.\n"},{"id":"457248","messageId":"kl6lczfa60d3.fsf@chooglen-macbookpro.roam.corp.google.com","threadId":"57979","inReplyTo":"patch-v2-08.12-99ac52d810f-20220613T220150Z-avarab@gmail.com","subject":"Re: [PATCH v2 08/12] submodule--helper: report \"submodule\" as our name in \"-h\" output","fromName":"Glen Choo","fromEmail":"chooglen@google.com","sentAt":"2022-06-15T04:01:44Z","receivedAt":"2022-06-15T04:01:49Z","isPatch":true,"sender":{"key":"glencbz@gmail.com","avatar":"https://avatars.githubusercontent.com/u/58092771?v=4"},"body":"\nÆvar Arnfjörð Bjarmason <avarab@gmail.com> writes:\n\n> diff --git a/builtin/submodule--helper.c b/builtin/submodule--helper.c\n> index 574d6e0a79b..c2f55779cb1 100644\n> --- a/builtin/submodule--helper.c\n> +++ b/builtin/submodule--helper.c\n> @@ -286,7 +286,7 @@ static int module_list(int argc, const char **argv, const char *prefix)\n>  \t};\n>  \n>  \tconst char *const git_submodule_helper_usage[] = {\n> -\t\tN_(\"git submodule--helper list [--prefix=<path>] [<path>...]\"),\n> +\t\tN_(\"git submodule list [--prefix=<path>] [<path>...]\"),\n>  \t\tNULL\n>  \t};\n> @@ -444,7 +444,7 @@ static int module_foreach(int argc, const char **argv, const char *prefix)\n>  \t};\n>  \n>  \tconst char *const git_submodule_helper_usage[] = {\n> -\t\tN_(\"git submodule--helper foreach [--quiet] [--recursive] [--] <command>\"),\n> +\t\tN_(\"git submodule foreach [--quiet] [--recursive] [--] <command>\"),\n>  \t\tNULL\n>  \t};\n>  \n> @@ -582,7 +582,7 @@ static int module_init(int argc, const char **argv, const char *prefix)\n>  \t};\n>  \n>  \tconst char *const git_submodule_helper_usage[] = {\n> -\t\tN_(\"git submodule--helper init [<options>] [<path>]\"),\n> +\t\tN_(\"git submodule init [<options>] [<path>]\"),\n>  \t\tNULL\n>  \t};\n>  \n> @@ -786,7 +786,7 @@ static int module_name(int argc, const char **argv, const char *prefix)\n>  \tconst struct submodule *sub;\n>  \n>  \tif (argc != 2)\n> -\t\tusage(_(\"git submodule--helper name <path>\"));\n> +\t\tusage(_(\"git submodule name <path>\"));\n>  \n>  \tsub = submodule_from_path(the_repository, null_oid(), argv[1]);\n>  \n> @@ -1185,7 +1185,7 @@ static int module_summary(int argc, const char **argv, const char *prefix)\n>  \t};\n>  \n>  \tconst char *const git_submodule_helper_usage[] = {\n> -\t\tN_(\"git submodule--helper summary [<options>] [<commit>] [--] [<path>]\"),\n> +\t\tN_(\"git submodule summary [<options>] [<commit>] [--] [<path>]\"),\n>  \t\tNULL\n>  \t};\n>  \n> @@ -1349,7 +1349,7 @@ static int module_sync(int argc, const char **argv, const char *prefix)\n>  \t};\n>  \n>  \tconst char *const git_submodule_helper_usage[] = {\n> -\t\tN_(\"git submodule--helper sync [--quiet] [--recursive] [<path>]\"),\n> +\t\tN_(\"git submodule sync [--quiet] [--recursive] [<path>]\"),\n>  \t\tNULL\n>  \t};\n>  \n> @@ -1789,7 +1789,7 @@ static int module_clone(int argc, const char **argv, const char *prefix)\n>  \t};\n>  \n>  \tconst char *const git_submodule_helper_usage[] = {\n> -\t\tN_(\"git submodule--helper clone [--prefix=<path>] [--quiet] \"\n> +\t\tN_(\"git submodule clone [--prefix=<path>] [--quiet] \"\n>  \t\t   \"[--reference <repository>] [--name <name>] [--depth <depth>] \"\n>  \t\t   \"[--single-branch] [--filter <filter-spec>] \"\n>  \t\t   \"--url <url> --path <path>\"),\n> @@ -2787,7 +2787,7 @@ static int absorb_git_dirs(int argc, const char **argv, const char *prefix)\n>  \t};\n>  \n>  \tconst char *const git_submodule_helper_usage[] = {\n> -\t\tN_(\"git submodule--helper absorbgitdirs [<options>] [<path>...]\"),\n> +\t\tN_(\"git submodule absorbgitdirs [<options>] [<path>...]\"),\n>  \t\tNULL\n>  \t};\n>  \n> @@ -2851,9 +2851,9 @@ static int module_config(int argc, const char **argv, const char *prefix)\n>  \t\tOPT_END()\n>  \t};\n>  \tconst char *const git_submodule_helper_usage[] = {\n> -\t\tN_(\"git submodule--helper config <name> [<value>]\"),\n> -\t\tN_(\"git submodule--helper config --unset <name>\"),\n> -\t\t\"git submodule--helper config --check-writeable\",\n> +\t\tN_(\"git submodule config <name> [<value>]\"),\n> +\t\tN_(\"git submodule config --unset <name>\"),\n> +\t\t\"git submodule config --check-writeable\",\n>  \t\tNULL\n>  \t};\n>  \n> @@ -2892,7 +2892,7 @@ static int module_set_url(int argc, const char **argv, const char *prefix)\n>  \t\tOPT_END()\n>  \t};\n>  \tconst char *const usage[] = {\n> -\t\tN_(\"git submodule--helper set-url [--quiet] <path> <newurl>\"),\n> +\t\tN_(\"git submodule set-url [--quiet] <path> <newurl>\"),\n>  \t\tNULL\n>  \t};\n>  \n> @@ -2931,8 +2931,8 @@ static int module_set_branch(int argc, const char **argv, const char *prefix)\n>  \t\tOPT_END()\n>  \t};\n>  \tconst char *const usage[] = {\n> -\t\tN_(\"git submodule--helper set-branch [-q|--quiet] (-d|--default) <path>\"),\n> -\t\tN_(\"git submodule--helper set-branch [-q|--quiet] (-b|--branch) <branch> <path>\"),\n> +\t\tN_(\"git submodule set-branch [-q|--quiet] (-d|--default) <path>\"),\n> +\t\tN_(\"git submodule set-branch [-q|--quiet] (-b|--branch) <branch> <path>\"),\n>  \t\tNULL\n>  \t};\n>  \n> @@ -2973,7 +2973,7 @@ static int module_create_branch(int argc, const char **argv, const char *prefix)\n>  \t\tOPT_END()\n>  \t};\n>  \tconst char *const usage[] = {\n> -\t\tN_(\"git submodule--helper create-branch [-f|--force] [--create-reflog] [-q|--quiet] [-t|--track] [-n|--dry-run] <name> <start-oid> <start-name>\"),\n> +\t\tN_(\"git submodule create-branch [-f|--force] [--create-reflog] [-q|--quiet] [-t|--track] [-n|--dry-run] <name> <start-oid> <start-name>\"),\n>  \t\tNULL\n>  \t};\n>  \n> @@ -3276,7 +3276,7 @@ static int module_add(int argc, const char **argv, const char *prefix)\n>  \t};\n>  \n>  \tconst char *const usage[] = {\n> -\t\tN_(\"git submodule--helper add [<options>] [--] <repository> [<path>]\"),\n> +\t\tN_(\"git submodule add [<options>] [--] <repository> [<path>]\"),\n>  \t\tNULL\n>  \t};\n\nI don't feel positive about pretending to be \"git submodule\" when the\nsubcommand is internal-only. Such commands are only invoked as \"git\nsubmodule--helper foo\" and we will probably never turn them into\nexternal-facing \"git submodule foo\" [1]. Even if it is internal-only,\nthere is a debugging benefit to emitting a usage string with the\ncorrect, non-user facing command name.\n\nI admit it might be a bit confusing to have a mix of usage strings with\n\"submodule--helper\" vs \"submodule\", but as long as we clearly label\nwhich commands are user-facing and which aren't, it shouldn't be too\nhard to maintain, e.g. this might just be a matter of adding comments to\nthe array of commands like:\n\n  static struct cmd_struct commands[] = {\n    /* User facing commands - pretend to be \"git submodule\" */\n    {\"name\", module_name},\n    {\"add\", module_add},\n    [...]\n    /* Internal-only commands */\n    {\"clone\", module_clone},\n    {\"resolve-relative-url-test\", resolve_relative_url_test},\n    [...]\n  };\n\nNotably, even with this patch we still _kind of_ have 'pseudo usage\nstrings' that reference \"git submodule--helper\". These are just\ninternal-only commands that don't use the parse_options() API, e.g.\n\n\tif (argc < 3)\n\t\tdie(\"submodule--helper push-check requires at least 2 arguments\");\n\nI think it's ok to leave them as-is, provided we also leave the other\ninternal-only commands as-is.\n\n[1] For convenience, here is a list of all of the subcommands changed in\nthis patch and whether they are user-facing/internal-only:\n\nUser-facing                 Internal-only\n\n- foreach                   - list\n- init                      - name\n- summary                   - clone\n- sync                      - config\n- absorbgitdirs             - create-branch\n- set-url\n- set-branch\n- add\n"},{"id":"457255","messageId":"220615.86r13qxmjx.gmgdl@evledraar.gmail.com","threadId":"57979","inReplyTo":"kl6lczfa60d3.fsf@chooglen-macbookpro.roam.corp.google.com","subject":"Re: [PATCH v2 08/12] submodule--helper: report \"submodule\" as our name in \"-h\" output","fromName":"Ævar Arnfjörð Bjarmason","fromEmail":"avarab@gmail.com","sentAt":"2022-06-15T09:42:09Z","receivedAt":"2022-06-15T10:12:46Z","isPatch":true,"sender":{"key":"avarab@gmail.com","avatar":"https://avatars.githubusercontent.com/u/45301?v=4"},"body":"\nOn Tue, Jun 14 2022, Glen Choo wrote:\n\n> Ævar Arnfjörð Bjarmason <avarab@gmail.com> writes:\n>\n>> diff --git a/builtin/submodule--helper.c b/builtin/submodule--helper.c\n>> index 574d6e0a79b..c2f55779cb1 100644\n>> --- a/builtin/submodule--helper.c\n>> +++ b/builtin/submodule--helper.c\n>> @@ -286,7 +286,7 @@ static int module_list(int argc, const char **argv, const char *prefix)\n>>  \t};\n>>  \n>>  \tconst char *const git_submodule_helper_usage[] = {\n>> -\t\tN_(\"git submodule--helper list [--prefix=<path>] [<path>...]\"),\n>> +\t\tN_(\"git submodule list [--prefix=<path>] [<path>...]\"),\n>>  \t\tNULL\n>>  \t};\n>> @@ -444,7 +444,7 @@ static int module_foreach(int argc, const char **argv, const char *prefix)\n>>  \t};\n>>  \n>>  \tconst char *const git_submodule_helper_usage[] = {\n>> -\t\tN_(\"git submodule--helper foreach [--quiet] [--recursive] [--] <command>\"),\n>> +\t\tN_(\"git submodule foreach [--quiet] [--recursive] [--] <command>\"),\n>>  \t\tNULL\n>>  \t};\n>>  \n>> @@ -582,7 +582,7 @@ static int module_init(int argc, const char **argv, const char *prefix)\n>>  \t};\n>>  \n>>  \tconst char *const git_submodule_helper_usage[] = {\n>> -\t\tN_(\"git submodule--helper init [<options>] [<path>]\"),\n>> +\t\tN_(\"git submodule init [<options>] [<path>]\"),\n>>  \t\tNULL\n>>  \t};\n>>  \n>> @@ -786,7 +786,7 @@ static int module_name(int argc, const char **argv, const char *prefix)\n>>  \tconst struct submodule *sub;\n>>  \n>>  \tif (argc != 2)\n>> -\t\tusage(_(\"git submodule--helper name <path>\"));\n>> +\t\tusage(_(\"git submodule name <path>\"));\n>>  \n>>  \tsub = submodule_from_path(the_repository, null_oid(), argv[1]);\n>>  \n>> @@ -1185,7 +1185,7 @@ static int module_summary(int argc, const char **argv, const char *prefix)\n>>  \t};\n>>  \n>>  \tconst char *const git_submodule_helper_usage[] = {\n>> -\t\tN_(\"git submodule--helper summary [<options>] [<commit>] [--] [<path>]\"),\n>> +\t\tN_(\"git submodule summary [<options>] [<commit>] [--] [<path>]\"),\n>>  \t\tNULL\n>>  \t};\n>>  \n>> @@ -1349,7 +1349,7 @@ static int module_sync(int argc, const char **argv, const char *prefix)\n>>  \t};\n>>  \n>>  \tconst char *const git_submodule_helper_usage[] = {\n>> -\t\tN_(\"git submodule--helper sync [--quiet] [--recursive] [<path>]\"),\n>> +\t\tN_(\"git submodule sync [--quiet] [--recursive] [<path>]\"),\n>>  \t\tNULL\n>>  \t};\n>>  \n>> @@ -1789,7 +1789,7 @@ static int module_clone(int argc, const char **argv, const char *prefix)\n>>  \t};\n>>  \n>>  \tconst char *const git_submodule_helper_usage[] = {\n>> -\t\tN_(\"git submodule--helper clone [--prefix=<path>] [--quiet] \"\n>> +\t\tN_(\"git submodule clone [--prefix=<path>] [--quiet] \"\n>>  \t\t   \"[--reference <repository>] [--name <name>] [--depth <depth>] \"\n>>  \t\t   \"[--single-branch] [--filter <filter-spec>] \"\n>>  \t\t   \"--url <url> --path <path>\"),\n>> @@ -2787,7 +2787,7 @@ static int absorb_git_dirs(int argc, const char **argv, const char *prefix)\n>>  \t};\n>>  \n>>  \tconst char *const git_submodule_helper_usage[] = {\n>> -\t\tN_(\"git submodule--helper absorbgitdirs [<options>] [<path>...]\"),\n>> +\t\tN_(\"git submodule absorbgitdirs [<options>] [<path>...]\"),\n>>  \t\tNULL\n>>  \t};\n>>  \n>> @@ -2851,9 +2851,9 @@ static int module_config(int argc, const char **argv, const char *prefix)\n>>  \t\tOPT_END()\n>>  \t};\n>>  \tconst char *const git_submodule_helper_usage[] = {\n>> -\t\tN_(\"git submodule--helper config <name> [<value>]\"),\n>> -\t\tN_(\"git submodule--helper config --unset <name>\"),\n>> -\t\t\"git submodule--helper config --check-writeable\",\n>> +\t\tN_(\"git submodule config <name> [<value>]\"),\n>> +\t\tN_(\"git submodule config --unset <name>\"),\n>> +\t\t\"git submodule config --check-writeable\",\n>>  \t\tNULL\n>>  \t};\n>>  \n>> @@ -2892,7 +2892,7 @@ static int module_set_url(int argc, const char **argv, const char *prefix)\n>>  \t\tOPT_END()\n>>  \t};\n>>  \tconst char *const usage[] = {\n>> -\t\tN_(\"git submodule--helper set-url [--quiet] <path> <newurl>\"),\n>> +\t\tN_(\"git submodule set-url [--quiet] <path> <newurl>\"),\n>>  \t\tNULL\n>>  \t};\n>>  \n>> @@ -2931,8 +2931,8 @@ static int module_set_branch(int argc, const char **argv, const char *prefix)\n>>  \t\tOPT_END()\n>>  \t};\n>>  \tconst char *const usage[] = {\n>> -\t\tN_(\"git submodule--helper set-branch [-q|--quiet] (-d|--default) <path>\"),\n>> -\t\tN_(\"git submodule--helper set-branch [-q|--quiet] (-b|--branch) <branch> <path>\"),\n>> +\t\tN_(\"git submodule set-branch [-q|--quiet] (-d|--default) <path>\"),\n>> +\t\tN_(\"git submodule set-branch [-q|--quiet] (-b|--branch) <branch> <path>\"),\n>>  \t\tNULL\n>>  \t};\n>>  \n>> @@ -2973,7 +2973,7 @@ static int module_create_branch(int argc, const char **argv, const char *prefix)\n>>  \t\tOPT_END()\n>>  \t};\n>>  \tconst char *const usage[] = {\n>> -\t\tN_(\"git submodule--helper create-branch [-f|--force] [--create-reflog] [-q|--quiet] [-t|--track] [-n|--dry-run] <name> <start-oid> <start-name>\"),\n>> +\t\tN_(\"git submodule create-branch [-f|--force] [--create-reflog] [-q|--quiet] [-t|--track] [-n|--dry-run] <name> <start-oid> <start-name>\"),\n>>  \t\tNULL\n>>  \t};\n>>  \n>> @@ -3276,7 +3276,7 @@ static int module_add(int argc, const char **argv, const char *prefix)\n>>  \t};\n>>  \n>>  \tconst char *const usage[] = {\n>> -\t\tN_(\"git submodule--helper add [<options>] [--] <repository> [<path>]\"),\n>> +\t\tN_(\"git submodule add [<options>] [--] <repository> [<path>]\"),\n>>  \t\tNULL\n>>  \t};\n\nFirst, I think this patch is premature, so let's just drop it in a\nre-roll. We don't *need* to fix this particular edge case or bug now,\nand can just do it as we do the final migration.\n\n> I don't feel positive about pretending to be \"git submodule\" when the\n> subcommand is internal-only. Such commands are only invoked as \"git\n> submodule--helper foo\" and we will probably never turn them into\n> external-facing \"git submodule foo\" [1]. Even if it is internal-only,\n> there is a debugging benefit to emitting a usage string with the\n> correct, non-user facing command name.\n\nI think we should really be most concerned about the end users here,\nnobody except git developers are going to want to invoke\n\"submodule--helper\" directly, so its help messages should be aimed at\nhelping users.\n\nAs you mention in another E-Mail it's currently not a big deal, I\n*think* that \"absorbgitdirs\" is the only case where we'll implicitly\nsuggest to a user that they might invoke \"git submodule--helper\" as we\nemit the usage info.\n\nBut I think for the patches that come after this we should definitely\nchange this, i.e. we don't want an in-between state where we have both\nof builtin/submodule{,--helper}.c because we haven't merged the two yet,\nbut are now telling users about the inernal-only helper.\n\n> I admit it might be a bit confusing to have a mix of usage strings with\n> \"submodule--helper\" vs \"submodule\", but as long as we clearly label\n> which commands are user-facing and which aren't, it shouldn't be too\n> hard to maintain, e.g. this might just be a matter of adding comments to\n> the array of commands like:\n>\n>   static struct cmd_struct commands[] = {\n>     /* User facing commands - pretend to be \"git submodule\" */\n>     {\"name\", module_name},\n>     {\"add\", module_add},\n>     [...]\n>     /* Internal-only commands */\n>     {\"clone\", module_clone},\n>     {\"resolve-relative-url-test\", resolve_relative_url_test},\n>     [...]\n>   };\n>\n> Notably, even with this patch we still _kind of_ have 'pseudo usage\n> strings' that reference \"git submodule--helper\". These are just\n> internal-only commands that don't use the parse_options() API, e.g.\n>\n> \tif (argc < 3)\n> \t\tdie(\"submodule--helper push-check requires at least 2 arguments\");\n>\n> I think it's ok to leave them as-is, provided we also leave the other\n> internal-only commands as-is.\n\nYes let's leave them, we'll be converting these to not invoke\nsub-processes sooner than later anyway.\n\n> [1] For convenience, here is a list of all of the subcommands changed in\n> this patch and whether they are user-facing/internal-only:\n>\n> User-facing                 Internal-only\n>\n> - foreach                   - list\n> - init                      - name\n> - summary                   - clone\n> - sync                      - config\n> - absorbgitdirs             - create-branch\n> - set-url\n> - set-branch\n> - add\n\nBut yeah, if/when we change the public-facing usage strings we should be\nleaving out the \"internal-only\" commands, thanks. I just did a dumb\nsearch/replace.\n"},{"id":"457289","messageId":"kl6l8rpx6f9q.fsf@chooglen-macbookpro.roam.corp.google.com","threadId":"57979","inReplyTo":"patch-v2-10.12-ac00a9599de-20220613T220150Z-avarab@gmail.com","subject":"Re: [PATCH v2 10/12] submodule--helper: eliminate internal \"--update\" option","fromName":"Glen Choo","fromEmail":"chooglen@google.com","sentAt":"2022-06-15T16:52:01Z","receivedAt":"2022-06-15T16:52:13Z","isPatch":true,"sender":{"key":"glencbz@gmail.com","avatar":"https://avatars.githubusercontent.com/u/58092771?v=4"},"body":"Ævar Arnfjörð Bjarmason <avarab@gmail.com> writes:\n\n> From: Glen Choo <chooglen@google.com>\n>\n> Follow-up on the preceding commit which taught \"git submodule--helper\n> update\" to understand \"--merge\", \"--checkout\" and \"--rebase\" and use\n> those options instead of \"--update=(rebase|merge|checkout|none)\" when\n> the command invokes itself.\n>\n> Unlike the preceding change this isn't strictly necessary to\n> eventually change \"git-submodule.sh\" so that it invokes \"git\n> submodule--helper update\" directly, but let's remove this\n> inconsistency in the command-line interface. We shouldn't need to\n> carry special synonyms for existing options in \"git submodule--helper\"\n> when that command can use the primary documented names instead.\n>\n> But, as seen in the post-image this makes the control flow within\n> \"builtin/submodule--helper.c\" simpler, we can now write directly to\n> the \"update_default\" member of \"struct update_data\" when parsing the\n> options in \"module_update()\".\n>\n> Signed-off-by: Glen Choo <chooglen@google.com>\n> Signed-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>\n> ---\n>  builtin/submodule--helper.c | 42 ++++++++++++++++---------------------\n>  1 file changed, 18 insertions(+), 24 deletions(-)\n>\n> diff --git a/builtin/submodule--helper.c b/builtin/submodule--helper.c\n> index 57f0237af23..65cf4b915df 100644\n> --- a/builtin/submodule--helper.c\n> +++ b/builtin/submodule--helper.c\n> @@ -1818,7 +1818,7 @@ static int module_clone(int argc, const char **argv, const char *prefix)\n>  static void determine_submodule_update_strategy(struct repository *r,\n>  \t\t\t\t\t\tint just_cloned,\n>  \t\t\t\t\t\tconst char *path,\n> -\t\t\t\t\t\tconst char *update,\n> +\t\t\t\t\t\tenum submodule_update_type update,\n>  \t\t\t\t\t\tstruct submodule_update_strategy *out)\n>  {\n>  \tconst struct submodule *sub = submodule_from_path(r, null_oid(), path);\n> @@ -1828,9 +1828,7 @@ static void determine_submodule_update_strategy(struct repository *r,\n>  \tkey = xstrfmt(\"submodule.%s.update\", sub->name);\n>  \n>  \tif (update) {\n> -\t\tif (parse_submodule_update_strategy(update, out) < 0)\n> -\t\t\tdie(_(\"Invalid update mode '%s' for submodule path '%s'\"),\n> -\t\t\t\tupdate, path);\n> +\t\tout->type = update;\n>  \t} else if (!repo_config_get_string_tmp(r, key, &val)) {\n>  \t\tif (parse_submodule_update_strategy(val, out) < 0)\n>  \t\t\tdie(_(\"Invalid update mode '%s' configured for submodule path '%s'\"),\n> @@ -1882,7 +1880,7 @@ struct update_data {\n>  \tconst char *prefix;\n>  \tconst char *recursive_prefix;\n>  \tconst char *displaypath;\n> -\tconst char *update_default;\n> +\tenum submodule_update_type update_default;\n>  \tstruct object_id suboid;\n>  \tstruct string_list references;\n>  \tstruct submodule_update_strategy update_strategy;\n> @@ -2406,6 +2404,8 @@ static void ensure_core_worktree(const char *path)\n>  \n>  static void update_data_to_args(struct update_data *update_data, struct strvec *args)\n>  {\n> +\tenum submodule_update_type ud = update_data->update_default;\n> +\n>  \tstrvec_pushl(args, \"submodule--helper\", \"update\", \"--recursive\", NULL);\n>  \tstrvec_pushf(args, \"--jobs=%d\", update_data->max_jobs);\n>  \tif (update_data->recursive_prefix)\n> @@ -2429,8 +2429,15 @@ static void update_data_to_args(struct update_data *update_data, struct strvec *\n>  \t\tstrvec_push(args, \"--require-init\");\n>  \tif (update_data->depth)\n>  \t\tstrvec_pushf(args, \"--depth=%d\", update_data->depth);\n> -\tif (update_data->update_default)\n> -\t\tstrvec_pushl(args, \"--update\", update_data->update_default, NULL);\n> +\tif (ud == SM_UPDATE_MERGE)\n> +\t\tstrvec_push(args, \"--merge\");\n> +\telse if (ud == SM_UPDATE_CHECKOUT)\n> +\t\tstrvec_push(args, \"--checkout\");\n> +\telse if (ud == SM_UPDATE_REBASE)\n> +\t\tstrvec_push(args, \"--rebase\");\n> +\telse if (ud != SM_UPDATE_UNSPECIFIED)\n> +\t\tBUG(\"cannot convert update_default=%d to args\", ud);\n> +\n>  \tif (update_data->references.nr) {\n>  \t\tstruct string_list_item *item;\n>  \t\tfor_each_string_list_item(item, &update_data->references)\n\nEverything up to here looks familiar ;)\n\n> @@ -2582,7 +2589,6 @@ static int module_update(int argc, const char **argv, const char *prefix)\n>  \tstruct update_data opt = UPDATE_DATA_INIT;\n>  \tstruct list_objects_filter_options filter_options;\n>  \tint ret;\n> -\tenum submodule_update_type update_type = SM_UPDATE_UNSPECIFIED;\n>  \n>  \tstruct option module_update_options[] = {\n>  \t\tOPT__FORCE(&opt.force, N_(\"force checkout updates\"), 0),\n> @@ -2601,16 +2607,13 @@ static int module_update(int argc, const char **argv, const char *prefix)\n>  \t\t\t   N_(\"path\"),\n>  \t\t\t   N_(\"path into the working tree, across nested \"\n>  \t\t\t      \"submodule boundaries\")),\n> -\t\tOPT_STRING(0, \"update\", &opt.update_default,\n> -\t\t\t   N_(\"string\"),\n> -\t\t\t   N_(\"rebase, merge, checkout or none\")),\n> -\t\tOPT_SET_INT(0, \"checkout\", &update_type,\n> +\t\tOPT_SET_INT(0, \"checkout\", &opt.update_default,\n>  \t\t\tN_(\"use the 'checkout' update strategy (default)\"),\n>  \t\t\tSM_UPDATE_CHECKOUT),\n> -\t\tOPT_SET_INT('m', \"merge\", &update_type,\n> +\t\tOPT_SET_INT('m', \"merge\", &opt.update_default,\n>  \t\t\tN_(\"use the 'merge' update strategy\"),\n>  \t\t\tSM_UPDATE_MERGE),\n> -\t\tOPT_SET_INT('r', \"rebase\", &update_type,\n> +\t\tOPT_SET_INT('r', \"rebase\", &opt.update_default,\n>  \t\t\tN_(\"use the 'rebase' update strategy\"),\n>  \t\t\tSM_UPDATE_REBASE),\n>  \t\tOPT_STRING_LIST(0, \"reference\", &opt.references, N_(\"repo\"),\n> @@ -2662,17 +2665,8 @@ static int module_update(int argc, const char **argv, const char *prefix)\n>  \n>  \topt.filter_options = &filter_options;\n>  \n> -\tif (update_type == SM_UPDATE_CHECKOUT)\n> -\t\topt.update_default = \"checkout\";\n> -\telse if (update_type == SM_UPDATE_MERGE)\n> -\t\topt.update_default = \"merge\";\n> -\telse if (update_type == SM_UPDATE_REBASE)\n> -\t\topt.update_default = \"rebase\";\n> -\n>  \tif (opt.update_default)\n> -\t\tif (parse_submodule_update_strategy(opt.update_default,\n> -\t\t\t\t\t\t    &opt.update_strategy) < 0)\n> -\t\t\tdie(_(\"bad value for update parameter\"));\n> +\t\topt.update_strategy.type = opt.update_default;\n\nHere we're undoing the changes in the previous patch. I guess there's a\nreadability benefit to having them separate, but I think both patches\nare simple enough that we can combine into one (with you as the author\n:).)\n"},{"id":"457291","messageId":"kl6l5yl16eyh.fsf@chooglen-macbookpro.roam.corp.google.com","threadId":"57979","inReplyTo":"patch-v2-12.12-31517345ae8-20220613T220150Z-avarab@gmail.com","subject":"Re: [PATCH v2 12/12] git-sh-setup.sh: remove \"say\" function, change last users","fromName":"Glen Choo","fromEmail":"chooglen@google.com","sentAt":"2022-06-15T16:58:46Z","receivedAt":"2022-06-15T16:59:13Z","isPatch":true,"sender":{"key":"glencbz@gmail.com","avatar":"https://avatars.githubusercontent.com/u/58092771?v=4"},"body":"Ævar Arnfjörð Bjarmason <avarab@gmail.com> writes:\n\n> Remove the \"say\" function, with various rewrites of the remaining\n> git-*.sh code to C and the preceding change to have git-submodule.sh\n> stop using the GIT_QUIET variable there were only four uses in\n> git-subtree.sh. Let's have it use an \"arg_quiet\" variable instead, and\n> move the \"say\" function over to it.\n>\n> The only other use was a trivial message in git-instaweb.sh, since it\n> has never supported the --quiet option (or similar) that code added in\n> 0b624b4ceee (instaweb: restart server if already running, 2009-11-22)\n> can simply use \"echo\" instead.\n>\n> The remaining in-tree hits from \"say\" are all for the sibling function\n> defined in t/test-lib.sh. It's safe to remove this function since it\n> has never been documented in Documentation/git-sh-setup.txt.\n>\n> Signed-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>\n> ---\n>  contrib/subtree/git-subtree.sh | 15 ++++++++++++---\n>  git-instaweb.sh                |  2 +-\n>  git-sh-setup.sh                |  9 ---------\n>  3 files changed, 13 insertions(+), 13 deletions(-)\n>\n> diff --git a/contrib/subtree/git-subtree.sh b/contrib/subtree/git-subtree.sh\n> index 1af1d9653e9..7562a395c24 100755\n> --- a/contrib/subtree/git-subtree.sh\n> +++ b/contrib/subtree/git-subtree.sh\n> @@ -50,6 +50,14 @@ m,message=    use the given message as the commit message for the merge commit\n>  \n>  indent=0\n>  \n> +# Usage: say [MSG...]\n> +say () {\n> +\tif test -z \"$arg_quiet\"\n> +\tthen\n> +\t\tprintf '%s\\n' \"$*\"\n> +\tfi\n> +}\n> +\n>  # Usage: debug [MSG...]\n>  debug () {\n>  \tif test -n \"$arg_debug\"\n> @@ -60,7 +68,7 @@ debug () {\n>  \n>  # Usage: progress [MSG...]\n>  progress () {\n> -\tif test -z \"$GIT_QUIET\"\n> +\tif test -z \"$arg_quiet\"\n>  \tthen\n>  \t\tif test -z \"$arg_debug\"\n>  \t\tthen\n> @@ -146,6 +154,7 @@ main () {\n>  \teval \"$set_args\"\n>  \n>  \t# Begin \"real\" flag parsing.\n> +\targ_quiet=\n>  \targ_debug=\n>  \targ_prefix=\n>  \targ_split_branch=\n> @@ -161,7 +170,7 @@ main () {\n>  \n>  \t\tcase \"$opt\" in\n>  \t\t-q)\n> -\t\t\tGIT_QUIET=1\n> +\t\t\targ_quiet=1\n>  \t\t\t;;\n>  \t\t-d)\n>  \t\t\targ_debug=1\n> @@ -252,7 +261,7 @@ main () {\n>  \tdir=\"$(dirname \"$arg_prefix/.\")\"\n>  \n>  \tdebug \"command: {$arg_command}\"\n> -\tdebug \"quiet: {$GIT_QUIET}\"\n> +\tdebug \"quiet: {$arg_quiet}\"\n>  \tdebug \"dir: {$dir}\"\n>  \tdebug \"opts: {$*}\"\n>  \tdebug\n\nOk, makes sense. I don't know git-subtree.sh well, but this looks\nconsistent with the rest of the file.\n\n> diff --git a/git-instaweb.sh b/git-instaweb.sh\n> index 4349566c891..c68f49454cd 100755\n> --- a/git-instaweb.sh\n> +++ b/git-instaweb.sh\n> @@ -102,7 +102,7 @@ resolve_full_httpd () {\n>  \n>  start_httpd () {\n>  \tif test -f \"$fqgitdir/pid\"; then\n> -\t\tsay \"Instance already running. Restarting...\"\n> +\t\techo \"Instance already running. Restarting...\"\n>  \t\tstop_httpd\n>  \tfi\n>  \n> diff --git a/git-sh-setup.sh b/git-sh-setup.sh\n> index ecb60d9e3cb..ce273fe0e48 100644\n> --- a/git-sh-setup.sh\n> +++ b/git-sh-setup.sh\n> @@ -57,15 +57,6 @@ die_with_status () {\n>  \texit \"$status\"\n>  }\n>  \n> -GIT_QUIET=\n> -\n> -say () {\n> -\tif test -z \"$GIT_QUIET\"\n> -\tthen\n> -\t\tprintf '%s\\n' \"$*\"\n> -\tfi\n> -}\n> -\n>  if test -n \"$OPTIONS_SPEC\"; then\n>  \tusage() {\n>  \t\t\"$0\" -h\n\nMakes sense.\n"},{"id":"457304","messageId":"kl6l35g56a4w.fsf@chooglen-macbookpro.roam.corp.google.com","threadId":"57979","inReplyTo":"cover-v2-00.12-00000000000-20220613T220150Z-avarab@gmail.com","subject":"Re: [PATCH v2 00/12] submodule: make \"git submodule--helper\" behave like \"git submodule\"","fromName":"Glen Choo","fromEmail":"chooglen@google.com","sentAt":"2022-06-15T18:42:55Z","receivedAt":"2022-06-15T18:43:01Z","isPatch":true,"sender":{"key":"glencbz@gmail.com","avatar":"https://avatars.githubusercontent.com/u/58092771?v=4"},"body":"\nSuper happy to see this moving forward, thanks!\nI'll summarize the discussion to make it easier for others to follow.\n\nÆvar Arnfjörð Bjarmason <avarab@gmail.com> writes:\n\n> This series:\n>\n>  * Removes dead code from git-submodule.sh, or dead code where it was\n>    the last user.\n\nThis is 1-2/12. Not strictly 'necessary', but removing the dead code\nmakes it easier to tell what git-submodule.sh is doing and will make the\nfinal review simpler.\n\nThese all look good to me.\n\n>  * Simplifies CLI parsing in git-submodule.sh, where it was doing\n>    something overly complex for no reason.\n>\n>  * Brings \"git submodule--helper\" in line with the CLI interface of\n>    \"git-submodule.sh\", for a follow-up series to remove the latter, as\n>    we'll be able to make a new \"git submodule\" in C dispatch directly\n>    to our new \"git submodule--helper\" code.\n>\n>  * Removes the \"-v\" option to \"git submodule\", which has been\n>    supported, but was a) never documented b) never did anything\n>    anyway, except as a way to negate an earlier \"--quiet\" option, as\n>    \"verbose\" was always the default.\n\n3-10/12 is the real crux of this series, which removes all of the extra\nparsing from \"git submodule\" by making \"git submodule--helper\" accept\nthe same args. This is great, because it means that \"submodule--helper\"\ncan just pretend to be \"submodule\".\n\nOne thing that this series _doesn't_ do (but the RFCs do) is to actually\ntake advantage of this fact and remove the options parsing from\ngit-submodule.sh, e.g.\n\n     cmd_foo() {\n        git ${wt_prefix:+-C \"$wt_prefix\"} submodule--helper foo \\\n        \t${GIT_QUIET:+--quiet} \"$@\"\n     }\n\nor in the case dispatch in [1]. Like we discussed earlier, I think this\nis for the better - getting rid of the options parsing is (probably)\ngoing to be most error-prone step, so it makes some sense to do that on\nits own.\n\nWe agreed that 8/12 should be moved to that later series, but everything\nelse looks good.\n\n>  * The last couple of patches are cleanup that isn't strictly\n>    neccesary for the end-goal of \"git submodule\" in C, but cleans up\n>    some more shellscript code.\n>\n>    The \"say\" function is removed from \"git-sh-setup.sh\", now that\n>    \"git-submodule.sh\" doesn't use it anymore (which happened before\n>    this series) we can replace the couple of remaining uses with\n>    \"echo\", and by having \"git-subtree.sh\" own the code that used to\n>    live in \"git-sh-setup.sh\".\n\nThis is 11-12/12, which removes \"say\" and related cruft.\n\nThe changes look ok. I'm not experienced with this area of the codebase,\nbut I've verified the findings in the commit messages.\n\n[1] https://lore.kernel.org/git/RFC-patch-09.20-bd0e4a4f8b8-20220610T011725Z-avarab@gmail.com\n"},{"id":"457697","messageId":"patch-v3-12.12-ecdd8c6ed28-20220622T142012Z-avarab@gmail.com","threadId":"57979","inReplyTo":"cover-v3-00.12-00000000000-20220622T142012Z-avarab@gmail.com","subject":"[PATCH v3 12/12] git-sh-setup.sh: remove \"say\" function, change last users","fromName":"Ævar Arnfjörð Bjarmason","fromEmail":"avarab@gmail.com","sentAt":"2022-06-22T14:28:07Z","receivedAt":"2022-06-22T14:28:52Z","isPatch":true,"sender":{"key":"avarab@gmail.com","avatar":"https://avatars.githubusercontent.com/u/45301?v=4"},"body":"Remove the \"say\" function, with various rewrites of the remaining\ngit-*.sh code to C and the preceding change to have git-submodule.sh\nstop using the GIT_QUIET variable there were only four uses in\ngit-subtree.sh. Let's have it use an \"arg_quiet\" variable instead, and\nmove the \"say\" function over to it.\n\nThe only other use was a trivial message in git-instaweb.sh, since it\nhas never supported the --quiet option (or similar) that code added in\n0b624b4ceee (instaweb: restart server if already running, 2009-11-22)\ncan simply use \"echo\" instead.\n\nThe remaining in-tree hits from \"say\" are all for the sibling function\ndefined in t/test-lib.sh. It's safe to remove this function since it\nhas never been documented in Documentation/git-sh-setup.txt.\n\nSigned-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>\n---\n contrib/subtree/git-subtree.sh | 15 ++++++++++++---\n git-instaweb.sh                |  2 +-\n git-sh-setup.sh                |  9 ---------\n 3 files changed, 13 insertions(+), 13 deletions(-)\n\ndiff --git a/contrib/subtree/git-subtree.sh b/contrib/subtree/git-subtree.sh\nindex 1af1d9653e9..7562a395c24 100755\n--- a/contrib/subtree/git-subtree.sh\n+++ b/contrib/subtree/git-subtree.sh\n@@ -50,6 +50,14 @@ m,message=    use the given message as the commit message for the merge commit\n \n indent=0\n \n+# Usage: say [MSG...]\n+say () {\n+\tif test -z \"$arg_quiet\"\n+\tthen\n+\t\tprintf '%s\\n' \"$*\"\n+\tfi\n+}\n+\n # Usage: debug [MSG...]\n debug () {\n \tif test -n \"$arg_debug\"\n@@ -60,7 +68,7 @@ debug () {\n \n # Usage: progress [MSG...]\n progress () {\n-\tif test -z \"$GIT_QUIET\"\n+\tif test -z \"$arg_quiet\"\n \tthen\n \t\tif test -z \"$arg_debug\"\n \t\tthen\n@@ -146,6 +154,7 @@ main () {\n \teval \"$set_args\"\n \n \t# Begin \"real\" flag parsing.\n+\targ_quiet=\n \targ_debug=\n \targ_prefix=\n \targ_split_branch=\n@@ -161,7 +170,7 @@ main () {\n \n \t\tcase \"$opt\" in\n \t\t-q)\n-\t\t\tGIT_QUIET=1\n+\t\t\targ_quiet=1\n \t\t\t;;\n \t\t-d)\n \t\t\targ_debug=1\n@@ -252,7 +261,7 @@ main () {\n \tdir=\"$(dirname \"$arg_prefix/.\")\"\n \n \tdebug \"command: {$arg_command}\"\n-\tdebug \"quiet: {$GIT_QUIET}\"\n+\tdebug \"quiet: {$arg_quiet}\"\n \tdebug \"dir: {$dir}\"\n \tdebug \"opts: {$*}\"\n \tdebug\ndiff --git a/git-instaweb.sh b/git-instaweb.sh\nindex 4349566c891..c68f49454cd 100755\n--- a/git-instaweb.sh\n+++ b/git-instaweb.sh\n@@ -102,7 +102,7 @@ resolve_full_httpd () {\n \n start_httpd () {\n \tif test -f \"$fqgitdir/pid\"; then\n-\t\tsay \"Instance already running. Restarting...\"\n+\t\techo \"Instance already running. Restarting...\"\n \t\tstop_httpd\n \tfi\n \ndiff --git a/git-sh-setup.sh b/git-sh-setup.sh\nindex ecb60d9e3cb..ce273fe0e48 100644\n--- a/git-sh-setup.sh\n+++ b/git-sh-setup.sh\n@@ -57,15 +57,6 @@ die_with_status () {\n \texit \"$status\"\n }\n \n-GIT_QUIET=\n-\n-say () {\n-\tif test -z \"$GIT_QUIET\"\n-\tthen\n-\t\tprintf '%s\\n' \"$*\"\n-\tfi\n-}\n-\n if test -n \"$OPTIONS_SPEC\"; then\n \tusage() {\n \t\t\"$0\" -h\n-- \n2.36.1.1239.gfba91521d90\n\n"},{"id":"457698","messageId":"patch-v3-01.12-ed487469d62-20220622T142012Z-avarab@gmail.com","threadId":"57979","inReplyTo":"cover-v3-00.12-00000000000-20220622T142012Z-avarab@gmail.com","subject":"[PATCH v3 01/12] git-submodule.sh: remove unused sanitize_submodule_env()","fromName":"Ævar Arnfjörð Bjarmason","fromEmail":"avarab@gmail.com","sentAt":"2022-06-22T14:27:56Z","receivedAt":"2022-06-22T14:29:23Z","isPatch":true,"sender":{"key":"avarab@gmail.com","avatar":"https://avatars.githubusercontent.com/u/45301?v=4"},"body":"The sanitize_submodule_env() function was last used before\nb3c5f5cb048 (submodule: move core cmd_update() logic to C,\n2022-03-15), let's remove it.\n\nThis also allows us to remove clear_local_git_env() from\ngit-sh-setup.sh. That function hasn't been documented in\nDocumentation/git-sh-setup.sh, and since 14111fc4927 (git: submodule\nhonor -c credential.* from command line, 2016-02-29) it had only been\nused in the sanitize_submodule_env() function being removed here.\n\nSigned-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>\n---\n git-sh-setup.sh  |  7 -------\n git-submodule.sh | 11 -----------\n 2 files changed, 18 deletions(-)\n\ndiff --git a/git-sh-setup.sh b/git-sh-setup.sh\nindex d92df37e992..ecb60d9e3cb 100644\n--- a/git-sh-setup.sh\n+++ b/git-sh-setup.sh\n@@ -285,13 +285,6 @@ get_author_ident_from_commit () {\n \tparse_ident_from_commit author AUTHOR\n }\n \n-# Clear repo-local GIT_* environment variables. Useful when switching to\n-# another repository (e.g. when entering a submodule). See also the env\n-# list in git_connect()\n-clear_local_git_env() {\n-\tunset $(git rev-parse --local-env-vars)\n-}\n-\n # Generate a virtual base file for a two-file merge. Uses git apply to\n # remove lines from $1 that are not in $2, leaving only common lines.\n create_virtual_base() {\ndiff --git a/git-submodule.sh b/git-submodule.sh\nindex fd0b4a2c947..bc436c4ca47 100755\n--- a/git-submodule.sh\n+++ b/git-submodule.sh\n@@ -56,17 +56,6 @@ isnumber()\n \tn=$(($1 + 0)) 2>/dev/null && test \"$n\" = \"$1\"\n }\n \n-# Sanitize the local git environment for use within a submodule. We\n-# can't simply use clear_local_git_env since we want to preserve some\n-# of the settings from GIT_CONFIG_PARAMETERS.\n-sanitize_submodule_env()\n-{\n-\tsave_config=$GIT_CONFIG_PARAMETERS\n-\tclear_local_git_env\n-\tGIT_CONFIG_PARAMETERS=$save_config\n-\texport GIT_CONFIG_PARAMETERS\n-}\n-\n #\n # Add a new submodule to the working tree, .gitmodules and the index\n #\n-- \n2.36.1.1239.gfba91521d90\n\n"},{"id":"457699","messageId":"cover-v3-00.12-00000000000-20220622T142012Z-avarab@gmail.com","threadId":"57979","inReplyTo":"cover-v2-00.12-00000000000-20220613T220150Z-avarab@gmail.com","subject":"[PATCH v3 00/12] submodule: make \"git submodule--helper\" behave like \"git submodule\"","fromName":"Ævar Arnfjörð Bjarmason","fromEmail":"avarab@gmail.com","sentAt":"2022-06-22T14:27:55Z","receivedAt":"2022-06-22T14:29:27Z","isPatch":true,"sender":{"key":"avarab@gmail.com","avatar":"https://avatars.githubusercontent.com/u/45301?v=4"},"body":"These are preparatory changes to make \"git submodule--helper\"'s\nbehavior align with that of \"git submodule\". The next step after this\nis to get rid of git-submodule.sh entirely, and make \"git submodule\" a\nbuilt-in.\n\nThe last two patches here are post-cleanup of related submodule code\nthat isn't strictly necessary, but good to do. Similarly this starts\nwith the removal of some dead code in the area.\n\nThe goal is to make these changes as small as possible, and as\nobviously correct as possible. This will help to make the meaty\nchanges that follow easier to review.\n\nSee\nhttps://lore.kernel.org/git/RFC-cover-00.20-00000000000-20220610T011725Z-avarab@gmail.com/\nfor the larger RFC series which does the \"git-submodule.sh to\nbuilt-in\" migration. It will need to be rebased on this series, which\nhas evolved since the initial RFC.\n\nChanges since v2:\n\n * Clarify that removing the --super-prefix code is safe in the commit message.\n * Typo/grammar etc. fixes.\n * I changed the authorship of the \"-v\" removal from Glen to myself,\n   as requested by Glen.\n * I said I'd drop 08/2, but I've kept a much amended version of it. I\n   think the \"-h\" output fixes make sense, but now we only change the\n   user-exposed commands, not those internal to \"git\n   submodule--helper\".\n * Glen suggested I squash 09-10/12, but instead I've created a helper\n   function in 09/12 that we can keep using, and thus avoid much of\n   the churn. I think splitting up the change we need for\n   \"git-submodule.sh\" from the internal interface concerns still make\n   sense.\n\nIf there's any outstanding feedback that's unadressed that wasn't the\nintent, so please point out if I've missed anything. Thanks!\n\nGlen Choo (1):\n  submodule--helper: eliminate internal \"--update\" option\n\nÆvar Arnfjörð Bjarmason (11):\n  git-submodule.sh: remove unused sanitize_submodule_env()\n  git-submodule.sh: remove unused $prefix var and --super-prefix\n  git-submodule.sh: make the \"$cached\" variable a boolean\n  git-submodule.sh: remove unused top-level \"--branch\" argument\n  submodule--helper: have --require-init imply --init\n  submodule update: remove \"-v\" option\n  submodule--helper: rename \"absorb-git-dirs\" to \"absorbgitdirs\"\n  submodule--helper: report \"submodule\" as our name in some \"-h\" output\n  submodule--helper: understand --checkout, --merge and --rebase\n    synonyms\n  git-submodule.sh: use \"$quiet\", not \"$GIT_QUIET\"\n  git-sh-setup.sh: remove \"say\" function, change last users\n\n builtin/submodule--helper.c    | 125 +++++++++++++++++++--------------\n contrib/subtree/git-subtree.sh |  15 +++-\n git-instaweb.sh                |   2 +-\n git-sh-setup.sh                |  16 -----\n git-submodule.sh               |  88 ++++++++---------------\n submodule.c                    |   2 +-\n t/t7406-submodule-update.sh    |   2 +-\n 7 files changed, 117 insertions(+), 133 deletions(-)\n\nRange-diff against v2:\n 1:  c5afc72e075 =  1:  ed487469d62 git-submodule.sh: remove unused sanitize_submodule_env()\n 2:  e127803d59d !  2:  082e015781e git-submodule.sh: remove unused $prefix var and --super-prefix\n    @@ Commit message\n         \"--super-prefix\" is not passing the option to\n         \"cmd_submodule__helper()\", rather it's an argument to \"git\" itself.\n     \n    +    One way to verify that this is indeed dead code is to try to check out\n    +    b3c5f5cb048^ and apply this change to a part of the code being removed\n    +    here:\n    +\n    +            -#define SUPPORT_SUPER_PREFIX (1<<0)\n    +            +#define SUPPORT_SUPER_PREFIX 0\n    +\n    +    Doing that will cause t7406-submodule-update.sh to fail with errors\n    +    such as:\n    +\n    +            -Submodule path '../super': checked out 'e1c658656b91df52a4634fbffeaa739807ce3521'\n    +            +Submodule path 'super': checked out 'e1c658656b91df52a4634fbffeaa739807ce3521'\n    +\n    +    I.e. the removal of the --super-prefix handling broke those cases, but\n    +    when doing the same ad-hoc test with b3c5f5cb048 all of our tests will\n    +    pass, since the \"--super-prefix\" will now be handled by earlier by\n    +    \"git\" itself.\n    +\n    +    So this is just one of the things that were overly complex in \"git\n    +    submodule--helper\", because parts of it had to bridge the gap between\n    +    *.sh and *.c land, but once we moved more parts to C we ended up\n    +    getting that for free.\n    +\n         Signed-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>\n     \n      ## builtin/submodule--helper.c ##\n 3:  d5c8613c654 !  3:  3948aa5d782 git-submodule.sh: make \"$cached\" variable a boolean\n    @@ Metadata\n     Author: Ævar Arnfjörð Bjarmason <avarab@gmail.com>\n     \n      ## Commit message ##\n    -    git-submodule.sh: make \"$cached\" variable a boolean\n    +    git-submodule.sh: make the \"$cached\" variable a boolean\n     \n         Remove the assignment of \"$1\" to the \"$cached\" variable. As seen in\n         the initial implementation in 70c7ac22de6 (Add git-submodule command,\n 4:  fd328329b68 !  4:  b5967afd59f git-submodule.sh: remove unused top-level \"--branch\" argument\n    @@ Commit message\n         we have \"--branch\" here already we'll emit usage, even for \"add\" and\n         \"set-branch\".\n     \n    -    So in addition to never having documented this form it hasn't worked\n    -    since b57e8119e6e was released with v2.22.0 it's safe to remove this\n    -    code. I.e. we don't want to support the form noted above, but only:\n    +    So in addition to never having documented this form, it hasn't worked\n    +    since b57e8119e6e was released with v2.22.0.\n    +\n    +    So it's safe to remove this code. I.e. we don't want to support the\n    +    form noted above, but only:\n     \n             git submodule (add | set-branch) --branch <branch> [<options>]\n     \n 5:  ef3265a588e !  5:  64e4aa41d21 submodule--helper: have --require-init imply --init\n    @@ Commit message\n     \n         We'll still need to keep the distinction between \"--init\" and\n         \"--require-init\" in git-submodule.sh. Once cmd_update() gets\n    -    re-implemented in C we'll be able to variables and other code related\n    -    to that, but not yet.\n    +    re-implemented in C we'll be able to change variables and other code\n    +    related to that, but not yet.\n     \n         Signed-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>\n     \n 6:  025694644fc !  6:  b82faad77bb submodule update: remove \"-v\" option\n    @@\n      ## Metadata ##\n    -Author: Glen Choo <chooglen@google.com>\n    +Author: Ævar Arnfjörð Bjarmason <avarab@gmail.com>\n     \n      ## Commit message ##\n         submodule update: remove \"-v\" option\n    @@ Commit message\n         \"--quiet\", 2020-09-30), it wasn't per-se testing --quiet, but fixing a\n         bug in e84c3cf3dc3: It used to set \"GIT_QUIET=0\" instead of unsetting\n         it on \"-v\", and thus we'd end up passing \"--quiet\" to \"git\n    -    submodule--helper\" on \"-v\", since the \"--quiet\" option was passed sing\n    -    the ${parameter:+word} construct.\n    +    submodule--helper\" on \"-v\", since the \"--quiet\" option was passed\n    +    using the ${parameter:+word} construct.\n     \n         Furthermore, even if someone had used the \"-v\" option they'd only be\n         getting the default output. Our default in both git-submodule.sh and\n    @@ Commit message\n     \n         I.e. to undo the effect of a previous \"--quiet\" on the command-line.\n     \n    -    Signed-off-by: Glen Choo <chooglen@google.com>\n         Signed-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>\n     \n      ## git-submodule.sh ##\n 7:  63155ab5026 =  7:  ff557f3c81a submodule--helper: rename \"absorb-git-dirs\" to \"absorbgitdirs\"\n 8:  99ac52d810f !  8:  bb1310b9abe submodule--helper: report \"submodule\" as our name in \"-h\" output\n    @@ Metadata\n     Author: Ævar Arnfjörð Bjarmason <avarab@gmail.com>\n     \n      ## Commit message ##\n    -    submodule--helper: report \"submodule\" as our name in \"-h\" output\n    +    submodule--helper: report \"submodule\" as our name in some \"-h\" output\n     \n    -    Change the rest of the usage output for \"git submodule--helper\" so\n    -    that it will pretend to be named \"git submodule\", which it already did\n    -    e.g. in the case of \"status\", \"deinit\" and \"update\".\n    +    Change the user-facing \"git submodule--helper\" commands so that\n    +    they'll report their name as being \"git submodule\". To a user these\n    +    commands are internal implementation details, and it doesn't make\n    +    sense to emit usage about an internal helper when \"git submodule\" is\n    +    invoked with invalid options.\n     \n    -    This will allow us to eventually dispatch further into \"git\n    -    submodule--helper\" from git-submodule.sh, while emitting the correct\n    -    usage output.\n    -\n    -    This does make the usage output of \"git submodule--helper\" itself\n    -    \"incorrect\", but since nothing user-facing invokes it directly it\n    -    makes sense to continue to elide that difference entirely. A user\n    -    isn't served by us exposing this internal implementation detail.\n    -\n    -    This fixes a bug that's been there ever since \"git submodule\n    -    absorbgitdirs\" was added in f6f85861400 (submodule: add absorb-git-dir\n    -    function, 2016-12-12). Before this we'd emit e.g. this on invalid\n    -    usage:\n    +    Before this we'd emit e.g.:\n     \n                 $ git submodule absorbgitdirs --blah\n                 error: unknown option `blah'\n                 usage: git submodule--helper absorbgitdirs [<options>] [<path>...]\n    +            [...]\n    +    And:\n    +\n    +            $ git submodule set-url -- --\n    +            usage: git submodule--helper set-url [--quiet] <path> <newurl>\n    +            [...]\n     \n    -    Now we'll emit the same, except that the usage line is now referring\n    -    to the correct command run by the user:\n    +    Now we'll start with \"usage: git submodule [...]\" in both of those\n    +    cases. This change does not alter the \"list\", \"name\", \"clone\",\n    +    \"config\" and \"create-branch\" commands, those are internal-only (as an\n    +    aside; their usage info should probably invoke BUG(...)). This only\n    +    changes the user-facing commands.\n     \n    -            usage: git submodule absorbgitdirs [<options>] [<path>...]\n    -            [.. same usage output ...]\n    +    The \"status\", \"deinit\" and \"update\" commands are not included in this\n    +    change, because their usage information already used \"submodule\"\n    +    rather than \"submodule--helper\".\n    +\n    +    I don't think it's currently possible to emit some of this usage\n    +    information in practice, as git-submodule.sh will catch unknown\n    +    options, and e.g. it doesn't seem to be possible to get \"add\" to emit\n    +    its usage information from \"submodule--helper\".\n    +\n    +    Though that change may be superfluous now, it's also harmless, and\n    +    will allow us to eventually dispatch further into \"git\n    +    submodule--helper\" from git-submodule.sh, while emitting the correct\n    +    usage output.\n     \n         Signed-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>\n     \n      ## builtin/submodule--helper.c ##\n    -@@ builtin/submodule--helper.c: static int module_list(int argc, const char **argv, const char *prefix)\n    - \t};\n    - \n    - \tconst char *const git_submodule_helper_usage[] = {\n    --\t\tN_(\"git submodule--helper list [--prefix=<path>] [<path>...]\"),\n    -+\t\tN_(\"git submodule list [--prefix=<path>] [<path>...]\"),\n    - \t\tNULL\n    - \t};\n    - \n     @@ builtin/submodule--helper.c: static int module_foreach(int argc, const char **argv, const char *prefix)\n      \t};\n      \n    @@ builtin/submodule--helper.c: static int module_init(int argc, const char **argv,\n      \t\tNULL\n      \t};\n      \n    -@@ builtin/submodule--helper.c: static int module_name(int argc, const char **argv, const char *prefix)\n    - \tconst struct submodule *sub;\n    - \n    - \tif (argc != 2)\n    --\t\tusage(_(\"git submodule--helper name <path>\"));\n    -+\t\tusage(_(\"git submodule name <path>\"));\n    - \n    - \tsub = submodule_from_path(the_repository, null_oid(), argv[1]);\n    - \n     @@ builtin/submodule--helper.c: static int module_summary(int argc, const char **argv, const char *prefix)\n      \t};\n      \n    @@ builtin/submodule--helper.c: static int module_sync(int argc, const char **argv,\n      \t\tNULL\n      \t};\n      \n    -@@ builtin/submodule--helper.c: static int module_clone(int argc, const char **argv, const char *prefix)\n    - \t};\n    - \n    - \tconst char *const git_submodule_helper_usage[] = {\n    --\t\tN_(\"git submodule--helper clone [--prefix=<path>] [--quiet] \"\n    -+\t\tN_(\"git submodule clone [--prefix=<path>] [--quiet] \"\n    - \t\t   \"[--reference <repository>] [--name <name>] [--depth <depth>] \"\n    - \t\t   \"[--single-branch] [--filter <filter-spec>] \"\n    - \t\t   \"--url <url> --path <path>\"),\n     @@ builtin/submodule--helper.c: static int absorb_git_dirs(int argc, const char **argv, const char *prefix)\n      \t};\n      \n    @@ builtin/submodule--helper.c: static int absorb_git_dirs(int argc, const char **a\n      \t\tNULL\n      \t};\n      \n    -@@ builtin/submodule--helper.c: static int module_config(int argc, const char **argv, const char *prefix)\n    - \t\tOPT_END()\n    - \t};\n    - \tconst char *const git_submodule_helper_usage[] = {\n    --\t\tN_(\"git submodule--helper config <name> [<value>]\"),\n    --\t\tN_(\"git submodule--helper config --unset <name>\"),\n    --\t\t\"git submodule--helper config --check-writeable\",\n    -+\t\tN_(\"git submodule config <name> [<value>]\"),\n    -+\t\tN_(\"git submodule config --unset <name>\"),\n    -+\t\t\"git submodule config --check-writeable\",\n    - \t\tNULL\n    - \t};\n    - \n     @@ builtin/submodule--helper.c: static int module_set_url(int argc, const char **argv, const char *prefix)\n      \t\tOPT_END()\n      \t};\n    @@ builtin/submodule--helper.c: static int module_set_branch(int argc, const char *\n      \t\tNULL\n      \t};\n      \n    -@@ builtin/submodule--helper.c: static int module_create_branch(int argc, const char **argv, const char *prefix)\n    - \t\tOPT_END()\n    - \t};\n    - \tconst char *const usage[] = {\n    --\t\tN_(\"git submodule--helper create-branch [-f|--force] [--create-reflog] [-q|--quiet] [-t|--track] [-n|--dry-run] <name> <start-oid> <start-name>\"),\n    -+\t\tN_(\"git submodule create-branch [-f|--force] [--create-reflog] [-q|--quiet] [-t|--track] [-n|--dry-run] <name> <start-oid> <start-name>\"),\n    - \t\tNULL\n    - \t};\n    - \n     @@ builtin/submodule--helper.c: static int module_add(int argc, const char **argv, const char *prefix)\n      \t};\n      \n 9:  80536424daa !  9:  e251fc115e1 submodule--helper: understand --checkout, --merge and --rebase synonyms\n    @@ Commit message\n         Signed-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>\n     \n      ## builtin/submodule--helper.c ##\n    +@@ builtin/submodule--helper.c: static void ensure_core_worktree(const char *path)\n    + \t}\n    + }\n    + \n    ++static const char *submodule_update_type_to_label(enum submodule_update_type type)\n    ++{\n    ++\tswitch (type) {\n    ++\tcase SM_UPDATE_CHECKOUT:\n    ++\t\treturn \"checkout\";\n    ++\tcase SM_UPDATE_MERGE:\n    ++\t\treturn \"merge\";\n    ++\tcase SM_UPDATE_REBASE:\n    ++\t\treturn \"rebase\";\n    ++\tcase SM_UPDATE_UNSPECIFIED:\n    ++\tcase SM_UPDATE_NONE:\n    ++\tcase SM_UPDATE_COMMAND:\n    ++\t\tbreak;\n    ++\t}\n    ++\tBUG(\"unreachable with type %d\", type);\n    ++}\n    ++\n    + static void update_data_to_args(struct update_data *update_data, struct strvec *args)\n    + {\n    + \tstrvec_pushl(args, \"submodule--helper\", \"update\", \"--recursive\", NULL);\n     @@ builtin/submodule--helper.c: static int module_update(int argc, const char **argv, const char *prefix)\n      \tstruct update_data opt = UPDATE_DATA_INIT;\n      \tstruct list_objects_filter_options filter_options;\n    @@ builtin/submodule--helper.c: static int module_update(int argc, const char **arg\n      \n      \topt.filter_options = &filter_options;\n      \n    -+\tif (update_type == SM_UPDATE_CHECKOUT)\n    -+\t\topt.update_default = \"checkout\";\n    -+\telse if (update_type == SM_UPDATE_MERGE)\n    -+\t\topt.update_default = \"merge\";\n    -+\telse if (update_type == SM_UPDATE_REBASE)\n    -+\t\topt.update_default = \"rebase\";\n    ++\tif (update_type != SM_UPDATE_UNSPECIFIED)\n    ++\t\topt.update_default = submodule_update_type_to_label(update_type);\n     +\n      \tif (opt.update_default)\n      \t\tif (parse_submodule_update_strategy(opt.update_default,\n10:  9ce9f78b2d0 ! 10:  66a229227a1 submodule--helper: eliminate internal \"--update\" option\n    @@ builtin/submodule--helper.c: struct update_data {\n      \tstruct object_id suboid;\n      \tstruct string_list references;\n      \tstruct submodule_update_strategy update_strategy;\n    -@@ builtin/submodule--helper.c: static void ensure_core_worktree(const char *path)\n    +@@ builtin/submodule--helper.c: static const char *submodule_update_type_to_label(enum submodule_update_type typ\n      \n      static void update_data_to_args(struct update_data *update_data, struct strvec *args)\n      {\n    -+\tenum submodule_update_type ud = update_data->update_default;\n    ++\tenum submodule_update_type update_type = update_data->update_default;\n     +\n      \tstrvec_pushl(args, \"submodule--helper\", \"update\", \"--recursive\", NULL);\n      \tstrvec_pushf(args, \"--jobs=%d\", update_data->max_jobs);\n    @@ builtin/submodule--helper.c: static void update_data_to_args(struct update_data\n      \t\tstrvec_pushf(args, \"--depth=%d\", update_data->depth);\n     -\tif (update_data->update_default)\n     -\t\tstrvec_pushl(args, \"--update\", update_data->update_default, NULL);\n    -+\tif (ud == SM_UPDATE_MERGE)\n    -+\t\tstrvec_push(args, \"--merge\");\n    -+\telse if (ud == SM_UPDATE_CHECKOUT)\n    -+\t\tstrvec_push(args, \"--checkout\");\n    -+\telse if (ud == SM_UPDATE_REBASE)\n    -+\t\tstrvec_push(args, \"--rebase\");\n    -+\telse if (ud != SM_UPDATE_UNSPECIFIED)\n    -+\t\tBUG(\"cannot convert update_default=%d to args\", ud);\n    ++\tif (update_type != SM_UPDATE_UNSPECIFIED)\n    ++\t\tstrvec_pushf(args, \"--%s\",\n    ++\t\t\t     submodule_update_type_to_label(update_type));\n     +\n      \tif (update_data->references.nr) {\n      \t\tstruct string_list_item *item;\n    @@ builtin/submodule--helper.c: static int module_update(int argc, const char **arg\n      \n      \topt.filter_options = &filter_options;\n      \n    --\tif (update_type == SM_UPDATE_CHECKOUT)\n    --\t\topt.update_default = \"checkout\";\n    --\telse if (update_type == SM_UPDATE_MERGE)\n    --\t\topt.update_default = \"merge\";\n    --\telse if (update_type == SM_UPDATE_REBASE)\n    --\t\topt.update_default = \"rebase\";\n    +-\tif (update_type != SM_UPDATE_UNSPECIFIED)\n    +-\t\topt.update_default = submodule_update_type_to_label(update_type);\n     -\n      \tif (opt.update_default)\n     -\t\tif (parse_submodule_update_strategy(opt.update_default,\n11:  42b107bc9df ! 11:  f8219cd461d git-submodule.sh: use \"$quiet\", not \"$GIT_QUIET\"\n    @@ Commit message\n         \"GIT_QUIET\".\n     \n         We still want to support --quiet for our own use though, but let's use\n    -    our own variable for that, but now it's obvious that we only care\n    -    about passing \"--quiet\" to \"git submodule--helper\", and not to change\n    -    the output of any \"say\" invocation.\n    +    our own variable for that. Now it's obvious that we only care about\n    +    passing \"--quiet\" to \"git submodule--helper\", and not to change the\n    +    output of any \"say\" invocation.\n     \n         Signed-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>\n     \n12:  336c6d5dd63 = 12:  ecdd8c6ed28 git-sh-setup.sh: remove \"say\" function, change last users\n-- \n2.36.1.1239.gfba91521d90\n\n"},{"id":"457700","messageId":"patch-v3-02.12-082e015781e-20220622T142012Z-avarab@gmail.com","threadId":"57979","inReplyTo":"cover-v3-00.12-00000000000-20220622T142012Z-avarab@gmail.com","subject":"[PATCH v3 02/12] git-submodule.sh: remove unused $prefix var and --super-prefix","fromName":"Ævar Arnfjörð Bjarmason","fromEmail":"avarab@gmail.com","sentAt":"2022-06-22T14:27:57Z","receivedAt":"2022-06-22T14:29:28Z","isPatch":true,"sender":{"key":"avarab@gmail.com","avatar":"https://avatars.githubusercontent.com/u/45301?v=4"},"body":"Remove the $prefix variable which isn't used anymore, and hasn't been\nsince b3c5f5cb048 (submodule: move core cmd_update() logic to C,\n2022-03-15).\n\nBefore that we'd use it to invoke \"git submodule--helper\" with the\n\"--recursive-prefix\" option, but since b3c5f5cb048 that \"git\nsubmodule--helper\" option is only used when it invokes itself.\n\nSince we haven't used it since then we haven't been passing the\n--super-prefix option to \"git submodule--helper\", and can therefore\nremove the handling of it from builtin/submodule--helper.c as well.\n\nNote also that the still-existing code in builtin/submodule--helper.c\nto invoke other \"git submodule--helper\" processes with\n\"--super-prefix\" is not passing the option to\n\"cmd_submodule__helper()\", rather it's an argument to \"git\" itself.\n\nOne way to verify that this is indeed dead code is to try to check out\nb3c5f5cb048^ and apply this change to a part of the code being removed\nhere:\n\n\t-#define SUPPORT_SUPER_PREFIX (1<<0)\n\t+#define SUPPORT_SUPER_PREFIX 0\n\nDoing that will cause t7406-submodule-update.sh to fail with errors\nsuch as:\n\n\t-Submodule path '../super': checked out 'e1c658656b91df52a4634fbffeaa739807ce3521'\n\t+Submodule path 'super': checked out 'e1c658656b91df52a4634fbffeaa739807ce3521'\n\nI.e. the removal of the --super-prefix handling broke those cases, but\nwhen doing the same ad-hoc test with b3c5f5cb048 all of our tests will\npass, since the \"--super-prefix\" will now be handled by earlier by\n\"git\" itself.\n\nSo this is just one of the things that were overly complex in \"git\nsubmodule--helper\", because parts of it had to bridge the gap between\n*.sh and *.c land, but once we moved more parts to C we ended up\ngetting that for free.\n\nSigned-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>\n---\n builtin/submodule--helper.c | 53 +++++++++++++++----------------------\n git-submodule.sh            |  6 ++---\n 2 files changed, 24 insertions(+), 35 deletions(-)\n\ndiff --git a/builtin/submodule--helper.c b/builtin/submodule--helper.c\nindex c597df7528e..03181c5ca50 100644\n--- a/builtin/submodule--helper.c\n+++ b/builtin/submodule--helper.c\n@@ -3365,35 +3365,32 @@ static int module_add(int argc, const char **argv, const char *prefix)\n \treturn 0;\n }\n \n-#define SUPPORT_SUPER_PREFIX (1<<0)\n-\n struct cmd_struct {\n \tconst char *cmd;\n \tint (*fn)(int, const char **, const char *);\n-\tunsigned option;\n };\n \n static struct cmd_struct commands[] = {\n-\t{\"list\", module_list, 0},\n-\t{\"name\", module_name, 0},\n-\t{\"clone\", module_clone, 0},\n-\t{\"add\", module_add, SUPPORT_SUPER_PREFIX},\n-\t{\"update\", module_update, 0},\n-\t{\"resolve-relative-url-test\", resolve_relative_url_test, 0},\n-\t{\"foreach\", module_foreach, SUPPORT_SUPER_PREFIX},\n-\t{\"init\", module_init, SUPPORT_SUPER_PREFIX},\n-\t{\"status\", module_status, SUPPORT_SUPER_PREFIX},\n-\t{\"sync\", module_sync, SUPPORT_SUPER_PREFIX},\n-\t{\"deinit\", module_deinit, 0},\n-\t{\"summary\", module_summary, SUPPORT_SUPER_PREFIX},\n-\t{\"push-check\", push_check, 0},\n-\t{\"absorb-git-dirs\", absorb_git_dirs, SUPPORT_SUPER_PREFIX},\n-\t{\"is-active\", is_active, 0},\n-\t{\"check-name\", check_name, 0},\n-\t{\"config\", module_config, 0},\n-\t{\"set-url\", module_set_url, 0},\n-\t{\"set-branch\", module_set_branch, 0},\n-\t{\"create-branch\", module_create_branch, 0},\n+\t{\"list\", module_list},\n+\t{\"name\", module_name},\n+\t{\"clone\", module_clone},\n+\t{\"add\", module_add},\n+\t{\"update\", module_update},\n+\t{\"resolve-relative-url-test\", resolve_relative_url_test},\n+\t{\"foreach\", module_foreach},\n+\t{\"init\", module_init},\n+\t{\"status\", module_status},\n+\t{\"sync\", module_sync},\n+\t{\"deinit\", module_deinit},\n+\t{\"summary\", module_summary},\n+\t{\"push-check\", push_check},\n+\t{\"absorb-git-dirs\", absorb_git_dirs},\n+\t{\"is-active\", is_active},\n+\t{\"check-name\", check_name},\n+\t{\"config\", module_config},\n+\t{\"set-url\", module_set_url},\n+\t{\"set-branch\", module_set_branch},\n+\t{\"create-branch\", module_create_branch},\n };\n \n int cmd_submodule__helper(int argc, const char **argv, const char *prefix)\n@@ -3402,15 +3399,9 @@ int cmd_submodule__helper(int argc, const char **argv, const char *prefix)\n \tif (argc < 2 || !strcmp(argv[1], \"-h\"))\n \t\tusage(\"git submodule--helper <command>\");\n \n-\tfor (i = 0; i < ARRAY_SIZE(commands); i++) {\n-\t\tif (!strcmp(argv[1], commands[i].cmd)) {\n-\t\t\tif (get_super_prefix() &&\n-\t\t\t    !(commands[i].option & SUPPORT_SUPER_PREFIX))\n-\t\t\t\tdie(_(\"%s doesn't support --super-prefix\"),\n-\t\t\t\t    commands[i].cmd);\n+\tfor (i = 0; i < ARRAY_SIZE(commands); i++)\n+\t\tif (!strcmp(argv[1], commands[i].cmd))\n \t\t\treturn commands[i].fn(argc - 1, argv + 1, prefix);\n-\t\t}\n-\t}\n \n \tdie(_(\"'%s' is not a valid submodule--helper \"\n \t      \"subcommand\"), argv[1]);\ndiff --git a/git-submodule.sh b/git-submodule.sh\nindex bc436c4ca47..53847bbf6e2 100755\n--- a/git-submodule.sh\n+++ b/git-submodule.sh\n@@ -41,7 +41,6 @@ files=\n remote=\n nofetch=\n update=\n-prefix=\n custom_name=\n depth=\n progress=\n@@ -127,7 +126,7 @@ cmd_add()\n \t\tusage\n \tfi\n \n-\tgit ${wt_prefix:+-C \"$wt_prefix\"} ${prefix:+--super-prefix \"$prefix\"} submodule--helper add ${GIT_QUIET:+--quiet} ${force:+--force} ${progress:+\"--progress\"} ${branch:+--branch \"$branch\"} ${reference_path:+--reference \"$reference_path\"} ${dissociate:+--dissociate} ${custom_name:+--name \"$custom_name\"} ${depth:+\"$depth\"} -- \"$@\"\n+\tgit ${wt_prefix:+-C \"$wt_prefix\"} submodule--helper add ${GIT_QUIET:+--quiet} ${force:+--force} ${progress:+\"--progress\"} ${branch:+--branch \"$branch\"} ${reference_path:+--reference \"$reference_path\"} ${dissociate:+--dissociate} ${custom_name:+--name \"$custom_name\"} ${depth:+\"$depth\"} -- \"$@\"\n }\n \n #\n@@ -189,7 +188,7 @@ cmd_init()\n \t\tshift\n \tdone\n \n-\tgit ${wt_prefix:+-C \"$wt_prefix\"} ${prefix:+--super-prefix \"$prefix\"} submodule--helper init ${GIT_QUIET:+--quiet} -- \"$@\"\n+\tgit ${wt_prefix:+-C \"$wt_prefix\"} submodule--helper init ${GIT_QUIET:+--quiet} -- \"$@\"\n }\n \n #\n@@ -346,7 +345,6 @@ cmd_update()\n \t\t${init:+--init} \\\n \t\t${nofetch:+--no-fetch} \\\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${dissociate:+\"--dissociate\"} \\\n-- \n2.36.1.1239.gfba91521d90\n\n"},{"id":"457701","messageId":"patch-v3-03.12-3948aa5d782-20220622T142012Z-avarab@gmail.com","threadId":"57979","inReplyTo":"cover-v3-00.12-00000000000-20220622T142012Z-avarab@gmail.com","subject":"[PATCH v3 03/12] git-submodule.sh: make the \"$cached\" variable a boolean","fromName":"Ævar Arnfjörð Bjarmason","fromEmail":"avarab@gmail.com","sentAt":"2022-06-22T14:27:58Z","receivedAt":"2022-06-22T14:29:35Z","isPatch":true,"sender":{"key":"avarab@gmail.com","avatar":"https://avatars.githubusercontent.com/u/45301?v=4"},"body":"Remove the assignment of \"$1\" to the \"$cached\" variable. As seen in\nthe initial implementation in 70c7ac22de6 (Add git-submodule command,\n2007-05-26) we only need to keep track of if we've seen the --cached\noption, not save the \"--cached\" string for later use.\n\nIn 28f9af5d25e (git-submodule summary: code framework, 2008-03-11)\n\"$1\" was assigned to it, but since there was no reason to do so let's\nstop doing it. This trivial change will make it easier to reason about\nan eventual change that'll remove the cmd_summary() function in favor\nof dispatching to \"git submodule--helper summary\" directly.\n\nSigned-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>\n---\n git-submodule.sh | 4 ++--\n 1 file changed, 2 insertions(+), 2 deletions(-)\n\ndiff --git a/git-submodule.sh b/git-submodule.sh\nindex 53847bbf6e2..b99a00d9f84 100755\n--- a/git-submodule.sh\n+++ b/git-submodule.sh\n@@ -446,7 +446,7 @@ cmd_summary() {\n \tdo\n \t\tcase \"$1\" in\n \t\t--cached)\n-\t\t\tcached=\"$1\"\n+\t\t\tcached=1\n \t\t\t;;\n \t\t--files)\n \t\t\tfiles=\"$1\"\n@@ -583,7 +583,7 @@ do\n \t\tbranch=\"$2\"; shift\n \t\t;;\n \t--cached)\n-\t\tcached=\"$1\"\n+\t\tcached=1\n \t\t;;\n \t--)\n \t\tbreak\n-- \n2.36.1.1239.gfba91521d90\n\n"},{"id":"457702","messageId":"patch-v3-04.12-b5967afd59f-20220622T142012Z-avarab@gmail.com","threadId":"57979","inReplyTo":"cover-v3-00.12-00000000000-20220622T142012Z-avarab@gmail.com","subject":"[PATCH v3 04/12] git-submodule.sh: remove unused top-level \"--branch\" argument","fromName":"Ævar Arnfjörð Bjarmason","fromEmail":"avarab@gmail.com","sentAt":"2022-06-22T14:27:59Z","receivedAt":"2022-06-22T14:29:37Z","isPatch":true,"sender":{"key":"avarab@gmail.com","avatar":"https://avatars.githubusercontent.com/u/45301?v=4"},"body":"In 5c08dbbdf1a (git-submodule: fix subcommand parser, 2008-01-15) the\n\"--branch\" option was supported as an option to \"git submodule\"\nitself, i.e. \"git submodule --branch\" as a side-effect of its\nimplementation.\n\nThen in b57e8119e6e (submodule: teach set-branch subcommand,\n2019-02-08) when the \"set-branch\" subcommand was added the assertion\nthat we shouldn't have \"--branch\" anywhere except as an argument to\n\"add\" and \"set-branch\" was copy/pasted from the adjacent check for\n\"--cache\" added (or rather modified) in 496eeeb19b9 (git-submodule.sh:\navoid \"test <cond> -a/-o <cond>\", 2014-06-10).\n\nBut there's been a logic error in that check, which at a glance looked\nlike it should be supporting:\n\n    git submodule --branch <branch> (add | set-branch) [<options>]\n\nBut due to \"||\" in the condition (as opposed to \"&&\" for \"--cache\") if\nwe have \"--branch\" here already we'll emit usage, even for \"add\" and\n\"set-branch\".\n\nSo in addition to never having documented this form, it hasn't worked\nsince b57e8119e6e was released with v2.22.0.\n\nSo it's safe to remove this code. I.e. we don't want to support the\nform noted above, but only:\n\n    git submodule (add | set-branch) --branch <branch> [<options>]\n\nSigned-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>\n---\n git-submodule.sh | 14 --------------\n 1 file changed, 14 deletions(-)\n\ndiff --git a/git-submodule.sh b/git-submodule.sh\nindex b99a00d9f84..20fc1b620fa 100755\n--- a/git-submodule.sh\n+++ b/git-submodule.sh\n@@ -574,14 +574,6 @@ do\n \t-q|--quiet)\n \t\tGIT_QUIET=1\n \t\t;;\n-\t-b|--branch)\n-\t\tcase \"$2\" in\n-\t\t'')\n-\t\t\tusage\n-\t\t\t;;\n-\t\tesac\n-\t\tbranch=\"$2\"; shift\n-\t\t;;\n \t--cached)\n \t\tcached=1\n \t\t;;\n@@ -609,12 +601,6 @@ then\n     fi\n fi\n \n-# \"-b branch\" is accepted only by \"add\" and \"set-branch\"\n-if test -n \"$branch\" && (test \"$command\" != add || test \"$command\" != set-branch)\n-then\n-\tusage\n-fi\n-\n # \"--cached\" is accepted only by \"status\" and \"summary\"\n if test -n \"$cached\" && test \"$command\" != status && test \"$command\" != summary\n then\n-- \n2.36.1.1239.gfba91521d90\n\n"},{"id":"457703","messageId":"patch-v3-06.12-b82faad77bb-20220622T142012Z-avarab@gmail.com","threadId":"57979","inReplyTo":"cover-v3-00.12-00000000000-20220622T142012Z-avarab@gmail.com","subject":"[PATCH v3 06/12] submodule update: remove \"-v\" option","fromName":"Ævar Arnfjörð Bjarmason","fromEmail":"avarab@gmail.com","sentAt":"2022-06-22T14:28:01Z","receivedAt":"2022-06-22T14:29:38Z","isPatch":true,"sender":{"key":"avarab@gmail.com","avatar":"https://avatars.githubusercontent.com/u/45301?v=4"},"body":"In e84c3cf3dc3 (git-submodule.sh: accept verbose flag in cmd_update to\nbe non-quiet, 2018-08-14) the \"git submodule update\" sub-command was\nmade to understand \"-v\", but the option was never documented.\n\nThe only in-tree user has been this test added in\n3ad0401e9e6 (submodule update: silence underlying merge/rebase with\n\"--quiet\", 2020-09-30), it wasn't per-se testing --quiet, but fixing a\nbug in e84c3cf3dc3: It used to set \"GIT_QUIET=0\" instead of unsetting\nit on \"-v\", and thus we'd end up passing \"--quiet\" to \"git\nsubmodule--helper\" on \"-v\", since the \"--quiet\" option was passed\nusing the ${parameter:+word} construct.\n\nFurthermore, even if someone had used the \"-v\" option they'd only be\ngetting the default output. Our default in both git-submodule.sh and\n\"git submodule--helper\" has been to be \"verbose\", so the only way this\noption could have matter is if it were used as e.g.:\n\n    git submodule --quiet update -v [...]\n\nI.e. to undo the effect of a previous \"--quiet\" on the command-line.\n\nSigned-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>\n---\n git-submodule.sh            | 3 ---\n t/t7406-submodule-update.sh | 2 +-\n 2 files changed, 1 insertion(+), 4 deletions(-)\n\ndiff --git a/git-submodule.sh b/git-submodule.sh\nindex 5b9683bf766..0df6b0fc974 100755\n--- a/git-submodule.sh\n+++ b/git-submodule.sh\n@@ -241,9 +241,6 @@ cmd_update()\n \t\t-q|--quiet)\n \t\t\tGIT_QUIET=1\n \t\t\t;;\n-\t\t-v)\n-\t\t\tunset GIT_QUIET\n-\t\t\t;;\n \t\t--progress)\n \t\t\tprogress=1\n \t\t\t;;\ndiff --git a/t/t7406-submodule-update.sh b/t/t7406-submodule-update.sh\nindex 43f779d751c..06d804e2131 100755\n--- a/t/t7406-submodule-update.sh\n+++ b/t/t7406-submodule-update.sh\n@@ -1074,7 +1074,7 @@ test_expect_success 'submodule update --quiet passes quietness to merge/rebase'\n \t git submodule update --rebase --quiet >out 2>err &&\n \t test_must_be_empty out &&\n \t test_must_be_empty err &&\n-\t git submodule update --rebase -v >out 2>err &&\n+\t git submodule update --rebase >out 2>err &&\n \t test_file_not_empty out &&\n \t test_must_be_empty err\n \t)\n-- \n2.36.1.1239.gfba91521d90\n\n"},{"id":"457704","messageId":"patch-v3-05.12-64e4aa41d21-20220622T142012Z-avarab@gmail.com","threadId":"57979","inReplyTo":"cover-v3-00.12-00000000000-20220622T142012Z-avarab@gmail.com","subject":"[PATCH v3 05/12] submodule--helper: have --require-init imply --init","fromName":"Ævar Arnfjörð Bjarmason","fromEmail":"avarab@gmail.com","sentAt":"2022-06-22T14:28:00Z","receivedAt":"2022-06-22T14:29:42Z","isPatch":true,"sender":{"key":"avarab@gmail.com","avatar":"https://avatars.githubusercontent.com/u/45301?v=4"},"body":"Adjust code added in 0060fd1511b (clone --recurse-submodules: prevent\nname squatting on Windows, 2019-09-12) to have the internal\n--require-init option imply --init, rather than having\n\"git-submodule.sh\" add it implicitly.\n\nThis change doesn't make any difference now, but eliminates another\nspecial-case where \"git submodule--helper update\"'s behavior was\ndifferent from \"git submodule update\". This will make it easier to\neventually replace the cmd_update() function in git-submodule.sh.\n\nWe'll still need to keep the distinction between \"--init\" and\n\"--require-init\" in git-submodule.sh. Once cmd_update() gets\nre-implemented in C we'll be able to change variables and other code\nrelated to that, but not yet.\n\nSigned-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>\n---\n builtin/submodule--helper.c | 5 ++++-\n git-submodule.sh            | 1 -\n 2 files changed, 4 insertions(+), 2 deletions(-)\n\ndiff --git a/builtin/submodule--helper.c b/builtin/submodule--helper.c\nindex 03181c5ca50..1876375a4a0 100644\n--- a/builtin/submodule--helper.c\n+++ b/builtin/submodule--helper.c\n@@ -2619,7 +2619,7 @@ static int module_update(int argc, const char **argv, const char *prefix)\n \t\tOPT_BOOL(0, \"progress\", &opt.progress,\n \t\t\t    N_(\"force cloning progress\")),\n \t\tOPT_BOOL(0, \"require-init\", &opt.require_init,\n-\t\t\t   N_(\"disallow cloning into non-empty directory\")),\n+\t\t\t   N_(\"disallow cloning into non-empty directory, implies --init\")),\n \t\tOPT_BOOL(0, \"single-branch\", &opt.single_branch,\n \t\t\t N_(\"clone only one branch, HEAD or --branch\")),\n \t\tOPT_PARSE_LIST_OBJECTS_FILTER(&filter_options),\n@@ -2643,6 +2643,9 @@ static int module_update(int argc, const char **argv, const char *prefix)\n \targc = parse_options(argc, argv, prefix, module_update_options,\n \t\t\t     git_submodule_helper_usage, 0);\n \n+\tif (opt.require_init)\n+\t\topt.init = 1;\n+\n \tif (filter_options.choice && !opt.init) {\n \t\tusage_with_options(git_submodule_helper_usage,\n \t\t\t\t   module_update_options);\ndiff --git a/git-submodule.sh b/git-submodule.sh\nindex 20fc1b620fa..5b9683bf766 100755\n--- a/git-submodule.sh\n+++ b/git-submodule.sh\n@@ -251,7 +251,6 @@ cmd_update()\n \t\t\tinit=1\n \t\t\t;;\n \t\t--require-init)\n-\t\t\tinit=1\n \t\t\trequire_init=1\n \t\t\t;;\n \t\t--remote)\n-- \n2.36.1.1239.gfba91521d90\n\n"},{"id":"457705","messageId":"patch-v3-10.12-66a229227a1-20220622T142012Z-avarab@gmail.com","threadId":"57979","inReplyTo":"cover-v3-00.12-00000000000-20220622T142012Z-avarab@gmail.com","subject":"[PATCH v3 10/12] submodule--helper: eliminate internal \"--update\" option","fromName":"Ævar Arnfjörð Bjarmason","fromEmail":"avarab@gmail.com","sentAt":"2022-06-22T14:28:05Z","receivedAt":"2022-06-22T14:29:44Z","isPatch":true,"sender":{"key":"avarab@gmail.com","avatar":"https://avatars.githubusercontent.com/u/45301?v=4"},"body":"From: Glen Choo <chooglen@google.com>\n\nFollow-up on the preceding commit which taught \"git submodule--helper\nupdate\" to understand \"--merge\", \"--checkout\" and \"--rebase\" and use\nthose options instead of \"--update=(rebase|merge|checkout|none)\" when\nthe command invokes itself.\n\nUnlike the preceding change this isn't strictly necessary to\neventually change \"git-submodule.sh\" so that it invokes \"git\nsubmodule--helper update\" directly, but let's remove this\ninconsistency in the command-line interface. We shouldn't need to\ncarry special synonyms for existing options in \"git submodule--helper\"\nwhen that command can use the primary documented names instead.\n\nBut, as seen in the post-image this makes the control flow within\n\"builtin/submodule--helper.c\" simpler, we can now write directly to\nthe \"update_default\" member of \"struct update_data\" when parsing the\noptions in \"module_update()\".\n\nSigned-off-by: Glen Choo <chooglen@google.com>\nSigned-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>\n---\n builtin/submodule--helper.c | 33 +++++++++++++--------------------\n 1 file changed, 13 insertions(+), 20 deletions(-)\n\ndiff --git a/builtin/submodule--helper.c b/builtin/submodule--helper.c\nindex 928b7a948b2..e7ee7b404be 100644\n--- a/builtin/submodule--helper.c\n+++ b/builtin/submodule--helper.c\n@@ -1818,7 +1818,7 @@ static int module_clone(int argc, const char **argv, const char *prefix)\n static void determine_submodule_update_strategy(struct repository *r,\n \t\t\t\t\t\tint just_cloned,\n \t\t\t\t\t\tconst char *path,\n-\t\t\t\t\t\tconst char *update,\n+\t\t\t\t\t\tenum submodule_update_type update,\n \t\t\t\t\t\tstruct submodule_update_strategy *out)\n {\n \tconst struct submodule *sub = submodule_from_path(r, null_oid(), path);\n@@ -1828,9 +1828,7 @@ static void determine_submodule_update_strategy(struct repository *r,\n \tkey = xstrfmt(\"submodule.%s.update\", sub->name);\n \n \tif (update) {\n-\t\tif (parse_submodule_update_strategy(update, out) < 0)\n-\t\t\tdie(_(\"Invalid update mode '%s' for submodule path '%s'\"),\n-\t\t\t\tupdate, path);\n+\t\tout->type = update;\n \t} else if (!repo_config_get_string_tmp(r, key, &val)) {\n \t\tif (parse_submodule_update_strategy(val, out) < 0)\n \t\t\tdie(_(\"Invalid update mode '%s' configured for submodule path '%s'\"),\n@@ -1882,7 +1880,7 @@ struct update_data {\n \tconst char *prefix;\n \tconst char *recursive_prefix;\n \tconst char *displaypath;\n-\tconst char *update_default;\n+\tenum submodule_update_type update_default;\n \tstruct object_id suboid;\n \tstruct string_list references;\n \tstruct submodule_update_strategy update_strategy;\n@@ -2424,6 +2422,8 @@ static const char *submodule_update_type_to_label(enum submodule_update_type typ\n \n static void update_data_to_args(struct update_data *update_data, struct strvec *args)\n {\n+\tenum submodule_update_type update_type = update_data->update_default;\n+\n \tstrvec_pushl(args, \"submodule--helper\", \"update\", \"--recursive\", NULL);\n \tstrvec_pushf(args, \"--jobs=%d\", update_data->max_jobs);\n \tif (update_data->recursive_prefix)\n@@ -2447,8 +2447,10 @@ static void update_data_to_args(struct update_data *update_data, struct strvec *\n \t\tstrvec_push(args, \"--require-init\");\n \tif (update_data->depth)\n \t\tstrvec_pushf(args, \"--depth=%d\", update_data->depth);\n-\tif (update_data->update_default)\n-\t\tstrvec_pushl(args, \"--update\", update_data->update_default, NULL);\n+\tif (update_type != SM_UPDATE_UNSPECIFIED)\n+\t\tstrvec_pushf(args, \"--%s\",\n+\t\t\t     submodule_update_type_to_label(update_type));\n+\n \tif (update_data->references.nr) {\n \t\tstruct string_list_item *item;\n \t\tfor_each_string_list_item(item, &update_data->references)\n@@ -2600,7 +2602,6 @@ static int module_update(int argc, const char **argv, const char *prefix)\n \tstruct update_data opt = UPDATE_DATA_INIT;\n \tstruct list_objects_filter_options filter_options;\n \tint ret;\n-\tenum submodule_update_type update_type = SM_UPDATE_UNSPECIFIED;\n \n \tstruct option module_update_options[] = {\n \t\tOPT__FORCE(&opt.force, N_(\"force checkout updates\"), 0),\n@@ -2619,16 +2620,13 @@ static int module_update(int argc, const char **argv, const char *prefix)\n \t\t\t   N_(\"path\"),\n \t\t\t   N_(\"path into the working tree, across nested \"\n \t\t\t      \"submodule boundaries\")),\n-\t\tOPT_STRING(0, \"update\", &opt.update_default,\n-\t\t\t   N_(\"string\"),\n-\t\t\t   N_(\"rebase, merge, checkout or none\")),\n-\t\tOPT_SET_INT(0, \"checkout\", &update_type,\n+\t\tOPT_SET_INT(0, \"checkout\", &opt.update_default,\n \t\t\tN_(\"use the 'checkout' update strategy (default)\"),\n \t\t\tSM_UPDATE_CHECKOUT),\n-\t\tOPT_SET_INT('m', \"merge\", &update_type,\n+\t\tOPT_SET_INT('m', \"merge\", &opt.update_default,\n \t\t\tN_(\"use the 'merge' update strategy\"),\n \t\t\tSM_UPDATE_MERGE),\n-\t\tOPT_SET_INT('r', \"rebase\", &update_type,\n+\t\tOPT_SET_INT('r', \"rebase\", &opt.update_default,\n \t\t\tN_(\"use the 'rebase' update strategy\"),\n \t\t\tSM_UPDATE_REBASE),\n \t\tOPT_STRING_LIST(0, \"reference\", &opt.references, N_(\"repo\"),\n@@ -2680,13 +2678,8 @@ static int module_update(int argc, const char **argv, const char *prefix)\n \n \topt.filter_options = &filter_options;\n \n-\tif (update_type != SM_UPDATE_UNSPECIFIED)\n-\t\topt.update_default = submodule_update_type_to_label(update_type);\n-\n \tif (opt.update_default)\n-\t\tif (parse_submodule_update_strategy(opt.update_default,\n-\t\t\t\t\t\t    &opt.update_strategy) < 0)\n-\t\t\tdie(_(\"bad value for update parameter\"));\n+\t\topt.update_strategy.type = opt.update_default;\n \n \tif (module_list_compute(argc, argv, prefix, &pathspec, &opt.list) < 0) {\n \t\tlist_objects_filter_release(&filter_options);\n-- \n2.36.1.1239.gfba91521d90\n\n"},{"id":"457706","messageId":"patch-v3-09.12-e251fc115e1-20220622T142012Z-avarab@gmail.com","threadId":"57979","inReplyTo":"cover-v3-00.12-00000000000-20220622T142012Z-avarab@gmail.com","subject":"[PATCH v3 09/12] submodule--helper: understand --checkout, --merge and --rebase synonyms","fromName":"Ævar Arnfjörð Bjarmason","fromEmail":"avarab@gmail.com","sentAt":"2022-06-22T14:28:04Z","receivedAt":"2022-06-22T14:29:45Z","isPatch":true,"sender":{"key":"avarab@gmail.com","avatar":"https://avatars.githubusercontent.com/u/45301?v=4"},"body":"Understand --checkout, --merge and --rebase synonyms for\n--update={checkout,merge,rebase}, as well as the short options that\n'git submodule' itself understands.\n\nThis removes a difference between the CLI API of \"git submodule\" and\n\"git submodule--helper\", making it easier to make the latter an alias\nfor the former. See 48308681b07 (git submodule update: have a\ndedicated helper for cloning, 2016-02-29) for the initial addition of\n--update.\n\nSigned-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>\n---\n builtin/submodule--helper.c | 30 ++++++++++++++++++++++++++++++\n git-submodule.sh            | 14 +++++++++-----\n 2 files changed, 39 insertions(+), 5 deletions(-)\n\ndiff --git a/builtin/submodule--helper.c b/builtin/submodule--helper.c\nindex 6af09d78d4b..928b7a948b2 100644\n--- a/builtin/submodule--helper.c\n+++ b/builtin/submodule--helper.c\n@@ -2405,6 +2405,23 @@ static void ensure_core_worktree(const char *path)\n \t}\n }\n \n+static const char *submodule_update_type_to_label(enum submodule_update_type type)\n+{\n+\tswitch (type) {\n+\tcase SM_UPDATE_CHECKOUT:\n+\t\treturn \"checkout\";\n+\tcase SM_UPDATE_MERGE:\n+\t\treturn \"merge\";\n+\tcase SM_UPDATE_REBASE:\n+\t\treturn \"rebase\";\n+\tcase SM_UPDATE_UNSPECIFIED:\n+\tcase SM_UPDATE_NONE:\n+\tcase SM_UPDATE_COMMAND:\n+\t\tbreak;\n+\t}\n+\tBUG(\"unreachable with type %d\", type);\n+}\n+\n static void update_data_to_args(struct update_data *update_data, struct strvec *args)\n {\n \tstrvec_pushl(args, \"submodule--helper\", \"update\", \"--recursive\", NULL);\n@@ -2583,6 +2600,7 @@ static int module_update(int argc, const char **argv, const char *prefix)\n \tstruct update_data opt = UPDATE_DATA_INIT;\n \tstruct list_objects_filter_options filter_options;\n \tint ret;\n+\tenum submodule_update_type update_type = SM_UPDATE_UNSPECIFIED;\n \n \tstruct option module_update_options[] = {\n \t\tOPT__FORCE(&opt.force, N_(\"force checkout updates\"), 0),\n@@ -2604,6 +2622,15 @@ static int module_update(int argc, const char **argv, const char *prefix)\n \t\tOPT_STRING(0, \"update\", &opt.update_default,\n \t\t\t   N_(\"string\"),\n \t\t\t   N_(\"rebase, merge, checkout or none\")),\n+\t\tOPT_SET_INT(0, \"checkout\", &update_type,\n+\t\t\tN_(\"use the 'checkout' update strategy (default)\"),\n+\t\t\tSM_UPDATE_CHECKOUT),\n+\t\tOPT_SET_INT('m', \"merge\", &update_type,\n+\t\t\tN_(\"use the 'merge' update strategy\"),\n+\t\t\tSM_UPDATE_MERGE),\n+\t\tOPT_SET_INT('r', \"rebase\", &update_type,\n+\t\t\tN_(\"use the 'rebase' update strategy\"),\n+\t\t\tSM_UPDATE_REBASE),\n \t\tOPT_STRING_LIST(0, \"reference\", &opt.references, N_(\"repo\"),\n \t\t\t   N_(\"reference repository\")),\n \t\tOPT_BOOL(0, \"dissociate\", &opt.dissociate,\n@@ -2653,6 +2680,9 @@ static int module_update(int argc, const char **argv, const char *prefix)\n \n \topt.filter_options = &filter_options;\n \n+\tif (update_type != SM_UPDATE_UNSPECIFIED)\n+\t\topt.update_default = submodule_update_type_to_label(update_type);\n+\n \tif (opt.update_default)\n \t\tif (parse_submodule_update_strategy(opt.update_default,\n \t\t\t\t\t\t    &opt.update_strategy) < 0)\ndiff --git a/git-submodule.sh b/git-submodule.sh\nindex 1c1dc320922..7fc7119fb21 100755\n--- a/git-submodule.sh\n+++ b/git-submodule.sh\n@@ -40,7 +40,9 @@ require_init=\n files=\n remote=\n nofetch=\n-update=\n+rebase=\n+merge=\n+checkout=\n custom_name=\n depth=\n progress=\n@@ -260,7 +262,7 @@ cmd_update()\n \t\t\tforce=$1\n \t\t\t;;\n \t\t-r|--rebase)\n-\t\t\tupdate=\"rebase\"\n+\t\t\trebase=1\n \t\t\t;;\n \t\t--reference)\n \t\t\tcase \"$2\" in '') usage ;; esac\n@@ -274,13 +276,13 @@ cmd_update()\n \t\t\tdissociate=1\n \t\t\t;;\n \t\t-m|--merge)\n-\t\t\tupdate=\"merge\"\n+\t\t\tmerge=1\n \t\t\t;;\n \t\t--recursive)\n \t\t\trecursive=1\n \t\t\t;;\n \t\t--checkout)\n-\t\t\tupdate=\"checkout\"\n+\t\t\tcheckout=1\n \t\t\t;;\n \t\t--recommend-shallow)\n \t\t\trecommend_shallow=\"--recommend-shallow\"\n@@ -341,7 +343,9 @@ cmd_update()\n \t\t${init:+--init} \\\n \t\t${nofetch:+--no-fetch} \\\n \t\t${wt_prefix:+--prefix \"$wt_prefix\"} \\\n-\t\t${update:+--update \"$update\"} \\\n+\t\t${rebase:+--rebase} \\\n+\t\t${merge:+--merge} \\\n+\t\t${checkout:+--checkout} \\\n \t\t${reference:+\"$reference\"} \\\n \t\t${dissociate:+\"--dissociate\"} \\\n \t\t${depth:+\"$depth\"} \\\n-- \n2.36.1.1239.gfba91521d90\n\n"},{"id":"457707","messageId":"patch-v3-08.12-bb1310b9abe-20220622T142012Z-avarab@gmail.com","threadId":"57979","inReplyTo":"cover-v3-00.12-00000000000-20220622T142012Z-avarab@gmail.com","subject":"[PATCH v3 08/12] submodule--helper: report \"submodule\" as our name in some \"-h\" output","fromName":"Ævar Arnfjörð Bjarmason","fromEmail":"avarab@gmail.com","sentAt":"2022-06-22T14:28:03Z","receivedAt":"2022-06-22T14:29:46Z","isPatch":true,"sender":{"key":"avarab@gmail.com","avatar":"https://avatars.githubusercontent.com/u/45301?v=4"},"body":"Change the user-facing \"git submodule--helper\" commands so that\nthey'll report their name as being \"git submodule\". To a user these\ncommands are internal implementation details, and it doesn't make\nsense to emit usage about an internal helper when \"git submodule\" is\ninvoked with invalid options.\n\nBefore this we'd emit e.g.:\n\n\t$ git submodule absorbgitdirs --blah\n\terror: unknown option `blah'\n\tusage: git submodule--helper absorbgitdirs [<options>] [<path>...]\n\t[...]\nAnd:\n\n\t$ git submodule set-url -- --\n\tusage: git submodule--helper set-url [--quiet] <path> <newurl>\n\t[...]\n\nNow we'll start with \"usage: git submodule [...]\" in both of those\ncases. This change does not alter the \"list\", \"name\", \"clone\",\n\"config\" and \"create-branch\" commands, those are internal-only (as an\naside; their usage info should probably invoke BUG(...)). This only\nchanges the user-facing commands.\n\nThe \"status\", \"deinit\" and \"update\" commands are not included in this\nchange, because their usage information already used \"submodule\"\nrather than \"submodule--helper\".\n\nI don't think it's currently possible to emit some of this usage\ninformation in practice, as git-submodule.sh will catch unknown\noptions, and e.g. it doesn't seem to be possible to get \"add\" to emit\nits usage information from \"submodule--helper\".\n\nThough that change may be superfluous now, it's also harmless, and\nwill allow us to eventually dispatch further into \"git\nsubmodule--helper\" from git-submodule.sh, while emitting the correct\nusage output.\n\nSigned-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>\n---\n builtin/submodule--helper.c | 18 +++++++++---------\n 1 file changed, 9 insertions(+), 9 deletions(-)\n\ndiff --git a/builtin/submodule--helper.c b/builtin/submodule--helper.c\nindex a298d8d0c12..6af09d78d4b 100644\n--- a/builtin/submodule--helper.c\n+++ b/builtin/submodule--helper.c\n@@ -444,7 +444,7 @@ static int module_foreach(int argc, const char **argv, const char *prefix)\n \t};\n \n \tconst char *const git_submodule_helper_usage[] = {\n-\t\tN_(\"git submodule--helper foreach [--quiet] [--recursive] [--] <command>\"),\n+\t\tN_(\"git submodule foreach [--quiet] [--recursive] [--] <command>\"),\n \t\tNULL\n \t};\n \n@@ -582,7 +582,7 @@ static int module_init(int argc, const char **argv, const char *prefix)\n \t};\n \n \tconst char *const git_submodule_helper_usage[] = {\n-\t\tN_(\"git submodule--helper init [<options>] [<path>]\"),\n+\t\tN_(\"git submodule init [<options>] [<path>]\"),\n \t\tNULL\n \t};\n \n@@ -1185,7 +1185,7 @@ static int module_summary(int argc, const char **argv, const char *prefix)\n \t};\n \n \tconst char *const git_submodule_helper_usage[] = {\n-\t\tN_(\"git submodule--helper summary [<options>] [<commit>] [--] [<path>]\"),\n+\t\tN_(\"git submodule summary [<options>] [<commit>] [--] [<path>]\"),\n \t\tNULL\n \t};\n \n@@ -1349,7 +1349,7 @@ static int module_sync(int argc, const char **argv, const char *prefix)\n \t};\n \n \tconst char *const git_submodule_helper_usage[] = {\n-\t\tN_(\"git submodule--helper sync [--quiet] [--recursive] [<path>]\"),\n+\t\tN_(\"git submodule sync [--quiet] [--recursive] [<path>]\"),\n \t\tNULL\n \t};\n \n@@ -2788,7 +2788,7 @@ static int absorb_git_dirs(int argc, const char **argv, const char *prefix)\n \t};\n \n \tconst char *const git_submodule_helper_usage[] = {\n-\t\tN_(\"git submodule--helper absorbgitdirs [<options>] [<path>...]\"),\n+\t\tN_(\"git submodule absorbgitdirs [<options>] [<path>...]\"),\n \t\tNULL\n \t};\n \n@@ -2893,7 +2893,7 @@ static int module_set_url(int argc, const char **argv, const char *prefix)\n \t\tOPT_END()\n \t};\n \tconst char *const usage[] = {\n-\t\tN_(\"git submodule--helper set-url [--quiet] <path> <newurl>\"),\n+\t\tN_(\"git submodule set-url [--quiet] <path> <newurl>\"),\n \t\tNULL\n \t};\n \n@@ -2932,8 +2932,8 @@ static int module_set_branch(int argc, const char **argv, const char *prefix)\n \t\tOPT_END()\n \t};\n \tconst char *const usage[] = {\n-\t\tN_(\"git submodule--helper set-branch [-q|--quiet] (-d|--default) <path>\"),\n-\t\tN_(\"git submodule--helper set-branch [-q|--quiet] (-b|--branch) <branch> <path>\"),\n+\t\tN_(\"git submodule set-branch [-q|--quiet] (-d|--default) <path>\"),\n+\t\tN_(\"git submodule set-branch [-q|--quiet] (-b|--branch) <branch> <path>\"),\n \t\tNULL\n \t};\n \n@@ -3277,7 +3277,7 @@ static int module_add(int argc, const char **argv, const char *prefix)\n \t};\n \n \tconst char *const usage[] = {\n-\t\tN_(\"git submodule--helper add [<options>] [--] <repository> [<path>]\"),\n+\t\tN_(\"git submodule add [<options>] [--] <repository> [<path>]\"),\n \t\tNULL\n \t};\n \n-- \n2.36.1.1239.gfba91521d90\n\n"},{"id":"457708","messageId":"patch-v3-07.12-ff557f3c81a-20220622T142012Z-avarab@gmail.com","threadId":"57979","inReplyTo":"cover-v3-00.12-00000000000-20220622T142012Z-avarab@gmail.com","subject":"[PATCH v3 07/12] submodule--helper: rename \"absorb-git-dirs\" to \"absorbgitdirs\"","fromName":"Ævar Arnfjörð Bjarmason","fromEmail":"avarab@gmail.com","sentAt":"2022-06-22T14:28:02Z","receivedAt":"2022-06-22T14:29:48Z","isPatch":true,"sender":{"key":"avarab@gmail.com","avatar":"https://avatars.githubusercontent.com/u/45301?v=4"},"body":"Rename the \"absorb-git-dirs\" subcommand to \"absorbgitdirs\", which is\nwhat the \"git submodule\" command itself has called it since the\nsubcommand was implemented in f6f85861400 (submodule: add\nabsorb-git-dir function, 2016-12-12).\n\nHaving these two be different will make it more tedious to dispatch to\neventually dispatch \"git submodule--helper\" directly, as we'd need to\nretain this name mapping. So let's get rid of this needless\ninconsistency.\n\nSigned-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>\n---\n builtin/submodule--helper.c | 4 ++--\n git-submodule.sh            | 2 +-\n submodule.c                 | 2 +-\n 3 files changed, 4 insertions(+), 4 deletions(-)\n\ndiff --git a/builtin/submodule--helper.c b/builtin/submodule--helper.c\nindex 1876375a4a0..a298d8d0c12 100644\n--- a/builtin/submodule--helper.c\n+++ b/builtin/submodule--helper.c\n@@ -2788,7 +2788,7 @@ static int absorb_git_dirs(int argc, const char **argv, const char *prefix)\n \t};\n \n \tconst char *const git_submodule_helper_usage[] = {\n-\t\tN_(\"git submodule--helper absorb-git-dirs [<options>] [<path>...]\"),\n+\t\tN_(\"git submodule--helper absorbgitdirs [<options>] [<path>...]\"),\n \t\tNULL\n \t};\n \n@@ -3387,7 +3387,7 @@ static struct cmd_struct commands[] = {\n \t{\"deinit\", module_deinit},\n \t{\"summary\", module_summary},\n \t{\"push-check\", push_check},\n-\t{\"absorb-git-dirs\", absorb_git_dirs},\n+\t{\"absorbgitdirs\", absorb_git_dirs},\n \t{\"is-active\", is_active},\n \t{\"check-name\", check_name},\n \t{\"config\", module_config},\ndiff --git a/git-submodule.sh b/git-submodule.sh\nindex 0df6b0fc974..1c1dc320922 100755\n--- a/git-submodule.sh\n+++ b/git-submodule.sh\n@@ -552,7 +552,7 @@ cmd_sync()\n \n cmd_absorbgitdirs()\n {\n-\tgit submodule--helper absorb-git-dirs --prefix \"$wt_prefix\" \"$@\"\n+\tgit submodule--helper absorbgitdirs --prefix \"$wt_prefix\" \"$@\"\n }\n \n # This loop parses the command line arguments to find the\ndiff --git a/submodule.c b/submodule.c\nindex 4e299f578f9..2af16c647d5 100644\n--- a/submodule.c\n+++ b/submodule.c\n@@ -2374,7 +2374,7 @@ void absorb_git_dir_into_superproject(const char *path,\n \t\tcp.no_stdin = 1;\n \t\tstrvec_pushl(&cp.args, \"--super-prefix\", sb.buf,\n \t\t\t     \"submodule--helper\",\n-\t\t\t     \"absorb-git-dirs\", NULL);\n+\t\t\t     \"absorbgitdirs\", NULL);\n \t\tprepare_submodule_repo_env(&cp.env);\n \t\tif (run_command(&cp))\n \t\t\tdie(_(\"could not recurse into submodule '%s'\"), path);\n-- \n2.36.1.1239.gfba91521d90\n\n"},{"id":"457709","messageId":"patch-v3-11.12-f8219cd461d-20220622T142012Z-avarab@gmail.com","threadId":"57979","inReplyTo":"cover-v3-00.12-00000000000-20220622T142012Z-avarab@gmail.com","subject":"[PATCH v3 11/12] git-submodule.sh: use \"$quiet\", not \"$GIT_QUIET\"","fromName":"Ævar Arnfjörð Bjarmason","fromEmail":"avarab@gmail.com","sentAt":"2022-06-22T14:28:06Z","receivedAt":"2022-06-22T14:29:50Z","isPatch":true,"sender":{"key":"avarab@gmail.com","avatar":"https://avatars.githubusercontent.com/u/45301?v=4"},"body":"Remove the use of the \"$GIT_QUIET\" variable in favor of our own\n\"$quiet\", ever since b3c5f5cb048 (submodule: move core cmd_update()\nlogic to C, 2022-03-15) we have not used the \"say\" function in\ngit-sh-setup.sh, which is the only thing that's affected by using\n\"GIT_QUIET\".\n\nWe still want to support --quiet for our own use though, but let's use\nour own variable for that. Now it's obvious that we only care about\npassing \"--quiet\" to \"git submodule--helper\", and not to change the\noutput of any \"say\" invocation.\n\nSigned-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>\n---\n git-submodule.sh | 37 +++++++++++++++++++------------------\n 1 file changed, 19 insertions(+), 18 deletions(-)\n\ndiff --git a/git-submodule.sh b/git-submodule.sh\nindex 7fc7119fb21..5e5d21c010f 100755\n--- a/git-submodule.sh\n+++ b/git-submodule.sh\n@@ -30,6 +30,7 @@ GIT_PROTOCOL_FROM_USER=0\n export GIT_PROTOCOL_FROM_USER\n \n command=\n+quiet=\n branch=\n force=\n reference=\n@@ -80,7 +81,7 @@ cmd_add()\n \t\t\tforce=$1\n \t\t\t;;\n \t\t-q|--quiet)\n-\t\t\tGIT_QUIET=1\n+\t\t\tquiet=1\n \t\t\t;;\n \t\t--progress)\n \t\t\tprogress=1\n@@ -128,7 +129,7 @@ cmd_add()\n \t\tusage\n \tfi\n \n-\tgit ${wt_prefix:+-C \"$wt_prefix\"} submodule--helper add ${GIT_QUIET:+--quiet} ${force:+--force} ${progress:+\"--progress\"} ${branch:+--branch \"$branch\"} ${reference_path:+--reference \"$reference_path\"} ${dissociate:+--dissociate} ${custom_name:+--name \"$custom_name\"} ${depth:+\"$depth\"} -- \"$@\"\n+\tgit ${wt_prefix:+-C \"$wt_prefix\"} submodule--helper add ${quiet:+--quiet} ${force:+--force} ${progress:+\"--progress\"} ${branch:+--branch \"$branch\"} ${reference_path:+--reference \"$reference_path\"} ${dissociate:+--dissociate} ${custom_name:+--name \"$custom_name\"} ${depth:+\"$depth\"} -- \"$@\"\n }\n \n #\n@@ -144,7 +145,7 @@ cmd_foreach()\n \tdo\n \t\tcase \"$1\" in\n \t\t-q|--quiet)\n-\t\t\tGIT_QUIET=1\n+\t\t\tquiet=1\n \t\t\t;;\n \t\t--recursive)\n \t\t\trecursive=1\n@@ -159,7 +160,7 @@ cmd_foreach()\n \t\tshift\n \tdone\n \n-\tgit ${wt_prefix:+-C \"$wt_prefix\"} submodule--helper foreach ${GIT_QUIET:+--quiet} ${recursive:+--recursive} -- \"$@\"\n+\tgit ${wt_prefix:+-C \"$wt_prefix\"} submodule--helper foreach ${quiet:+--quiet} ${recursive:+--recursive} -- \"$@\"\n }\n \n #\n@@ -174,7 +175,7 @@ cmd_init()\n \tdo\n \t\tcase \"$1\" in\n \t\t-q|--quiet)\n-\t\t\tGIT_QUIET=1\n+\t\t\tquiet=1\n \t\t\t;;\n \t\t--)\n \t\t\tshift\n@@ -190,7 +191,7 @@ cmd_init()\n \t\tshift\n \tdone\n \n-\tgit ${wt_prefix:+-C \"$wt_prefix\"} submodule--helper init ${GIT_QUIET:+--quiet} -- \"$@\"\n+\tgit ${wt_prefix:+-C \"$wt_prefix\"} submodule--helper init ${quiet:+--quiet} -- \"$@\"\n }\n \n #\n@@ -207,7 +208,7 @@ cmd_deinit()\n \t\t\tforce=$1\n \t\t\t;;\n \t\t-q|--quiet)\n-\t\t\tGIT_QUIET=1\n+\t\t\tquiet=1\n \t\t\t;;\n \t\t--all)\n \t\t\tdeinit_all=t\n@@ -226,7 +227,7 @@ cmd_deinit()\n \t\tshift\n \tdone\n \n-\tgit ${wt_prefix:+-C \"$wt_prefix\"} submodule--helper deinit ${GIT_QUIET:+--quiet} ${force:+--force} ${deinit_all:+--all} -- \"$@\"\n+\tgit ${wt_prefix:+-C \"$wt_prefix\"} submodule--helper deinit ${quiet:+--quiet} ${force:+--force} ${deinit_all:+--all} -- \"$@\"\n }\n \n #\n@@ -241,7 +242,7 @@ cmd_update()\n \tdo\n \t\tcase \"$1\" in\n \t\t-q|--quiet)\n-\t\t\tGIT_QUIET=1\n+\t\t\tquiet=1\n \t\t\t;;\n \t\t--progress)\n \t\t\tprogress=1\n@@ -335,7 +336,7 @@ cmd_update()\n \tdone\n \n \tgit ${wt_prefix:+-C \"$wt_prefix\"} submodule--helper update \\\n-\t\t${GIT_QUIET:+--quiet} \\\n+\t\t${quiet:+--quiet} \\\n \t\t${force:+--force} \\\n \t\t${progress:+\"--progress\"} \\\n \t\t${remote:+--remote} \\\n@@ -396,7 +397,7 @@ cmd_set_branch() {\n \t\tshift\n \tdone\n \n-\tgit ${wt_prefix:+-C \"$wt_prefix\"} submodule--helper set-branch ${GIT_QUIET:+--quiet} ${branch:+--branch \"$branch\"} ${default:+--default} -- \"$@\"\n+\tgit ${wt_prefix:+-C \"$wt_prefix\"} submodule--helper set-branch ${quiet:+--quiet} ${branch:+--branch \"$branch\"} ${default:+--default} -- \"$@\"\n }\n \n #\n@@ -409,7 +410,7 @@ cmd_set_url() {\n \tdo\n \t\tcase \"$1\" in\n \t\t-q|--quiet)\n-\t\t\tGIT_QUIET=1\n+\t\t\tquiet=1\n \t\t\t;;\n \t\t--)\n \t\t\tshift\n@@ -425,7 +426,7 @@ cmd_set_url() {\n \t\tshift\n \tdone\n \n-\tgit ${wt_prefix:+-C \"$wt_prefix\"} submodule--helper set-url ${GIT_QUIET:+--quiet} -- \"$@\"\n+\tgit ${wt_prefix:+-C \"$wt_prefix\"} submodule--helper set-url ${quiet:+--quiet} -- \"$@\"\n }\n \n #\n@@ -496,7 +497,7 @@ cmd_status()\n \tdo\n \t\tcase \"$1\" in\n \t\t-q|--quiet)\n-\t\t\tGIT_QUIET=1\n+\t\t\tquiet=1\n \t\t\t;;\n \t\t--cached)\n \t\t\tcached=1\n@@ -518,7 +519,7 @@ cmd_status()\n \t\tshift\n \tdone\n \n-\tgit ${wt_prefix:+-C \"$wt_prefix\"} submodule--helper status ${GIT_QUIET:+--quiet} ${cached:+--cached} ${recursive:+--recursive} -- \"$@\"\n+\tgit ${wt_prefix:+-C \"$wt_prefix\"} submodule--helper status ${quiet:+--quiet} ${cached:+--cached} ${recursive:+--recursive} -- \"$@\"\n }\n #\n # Sync remote urls for submodules\n@@ -531,7 +532,7 @@ cmd_sync()\n \tdo\n \t\tcase \"$1\" in\n \t\t-q|--quiet)\n-\t\t\tGIT_QUIET=1\n+\t\t\tquiet=1\n \t\t\tshift\n \t\t\t;;\n \t\t--recursive)\n@@ -551,7 +552,7 @@ cmd_sync()\n \t\tesac\n \tdone\n \n-\tgit ${wt_prefix:+-C \"$wt_prefix\"} submodule--helper sync ${GIT_QUIET:+--quiet} ${recursive:+--recursive} -- \"$@\"\n+\tgit ${wt_prefix:+-C \"$wt_prefix\"} submodule--helper sync ${quiet:+--quiet} ${recursive:+--recursive} -- \"$@\"\n }\n \n cmd_absorbgitdirs()\n@@ -572,7 +573,7 @@ do\n \t\tcommand=$1\n \t\t;;\n \t-q|--quiet)\n-\t\tGIT_QUIET=1\n+\t\tquiet=1\n \t\t;;\n \t--cached)\n \t\tcached=1\n-- \n2.36.1.1239.gfba91521d90\n\n"},{"id":"457736","messageId":"kl6l4k0ck0y7.fsf@chooglen-macbookpro.roam.corp.google.com","threadId":"57979","inReplyTo":"patch-v3-08.12-bb1310b9abe-20220622T142012Z-avarab@gmail.com","subject":"Re: [PATCH v3 08/12] submodule--helper: report \"submodule\" as our name in some \"-h\" output","fromName":"Glen Choo","fromEmail":"chooglen@google.com","sentAt":"2022-06-22T18:28:00Z","receivedAt":"2022-06-22T18:28:14Z","isPatch":true,"sender":{"key":"glencbz@gmail.com","avatar":"https://avatars.githubusercontent.com/u/58092771?v=4"},"body":"Ævar Arnfjörð Bjarmason <avarab@gmail.com> writes:\n\n> Change the user-facing \"git submodule--helper\" commands so that\n> they'll report their name as being \"git submodule\". To a user these\n> commands are internal implementation details, and it doesn't make\n> sense to emit usage about an internal helper when \"git submodule\" is\n> invoked with invalid options.\n>\n> Before this we'd emit e.g.:\n>\n> \t$ git submodule absorbgitdirs --blah\n> \terror: unknown option `blah'\n> \tusage: git submodule--helper absorbgitdirs [<options>] [<path>...]\n> \t[...]\n> And:\n>\n> \t$ git submodule set-url -- --\n> \tusage: git submodule--helper set-url [--quiet] <path> <newurl>\n> \t[...]\n>\n> Now we'll start with \"usage: git submodule [...]\" in both of those\n> cases. This change does not alter the \"list\", \"name\", \"clone\",\n> \"config\" and \"create-branch\" commands, those are internal-only (as an\n> aside; their usage info should probably invoke BUG(...)). This only\n> changes the user-facing commands.\n>\n> The \"status\", \"deinit\" and \"update\" commands are not included in this\n> change, because their usage information already used \"submodule\"\n> rather than \"submodule--helper\".\n\nI enumerated over all of the commands just to be sure:\n\n- The commands named here and the changed commands cover all of the uses\n  of the usage_*/parse_options API.\n\n- We still mention \"submodule--helper\" in two internal facing commands\n  (\"is-active\" and \"push-check\"), but those call die() (should be BUG()\n  I assume?) instead of usage_*().\n\n- The other two commands (\"resolve-relative-url-test\" and \"check-name\")\n  are internal facing commands that never print usage information.\n\nSo this covers all of the cases. Great!\n\n> I don't think it's currently possible to emit some of this usage\n> information in practice, as git-submodule.sh will catch unknown\n> options, and e.g. it doesn't seem to be possible to get \"add\" to emit\n> its usage information from \"submodule--helper\".\n>\n> Though that change may be superfluous now, it's also harmless, and\n> will allow us to eventually dispatch further into \"git\n> submodule--helper\" from git-submodule.sh, while emitting the correct\n> usage output.\n\nMakes sense.\n\n>\n> Signed-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>\n> ---\n>  builtin/submodule--helper.c | 18 +++++++++---------\n>  1 file changed, 9 insertions(+), 9 deletions(-)\n>\n> diff --git a/builtin/submodule--helper.c b/builtin/submodule--helper.c\n> index a298d8d0c12..6af09d78d4b 100644\n> --- a/builtin/submodule--helper.c\n> +++ b/builtin/submodule--helper.c\n> @@ -444,7 +444,7 @@ static int module_foreach(int argc, const char **argv, const char *prefix)\n>  \t};\n>  \n>  \tconst char *const git_submodule_helper_usage[] = {\n> -\t\tN_(\"git submodule--helper foreach [--quiet] [--recursive] [--] <command>\"),\n> +\t\tN_(\"git submodule foreach [--quiet] [--recursive] [--] <command>\"),\n>  \t\tNULL\n>  \t};\n>  \n> @@ -582,7 +582,7 @@ static int module_init(int argc, const char **argv, const char *prefix)\n>  \t};\n>  \n>  \tconst char *const git_submodule_helper_usage[] = {\n> -\t\tN_(\"git submodule--helper init [<options>] [<path>]\"),\n> +\t\tN_(\"git submodule init [<options>] [<path>]\"),\n>  \t\tNULL\n>  \t};\n>  \n> @@ -1185,7 +1185,7 @@ static int module_summary(int argc, const char **argv, const char *prefix)\n>  \t};\n>  \n>  \tconst char *const git_submodule_helper_usage[] = {\n> -\t\tN_(\"git submodule--helper summary [<options>] [<commit>] [--] [<path>]\"),\n> +\t\tN_(\"git submodule summary [<options>] [<commit>] [--] [<path>]\"),\n>  \t\tNULL\n>  \t};\n>  \n> @@ -1349,7 +1349,7 @@ static int module_sync(int argc, const char **argv, const char *prefix)\n>  \t};\n>  \n>  \tconst char *const git_submodule_helper_usage[] = {\n> -\t\tN_(\"git submodule--helper sync [--quiet] [--recursive] [<path>]\"),\n> +\t\tN_(\"git submodule sync [--quiet] [--recursive] [<path>]\"),\n>  \t\tNULL\n>  \t};\n>  \n> @@ -2788,7 +2788,7 @@ static int absorb_git_dirs(int argc, const char **argv, const char *prefix)\n>  \t};\n>  \n>  \tconst char *const git_submodule_helper_usage[] = {\n> -\t\tN_(\"git submodule--helper absorbgitdirs [<options>] [<path>...]\"),\n> +\t\tN_(\"git submodule absorbgitdirs [<options>] [<path>...]\"),\n>  \t\tNULL\n>  \t};\n>  \n> @@ -2893,7 +2893,7 @@ static int module_set_url(int argc, const char **argv, const char *prefix)\n>  \t\tOPT_END()\n>  \t};\n>  \tconst char *const usage[] = {\n> -\t\tN_(\"git submodule--helper set-url [--quiet] <path> <newurl>\"),\n> +\t\tN_(\"git submodule set-url [--quiet] <path> <newurl>\"),\n>  \t\tNULL\n>  \t};\n>  \n> @@ -2932,8 +2932,8 @@ static int module_set_branch(int argc, const char **argv, const char *prefix)\n>  \t\tOPT_END()\n>  \t};\n>  \tconst char *const usage[] = {\n> -\t\tN_(\"git submodule--helper set-branch [-q|--quiet] (-d|--default) <path>\"),\n> -\t\tN_(\"git submodule--helper set-branch [-q|--quiet] (-b|--branch) <branch> <path>\"),\n> +\t\tN_(\"git submodule set-branch [-q|--quiet] (-d|--default) <path>\"),\n> +\t\tN_(\"git submodule set-branch [-q|--quiet] (-b|--branch) <branch> <path>\"),\n>  \t\tNULL\n>  \t};\n>  \n> @@ -3277,7 +3277,7 @@ static int module_add(int argc, const char **argv, const char *prefix)\n>  \t};\n>  \n>  \tconst char *const usage[] = {\n> -\t\tN_(\"git submodule--helper add [<options>] [--] <repository> [<path>]\"),\n> +\t\tN_(\"git submodule add [<options>] [--] <repository> [<path>]\"),\n>  \t\tNULL\n>  \t};\n>  \n> -- \n> 2.36.1.1239.gfba91521d90\n"},{"id":"457737","messageId":"kl6lzgi4il0z.fsf@chooglen-macbookpro.roam.corp.google.com","threadId":"57979","inReplyTo":"patch-v3-09.12-e251fc115e1-20220622T142012Z-avarab@gmail.com","subject":"Re: [PATCH v3 09/12] submodule--helper: understand --checkout, --merge and --rebase synonyms","fromName":"Glen Choo","fromEmail":"chooglen@google.com","sentAt":"2022-06-22T18:57:16Z","receivedAt":"2022-06-22T18:57:26Z","isPatch":true,"sender":{"key":"glencbz@gmail.com","avatar":"https://avatars.githubusercontent.com/u/58092771?v=4"},"body":"\nAs you noted in your cover letter, this version of 09-10/12 is a lot\ncleaner and more obviously correct.\n\nÆvar Arnfjörð Bjarmason <avarab@gmail.com> writes:\n\n> Understand --checkout, --merge and --rebase synonyms for\n> --update={checkout,merge,rebase}, as well as the short options that\n> 'git submodule' itself understands.\n>\n> This removes a difference between the CLI API of \"git submodule\" and\n> \"git submodule--helper\", making it easier to make the latter an alias\n> for the former. See 48308681b07 (git submodule update: have a\n> dedicated helper for cloning, 2016-02-29) for the initial addition of\n> --update.\n>\n> Signed-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>\n> ---\n>  builtin/submodule--helper.c | 30 ++++++++++++++++++++++++++++++\n>  git-submodule.sh            | 14 +++++++++-----\n>  2 files changed, 39 insertions(+), 5 deletions(-)\n>\n> diff --git a/builtin/submodule--helper.c b/builtin/submodule--helper.c\n> index 6af09d78d4b..928b7a948b2 100644\n> --- a/builtin/submodule--helper.c\n> +++ b/builtin/submodule--helper.c\n> @@ -2405,6 +2405,23 @@ static void ensure_core_worktree(const char *path)\n>  \t}\n>  }\n>  \n> +static const char *submodule_update_type_to_label(enum submodule_update_type type)\n> +{\n> +\tswitch (type) {\n> +\tcase SM_UPDATE_CHECKOUT:\n> +\t\treturn \"checkout\";\n> +\tcase SM_UPDATE_MERGE:\n> +\t\treturn \"merge\";\n> +\tcase SM_UPDATE_REBASE:\n> +\t\treturn \"rebase\";\n> +\tcase SM_UPDATE_UNSPECIFIED:\n> +\tcase SM_UPDATE_NONE:\n> +\tcase SM_UPDATE_COMMAND:\n> +\t\tbreak;\n> +\t}\n> +\tBUG(\"unreachable with type %d\", type);\n> +}\n> +\n>  static void update_data_to_args(struct update_data *update_data, struct strvec *args)\n>  {\n>  \tstrvec_pushl(args, \"submodule--helper\", \"update\", \"--recursive\", NULL);\n> @@ -2583,6 +2600,7 @@ static int module_update(int argc, const char **argv, const char *prefix)\n>  \tstruct update_data opt = UPDATE_DATA_INIT;\n>  \tstruct list_objects_filter_options filter_options;\n>  \tint ret;\n> +\tenum submodule_update_type update_type = SM_UPDATE_UNSPECIFIED;\n>  \n>  \tstruct option module_update_options[] = {\n>  \t\tOPT__FORCE(&opt.force, N_(\"force checkout updates\"), 0),\n> @@ -2604,6 +2622,15 @@ static int module_update(int argc, const char **argv, const char *prefix)\n>  \t\tOPT_STRING(0, \"update\", &opt.update_default,\n>  \t\t\t   N_(\"string\"),\n>  \t\t\t   N_(\"rebase, merge, checkout or none\")),\n> +\t\tOPT_SET_INT(0, \"checkout\", &update_type,\n> +\t\t\tN_(\"use the 'checkout' update strategy (default)\"),\n> +\t\t\tSM_UPDATE_CHECKOUT),\n> +\t\tOPT_SET_INT('m', \"merge\", &update_type,\n> +\t\t\tN_(\"use the 'merge' update strategy\"),\n> +\t\t\tSM_UPDATE_MERGE),\n> +\t\tOPT_SET_INT('r', \"rebase\", &update_type,\n> +\t\t\tN_(\"use the 'rebase' update strategy\"),\n> +\t\t\tSM_UPDATE_REBASE),\n>  \t\tOPT_STRING_LIST(0, \"reference\", &opt.references, N_(\"repo\"),\n>  \t\t\t   N_(\"reference repository\")),\n>  \t\tOPT_BOOL(0, \"dissociate\", &opt.dissociate,\n> @@ -2653,6 +2680,9 @@ static int module_update(int argc, const char **argv, const char *prefix)\n> \n>   opt.filter_options = &filter_options;\n> \n> +\tif (update_type != SM_UPDATE_UNSPECIFIED)\n> +\t\topt.update_default = submodule_update_type_to_label(update_type);\n> +\n>   if (opt.update_default)\n>     if (parse_submodule_update_strategy(opt.update_default,\n>                 &opt.update_strategy) < 0)\n> diff --git a/git-submodule.sh b/git-submodule.sh\n> index 1c1dc320922..7fc7119fb21 100755\n> --- a/git-submodule.sh\n> +++ b/git-submodule.sh\n> @@ -40,7 +40,9 @@ require_init=\n>  files=\n>  remote=\n>  nofetch=\n> -update=\n> +rebase=\n> +merge=\n> +checkout=\n>  custom_name=\n>  depth=\n>  progress=\n> @@ -260,7 +262,7 @@ cmd_update()\n>       force=$1\n>       ;;\n>     -r|--rebase)\n> -\t\t\tupdate=\"rebase\"\n> +\t\t\trebase=1\n>       ;;\n>     --reference)\n>       case \"$2\" in '') usage ;; esac\n> @@ -274,13 +276,13 @@ cmd_update()\n>       dissociate=1\n>       ;;\n>     -m|--merge)\n> -\t\t\tupdate=\"merge\"\n> +\t\t\tmerge=1\n>       ;;\n>     --recursive)\n>       recursive=1\n>       ;;\n>     --checkout)\n> -\t\t\tupdate=\"checkout\"\n> +\t\t\tcheckout=1\n>       ;;\n>     --recommend-shallow)\n>       recommend_shallow=\"--recommend-shallow\"\n> @@ -341,7 +343,9 @@ cmd_update()\n>     ${init:+--init} \\\n>     ${nofetch:+--no-fetch} \\\n>     ${wt_prefix:+--prefix \"$wt_prefix\"} \\\n> -\t\t${update:+--update \"$update\"} \\\n> +\t\t${rebase:+--rebase} \\\n> +\t\t${merge:+--merge} \\\n> +\t\t${checkout:+--checkout} \\\n>     ${reference:+\"$reference\"} \\\n>     ${dissociate:+\"--dissociate\"} \\\n>     ${depth:+\"$depth\"} \\\n\nA small inelegance is that a user could theoretically pass both\n\"--update={checkout,rebase,merge}\" and \"--{checkout,rebase,merge}\",\nwhere one option ends of clobbering the other (Is it last one wins?).\n\nIdeally we'd check for this kind of invalid usage and die, but maybe\nit's not worth the effort since we fix this in the next patch already?\n\nThis wouldn't happen if we squashed 09-10/12 together like I initially\nsuggested, but then the patches would no longer be as obviously correct.\n\nNeither seems obviously better than the other, so I'm ok with this\neither way.\n"},{"id":"457738","messageId":"kl6lwnd8ikp0.fsf@chooglen-macbookpro.roam.corp.google.com","threadId":"57979","inReplyTo":"kl6lzgi4il0z.fsf@chooglen-macbookpro.roam.corp.google.com","subject":"Re: [PATCH v3 09/12] submodule--helper: understand --checkout, --merge and --rebase synonyms","fromName":"Glen Choo","fromEmail":"chooglen@google.com","sentAt":"2022-06-22T19:04:27Z","receivedAt":"2022-06-22T19:04:36Z","isPatch":true,"sender":{"key":"glencbz@gmail.com","avatar":"https://avatars.githubusercontent.com/u/58092771?v=4"},"body":"Glen Choo <chooglen@google.com> writes:\n\n> As you noted in your cover letter, this version of 09-10/12 is a lot\n> cleaner and more obviously correct.\n>\n> Ævar Arnfjörð Bjarmason <avarab@gmail.com> writes:\n>\n>> @@ -40,7 +40,9 @@ require_init=\n>>  files=\n>>  remote=\n>>  nofetch=\n>> -update=\n>> +rebase=\n>> +merge=\n>> +checkout=\n>>  custom_name=\n>>  depth=\n>>  progress=\n>> @@ -260,7 +262,7 @@ cmd_update()\n>>       force=$1\n>>       ;;\n>>     -r|--rebase)\n>> -\t\t\tupdate=\"rebase\"\n>> +\t\t\trebase=1\n>>       ;;\n>>     --reference)\n>>       case \"$2\" in '') usage ;; esac\n>> @@ -274,13 +276,13 @@ cmd_update()\n>>       dissociate=1\n>>       ;;\n>>     -m|--merge)\n>> -\t\t\tupdate=\"merge\"\n>> +\t\t\tmerge=1\n>>       ;;\n>>     --recursive)\n>>       recursive=1\n>>       ;;\n>>     --checkout)\n>> -\t\t\tupdate=\"checkout\"\n>> +\t\t\tcheckout=1\n>>       ;;\n>>     --recommend-shallow)\n>>       recommend_shallow=\"--recommend-shallow\"\n>> @@ -341,7 +343,9 @@ cmd_update()\n>>     ${init:+--init} \\\n>>     ${nofetch:+--no-fetch} \\\n>>     ${wt_prefix:+--prefix \"$wt_prefix\"} \\\n>> -\t\t${update:+--update \"$update\"} \\\n>> +\t\t${rebase:+--rebase} \\\n>> +\t\t${merge:+--merge} \\\n>> +\t\t${checkout:+--checkout} \\\n>>     ${reference:+\"$reference\"} \\\n>>     ${dissociate:+\"--dissociate\"} \\\n>>     ${depth:+\"$depth\"} \\\n>\n> A small inelegance is that a user could theoretically pass both\n> \"--update={checkout,rebase,merge}\" and \"--{checkout,rebase,merge}\",\n> where one option ends of clobbering the other (Is it last one wins?).\n>\n> Ideally we'd check for this kind of invalid usage and die, but maybe\n> it's not worth the effort since we fix this in the next patch already?\n>\n> This wouldn't happen if we squashed 09-10/12 together like I initially\n> suggested, but then the patches would no longer be as obviously correct.\n>\n> Neither seems obviously better than the other, so I'm ok with this\n> either way.\n\nScratch that, I got confused. A user can't invoke \"git submodule update\n--update=foo\" because that's not allowed by git-submodule.sh.\n\nSo this version doesn't actually introduce any user-facing oddity\nunless they're invoking \"git submodule--helper update\" (which they\nreally shouldn't, and we introduced it very recently anyway), and I\nthink this makes it better to keep these patches separate instead of\nsquashing them.\n"},{"id":"457755","messageId":"kl6ltu8ci7r5.fsf@chooglen-macbookpro.roam.corp.google.com","threadId":"57979","inReplyTo":"patch-v3-02.12-082e015781e-20220622T142012Z-avarab@gmail.com","subject":"Re: [PATCH v3 02/12] git-submodule.sh: remove unused $prefix var and --super-prefix","fromName":"Glen Choo","fromEmail":"chooglen@google.com","sentAt":"2022-06-22T23:43:58Z","receivedAt":"2022-06-22T23:44:12Z","isPatch":true,"sender":{"key":"glencbz@gmail.com","avatar":"https://avatars.githubusercontent.com/u/58092771?v=4"},"body":"\nÆvar Arnfjörð Bjarmason <avarab@gmail.com> writes:\n\n> Remove the $prefix variable which isn't used anymore, and hasn't been\n> since b3c5f5cb048 (submodule: move core cmd_update() logic to C,\n> 2022-03-15).\n>\n> Before that we'd use it to invoke \"git submodule--helper\" with the\n> \"--recursive-prefix\" option, but since b3c5f5cb048 that \"git\n> submodule--helper\" option is only used when it invokes itself.\n>\n> Since we haven't used it since then we haven't been passing the\n> --super-prefix option to \"git submodule--helper\", and can therefore\n> remove the handling of it from builtin/submodule--helper.c as well.\n>\n> Note also that the still-existing code in builtin/submodule--helper.c\n> to invoke other \"git submodule--helper\" processes with\n> \"--super-prefix\" is not passing the option to\n> \"cmd_submodule__helper()\", rather it's an argument to \"git\" itself.\n>\n> One way to verify that this is indeed dead code is to try to check out\n> b3c5f5cb048^ and apply this change to a part of the code being removed\n> here:\n>\n> \t-#define SUPPORT_SUPER_PREFIX (1<<0)\n> \t+#define SUPPORT_SUPER_PREFIX 0\n>\n> Doing that will cause t7406-submodule-update.sh to fail with errors\n> such as:\n>\n> \t-Submodule path '../super': checked out 'e1c658656b91df52a4634fbffeaa739807ce3521'\n> \t+Submodule path 'super': checked out 'e1c658656b91df52a4634fbffeaa739807ce3521'\n>\n> I.e. the removal of the --super-prefix handling broke those cases, but\n> when doing the same ad-hoc test with b3c5f5cb048 all of our tests will\n> pass, since the \"--super-prefix\" will now be handled by earlier by\n> \"git\" itself.\n\nYour finding is correct, but I just can't figure out why it is this way.\nNeither b3c5f5cb048 nor b3c5f5cb048^ make any use of \"--super-prefix\"\n(both use \"--recursive-prefix\"). And what's most puzzling to me is...\n\n> @@ -3402,15 +3399,9 @@ int cmd_submodule__helper(int argc, const char **argv, const char *prefix)\n>  \tif (argc < 2 || !strcmp(argv[1], \"-h\"))\n>  \t\tusage(\"git submodule--helper <command>\");\n>  \n> -\tfor (i = 0; i < ARRAY_SIZE(commands); i++) {\n> -\t\tif (!strcmp(argv[1], commands[i].cmd)) {\n> -\t\t\tif (get_super_prefix() &&\n> -\t\t\t    !(commands[i].option & SUPPORT_SUPER_PREFIX))\n> -\t\t\t\tdie(_(\"%s doesn't support --super-prefix\"),\n> -\t\t\t\t    commands[i].cmd);\n> +\tfor (i = 0; i < ARRAY_SIZE(commands); i++)\n> +\t\tif (!strcmp(argv[1], commands[i].cmd))\n>  \t\t\treturn commands[i].fn(argc - 1, argv + 1, prefix);\n> -\t\t}\n> -\t}\n>  \n>  \tdie(_(\"'%s' is not a valid submodule--helper \"\n>  \t      \"subcommand\"), argv[1]);\n\nthat all we do here is die() if we see \"--super-prefix\" but it is not\nsupported. I wouldn't expect that the printed result is different; I'd\nexpect git to die(). This isn't even an issue with SUPPORT_SUPER_PREFIX\neither - if we just had:\n\n\tif (get_super_prefix())\n\t\tdie(_(\"%s doesn't support --super-prefix\"),\n\t\t    commands[i].cmd);\n\nwe still see the same failure. At any rate, we don't seem to need\n\"--super-prefix\" any more, so I didn't look deeper into it.\n\nOne thing that I noticed (while trying to replace \"--recursive-prefix\"\nwith \"--super-prefix\" is that since this check checks the environment\nfor the super prefix and not the CLI option, it will complain if we do\n\"git --super-prefix=foo submodule unsupported-command\", and e.g. t7407\nwill fail if we add\n\n  -\t{\"foreach\", module_foreach, SUPPORT_SUPER_PREFIX},\n  +\t{\"foreach\", module_foreach, 0},\n\nI don't like this check but for another reason: the super prefix is set\nin a GIT_* environment variable so it gets passed to all child\nprocesses. So e.g. if we teach \"git submodule update\" to use\n\"--super-prefix\", we must mark module_update with SUPPORT_SUPER_PREFIX.\nBut because that invokes \"git submodule clone\", \"module_clone\" must also\nbe marked SUPPORT_SUPER_PREFIX.\n\nFrankly, I'm not sure why we need to check for SUPPORT_SUPER_PREFIX in\nthe \"git submodule--helper\" subcommand. I see that it was introduced in\n89c8626557 (submodule helper: support super prefix, 2016-12-08) as part\nof what eventually became absorbgitdirs, but I couldn't find any\ndiscussion of why we need this check when it was first proposed [1].\n\nI'm not 100% sure of why we need the top level check either, but as I\nunderstand it, it's a way of saying whether a command \"supports\nsubmodules\" or not [2]. If so, then checking whether a \"git\nsubmodule--helper\" command can recurse into submodules sounds like a\npointless exercise.\n\nI'm still all for deleting this because it really doesn't seem useful,\nbut I'd be lot more confident if someone knows why we have this to begin\nwith.\n\n[1] https://lore.kernel.org/git/20161122192235.6055-1-sbeller@google.com/\n[2] https://lore.kernel.org/git/1474930003-83750-2-git-send-email-bmwill@google.com/\n"},{"id":"457825","messageId":"kl6lh74aivc6.fsf@chooglen-macbookpro.roam.corp.google.com","threadId":"57979","inReplyTo":"cover-v3-00.12-00000000000-20220622T142012Z-avarab@gmail.com","subject":"Re: [PATCH v3 00/12] submodule: make \"git submodule--helper\" behave like \"git submodule\"","fromName":"Glen Choo","fromEmail":"chooglen@google.com","sentAt":"2022-06-24T03:39:05Z","receivedAt":"2022-06-24T03:39:51Z","isPatch":true,"sender":{"key":"glencbz@gmail.com","avatar":"https://avatars.githubusercontent.com/u/58092771?v=4"},"body":"Ævar Arnfjörð Bjarmason <avarab@gmail.com> writes:\n\n> These are preparatory changes to make \"git submodule--helper\"'s\n> behavior align with that of \"git submodule\". The next step after this\n> is to get rid of git-submodule.sh entirely, and make \"git submodule\" a\n> built-in.\n>\n> The last two patches here are post-cleanup of related submodule code\n> that isn't strictly necessary, but good to do. Similarly this starts\n> with the removal of some dead code in the area.\n>\n> The goal is to make these changes as small as possible, and as\n> obviously correct as possible. This will help to make the meaty\n> changes that follow easier to review.\n\nThanks for taking this up! I have some lingering confusion over the\nbehavior described in 02/12's commit message, but I am quite convinced\nthat 02/12 is good - the check that it removes is not needed for\ncorrectness and it doesn't make much sense as safeguard for developers\n[1].\n\nNearly everything else is very obviously correct, and I've\ndouble-checked most of the assertions in the commit messages as well. So\nI'm happy to give this my reviewed-by.\n\n  Reviewed-by: Glen Choo <chooglen@google.com>\n\n[1] https://lore.kernel.org/git/kl6ltu8ci7r5.fsf@chooglen-macbookpro.roam.corp.google.com\n"},{"id":"457848","messageId":"220624.86h74ahygt.gmgdl@evledraar.gmail.com","threadId":"57979","inReplyTo":"kl6ltu8ci7r5.fsf@chooglen-macbookpro.roam.corp.google.com","subject":"Re: [PATCH v3 02/12] git-submodule.sh: remove unused $prefix var and --super-prefix","fromName":"Ævar Arnfjörð Bjarmason","fromEmail":"avarab@gmail.com","sentAt":"2022-06-24T15:07:24Z","receivedAt":"2022-06-24T15:29:14Z","isPatch":true,"sender":{"key":"avarab@gmail.com","avatar":"https://avatars.githubusercontent.com/u/45301?v=4"},"body":"\nOn Wed, Jun 22 2022, Glen Choo wrote:\n\n> Ævar Arnfjörð Bjarmason <avarab@gmail.com> writes:\n>\n>> Remove the $prefix variable which isn't used anymore, and hasn't been\n>> since b3c5f5cb048 (submodule: move core cmd_update() logic to C,\n>> 2022-03-15).\n>>\n>> Before that we'd use it to invoke \"git submodule--helper\" with the\n>> \"--recursive-prefix\" option, but since b3c5f5cb048 that \"git\n>> submodule--helper\" option is only used when it invokes itself.\n>>\n>> Since we haven't used it since then we haven't been passing the\n>> --super-prefix option to \"git submodule--helper\", and can therefore\n>> remove the handling of it from builtin/submodule--helper.c as well.\n>>\n>> Note also that the still-existing code in builtin/submodule--helper.c\n>> to invoke other \"git submodule--helper\" processes with\n>> \"--super-prefix\" is not passing the option to\n>> \"cmd_submodule__helper()\", rather it's an argument to \"git\" itself.\n>>\n>> One way to verify that this is indeed dead code is to try to check out\n>> b3c5f5cb048^ and apply this change to a part of the code being removed\n>> here:\n>>\n>> \t-#define SUPPORT_SUPER_PREFIX (1<<0)\n>> \t+#define SUPPORT_SUPER_PREFIX 0\n>>\n>> Doing that will cause t7406-submodule-update.sh to fail with errors\n>> such as:\n>>\n>> \t-Submodule path '../super': checked out 'e1c658656b91df52a4634fbffeaa739807ce3521'\n>> \t+Submodule path 'super': checked out 'e1c658656b91df52a4634fbffeaa739807ce3521'\n>>\n>> I.e. the removal of the --super-prefix handling broke those cases, but\n>> when doing the same ad-hoc test with b3c5f5cb048 all of our tests will\n>> pass, since the \"--super-prefix\" will now be handled by earlier by\n>> \"git\" itself.\n>\n> Your finding is correct, but I just can't figure out why it is this way.\n> Neither b3c5f5cb048 nor b3c5f5cb048^ make any use of \"--super-prefix\"\n> (both use \"--recursive-prefix\"). And what's most puzzling to me is...\n>\n>> @@ -3402,15 +3399,9 @@ int cmd_submodule__helper(int argc, const char **argv, const char *prefix)\n>>  \tif (argc < 2 || !strcmp(argv[1], \"-h\"))\n>>  \t\tusage(\"git submodule--helper <command>\");\n>>  \n>> -\tfor (i = 0; i < ARRAY_SIZE(commands); i++) {\n>> -\t\tif (!strcmp(argv[1], commands[i].cmd)) {\n>> -\t\t\tif (get_super_prefix() &&\n>> -\t\t\t    !(commands[i].option & SUPPORT_SUPER_PREFIX))\n>> -\t\t\t\tdie(_(\"%s doesn't support --super-prefix\"),\n>> -\t\t\t\t    commands[i].cmd);\n>> +\tfor (i = 0; i < ARRAY_SIZE(commands); i++)\n>> +\t\tif (!strcmp(argv[1], commands[i].cmd))\n>>  \t\t\treturn commands[i].fn(argc - 1, argv + 1, prefix);\n>> -\t\t}\n>> -\t}\n>>  \n>>  \tdie(_(\"'%s' is not a valid submodule--helper \"\n>>  \t      \"subcommand\"), argv[1]);\n>\n> that all we do here is die() if we see \"--super-prefix\" but it is not\n> supported. I wouldn't expect that the printed result is different; I'd\n> expect git to die(). This isn't even an issue with SUPPORT_SUPER_PREFIX\n> either - if we just had:\n>\n> \tif (get_super_prefix())\n> \t\tdie(_(\"%s doesn't support --super-prefix\"),\n> \t\t    commands[i].cmd);\n>\n> we still see the same failure. At any rate, we don't seem to need\n> \"--super-prefix\" any more, so I didn't look deeper into it.\n>\n> One thing that I noticed (while trying to replace \"--recursive-prefix\"\n> with \"--super-prefix\" is that since this check checks the environment\n> for the super prefix and not the CLI option, it will complain if we do\n> \"git --super-prefix=foo submodule unsupported-command\", and e.g. t7407\n> will fail if we add\n>\n>   -\t{\"foreach\", module_foreach, SUPPORT_SUPER_PREFIX},\n>   +\t{\"foreach\", module_foreach, 0},\n>\n> I don't like this check but for another reason: the super prefix is set\n> in a GIT_* environment variable so it gets passed to all child\n> processes. So e.g. if we teach \"git submodule update\" to use\n> \"--super-prefix\", we must mark module_update with SUPPORT_SUPER_PREFIX.\n> But because that invokes \"git submodule clone\", \"module_clone\" must also\n> be marked SUPPORT_SUPER_PREFIX.\n>\n> Frankly, I'm not sure why we need to check for SUPPORT_SUPER_PREFIX in\n> the \"git submodule--helper\" subcommand. I see that it was introduced in\n> 89c8626557 (submodule helper: support super prefix, 2016-12-08) as part\n> of what eventually became absorbgitdirs, but I couldn't find any\n> discussion of why we need this check when it was first proposed [1].\n>\n> I'm not 100% sure of why we need the top level check either, but as I\n> understand it, it's a way of saying whether a command \"supports\n> submodules\" or not [2]. If so, then checking whether a \"git\n> submodule--helper\" command can recurse into submodules sounds like a\n> pointless exercise.\n>\n> I'm still all for deleting this because it really doesn't seem useful,\n> but I'd be lot more confident if someone knows why we have this to begin\n> with.\n>\n> [1] https://lore.kernel.org/git/20161122192235.6055-1-sbeller@google.com/\n> [2] https://lore.kernel.org/git/1474930003-83750-2-git-send-email-bmwill@google.com/\n\nI think I figured this out. I'm right about it being unnecessary, but\nthe explanation in the commit message is wrong.\n\nWhat threw me off the trail is that the series that included b3c5f5cb048\n(submodule: move core cmd_update() logic to C, 2022-03-15) has in\nintra-series regression, which is what you're seeing here.\n\nI.e. its parent 75df9df0f81 (submodule--helper: reduce logic in\nrun_update_procedure(), 2022-03-15) will fail with the above \"../super\"\nerror without that local change. You won't get the failure on its\nparent, c9911c9358e (submodule--helper: teach update_data more options,\n2022-03-15).\n\nI.e. 75df9df0f81 & b3c5f5cb048 should have been squashed, anyway.\n\nThe actual point *for that test* at which we could have deleted that\n\"define\" is 29a5e9e1ffe (submodule--helper update-clone: learn --init,\n2022-03-04), but other tests fail.\n\nThe actual point is this commit in this series, I'll dig some more,\nsorry about sending you down the wrong path. That digression was just\nabout chechking if we'd passed --super-prefix, which is changed in this\nsame commit...\n\nI'll dig some more and re-roll.\n"},{"id":"457855","messageId":"kl6ledzehusb.fsf@chooglen-macbookpro.roam.corp.google.com","threadId":"57979","inReplyTo":"220624.86h74ahygt.gmgdl@evledraar.gmail.com","subject":"Re: [PATCH v3 02/12] git-submodule.sh: remove unused $prefix var and --super-prefix","fromName":"Glen Choo","fromEmail":"chooglen@google.com","sentAt":"2022-06-24T16:48:36Z","receivedAt":"2022-06-24T16:48:42Z","isPatch":true,"sender":{"key":"glencbz@gmail.com","avatar":"https://avatars.githubusercontent.com/u/58092771?v=4"},"body":"Ævar Arnfjörð Bjarmason <avarab@gmail.com> writes:\n\n> On Wed, Jun 22 2022, Glen Choo wrote:\n>\n>> Ævar Arnfjörð Bjarmason <avarab@gmail.com> writes:\n>>\n>>> Remove the $prefix variable which isn't used anymore, and hasn't been\n>>> since b3c5f5cb048 (submodule: move core cmd_update() logic to C,\n>>> 2022-03-15).\n>>>\n>>> Before that we'd use it to invoke \"git submodule--helper\" with the\n>>> \"--recursive-prefix\" option, but since b3c5f5cb048 that \"git\n>>> submodule--helper\" option is only used when it invokes itself.\n>>>\n>>> Since we haven't used it since then we haven't been passing the\n>>> --super-prefix option to \"git submodule--helper\", and can therefore\n>>> remove the handling of it from builtin/submodule--helper.c as well.\n>>>\n>>> Note also that the still-existing code in builtin/submodule--helper.c\n>>> to invoke other \"git submodule--helper\" processes with\n>>> \"--super-prefix\" is not passing the option to\n>>> \"cmd_submodule__helper()\", rather it's an argument to \"git\" itself.\n>>>\n>>> One way to verify that this is indeed dead code is to try to check out\n>>> b3c5f5cb048^ and apply this change to a part of the code being removed\n>>> here:\n>>>\n>>> \t-#define SUPPORT_SUPER_PREFIX (1<<0)\n>>> \t+#define SUPPORT_SUPER_PREFIX 0\n>>>\n>>> Doing that will cause t7406-submodule-update.sh to fail with errors\n>>> such as:\n>>>\n>>> \t-Submodule path '../super': checked out 'e1c658656b91df52a4634fbffeaa739807ce3521'\n>>> \t+Submodule path 'super': checked out 'e1c658656b91df52a4634fbffeaa739807ce3521'\n>>>\n>>> I.e. the removal of the --super-prefix handling broke those cases, but\n>>> when doing the same ad-hoc test with b3c5f5cb048 all of our tests will\n>>> pass, since the \"--super-prefix\" will now be handled by earlier by\n>>> \"git\" itself.\n>>\n>> Your finding is correct, but I just can't figure out why it is this way.\n>> Neither b3c5f5cb048 nor b3c5f5cb048^ make any use of \"--super-prefix\"\n>> (both use \"--recursive-prefix\"). And what's most puzzling to me is...\n>>\n>>> @@ -3402,15 +3399,9 @@ int cmd_submodule__helper(int argc, const char **argv, const char *prefix)\n>>>  \tif (argc < 2 || !strcmp(argv[1], \"-h\"))\n>>>  \t\tusage(\"git submodule--helper <command>\");\n>>>  \n>>> -\tfor (i = 0; i < ARRAY_SIZE(commands); i++) {\n>>> -\t\tif (!strcmp(argv[1], commands[i].cmd)) {\n>>> -\t\t\tif (get_super_prefix() &&\n>>> -\t\t\t    !(commands[i].option & SUPPORT_SUPER_PREFIX))\n>>> -\t\t\t\tdie(_(\"%s doesn't support --super-prefix\"),\n>>> -\t\t\t\t    commands[i].cmd);\n>>> +\tfor (i = 0; i < ARRAY_SIZE(commands); i++)\n>>> +\t\tif (!strcmp(argv[1], commands[i].cmd))\n>>>  \t\t\treturn commands[i].fn(argc - 1, argv + 1, prefix);\n>>> -\t\t}\n>>> -\t}\n>>>  \n>>>  \tdie(_(\"'%s' is not a valid submodule--helper \"\n>>>  \t      \"subcommand\"), argv[1]);\n>>\n>> that all we do here is die() if we see \"--super-prefix\" but it is not\n>> supported. I wouldn't expect that the printed result is different; I'd\n>> expect git to die(). This isn't even an issue with SUPPORT_SUPER_PREFIX\n>> either - if we just had:\n>>\n>> \tif (get_super_prefix())\n>> \t\tdie(_(\"%s doesn't support --super-prefix\"),\n>> \t\t    commands[i].cmd);\n>>\n>> we still see the same failure. At any rate, we don't seem to need\n>> \"--super-prefix\" any more, so I didn't look deeper into it.\n>>\n>> One thing that I noticed (while trying to replace \"--recursive-prefix\"\n>> with \"--super-prefix\" is that since this check checks the environment\n>> for the super prefix and not the CLI option, it will complain if we do\n>> \"git --super-prefix=foo submodule unsupported-command\", and e.g. t7407\n>> will fail if we add\n>>\n>>   -\t{\"foreach\", module_foreach, SUPPORT_SUPER_PREFIX},\n>>   +\t{\"foreach\", module_foreach, 0},\n>>\n>> I don't like this check but for another reason: the super prefix is set\n>> in a GIT_* environment variable so it gets passed to all child\n>> processes. So e.g. if we teach \"git submodule update\" to use\n>> \"--super-prefix\", we must mark module_update with SUPPORT_SUPER_PREFIX.\n>> But because that invokes \"git submodule clone\", \"module_clone\" must also\n>> be marked SUPPORT_SUPER_PREFIX.\n>>\n>> Frankly, I'm not sure why we need to check for SUPPORT_SUPER_PREFIX in\n>> the \"git submodule--helper\" subcommand. I see that it was introduced in\n>> 89c8626557 (submodule helper: support super prefix, 2016-12-08) as part\n>> of what eventually became absorbgitdirs, but I couldn't find any\n>> discussion of why we need this check when it was first proposed [1].\n>>\n>> I'm not 100% sure of why we need the top level check either, but as I\n>> understand it, it's a way of saying whether a command \"supports\n>> submodules\" or not [2]. If so, then checking whether a \"git\n>> submodule--helper\" command can recurse into submodules sounds like a\n>> pointless exercise.\n>>\n>> I'm still all for deleting this because it really doesn't seem useful,\n>> but I'd be lot more confident if someone knows why we have this to begin\n>> with.\n>>\n>> [1] https://lore.kernel.org/git/20161122192235.6055-1-sbeller@google.com/\n>> [2] https://lore.kernel.org/git/1474930003-83750-2-git-send-email-bmwill@google.com/\n>\n> I think I figured this out. I'm right about it being unnecessary, but\n> the explanation in the commit message is wrong.\n>\n> What threw me off the trail is that the series that included b3c5f5cb048\n> (submodule: move core cmd_update() logic to C, 2022-03-15) has in\n> intra-series regression, which is what you're seeing here.\n>\n> I.e. its parent 75df9df0f81 (submodule--helper: reduce logic in\n> run_update_procedure(), 2022-03-15) will fail with the above \"../super\"\n> error without that local change. You won't get the failure on its\n> parent, c9911c9358e (submodule--helper: teach update_data more options,\n> 2022-03-15).\n>\n> I.e. 75df9df0f81 & b3c5f5cb048 should have been squashed, anyway.\n>\n> The actual point *for that test* at which we could have deleted that\n> \"define\" is 29a5e9e1ffe (submodule--helper update-clone: learn --init,\n> 2022-03-04), but other tests fail.\n>\n> The actual point is this commit in this series, I'll dig some more,\n> sorry about sending you down the wrong path. That digression was just\n> about chechking if we'd passed --super-prefix, which is changed in this\n> same commit...\n>\n> I'll dig some more and re-roll.\n\nAh that might explain some things. I'm still not sure how removing\nSUPPORT_SUPER_PREFIX gives the result we see here, but here are some\nobservations using the extra info I learned while converting\n\"--recursive-prefix\" -> \"--super-prefix\":\n\n- 29a5e9e1ffe and its parent teach init_submodule() how to use the\n  \"--recursive-prefix\" flag as a substitute for \"--super-prefix\".\n  \"--recursive-prefix\" is used exclusively by \"git submodule update\" and\n  does exactly the same thing as \"--super-prefix\".\n\n  Those commits pass \"--recursive-prefix\" to\n  do_get_submodule_displaypath(), which is an escape hatch to\n  get_submodule_displaypath() (which always uses \"--super-prefix\").\n\n- 75df9df0f81 introduced a regression because we now pass\n  update_data.prefix to get_submodule_displaypath() instead of prefix,\n  and update_data.prefix was never set (oops, that's my mistake). This\n  was rectified in its child (b3c5f5cb048), where we start to set\n  update_data.prefix when the two subcommands were combined.\n\n  As a sidenote, in 75df9df0f81's diff, we see that recursive_prefix is\n  used in conjunction with get_submodule_displaypath(), which means that\n  we could theoretically use *both* \"--recursive-prefix\" AND\n  \"--super-prefix\" at the same time. We don't do that though, because\n  \"--super-prefix\" was never used by \"git submodule update\".\n\n  (This prefixed_path stuff is going away when I convert\n  \"--recursive-prefix\" to \"--super-prefix\", so don't feel the need to\n  clean it up).\n"},{"id":"458007","messageId":"cover-v4-00.12-00000000000-20220628T095914Z-avarab@gmail.com","threadId":"57979","inReplyTo":"cover-v3-00.12-00000000000-20220622T142012Z-avarab@gmail.com","subject":"[PATCH v4 00/12] submodule: make \"git submodule--helper\" behave like \"git submodule\"","fromName":"Ævar Arnfjörð Bjarmason","fromEmail":"avarab@gmail.com","sentAt":"2022-06-28T10:05:22Z","receivedAt":"2022-06-28T10:06:13Z","isPatch":true,"sender":{"key":"avarab@gmail.com","avatar":"https://avatars.githubusercontent.com/u/45301?v=4"},"body":"These are preparatory changes to make \"git submodule--helper\"'s\nbehavior align with that of \"git submodule\". The next step after this\nis to get rid of git-submodule.sh entirely, and make \"git submodule\" a\nbuilt-in.\n\nThe last two patches here are post-cleanup of related submodule code\nthat isn't strictly necessary, but good to do. Similarly this starts\nwith the removal of some dead code in the area.\n\nThe goal is to make these changes as small as possible, and as\nobviously correct as possible. This will help to make the meaty\nchanges that follow easier to review.\n\nChanges since v3:\n\n * Leave the --super-prefix changes aside for now. As discussed in the\n   v3 follow-up, now we're only removing the unused $prefix variable.\n\n   Since the v2 was submitted Glen's submitted a series of his own. I\n   think any non-trivial updates to --super-prefix are better done\n   there, as noted in:\n   https://lore.kernel.org/git/220628.86wnd1f9t1.gmgdl@evledraar.gmail.com/\n\n   The overall diffstat is much smaller as a result, and I think this\n   series should be ready for \"next\" now, as the remaining changes are\n   well-revieweda at this point, with no outstanding issues.\n\nGlen Choo (1):\n  submodule--helper: eliminate internal \"--update\" option\n\nÆvar Arnfjörð Bjarmason (11):\n  git-submodule.sh: remove unused sanitize_submodule_env()\n  git-submodule.sh: remove unused $prefix variable\n  git-submodule.sh: make the \"$cached\" variable a boolean\n  git-submodule.sh: remove unused top-level \"--branch\" argument\n  submodule--helper: have --require-init imply --init\n  submodule update: remove \"-v\" option\n  submodule--helper: rename \"absorb-git-dirs\" to \"absorbgitdirs\"\n  submodule--helper: report \"submodule\" as our name in some \"-h\" output\n  submodule--helper: understand --checkout, --merge and --rebase\n    synonyms\n  git-submodule.sh: use \"$quiet\", not \"$GIT_QUIET\"\n  git-sh-setup.sh: remove \"say\" function, change last users\n\n builtin/submodule--helper.c    | 74 ++++++++++++++++++----------\n contrib/subtree/git-subtree.sh | 15 ++++--\n git-instaweb.sh                |  2 +-\n git-sh-setup.sh                | 16 -------\n git-submodule.sh               | 88 ++++++++++++----------------------\n submodule.c                    |  2 +-\n t/t7406-submodule-update.sh    |  2 +-\n 7 files changed, 96 insertions(+), 103 deletions(-)\n\nRange-diff against v3:\n 1:  ed487469d62 =  1:  63150b4091c git-submodule.sh: remove unused sanitize_submodule_env()\n 2:  082e015781e !  2:  7bf62497c54 git-submodule.sh: remove unused $prefix var and --super-prefix\n    @@ Metadata\n     Author: Ævar Arnfjörð Bjarmason <avarab@gmail.com>\n     \n      ## Commit message ##\n    -    git-submodule.sh: remove unused $prefix var and --super-prefix\n    +    git-submodule.sh: remove unused $prefix variable\n     \n         Remove the $prefix variable which isn't used anymore, and hasn't been\n         since b3c5f5cb048 (submodule: move core cmd_update() logic to C,\n    @@ Commit message\n         \"--recursive-prefix\" option, but since b3c5f5cb048 that \"git\n         submodule--helper\" option is only used when it invokes itself.\n     \n    -    Since we haven't used it since then we haven't been passing the\n    -    --super-prefix option to \"git submodule--helper\", and can therefore\n    -    remove the handling of it from builtin/submodule--helper.c as well.\n    -\n    -    Note also that the still-existing code in builtin/submodule--helper.c\n    -    to invoke other \"git submodule--helper\" processes with\n    -    \"--super-prefix\" is not passing the option to\n    -    \"cmd_submodule__helper()\", rather it's an argument to \"git\" itself.\n    -\n    -    One way to verify that this is indeed dead code is to try to check out\n    -    b3c5f5cb048^ and apply this change to a part of the code being removed\n    -    here:\n    -\n    -            -#define SUPPORT_SUPER_PREFIX (1<<0)\n    -            +#define SUPPORT_SUPER_PREFIX 0\n    -\n    -    Doing that will cause t7406-submodule-update.sh to fail with errors\n    -    such as:\n    -\n    -            -Submodule path '../super': checked out 'e1c658656b91df52a4634fbffeaa739807ce3521'\n    -            +Submodule path 'super': checked out 'e1c658656b91df52a4634fbffeaa739807ce3521'\n    -\n    -    I.e. the removal of the --super-prefix handling broke those cases, but\n    -    when doing the same ad-hoc test with b3c5f5cb048 all of our tests will\n    -    pass, since the \"--super-prefix\" will now be handled by earlier by\n    -    \"git\" itself.\n    -\n    -    So this is just one of the things that were overly complex in \"git\n    -    submodule--helper\", because parts of it had to bridge the gap between\n    -    *.sh and *.c land, but once we moved more parts to C we ended up\n    -    getting that for free.\n    +    So the \"--recursive-prefix\" option is still in use, but at this point\n    +    only when the helper invokes itself during submodule recursion. See\n    +    the \"--recursive-prefix\" option added in\n    +    c51f8f94e5b (submodule--helper: run update procedures from C,\n    +    2021-08-24).\n     \n         Signed-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>\n     \n    - ## builtin/submodule--helper.c ##\n    -@@ builtin/submodule--helper.c: static int module_add(int argc, const char **argv, const char *prefix)\n    - \treturn 0;\n    - }\n    - \n    --#define SUPPORT_SUPER_PREFIX (1<<0)\n    --\n    - struct cmd_struct {\n    - \tconst char *cmd;\n    - \tint (*fn)(int, const char **, const char *);\n    --\tunsigned option;\n    - };\n    - \n    - static struct cmd_struct commands[] = {\n    --\t{\"list\", module_list, 0},\n    --\t{\"name\", module_name, 0},\n    --\t{\"clone\", module_clone, 0},\n    --\t{\"add\", module_add, SUPPORT_SUPER_PREFIX},\n    --\t{\"update\", module_update, 0},\n    --\t{\"resolve-relative-url-test\", resolve_relative_url_test, 0},\n    --\t{\"foreach\", module_foreach, SUPPORT_SUPER_PREFIX},\n    --\t{\"init\", module_init, SUPPORT_SUPER_PREFIX},\n    --\t{\"status\", module_status, SUPPORT_SUPER_PREFIX},\n    --\t{\"sync\", module_sync, SUPPORT_SUPER_PREFIX},\n    --\t{\"deinit\", module_deinit, 0},\n    --\t{\"summary\", module_summary, SUPPORT_SUPER_PREFIX},\n    --\t{\"push-check\", push_check, 0},\n    --\t{\"absorb-git-dirs\", absorb_git_dirs, SUPPORT_SUPER_PREFIX},\n    --\t{\"is-active\", is_active, 0},\n    --\t{\"check-name\", check_name, 0},\n    --\t{\"config\", module_config, 0},\n    --\t{\"set-url\", module_set_url, 0},\n    --\t{\"set-branch\", module_set_branch, 0},\n    --\t{\"create-branch\", module_create_branch, 0},\n    -+\t{\"list\", module_list},\n    -+\t{\"name\", module_name},\n    -+\t{\"clone\", module_clone},\n    -+\t{\"add\", module_add},\n    -+\t{\"update\", module_update},\n    -+\t{\"resolve-relative-url-test\", resolve_relative_url_test},\n    -+\t{\"foreach\", module_foreach},\n    -+\t{\"init\", module_init},\n    -+\t{\"status\", module_status},\n    -+\t{\"sync\", module_sync},\n    -+\t{\"deinit\", module_deinit},\n    -+\t{\"summary\", module_summary},\n    -+\t{\"push-check\", push_check},\n    -+\t{\"absorb-git-dirs\", absorb_git_dirs},\n    -+\t{\"is-active\", is_active},\n    -+\t{\"check-name\", check_name},\n    -+\t{\"config\", module_config},\n    -+\t{\"set-url\", module_set_url},\n    -+\t{\"set-branch\", module_set_branch},\n    -+\t{\"create-branch\", module_create_branch},\n    - };\n    - \n    - int cmd_submodule__helper(int argc, const char **argv, const char *prefix)\n    -@@ builtin/submodule--helper.c: int cmd_submodule__helper(int argc, const char **argv, const char *prefix)\n    - \tif (argc < 2 || !strcmp(argv[1], \"-h\"))\n    - \t\tusage(\"git submodule--helper <command>\");\n    - \n    --\tfor (i = 0; i < ARRAY_SIZE(commands); i++) {\n    --\t\tif (!strcmp(argv[1], commands[i].cmd)) {\n    --\t\t\tif (get_super_prefix() &&\n    --\t\t\t    !(commands[i].option & SUPPORT_SUPER_PREFIX))\n    --\t\t\t\tdie(_(\"%s doesn't support --super-prefix\"),\n    --\t\t\t\t    commands[i].cmd);\n    -+\tfor (i = 0; i < ARRAY_SIZE(commands); i++)\n    -+\t\tif (!strcmp(argv[1], commands[i].cmd))\n    - \t\t\treturn commands[i].fn(argc - 1, argv + 1, prefix);\n    --\t\t}\n    --\t}\n    - \n    - \tdie(_(\"'%s' is not a valid submodule--helper \"\n    - \t      \"subcommand\"), argv[1]);\n    -\n      ## git-submodule.sh ##\n     @@ git-submodule.sh: files=\n      remote=\n 3:  3948aa5d782 =  3:  e4750f190f8 git-submodule.sh: make the \"$cached\" variable a boolean\n 4:  b5967afd59f =  4:  52d97fd4c36 git-submodule.sh: remove unused top-level \"--branch\" argument\n 5:  64e4aa41d21 =  5:  a4632f00a4a submodule--helper: have --require-init imply --init\n 6:  b82faad77bb =  6:  ad5aad8fed7 submodule update: remove \"-v\" option\n 7:  ff557f3c81a !  7:  9c8a102acc0 submodule--helper: rename \"absorb-git-dirs\" to \"absorbgitdirs\"\n    @@ builtin/submodule--helper.c: static int absorb_git_dirs(int argc, const char **a\n      \t};\n      \n     @@ builtin/submodule--helper.c: static struct cmd_struct commands[] = {\n    - \t{\"deinit\", module_deinit},\n    - \t{\"summary\", module_summary},\n    - \t{\"push-check\", push_check},\n    --\t{\"absorb-git-dirs\", absorb_git_dirs},\n    -+\t{\"absorbgitdirs\", absorb_git_dirs},\n    - \t{\"is-active\", is_active},\n    - \t{\"check-name\", check_name},\n    - \t{\"config\", module_config},\n    + \t{\"deinit\", module_deinit, 0},\n    + \t{\"summary\", module_summary, SUPPORT_SUPER_PREFIX},\n    + \t{\"push-check\", push_check, 0},\n    +-\t{\"absorb-git-dirs\", absorb_git_dirs, SUPPORT_SUPER_PREFIX},\n    ++\t{\"absorbgitdirs\", absorb_git_dirs, SUPPORT_SUPER_PREFIX},\n    + \t{\"is-active\", is_active, 0},\n    + \t{\"check-name\", check_name, 0},\n    + \t{\"config\", module_config, 0},\n     \n      ## git-submodule.sh ##\n     @@ git-submodule.sh: cmd_sync()\n 8:  bb1310b9abe =  8:  b8a9b085633 submodule--helper: report \"submodule\" as our name in some \"-h\" output\n 9:  e251fc115e1 =  9:  e8ddb95dcbf submodule--helper: understand --checkout, --merge and --rebase synonyms\n10:  66a229227a1 = 10:  abb5cb499aa submodule--helper: eliminate internal \"--update\" option\n11:  f8219cd461d = 11:  c7eac40a0f2 git-submodule.sh: use \"$quiet\", not \"$GIT_QUIET\"\n12:  ecdd8c6ed28 = 12:  f8f332f3c0a git-sh-setup.sh: remove \"say\" function, change last users\n-- \n2.37.0.880.gf07d56b18ba\n\n"},{"id":"458008","messageId":"patch-v4-01.12-63150b4091c-20220628T095914Z-avarab@gmail.com","threadId":"57979","inReplyTo":"cover-v4-00.12-00000000000-20220628T095914Z-avarab@gmail.com","subject":"[PATCH v4 01/12] git-submodule.sh: remove unused sanitize_submodule_env()","fromName":"Ævar Arnfjörð Bjarmason","fromEmail":"avarab@gmail.com","sentAt":"2022-06-28T10:05:23Z","receivedAt":"2022-06-28T10:06:16Z","isPatch":true,"sender":{"key":"avarab@gmail.com","avatar":"https://avatars.githubusercontent.com/u/45301?v=4"},"body":"The sanitize_submodule_env() function was last used before\nb3c5f5cb048 (submodule: move core cmd_update() logic to C,\n2022-03-15), let's remove it.\n\nThis also allows us to remove clear_local_git_env() from\ngit-sh-setup.sh. That function hasn't been documented in\nDocumentation/git-sh-setup.sh, and since 14111fc4927 (git: submodule\nhonor -c credential.* from command line, 2016-02-29) it had only been\nused in the sanitize_submodule_env() function being removed here.\n\nSigned-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>\n---\n git-sh-setup.sh  |  7 -------\n git-submodule.sh | 11 -----------\n 2 files changed, 18 deletions(-)\n\ndiff --git a/git-sh-setup.sh b/git-sh-setup.sh\nindex d92df37e992..ecb60d9e3cb 100644\n--- a/git-sh-setup.sh\n+++ b/git-sh-setup.sh\n@@ -285,13 +285,6 @@ get_author_ident_from_commit () {\n \tparse_ident_from_commit author AUTHOR\n }\n \n-# Clear repo-local GIT_* environment variables. Useful when switching to\n-# another repository (e.g. when entering a submodule). See also the env\n-# list in git_connect()\n-clear_local_git_env() {\n-\tunset $(git rev-parse --local-env-vars)\n-}\n-\n # Generate a virtual base file for a two-file merge. Uses git apply to\n # remove lines from $1 that are not in $2, leaving only common lines.\n create_virtual_base() {\ndiff --git a/git-submodule.sh b/git-submodule.sh\nindex fd0b4a2c947..bc436c4ca47 100755\n--- a/git-submodule.sh\n+++ b/git-submodule.sh\n@@ -56,17 +56,6 @@ isnumber()\n \tn=$(($1 + 0)) 2>/dev/null && test \"$n\" = \"$1\"\n }\n \n-# Sanitize the local git environment for use within a submodule. We\n-# can't simply use clear_local_git_env since we want to preserve some\n-# of the settings from GIT_CONFIG_PARAMETERS.\n-sanitize_submodule_env()\n-{\n-\tsave_config=$GIT_CONFIG_PARAMETERS\n-\tclear_local_git_env\n-\tGIT_CONFIG_PARAMETERS=$save_config\n-\texport GIT_CONFIG_PARAMETERS\n-}\n-\n #\n # Add a new submodule to the working tree, .gitmodules and the index\n #\n-- \n2.37.0.880.gf07d56b18ba\n\n"},{"id":"458009","messageId":"patch-v4-02.12-7bf62497c54-20220628T095914Z-avarab@gmail.com","threadId":"57979","inReplyTo":"cover-v4-00.12-00000000000-20220628T095914Z-avarab@gmail.com","subject":"[PATCH v4 02/12] git-submodule.sh: remove unused $prefix variable","fromName":"Ævar Arnfjörð Bjarmason","fromEmail":"avarab@gmail.com","sentAt":"2022-06-28T10:05:24Z","receivedAt":"2022-06-28T10:06:18Z","isPatch":true,"sender":{"key":"avarab@gmail.com","avatar":"https://avatars.githubusercontent.com/u/45301?v=4"},"body":"Remove the $prefix variable which isn't used anymore, and hasn't been\nsince b3c5f5cb048 (submodule: move core cmd_update() logic to C,\n2022-03-15).\n\nBefore that we'd use it to invoke \"git submodule--helper\" with the\n\"--recursive-prefix\" option, but since b3c5f5cb048 that \"git\nsubmodule--helper\" option is only used when it invokes itself.\n\nSo the \"--recursive-prefix\" option is still in use, but at this point\nonly when the helper invokes itself during submodule recursion. See\nthe \"--recursive-prefix\" option added in\nc51f8f94e5b (submodule--helper: run update procedures from C,\n2021-08-24).\n\nSigned-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>\n---\n git-submodule.sh | 6 ++----\n 1 file changed, 2 insertions(+), 4 deletions(-)\n\ndiff --git a/git-submodule.sh b/git-submodule.sh\nindex bc436c4ca47..53847bbf6e2 100755\n--- a/git-submodule.sh\n+++ b/git-submodule.sh\n@@ -41,7 +41,6 @@ files=\n remote=\n nofetch=\n update=\n-prefix=\n custom_name=\n depth=\n progress=\n@@ -127,7 +126,7 @@ cmd_add()\n \t\tusage\n \tfi\n \n-\tgit ${wt_prefix:+-C \"$wt_prefix\"} ${prefix:+--super-prefix \"$prefix\"} submodule--helper add ${GIT_QUIET:+--quiet} ${force:+--force} ${progress:+\"--progress\"} ${branch:+--branch \"$branch\"} ${reference_path:+--reference \"$reference_path\"} ${dissociate:+--dissociate} ${custom_name:+--name \"$custom_name\"} ${depth:+\"$depth\"} -- \"$@\"\n+\tgit ${wt_prefix:+-C \"$wt_prefix\"} submodule--helper add ${GIT_QUIET:+--quiet} ${force:+--force} ${progress:+\"--progress\"} ${branch:+--branch \"$branch\"} ${reference_path:+--reference \"$reference_path\"} ${dissociate:+--dissociate} ${custom_name:+--name \"$custom_name\"} ${depth:+\"$depth\"} -- \"$@\"\n }\n \n #\n@@ -189,7 +188,7 @@ cmd_init()\n \t\tshift\n \tdone\n \n-\tgit ${wt_prefix:+-C \"$wt_prefix\"} ${prefix:+--super-prefix \"$prefix\"} submodule--helper init ${GIT_QUIET:+--quiet} -- \"$@\"\n+\tgit ${wt_prefix:+-C \"$wt_prefix\"} submodule--helper init ${GIT_QUIET:+--quiet} -- \"$@\"\n }\n \n #\n@@ -346,7 +345,6 @@ cmd_update()\n \t\t${init:+--init} \\\n \t\t${nofetch:+--no-fetch} \\\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${dissociate:+\"--dissociate\"} \\\n-- \n2.37.0.880.gf07d56b18ba\n\n"},{"id":"458010","messageId":"patch-v4-03.12-e4750f190f8-20220628T095914Z-avarab@gmail.com","threadId":"57979","inReplyTo":"cover-v4-00.12-00000000000-20220628T095914Z-avarab@gmail.com","subject":"[PATCH v4 03/12] git-submodule.sh: make the \"$cached\" variable a boolean","fromName":"Ævar Arnfjörð Bjarmason","fromEmail":"avarab@gmail.com","sentAt":"2022-06-28T10:05:25Z","receivedAt":"2022-06-28T10:06:30Z","isPatch":true,"sender":{"key":"avarab@gmail.com","avatar":"https://avatars.githubusercontent.com/u/45301?v=4"},"body":"Remove the assignment of \"$1\" to the \"$cached\" variable. As seen in\nthe initial implementation in 70c7ac22de6 (Add git-submodule command,\n2007-05-26) we only need to keep track of if we've seen the --cached\noption, not save the \"--cached\" string for later use.\n\nIn 28f9af5d25e (git-submodule summary: code framework, 2008-03-11)\n\"$1\" was assigned to it, but since there was no reason to do so let's\nstop doing it. This trivial change will make it easier to reason about\nan eventual change that'll remove the cmd_summary() function in favor\nof dispatching to \"git submodule--helper summary\" directly.\n\nSigned-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>\n---\n git-submodule.sh | 4 ++--\n 1 file changed, 2 insertions(+), 2 deletions(-)\n\ndiff --git a/git-submodule.sh b/git-submodule.sh\nindex 53847bbf6e2..b99a00d9f84 100755\n--- a/git-submodule.sh\n+++ b/git-submodule.sh\n@@ -446,7 +446,7 @@ cmd_summary() {\n \tdo\n \t\tcase \"$1\" in\n \t\t--cached)\n-\t\t\tcached=\"$1\"\n+\t\t\tcached=1\n \t\t\t;;\n \t\t--files)\n \t\t\tfiles=\"$1\"\n@@ -583,7 +583,7 @@ do\n \t\tbranch=\"$2\"; shift\n \t\t;;\n \t--cached)\n-\t\tcached=\"$1\"\n+\t\tcached=1\n \t\t;;\n \t--)\n \t\tbreak\n-- \n2.37.0.880.gf07d56b18ba\n\n"},{"id":"458011","messageId":"patch-v4-08.12-b8a9b085633-20220628T095914Z-avarab@gmail.com","threadId":"57979","inReplyTo":"cover-v4-00.12-00000000000-20220628T095914Z-avarab@gmail.com","subject":"[PATCH v4 08/12] submodule--helper: report \"submodule\" as our name in some \"-h\" output","fromName":"Ævar Arnfjörð Bjarmason","fromEmail":"avarab@gmail.com","sentAt":"2022-06-28T10:05:30Z","receivedAt":"2022-06-28T10:06:31Z","isPatch":true,"sender":{"key":"avarab@gmail.com","avatar":"https://avatars.githubusercontent.com/u/45301?v=4"},"body":"Change the user-facing \"git submodule--helper\" commands so that\nthey'll report their name as being \"git submodule\". To a user these\ncommands are internal implementation details, and it doesn't make\nsense to emit usage about an internal helper when \"git submodule\" is\ninvoked with invalid options.\n\nBefore this we'd emit e.g.:\n\n\t$ git submodule absorbgitdirs --blah\n\terror: unknown option `blah'\n\tusage: git submodule--helper absorbgitdirs [<options>] [<path>...]\n\t[...]\nAnd:\n\n\t$ git submodule set-url -- --\n\tusage: git submodule--helper set-url [--quiet] <path> <newurl>\n\t[...]\n\nNow we'll start with \"usage: git submodule [...]\" in both of those\ncases. This change does not alter the \"list\", \"name\", \"clone\",\n\"config\" and \"create-branch\" commands, those are internal-only (as an\naside; their usage info should probably invoke BUG(...)). This only\nchanges the user-facing commands.\n\nThe \"status\", \"deinit\" and \"update\" commands are not included in this\nchange, because their usage information already used \"submodule\"\nrather than \"submodule--helper\".\n\nI don't think it's currently possible to emit some of this usage\ninformation in practice, as git-submodule.sh will catch unknown\noptions, and e.g. it doesn't seem to be possible to get \"add\" to emit\nits usage information from \"submodule--helper\".\n\nThough that change may be superfluous now, it's also harmless, and\nwill allow us to eventually dispatch further into \"git\nsubmodule--helper\" from git-submodule.sh, while emitting the correct\nusage output.\n\nSigned-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>\n---\n builtin/submodule--helper.c | 18 +++++++++---------\n 1 file changed, 9 insertions(+), 9 deletions(-)\n\ndiff --git a/builtin/submodule--helper.c b/builtin/submodule--helper.c\nindex 10223a00927..d145d53addd 100644\n--- a/builtin/submodule--helper.c\n+++ b/builtin/submodule--helper.c\n@@ -444,7 +444,7 @@ static int module_foreach(int argc, const char **argv, const char *prefix)\n \t};\n \n \tconst char *const git_submodule_helper_usage[] = {\n-\t\tN_(\"git submodule--helper foreach [--quiet] [--recursive] [--] <command>\"),\n+\t\tN_(\"git submodule foreach [--quiet] [--recursive] [--] <command>\"),\n \t\tNULL\n \t};\n \n@@ -582,7 +582,7 @@ static int module_init(int argc, const char **argv, const char *prefix)\n \t};\n \n \tconst char *const git_submodule_helper_usage[] = {\n-\t\tN_(\"git submodule--helper init [<options>] [<path>]\"),\n+\t\tN_(\"git submodule init [<options>] [<path>]\"),\n \t\tNULL\n \t};\n \n@@ -1185,7 +1185,7 @@ static int module_summary(int argc, const char **argv, const char *prefix)\n \t};\n \n \tconst char *const git_submodule_helper_usage[] = {\n-\t\tN_(\"git submodule--helper summary [<options>] [<commit>] [--] [<path>]\"),\n+\t\tN_(\"git submodule summary [<options>] [<commit>] [--] [<path>]\"),\n \t\tNULL\n \t};\n \n@@ -1349,7 +1349,7 @@ static int module_sync(int argc, const char **argv, const char *prefix)\n \t};\n \n \tconst char *const git_submodule_helper_usage[] = {\n-\t\tN_(\"git submodule--helper sync [--quiet] [--recursive] [<path>]\"),\n+\t\tN_(\"git submodule sync [--quiet] [--recursive] [<path>]\"),\n \t\tNULL\n \t};\n \n@@ -2788,7 +2788,7 @@ static int absorb_git_dirs(int argc, const char **argv, const char *prefix)\n \t};\n \n \tconst char *const git_submodule_helper_usage[] = {\n-\t\tN_(\"git submodule--helper absorbgitdirs [<options>] [<path>...]\"),\n+\t\tN_(\"git submodule absorbgitdirs [<options>] [<path>...]\"),\n \t\tNULL\n \t};\n \n@@ -2893,7 +2893,7 @@ static int module_set_url(int argc, const char **argv, const char *prefix)\n \t\tOPT_END()\n \t};\n \tconst char *const usage[] = {\n-\t\tN_(\"git submodule--helper set-url [--quiet] <path> <newurl>\"),\n+\t\tN_(\"git submodule set-url [--quiet] <path> <newurl>\"),\n \t\tNULL\n \t};\n \n@@ -2932,8 +2932,8 @@ static int module_set_branch(int argc, const char **argv, const char *prefix)\n \t\tOPT_END()\n \t};\n \tconst char *const usage[] = {\n-\t\tN_(\"git submodule--helper set-branch [-q|--quiet] (-d|--default) <path>\"),\n-\t\tN_(\"git submodule--helper set-branch [-q|--quiet] (-b|--branch) <branch> <path>\"),\n+\t\tN_(\"git submodule set-branch [-q|--quiet] (-d|--default) <path>\"),\n+\t\tN_(\"git submodule set-branch [-q|--quiet] (-b|--branch) <branch> <path>\"),\n \t\tNULL\n \t};\n \n@@ -3277,7 +3277,7 @@ static int module_add(int argc, const char **argv, const char *prefix)\n \t};\n \n \tconst char *const usage[] = {\n-\t\tN_(\"git submodule--helper add [<options>] [--] <repository> [<path>]\"),\n+\t\tN_(\"git submodule add [<options>] [--] <repository> [<path>]\"),\n \t\tNULL\n \t};\n \n-- \n2.37.0.880.gf07d56b18ba\n\n"},{"id":"458012","messageId":"patch-v4-07.12-9c8a102acc0-20220628T095914Z-avarab@gmail.com","threadId":"57979","inReplyTo":"cover-v4-00.12-00000000000-20220628T095914Z-avarab@gmail.com","subject":"[PATCH v4 07/12] submodule--helper: rename \"absorb-git-dirs\" to \"absorbgitdirs\"","fromName":"Ævar Arnfjörð Bjarmason","fromEmail":"avarab@gmail.com","sentAt":"2022-06-28T10:05:29Z","receivedAt":"2022-06-28T10:06:33Z","isPatch":true,"sender":{"key":"avarab@gmail.com","avatar":"https://avatars.githubusercontent.com/u/45301?v=4"},"body":"Rename the \"absorb-git-dirs\" subcommand to \"absorbgitdirs\", which is\nwhat the \"git submodule\" command itself has called it since the\nsubcommand was implemented in f6f85861400 (submodule: add\nabsorb-git-dir function, 2016-12-12).\n\nHaving these two be different will make it more tedious to dispatch to\neventually dispatch \"git submodule--helper\" directly, as we'd need to\nretain this name mapping. So let's get rid of this needless\ninconsistency.\n\nSigned-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>\n---\n builtin/submodule--helper.c | 4 ++--\n git-submodule.sh            | 2 +-\n submodule.c                 | 2 +-\n 3 files changed, 4 insertions(+), 4 deletions(-)\n\ndiff --git a/builtin/submodule--helper.c b/builtin/submodule--helper.c\nindex 0fab3a52e88..10223a00927 100644\n--- a/builtin/submodule--helper.c\n+++ b/builtin/submodule--helper.c\n@@ -2788,7 +2788,7 @@ static int absorb_git_dirs(int argc, const char **argv, const char *prefix)\n \t};\n \n \tconst char *const git_submodule_helper_usage[] = {\n-\t\tN_(\"git submodule--helper absorb-git-dirs [<options>] [<path>...]\"),\n+\t\tN_(\"git submodule--helper absorbgitdirs [<options>] [<path>...]\"),\n \t\tNULL\n \t};\n \n@@ -3390,7 +3390,7 @@ static struct cmd_struct commands[] = {\n \t{\"deinit\", module_deinit, 0},\n \t{\"summary\", module_summary, SUPPORT_SUPER_PREFIX},\n \t{\"push-check\", push_check, 0},\n-\t{\"absorb-git-dirs\", absorb_git_dirs, SUPPORT_SUPER_PREFIX},\n+\t{\"absorbgitdirs\", absorb_git_dirs, SUPPORT_SUPER_PREFIX},\n \t{\"is-active\", is_active, 0},\n \t{\"check-name\", check_name, 0},\n \t{\"config\", module_config, 0},\ndiff --git a/git-submodule.sh b/git-submodule.sh\nindex 0df6b0fc974..1c1dc320922 100755\n--- a/git-submodule.sh\n+++ b/git-submodule.sh\n@@ -552,7 +552,7 @@ cmd_sync()\n \n cmd_absorbgitdirs()\n {\n-\tgit submodule--helper absorb-git-dirs --prefix \"$wt_prefix\" \"$@\"\n+\tgit submodule--helper absorbgitdirs --prefix \"$wt_prefix\" \"$@\"\n }\n \n # This loop parses the command line arguments to find the\ndiff --git a/submodule.c b/submodule.c\nindex 4e299f578f9..2af16c647d5 100644\n--- a/submodule.c\n+++ b/submodule.c\n@@ -2374,7 +2374,7 @@ void absorb_git_dir_into_superproject(const char *path,\n \t\tcp.no_stdin = 1;\n \t\tstrvec_pushl(&cp.args, \"--super-prefix\", sb.buf,\n \t\t\t     \"submodule--helper\",\n-\t\t\t     \"absorb-git-dirs\", NULL);\n+\t\t\t     \"absorbgitdirs\", NULL);\n \t\tprepare_submodule_repo_env(&cp.env);\n \t\tif (run_command(&cp))\n \t\t\tdie(_(\"could not recurse into submodule '%s'\"), path);\n-- \n2.37.0.880.gf07d56b18ba\n\n"},{"id":"458013","messageId":"patch-v4-06.12-ad5aad8fed7-20220628T095914Z-avarab@gmail.com","threadId":"57979","inReplyTo":"cover-v4-00.12-00000000000-20220628T095914Z-avarab@gmail.com","subject":"[PATCH v4 06/12] submodule update: remove \"-v\" option","fromName":"Ævar Arnfjörð Bjarmason","fromEmail":"avarab@gmail.com","sentAt":"2022-06-28T10:05:28Z","receivedAt":"2022-06-28T10:06:35Z","isPatch":true,"sender":{"key":"avarab@gmail.com","avatar":"https://avatars.githubusercontent.com/u/45301?v=4"},"body":"In e84c3cf3dc3 (git-submodule.sh: accept verbose flag in cmd_update to\nbe non-quiet, 2018-08-14) the \"git submodule update\" sub-command was\nmade to understand \"-v\", but the option was never documented.\n\nThe only in-tree user has been this test added in\n3ad0401e9e6 (submodule update: silence underlying merge/rebase with\n\"--quiet\", 2020-09-30), it wasn't per-se testing --quiet, but fixing a\nbug in e84c3cf3dc3: It used to set \"GIT_QUIET=0\" instead of unsetting\nit on \"-v\", and thus we'd end up passing \"--quiet\" to \"git\nsubmodule--helper\" on \"-v\", since the \"--quiet\" option was passed\nusing the ${parameter:+word} construct.\n\nFurthermore, even if someone had used the \"-v\" option they'd only be\ngetting the default output. Our default in both git-submodule.sh and\n\"git submodule--helper\" has been to be \"verbose\", so the only way this\noption could have matter is if it were used as e.g.:\n\n    git submodule --quiet update -v [...]\n\nI.e. to undo the effect of a previous \"--quiet\" on the command-line.\n\nSigned-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>\n---\n git-submodule.sh            | 3 ---\n t/t7406-submodule-update.sh | 2 +-\n 2 files changed, 1 insertion(+), 4 deletions(-)\n\ndiff --git a/git-submodule.sh b/git-submodule.sh\nindex 5b9683bf766..0df6b0fc974 100755\n--- a/git-submodule.sh\n+++ b/git-submodule.sh\n@@ -241,9 +241,6 @@ cmd_update()\n \t\t-q|--quiet)\n \t\t\tGIT_QUIET=1\n \t\t\t;;\n-\t\t-v)\n-\t\t\tunset GIT_QUIET\n-\t\t\t;;\n \t\t--progress)\n \t\t\tprogress=1\n \t\t\t;;\ndiff --git a/t/t7406-submodule-update.sh b/t/t7406-submodule-update.sh\nindex 43f779d751c..06d804e2131 100755\n--- a/t/t7406-submodule-update.sh\n+++ b/t/t7406-submodule-update.sh\n@@ -1074,7 +1074,7 @@ test_expect_success 'submodule update --quiet passes quietness to merge/rebase'\n \t git submodule update --rebase --quiet >out 2>err &&\n \t test_must_be_empty out &&\n \t test_must_be_empty err &&\n-\t git submodule update --rebase -v >out 2>err &&\n+\t git submodule update --rebase >out 2>err &&\n \t test_file_not_empty out &&\n \t test_must_be_empty err\n \t)\n-- \n2.37.0.880.gf07d56b18ba\n\n"},{"id":"458014","messageId":"patch-v4-12.12-f8f332f3c0a-20220628T095914Z-avarab@gmail.com","threadId":"57979","inReplyTo":"cover-v4-00.12-00000000000-20220628T095914Z-avarab@gmail.com","subject":"[PATCH v4 12/12] git-sh-setup.sh: remove \"say\" function, change last users","fromName":"Ævar Arnfjörð Bjarmason","fromEmail":"avarab@gmail.com","sentAt":"2022-06-28T10:05:34Z","receivedAt":"2022-06-28T10:06:36Z","isPatch":true,"sender":{"key":"avarab@gmail.com","avatar":"https://avatars.githubusercontent.com/u/45301?v=4"},"body":"Remove the \"say\" function, with various rewrites of the remaining\ngit-*.sh code to C and the preceding change to have git-submodule.sh\nstop using the GIT_QUIET variable there were only four uses in\ngit-subtree.sh. Let's have it use an \"arg_quiet\" variable instead, and\nmove the \"say\" function over to it.\n\nThe only other use was a trivial message in git-instaweb.sh, since it\nhas never supported the --quiet option (or similar) that code added in\n0b624b4ceee (instaweb: restart server if already running, 2009-11-22)\ncan simply use \"echo\" instead.\n\nThe remaining in-tree hits from \"say\" are all for the sibling function\ndefined in t/test-lib.sh. It's safe to remove this function since it\nhas never been documented in Documentation/git-sh-setup.txt.\n\nSigned-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>\n---\n contrib/subtree/git-subtree.sh | 15 ++++++++++++---\n git-instaweb.sh                |  2 +-\n git-sh-setup.sh                |  9 ---------\n 3 files changed, 13 insertions(+), 13 deletions(-)\n\ndiff --git a/contrib/subtree/git-subtree.sh b/contrib/subtree/git-subtree.sh\nindex 1af1d9653e9..7562a395c24 100755\n--- a/contrib/subtree/git-subtree.sh\n+++ b/contrib/subtree/git-subtree.sh\n@@ -50,6 +50,14 @@ m,message=    use the given message as the commit message for the merge commit\n \n indent=0\n \n+# Usage: say [MSG...]\n+say () {\n+\tif test -z \"$arg_quiet\"\n+\tthen\n+\t\tprintf '%s\\n' \"$*\"\n+\tfi\n+}\n+\n # Usage: debug [MSG...]\n debug () {\n \tif test -n \"$arg_debug\"\n@@ -60,7 +68,7 @@ debug () {\n \n # Usage: progress [MSG...]\n progress () {\n-\tif test -z \"$GIT_QUIET\"\n+\tif test -z \"$arg_quiet\"\n \tthen\n \t\tif test -z \"$arg_debug\"\n \t\tthen\n@@ -146,6 +154,7 @@ main () {\n \teval \"$set_args\"\n \n \t# Begin \"real\" flag parsing.\n+\targ_quiet=\n \targ_debug=\n \targ_prefix=\n \targ_split_branch=\n@@ -161,7 +170,7 @@ main () {\n \n \t\tcase \"$opt\" in\n \t\t-q)\n-\t\t\tGIT_QUIET=1\n+\t\t\targ_quiet=1\n \t\t\t;;\n \t\t-d)\n \t\t\targ_debug=1\n@@ -252,7 +261,7 @@ main () {\n \tdir=\"$(dirname \"$arg_prefix/.\")\"\n \n \tdebug \"command: {$arg_command}\"\n-\tdebug \"quiet: {$GIT_QUIET}\"\n+\tdebug \"quiet: {$arg_quiet}\"\n \tdebug \"dir: {$dir}\"\n \tdebug \"opts: {$*}\"\n \tdebug\ndiff --git a/git-instaweb.sh b/git-instaweb.sh\nindex 4349566c891..c68f49454cd 100755\n--- a/git-instaweb.sh\n+++ b/git-instaweb.sh\n@@ -102,7 +102,7 @@ resolve_full_httpd () {\n \n start_httpd () {\n \tif test -f \"$fqgitdir/pid\"; then\n-\t\tsay \"Instance already running. Restarting...\"\n+\t\techo \"Instance already running. Restarting...\"\n \t\tstop_httpd\n \tfi\n \ndiff --git a/git-sh-setup.sh b/git-sh-setup.sh\nindex ecb60d9e3cb..ce273fe0e48 100644\n--- a/git-sh-setup.sh\n+++ b/git-sh-setup.sh\n@@ -57,15 +57,6 @@ die_with_status () {\n \texit \"$status\"\n }\n \n-GIT_QUIET=\n-\n-say () {\n-\tif test -z \"$GIT_QUIET\"\n-\tthen\n-\t\tprintf '%s\\n' \"$*\"\n-\tfi\n-}\n-\n if test -n \"$OPTIONS_SPEC\"; then\n \tusage() {\n \t\t\"$0\" -h\n-- \n2.37.0.880.gf07d56b18ba\n\n"},{"id":"458015","messageId":"patch-v4-04.12-52d97fd4c36-20220628T095914Z-avarab@gmail.com","threadId":"57979","inReplyTo":"cover-v4-00.12-00000000000-20220628T095914Z-avarab@gmail.com","subject":"[PATCH v4 04/12] git-submodule.sh: remove unused top-level \"--branch\" argument","fromName":"Ævar Arnfjörð Bjarmason","fromEmail":"avarab@gmail.com","sentAt":"2022-06-28T10:05:26Z","receivedAt":"2022-06-28T10:06:37Z","isPatch":true,"sender":{"key":"avarab@gmail.com","avatar":"https://avatars.githubusercontent.com/u/45301?v=4"},"body":"In 5c08dbbdf1a (git-submodule: fix subcommand parser, 2008-01-15) the\n\"--branch\" option was supported as an option to \"git submodule\"\nitself, i.e. \"git submodule --branch\" as a side-effect of its\nimplementation.\n\nThen in b57e8119e6e (submodule: teach set-branch subcommand,\n2019-02-08) when the \"set-branch\" subcommand was added the assertion\nthat we shouldn't have \"--branch\" anywhere except as an argument to\n\"add\" and \"set-branch\" was copy/pasted from the adjacent check for\n\"--cache\" added (or rather modified) in 496eeeb19b9 (git-submodule.sh:\navoid \"test <cond> -a/-o <cond>\", 2014-06-10).\n\nBut there's been a logic error in that check, which at a glance looked\nlike it should be supporting:\n\n    git submodule --branch <branch> (add | set-branch) [<options>]\n\nBut due to \"||\" in the condition (as opposed to \"&&\" for \"--cache\") if\nwe have \"--branch\" here already we'll emit usage, even for \"add\" and\n\"set-branch\".\n\nSo in addition to never having documented this form, it hasn't worked\nsince b57e8119e6e was released with v2.22.0.\n\nSo it's safe to remove this code. I.e. we don't want to support the\nform noted above, but only:\n\n    git submodule (add | set-branch) --branch <branch> [<options>]\n\nSigned-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>\n---\n git-submodule.sh | 14 --------------\n 1 file changed, 14 deletions(-)\n\ndiff --git a/git-submodule.sh b/git-submodule.sh\nindex b99a00d9f84..20fc1b620fa 100755\n--- a/git-submodule.sh\n+++ b/git-submodule.sh\n@@ -574,14 +574,6 @@ do\n \t-q|--quiet)\n \t\tGIT_QUIET=1\n \t\t;;\n-\t-b|--branch)\n-\t\tcase \"$2\" in\n-\t\t'')\n-\t\t\tusage\n-\t\t\t;;\n-\t\tesac\n-\t\tbranch=\"$2\"; shift\n-\t\t;;\n \t--cached)\n \t\tcached=1\n \t\t;;\n@@ -609,12 +601,6 @@ then\n     fi\n fi\n \n-# \"-b branch\" is accepted only by \"add\" and \"set-branch\"\n-if test -n \"$branch\" && (test \"$command\" != add || test \"$command\" != set-branch)\n-then\n-\tusage\n-fi\n-\n # \"--cached\" is accepted only by \"status\" and \"summary\"\n if test -n \"$cached\" && test \"$command\" != status && test \"$command\" != summary\n then\n-- \n2.37.0.880.gf07d56b18ba\n\n"},{"id":"458016","messageId":"patch-v4-05.12-a4632f00a4a-20220628T095914Z-avarab@gmail.com","threadId":"57979","inReplyTo":"cover-v4-00.12-00000000000-20220628T095914Z-avarab@gmail.com","subject":"[PATCH v4 05/12] submodule--helper: have --require-init imply --init","fromName":"Ævar Arnfjörð Bjarmason","fromEmail":"avarab@gmail.com","sentAt":"2022-06-28T10:05:27Z","receivedAt":"2022-06-28T10:06:39Z","isPatch":true,"sender":{"key":"avarab@gmail.com","avatar":"https://avatars.githubusercontent.com/u/45301?v=4"},"body":"Adjust code added in 0060fd1511b (clone --recurse-submodules: prevent\nname squatting on Windows, 2019-09-12) to have the internal\n--require-init option imply --init, rather than having\n\"git-submodule.sh\" add it implicitly.\n\nThis change doesn't make any difference now, but eliminates another\nspecial-case where \"git submodule--helper update\"'s behavior was\ndifferent from \"git submodule update\". This will make it easier to\neventually replace the cmd_update() function in git-submodule.sh.\n\nWe'll still need to keep the distinction between \"--init\" and\n\"--require-init\" in git-submodule.sh. Once cmd_update() gets\nre-implemented in C we'll be able to change variables and other code\nrelated to that, but not yet.\n\nSigned-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>\n---\n builtin/submodule--helper.c | 5 ++++-\n git-submodule.sh            | 1 -\n 2 files changed, 4 insertions(+), 2 deletions(-)\n\ndiff --git a/builtin/submodule--helper.c b/builtin/submodule--helper.c\nindex c597df7528e..0fab3a52e88 100644\n--- a/builtin/submodule--helper.c\n+++ b/builtin/submodule--helper.c\n@@ -2619,7 +2619,7 @@ static int module_update(int argc, const char **argv, const char *prefix)\n \t\tOPT_BOOL(0, \"progress\", &opt.progress,\n \t\t\t    N_(\"force cloning progress\")),\n \t\tOPT_BOOL(0, \"require-init\", &opt.require_init,\n-\t\t\t   N_(\"disallow cloning into non-empty directory\")),\n+\t\t\t   N_(\"disallow cloning into non-empty directory, implies --init\")),\n \t\tOPT_BOOL(0, \"single-branch\", &opt.single_branch,\n \t\t\t N_(\"clone only one branch, HEAD or --branch\")),\n \t\tOPT_PARSE_LIST_OBJECTS_FILTER(&filter_options),\n@@ -2643,6 +2643,9 @@ static int module_update(int argc, const char **argv, const char *prefix)\n \targc = parse_options(argc, argv, prefix, module_update_options,\n \t\t\t     git_submodule_helper_usage, 0);\n \n+\tif (opt.require_init)\n+\t\topt.init = 1;\n+\n \tif (filter_options.choice && !opt.init) {\n \t\tusage_with_options(git_submodule_helper_usage,\n \t\t\t\t   module_update_options);\ndiff --git a/git-submodule.sh b/git-submodule.sh\nindex 20fc1b620fa..5b9683bf766 100755\n--- a/git-submodule.sh\n+++ b/git-submodule.sh\n@@ -251,7 +251,6 @@ cmd_update()\n \t\t\tinit=1\n \t\t\t;;\n \t\t--require-init)\n-\t\t\tinit=1\n \t\t\trequire_init=1\n \t\t\t;;\n \t\t--remote)\n-- \n2.37.0.880.gf07d56b18ba\n\n"},{"id":"458017","messageId":"patch-v4-10.12-abb5cb499aa-20220628T095914Z-avarab@gmail.com","threadId":"57979","inReplyTo":"cover-v4-00.12-00000000000-20220628T095914Z-avarab@gmail.com","subject":"[PATCH v4 10/12] submodule--helper: eliminate internal \"--update\" option","fromName":"Ævar Arnfjörð Bjarmason","fromEmail":"avarab@gmail.com","sentAt":"2022-06-28T10:05:32Z","receivedAt":"2022-06-28T10:06:40Z","isPatch":true,"sender":{"key":"avarab@gmail.com","avatar":"https://avatars.githubusercontent.com/u/45301?v=4"},"body":"From: Glen Choo <chooglen@google.com>\n\nFollow-up on the preceding commit which taught \"git submodule--helper\nupdate\" to understand \"--merge\", \"--checkout\" and \"--rebase\" and use\nthose options instead of \"--update=(rebase|merge|checkout|none)\" when\nthe command invokes itself.\n\nUnlike the preceding change this isn't strictly necessary to\neventually change \"git-submodule.sh\" so that it invokes \"git\nsubmodule--helper update\" directly, but let's remove this\ninconsistency in the command-line interface. We shouldn't need to\ncarry special synonyms for existing options in \"git submodule--helper\"\nwhen that command can use the primary documented names instead.\n\nBut, as seen in the post-image this makes the control flow within\n\"builtin/submodule--helper.c\" simpler, we can now write directly to\nthe \"update_default\" member of \"struct update_data\" when parsing the\noptions in \"module_update()\".\n\nSigned-off-by: Glen Choo <chooglen@google.com>\nSigned-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>\n---\n builtin/submodule--helper.c | 33 +++++++++++++--------------------\n 1 file changed, 13 insertions(+), 20 deletions(-)\n\ndiff --git a/builtin/submodule--helper.c b/builtin/submodule--helper.c\nindex e35ae0322ee..d60f6cd9de0 100644\n--- a/builtin/submodule--helper.c\n+++ b/builtin/submodule--helper.c\n@@ -1818,7 +1818,7 @@ static int module_clone(int argc, const char **argv, const char *prefix)\n static void determine_submodule_update_strategy(struct repository *r,\n \t\t\t\t\t\tint just_cloned,\n \t\t\t\t\t\tconst char *path,\n-\t\t\t\t\t\tconst char *update,\n+\t\t\t\t\t\tenum submodule_update_type update,\n \t\t\t\t\t\tstruct submodule_update_strategy *out)\n {\n \tconst struct submodule *sub = submodule_from_path(r, null_oid(), path);\n@@ -1828,9 +1828,7 @@ static void determine_submodule_update_strategy(struct repository *r,\n \tkey = xstrfmt(\"submodule.%s.update\", sub->name);\n \n \tif (update) {\n-\t\tif (parse_submodule_update_strategy(update, out) < 0)\n-\t\t\tdie(_(\"Invalid update mode '%s' for submodule path '%s'\"),\n-\t\t\t\tupdate, path);\n+\t\tout->type = update;\n \t} else if (!repo_config_get_string_tmp(r, key, &val)) {\n \t\tif (parse_submodule_update_strategy(val, out) < 0)\n \t\t\tdie(_(\"Invalid update mode '%s' configured for submodule path '%s'\"),\n@@ -1882,7 +1880,7 @@ struct update_data {\n \tconst char *prefix;\n \tconst char *recursive_prefix;\n \tconst char *displaypath;\n-\tconst char *update_default;\n+\tenum submodule_update_type update_default;\n \tstruct object_id suboid;\n \tstruct string_list references;\n \tstruct submodule_update_strategy update_strategy;\n@@ -2424,6 +2422,8 @@ static const char *submodule_update_type_to_label(enum submodule_update_type typ\n \n static void update_data_to_args(struct update_data *update_data, struct strvec *args)\n {\n+\tenum submodule_update_type update_type = update_data->update_default;\n+\n \tstrvec_pushl(args, \"submodule--helper\", \"update\", \"--recursive\", NULL);\n \tstrvec_pushf(args, \"--jobs=%d\", update_data->max_jobs);\n \tif (update_data->recursive_prefix)\n@@ -2447,8 +2447,10 @@ static void update_data_to_args(struct update_data *update_data, struct strvec *\n \t\tstrvec_push(args, \"--require-init\");\n \tif (update_data->depth)\n \t\tstrvec_pushf(args, \"--depth=%d\", update_data->depth);\n-\tif (update_data->update_default)\n-\t\tstrvec_pushl(args, \"--update\", update_data->update_default, NULL);\n+\tif (update_type != SM_UPDATE_UNSPECIFIED)\n+\t\tstrvec_pushf(args, \"--%s\",\n+\t\t\t     submodule_update_type_to_label(update_type));\n+\n \tif (update_data->references.nr) {\n \t\tstruct string_list_item *item;\n \t\tfor_each_string_list_item(item, &update_data->references)\n@@ -2600,7 +2602,6 @@ static int module_update(int argc, const char **argv, const char *prefix)\n \tstruct update_data opt = UPDATE_DATA_INIT;\n \tstruct list_objects_filter_options filter_options;\n \tint ret;\n-\tenum submodule_update_type update_type = SM_UPDATE_UNSPECIFIED;\n \n \tstruct option module_update_options[] = {\n \t\tOPT__FORCE(&opt.force, N_(\"force checkout updates\"), 0),\n@@ -2619,16 +2620,13 @@ static int module_update(int argc, const char **argv, const char *prefix)\n \t\t\t   N_(\"path\"),\n \t\t\t   N_(\"path into the working tree, across nested \"\n \t\t\t      \"submodule boundaries\")),\n-\t\tOPT_STRING(0, \"update\", &opt.update_default,\n-\t\t\t   N_(\"string\"),\n-\t\t\t   N_(\"rebase, merge, checkout or none\")),\n-\t\tOPT_SET_INT(0, \"checkout\", &update_type,\n+\t\tOPT_SET_INT(0, \"checkout\", &opt.update_default,\n \t\t\tN_(\"use the 'checkout' update strategy (default)\"),\n \t\t\tSM_UPDATE_CHECKOUT),\n-\t\tOPT_SET_INT('m', \"merge\", &update_type,\n+\t\tOPT_SET_INT('m', \"merge\", &opt.update_default,\n \t\t\tN_(\"use the 'merge' update strategy\"),\n \t\t\tSM_UPDATE_MERGE),\n-\t\tOPT_SET_INT('r', \"rebase\", &update_type,\n+\t\tOPT_SET_INT('r', \"rebase\", &opt.update_default,\n \t\t\tN_(\"use the 'rebase' update strategy\"),\n \t\t\tSM_UPDATE_REBASE),\n \t\tOPT_STRING_LIST(0, \"reference\", &opt.references, N_(\"repo\"),\n@@ -2680,13 +2678,8 @@ static int module_update(int argc, const char **argv, const char *prefix)\n \n \topt.filter_options = &filter_options;\n \n-\tif (update_type != SM_UPDATE_UNSPECIFIED)\n-\t\topt.update_default = submodule_update_type_to_label(update_type);\n-\n \tif (opt.update_default)\n-\t\tif (parse_submodule_update_strategy(opt.update_default,\n-\t\t\t\t\t\t    &opt.update_strategy) < 0)\n-\t\t\tdie(_(\"bad value for update parameter\"));\n+\t\topt.update_strategy.type = opt.update_default;\n \n \tif (module_list_compute(argc, argv, prefix, &pathspec, &opt.list) < 0) {\n \t\tlist_objects_filter_release(&filter_options);\n-- \n2.37.0.880.gf07d56b18ba\n\n"},{"id":"458018","messageId":"patch-v4-11.12-c7eac40a0f2-20220628T095914Z-avarab@gmail.com","threadId":"57979","inReplyTo":"cover-v4-00.12-00000000000-20220628T095914Z-avarab@gmail.com","subject":"[PATCH v4 11/12] git-submodule.sh: use \"$quiet\", not \"$GIT_QUIET\"","fromName":"Ævar Arnfjörð Bjarmason","fromEmail":"avarab@gmail.com","sentAt":"2022-06-28T10:05:33Z","receivedAt":"2022-06-28T10:06:41Z","isPatch":true,"sender":{"key":"avarab@gmail.com","avatar":"https://avatars.githubusercontent.com/u/45301?v=4"},"body":"Remove the use of the \"$GIT_QUIET\" variable in favor of our own\n\"$quiet\", ever since b3c5f5cb048 (submodule: move core cmd_update()\nlogic to C, 2022-03-15) we have not used the \"say\" function in\ngit-sh-setup.sh, which is the only thing that's affected by using\n\"GIT_QUIET\".\n\nWe still want to support --quiet for our own use though, but let's use\nour own variable for that. Now it's obvious that we only care about\npassing \"--quiet\" to \"git submodule--helper\", and not to change the\noutput of any \"say\" invocation.\n\nSigned-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>\n---\n git-submodule.sh | 37 +++++++++++++++++++------------------\n 1 file changed, 19 insertions(+), 18 deletions(-)\n\ndiff --git a/git-submodule.sh b/git-submodule.sh\nindex 7fc7119fb21..5e5d21c010f 100755\n--- a/git-submodule.sh\n+++ b/git-submodule.sh\n@@ -30,6 +30,7 @@ GIT_PROTOCOL_FROM_USER=0\n export GIT_PROTOCOL_FROM_USER\n \n command=\n+quiet=\n branch=\n force=\n reference=\n@@ -80,7 +81,7 @@ cmd_add()\n \t\t\tforce=$1\n \t\t\t;;\n \t\t-q|--quiet)\n-\t\t\tGIT_QUIET=1\n+\t\t\tquiet=1\n \t\t\t;;\n \t\t--progress)\n \t\t\tprogress=1\n@@ -128,7 +129,7 @@ cmd_add()\n \t\tusage\n \tfi\n \n-\tgit ${wt_prefix:+-C \"$wt_prefix\"} submodule--helper add ${GIT_QUIET:+--quiet} ${force:+--force} ${progress:+\"--progress\"} ${branch:+--branch \"$branch\"} ${reference_path:+--reference \"$reference_path\"} ${dissociate:+--dissociate} ${custom_name:+--name \"$custom_name\"} ${depth:+\"$depth\"} -- \"$@\"\n+\tgit ${wt_prefix:+-C \"$wt_prefix\"} submodule--helper add ${quiet:+--quiet} ${force:+--force} ${progress:+\"--progress\"} ${branch:+--branch \"$branch\"} ${reference_path:+--reference \"$reference_path\"} ${dissociate:+--dissociate} ${custom_name:+--name \"$custom_name\"} ${depth:+\"$depth\"} -- \"$@\"\n }\n \n #\n@@ -144,7 +145,7 @@ cmd_foreach()\n \tdo\n \t\tcase \"$1\" in\n \t\t-q|--quiet)\n-\t\t\tGIT_QUIET=1\n+\t\t\tquiet=1\n \t\t\t;;\n \t\t--recursive)\n \t\t\trecursive=1\n@@ -159,7 +160,7 @@ cmd_foreach()\n \t\tshift\n \tdone\n \n-\tgit ${wt_prefix:+-C \"$wt_prefix\"} submodule--helper foreach ${GIT_QUIET:+--quiet} ${recursive:+--recursive} -- \"$@\"\n+\tgit ${wt_prefix:+-C \"$wt_prefix\"} submodule--helper foreach ${quiet:+--quiet} ${recursive:+--recursive} -- \"$@\"\n }\n \n #\n@@ -174,7 +175,7 @@ cmd_init()\n \tdo\n \t\tcase \"$1\" in\n \t\t-q|--quiet)\n-\t\t\tGIT_QUIET=1\n+\t\t\tquiet=1\n \t\t\t;;\n \t\t--)\n \t\t\tshift\n@@ -190,7 +191,7 @@ cmd_init()\n \t\tshift\n \tdone\n \n-\tgit ${wt_prefix:+-C \"$wt_prefix\"} submodule--helper init ${GIT_QUIET:+--quiet} -- \"$@\"\n+\tgit ${wt_prefix:+-C \"$wt_prefix\"} submodule--helper init ${quiet:+--quiet} -- \"$@\"\n }\n \n #\n@@ -207,7 +208,7 @@ cmd_deinit()\n \t\t\tforce=$1\n \t\t\t;;\n \t\t-q|--quiet)\n-\t\t\tGIT_QUIET=1\n+\t\t\tquiet=1\n \t\t\t;;\n \t\t--all)\n \t\t\tdeinit_all=t\n@@ -226,7 +227,7 @@ cmd_deinit()\n \t\tshift\n \tdone\n \n-\tgit ${wt_prefix:+-C \"$wt_prefix\"} submodule--helper deinit ${GIT_QUIET:+--quiet} ${force:+--force} ${deinit_all:+--all} -- \"$@\"\n+\tgit ${wt_prefix:+-C \"$wt_prefix\"} submodule--helper deinit ${quiet:+--quiet} ${force:+--force} ${deinit_all:+--all} -- \"$@\"\n }\n \n #\n@@ -241,7 +242,7 @@ cmd_update()\n \tdo\n \t\tcase \"$1\" in\n \t\t-q|--quiet)\n-\t\t\tGIT_QUIET=1\n+\t\t\tquiet=1\n \t\t\t;;\n \t\t--progress)\n \t\t\tprogress=1\n@@ -335,7 +336,7 @@ cmd_update()\n \tdone\n \n \tgit ${wt_prefix:+-C \"$wt_prefix\"} submodule--helper update \\\n-\t\t${GIT_QUIET:+--quiet} \\\n+\t\t${quiet:+--quiet} \\\n \t\t${force:+--force} \\\n \t\t${progress:+\"--progress\"} \\\n \t\t${remote:+--remote} \\\n@@ -396,7 +397,7 @@ cmd_set_branch() {\n \t\tshift\n \tdone\n \n-\tgit ${wt_prefix:+-C \"$wt_prefix\"} submodule--helper set-branch ${GIT_QUIET:+--quiet} ${branch:+--branch \"$branch\"} ${default:+--default} -- \"$@\"\n+\tgit ${wt_prefix:+-C \"$wt_prefix\"} submodule--helper set-branch ${quiet:+--quiet} ${branch:+--branch \"$branch\"} ${default:+--default} -- \"$@\"\n }\n \n #\n@@ -409,7 +410,7 @@ cmd_set_url() {\n \tdo\n \t\tcase \"$1\" in\n \t\t-q|--quiet)\n-\t\t\tGIT_QUIET=1\n+\t\t\tquiet=1\n \t\t\t;;\n \t\t--)\n \t\t\tshift\n@@ -425,7 +426,7 @@ cmd_set_url() {\n \t\tshift\n \tdone\n \n-\tgit ${wt_prefix:+-C \"$wt_prefix\"} submodule--helper set-url ${GIT_QUIET:+--quiet} -- \"$@\"\n+\tgit ${wt_prefix:+-C \"$wt_prefix\"} submodule--helper set-url ${quiet:+--quiet} -- \"$@\"\n }\n \n #\n@@ -496,7 +497,7 @@ cmd_status()\n \tdo\n \t\tcase \"$1\" in\n \t\t-q|--quiet)\n-\t\t\tGIT_QUIET=1\n+\t\t\tquiet=1\n \t\t\t;;\n \t\t--cached)\n \t\t\tcached=1\n@@ -518,7 +519,7 @@ cmd_status()\n \t\tshift\n \tdone\n \n-\tgit ${wt_prefix:+-C \"$wt_prefix\"} submodule--helper status ${GIT_QUIET:+--quiet} ${cached:+--cached} ${recursive:+--recursive} -- \"$@\"\n+\tgit ${wt_prefix:+-C \"$wt_prefix\"} submodule--helper status ${quiet:+--quiet} ${cached:+--cached} ${recursive:+--recursive} -- \"$@\"\n }\n #\n # Sync remote urls for submodules\n@@ -531,7 +532,7 @@ cmd_sync()\n \tdo\n \t\tcase \"$1\" in\n \t\t-q|--quiet)\n-\t\t\tGIT_QUIET=1\n+\t\t\tquiet=1\n \t\t\tshift\n \t\t\t;;\n \t\t--recursive)\n@@ -551,7 +552,7 @@ cmd_sync()\n \t\tesac\n \tdone\n \n-\tgit ${wt_prefix:+-C \"$wt_prefix\"} submodule--helper sync ${GIT_QUIET:+--quiet} ${recursive:+--recursive} -- \"$@\"\n+\tgit ${wt_prefix:+-C \"$wt_prefix\"} submodule--helper sync ${quiet:+--quiet} ${recursive:+--recursive} -- \"$@\"\n }\n \n cmd_absorbgitdirs()\n@@ -572,7 +573,7 @@ do\n \t\tcommand=$1\n \t\t;;\n \t-q|--quiet)\n-\t\tGIT_QUIET=1\n+\t\tquiet=1\n \t\t;;\n \t--cached)\n \t\tcached=1\n-- \n2.37.0.880.gf07d56b18ba\n\n"},{"id":"458019","messageId":"patch-v4-09.12-e8ddb95dcbf-20220628T095914Z-avarab@gmail.com","threadId":"57979","inReplyTo":"cover-v4-00.12-00000000000-20220628T095914Z-avarab@gmail.com","subject":"[PATCH v4 09/12] submodule--helper: understand --checkout, --merge and --rebase synonyms","fromName":"Ævar Arnfjörð Bjarmason","fromEmail":"avarab@gmail.com","sentAt":"2022-06-28T10:05:31Z","receivedAt":"2022-06-28T10:06:44Z","isPatch":true,"sender":{"key":"avarab@gmail.com","avatar":"https://avatars.githubusercontent.com/u/45301?v=4"},"body":"Understand --checkout, --merge and --rebase synonyms for\n--update={checkout,merge,rebase}, as well as the short options that\n'git submodule' itself understands.\n\nThis removes a difference between the CLI API of \"git submodule\" and\n\"git submodule--helper\", making it easier to make the latter an alias\nfor the former. See 48308681b07 (git submodule update: have a\ndedicated helper for cloning, 2016-02-29) for the initial addition of\n--update.\n\nSigned-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>\n---\n builtin/submodule--helper.c | 30 ++++++++++++++++++++++++++++++\n git-submodule.sh            | 14 +++++++++-----\n 2 files changed, 39 insertions(+), 5 deletions(-)\n\ndiff --git a/builtin/submodule--helper.c b/builtin/submodule--helper.c\nindex d145d53addd..e35ae0322ee 100644\n--- a/builtin/submodule--helper.c\n+++ b/builtin/submodule--helper.c\n@@ -2405,6 +2405,23 @@ static void ensure_core_worktree(const char *path)\n \t}\n }\n \n+static const char *submodule_update_type_to_label(enum submodule_update_type type)\n+{\n+\tswitch (type) {\n+\tcase SM_UPDATE_CHECKOUT:\n+\t\treturn \"checkout\";\n+\tcase SM_UPDATE_MERGE:\n+\t\treturn \"merge\";\n+\tcase SM_UPDATE_REBASE:\n+\t\treturn \"rebase\";\n+\tcase SM_UPDATE_UNSPECIFIED:\n+\tcase SM_UPDATE_NONE:\n+\tcase SM_UPDATE_COMMAND:\n+\t\tbreak;\n+\t}\n+\tBUG(\"unreachable with type %d\", type);\n+}\n+\n static void update_data_to_args(struct update_data *update_data, struct strvec *args)\n {\n \tstrvec_pushl(args, \"submodule--helper\", \"update\", \"--recursive\", NULL);\n@@ -2583,6 +2600,7 @@ static int module_update(int argc, const char **argv, const char *prefix)\n \tstruct update_data opt = UPDATE_DATA_INIT;\n \tstruct list_objects_filter_options filter_options;\n \tint ret;\n+\tenum submodule_update_type update_type = SM_UPDATE_UNSPECIFIED;\n \n \tstruct option module_update_options[] = {\n \t\tOPT__FORCE(&opt.force, N_(\"force checkout updates\"), 0),\n@@ -2604,6 +2622,15 @@ static int module_update(int argc, const char **argv, const char *prefix)\n \t\tOPT_STRING(0, \"update\", &opt.update_default,\n \t\t\t   N_(\"string\"),\n \t\t\t   N_(\"rebase, merge, checkout or none\")),\n+\t\tOPT_SET_INT(0, \"checkout\", &update_type,\n+\t\t\tN_(\"use the 'checkout' update strategy (default)\"),\n+\t\t\tSM_UPDATE_CHECKOUT),\n+\t\tOPT_SET_INT('m', \"merge\", &update_type,\n+\t\t\tN_(\"use the 'merge' update strategy\"),\n+\t\t\tSM_UPDATE_MERGE),\n+\t\tOPT_SET_INT('r', \"rebase\", &update_type,\n+\t\t\tN_(\"use the 'rebase' update strategy\"),\n+\t\t\tSM_UPDATE_REBASE),\n \t\tOPT_STRING_LIST(0, \"reference\", &opt.references, N_(\"repo\"),\n \t\t\t   N_(\"reference repository\")),\n \t\tOPT_BOOL(0, \"dissociate\", &opt.dissociate,\n@@ -2653,6 +2680,9 @@ static int module_update(int argc, const char **argv, const char *prefix)\n \n \topt.filter_options = &filter_options;\n \n+\tif (update_type != SM_UPDATE_UNSPECIFIED)\n+\t\topt.update_default = submodule_update_type_to_label(update_type);\n+\n \tif (opt.update_default)\n \t\tif (parse_submodule_update_strategy(opt.update_default,\n \t\t\t\t\t\t    &opt.update_strategy) < 0)\ndiff --git a/git-submodule.sh b/git-submodule.sh\nindex 1c1dc320922..7fc7119fb21 100755\n--- a/git-submodule.sh\n+++ b/git-submodule.sh\n@@ -40,7 +40,9 @@ require_init=\n files=\n remote=\n nofetch=\n-update=\n+rebase=\n+merge=\n+checkout=\n custom_name=\n depth=\n progress=\n@@ -260,7 +262,7 @@ cmd_update()\n \t\t\tforce=$1\n \t\t\t;;\n \t\t-r|--rebase)\n-\t\t\tupdate=\"rebase\"\n+\t\t\trebase=1\n \t\t\t;;\n \t\t--reference)\n \t\t\tcase \"$2\" in '') usage ;; esac\n@@ -274,13 +276,13 @@ cmd_update()\n \t\t\tdissociate=1\n \t\t\t;;\n \t\t-m|--merge)\n-\t\t\tupdate=\"merge\"\n+\t\t\tmerge=1\n \t\t\t;;\n \t\t--recursive)\n \t\t\trecursive=1\n \t\t\t;;\n \t\t--checkout)\n-\t\t\tupdate=\"checkout\"\n+\t\t\tcheckout=1\n \t\t\t;;\n \t\t--recommend-shallow)\n \t\t\trecommend_shallow=\"--recommend-shallow\"\n@@ -341,7 +343,9 @@ cmd_update()\n \t\t${init:+--init} \\\n \t\t${nofetch:+--no-fetch} \\\n \t\t${wt_prefix:+--prefix \"$wt_prefix\"} \\\n-\t\t${update:+--update \"$update\"} \\\n+\t\t${rebase:+--rebase} \\\n+\t\t${merge:+--merge} \\\n+\t\t${checkout:+--checkout} \\\n \t\t${reference:+\"$reference\"} \\\n \t\t${dissociate:+\"--dissociate\"} \\\n \t\t${depth:+\"$depth\"} \\\n-- \n2.37.0.880.gf07d56b18ba\n\n"},{"id":"458050","messageId":"kl6l1qv8ivcs.fsf@chooglen-macbookpro.roam.corp.google.com","threadId":"57979","inReplyTo":"cover-v4-00.12-00000000000-20220628T095914Z-avarab@gmail.com","subject":"Re: [PATCH v4 00/12] submodule: make \"git submodule--helper\" behave like \"git submodule\"","fromName":"Glen Choo","fromEmail":"chooglen@google.com","sentAt":"2022-06-28T16:52:19Z","receivedAt":"2022-06-28T16:54:55Z","isPatch":true,"sender":{"key":"glencbz@gmail.com","avatar":"https://avatars.githubusercontent.com/u/58092771?v=4"},"body":"Ævar Arnfjörð Bjarmason <avarab@gmail.com> writes:\n\n> Changes since v3:\n>\n>  * Leave the --super-prefix changes aside for now. As discussed in the\n>    v3 follow-up, now we're only removing the unused $prefix variable.\n>\n>    Since the v2 was submitted Glen's submitted a series of his own. I\n>    think any non-trivial updates to --super-prefix are better done\n>    there, as noted in:\n>    https://lore.kernel.org/git/220628.86wnd1f9t1.gmgdl@evledraar.gmail.com/\n>\n>    The overall diffstat is much smaller as a result, and I think this\n>    series should be ready for \"next\" now, as the remaining changes are\n>    well-revieweda at this point, with no outstanding issues.\n\nAgreed. Since we no longer touch \"--super-prefix\", I think there aren't\nany remaining concerns.\n\nIn v3, I was slightly concerned that we didn't fully understand the\nrationale behind \"--super-prefix\" before changing it, but I still gave\nthat version my Reviewed-by because I'm convinced that the\n\"--super-prefix\" check isn't doing anything useful (and can be\nannoyingly overzealous).\n"}]}