{"thread":{"id":"60803","subject":"[PATCH 0/5] completion: remove hardcoded config variable names","startedAt":"2024-01-28T20:02:57Z","lastAt":"2024-02-14T00:24:15Z","messageCount":32,"participants":["Philippe Blain via GitGitGadget","Junio C Hamano","Patrick Steinhardt","Philippe Blain"],"isPatch":true,"patchVersion":1,"patchTotal":5},"messages":[{"id":"487472","messageId":"pull.1660.git.git.1706472173.gitgitgadget@gmail.com","threadId":"60803","inReplyTo":null,"subject":"[PATCH 0/5] completion: remove hardcoded config variable names","fromName":"Philippe Blain via GitGitGadget","fromEmail":"gitgitgadget@gmail.com","sentAt":"2024-01-28T20:02:48Z","receivedAt":"2024-01-28T20:02:57Z","isPatch":true,"sender":{"key":"levraiphilippeblain@gmail.com","avatar":"https://avatars.githubusercontent.com/u/44212482?v=4"},"body":"This series removes hardcoded config variable names in the\n__git_complete_config_variable_name function, partly by adding a new mode to\n'git help'. It also adds completion for 'submodule.*' config variables,\nwhich were previously missing.\n\nI think it makes sense to do that in the same series since it's closely\nrelated, and splitting it would result in textual conflicts between both\nseries if one does not build on top of the other, but I'm open to other\nsuggestions.\n\nThanks,\n\nPhilippe.\n\nPhilippe Blain (5):\n  completion: add space after config variable names also in Bash 3\n  completion: complete 'submodule.*' config variables\n  completion: add and use\n    __git_compute_first_level_config_vars_for_section\n  builtin/help: add --config-all-for-completion\n  completion: add an use\n    __git_compute_second_level_config_vars_for_section\n\n builtin/help.c                         |  7 ++\n contrib/completion/git-completion.bash | 90 +++++++++++++-------------\n t/t9902-completion.sh                  | 21 ++++++\n 3 files changed, 74 insertions(+), 44 deletions(-)\n\n\nbase-commit: b50a608ba20348cb3dfc16a696816d51780e3f0f\nPublished-As: https://github.com/gitgitgadget/git/releases/tag/pr-git-1660%2Fphil-blain%2Fcompletion-submodule-config-v1\nFetch-It-Via: git fetch https://github.com/gitgitgadget/git pr-git-1660/phil-blain/completion-submodule-config-v1\nPull-Request: https://github.com/git/git/pull/1660\n-- \ngitgitgadget\n"},{"id":"487473","messageId":"837d92a6c277015fc8633ca84557124465390548.1706472173.git.gitgitgadget@gmail.com","threadId":"60803","inReplyTo":"pull.1660.git.git.1706472173.gitgitgadget@gmail.com","subject":"[PATCH 1/5] completion: add space after config variable names also in Bash 3","fromName":"Philippe Blain via GitGitGadget","fromEmail":"gitgitgadget@gmail.com","sentAt":"2024-01-28T20:02:49Z","receivedAt":"2024-01-28T20:02:57Z","isPatch":true,"sender":{"key":"levraiphilippeblain@gmail.com","avatar":"https://avatars.githubusercontent.com/u/44212482?v=4"},"body":"From: Philippe Blain <levraiphilippeblain@gmail.com>\n\nIn be6444d1ca (completion: bash: add correct suffix in variables,\n2021-08-16), __git_complete_config_variable_name was changed to use\n\"${sfx- }\" instead of \"$sfx\" as the fourth argument of _gitcomp_nl and\n_gitcomp_nl_append, such that this argument evaluates to a space if sfx\nis unset. This was to ensure that e.g.\n\n\tgit config branch.autoSetupMe[TAB]\n\ncorrectly completes to 'branch.autoSetupMerge ' with the trailing space.\nThis commits notes that the fix only works in Bash 4 because in Bash 3\nthe 'local sfx' construct at the beginning of\n__git_complete_config_variable_name creates an empty string.\n\nMake the fix also work for Bash 3 by using the \"unset or null' parameter\nexpansion syntax (\"${sfx:- }\"), such that the parameter is also expanded\nto a space if it is set but null, as is the behaviour of 'local sfx' in\nBash 3.\n\nSigned-off-by: Philippe Blain <levraiphilippeblain@gmail.com>\n---\n contrib/completion/git-completion.bash | 6 +++---\n 1 file changed, 3 insertions(+), 3 deletions(-)\n\ndiff --git a/contrib/completion/git-completion.bash b/contrib/completion/git-completion.bash\nindex 6662db221df..159a4fd8add 100644\n--- a/contrib/completion/git-completion.bash\n+++ b/contrib/completion/git-completion.bash\n@@ -2750,7 +2750,7 @@ __git_complete_config_variable_name ()\n \t\tlocal pfx=\"${cur_%.*}.\"\n \t\tcur_=\"${cur_#*.}\"\n \t\t__gitcomp_direct \"$(__git_heads \"$pfx\" \"$cur_\" \".\")\"\n-\t\t__gitcomp_nl_append $'autoSetupMerge\\nautoSetupRebase\\n' \"$pfx\" \"$cur_\" \"${sfx- }\"\n+\t\t__gitcomp_nl_append $'autoSetupMerge\\nautoSetupRebase\\n' \"$pfx\" \"$cur_\" \"${sfx:- }\"\n \t\treturn\n \t\t;;\n \tguitool.*.*)\n@@ -2784,7 +2784,7 @@ __git_complete_config_variable_name ()\n \t\tlocal pfx=\"${cur_%.*}.\"\n \t\tcur_=\"${cur_#*.}\"\n \t\t__git_compute_all_commands\n-\t\t__gitcomp_nl \"$__git_all_commands\" \"$pfx\" \"$cur_\" \"${sfx- }\"\n+\t\t__gitcomp_nl \"$__git_all_commands\" \"$pfx\" \"$cur_\" \"${sfx:- }\"\n \t\treturn\n \t\t;;\n \tremote.*.*)\n@@ -2800,7 +2800,7 @@ __git_complete_config_variable_name ()\n \t\tlocal pfx=\"${cur_%.*}.\"\n \t\tcur_=\"${cur_#*.}\"\n \t\t__gitcomp_nl \"$(__git_remotes)\" \"$pfx\" \"$cur_\" \".\"\n-\t\t__gitcomp_nl_append \"pushDefault\" \"$pfx\" \"$cur_\" \"${sfx- }\"\n+\t\t__gitcomp_nl_append \"pushDefault\" \"$pfx\" \"$cur_\" \"${sfx:- }\"\n \t\treturn\n \t\t;;\n \turl.*.*)\n-- \ngitgitgadget\n\n"},{"id":"487474","messageId":"2dd3085f8d80fa1f5209cffde60b4ab98766baf9.1706472173.git.gitgitgadget@gmail.com","threadId":"60803","inReplyTo":"pull.1660.git.git.1706472173.gitgitgadget@gmail.com","subject":"[PATCH 2/5] completion: complete 'submodule.*' config variables","fromName":"Philippe Blain via GitGitGadget","fromEmail":"gitgitgadget@gmail.com","sentAt":"2024-01-28T20:02:50Z","receivedAt":"2024-01-28T20:02:59Z","isPatch":true,"sender":{"key":"levraiphilippeblain@gmail.com","avatar":"https://avatars.githubusercontent.com/u/44212482?v=4"},"body":"From: Philippe Blain <philippe.blain@canada.ca>\n\nIn the Bash completion script, function\n__git_complete_config_variable_name completes config variables and has\nspecial logic to deal with config variables involving user-defined\nnames, like branch.<name>.* and remote.<name>.*.\n\nThis special logic is missing for submodule-related config variables.\nAdd the appropriate branches to the case statement, making use of the\nin-tree '.gitmodules' to list relevant submodules.\n\nSigned-off-by: Philippe Blain <levraiphilippeblain@gmail.com>\n---\n contrib/completion/git-completion.bash | 13 +++++++++++++\n 1 file changed, 13 insertions(+)\n\ndiff --git a/contrib/completion/git-completion.bash b/contrib/completion/git-completion.bash\nindex 159a4fd8add..8af9bc3f4e1 100644\n--- a/contrib/completion/git-completion.bash\n+++ b/contrib/completion/git-completion.bash\n@@ -2803,6 +2803,19 @@ __git_complete_config_variable_name ()\n \t\t__gitcomp_nl_append \"pushDefault\" \"$pfx\" \"$cur_\" \"${sfx:- }\"\n \t\treturn\n \t\t;;\n+\tsubmodule.*.*)\n+\t\tlocal pfx=\"${cur_%.*}.\"\n+\t\tcur_=\"${cur_##*.}\"\n+\t\t__gitcomp \"url update branch fetchRecurseSubmodules ignore active\" \"$pfx\" \"$cur_\" \"$sfx\"\n+\t\treturn\n+\t\t;;\n+\tsubmodule.*)\n+\t\tlocal pfx=\"${cur_%.*}.\"\n+\t\tcur_=\"${cur_#*.}\"\n+\t\t__gitcomp_nl \"$(__git config -f \"$(__git rev-parse --show-toplevel)/.gitmodules\" --get-regexp 'submodule.*.path' | awk -F. '{print $2}')\" \"$pfx\" \"$cur_\" \".\"\n+\t\t__gitcomp_nl_append $'alternateErrorStrategy\\nfetchJobs\\nactive\\nalternateLocation\\nrecurse\\npropagateBranches' \"$pfx\" \"$cur_\" \"${sfx:- }\"\n+\t\treturn\n+\t\t;;\n \turl.*.*)\n \t\tlocal pfx=\"${cur_%.*}.\"\n \t\tcur_=\"${cur_##*.}\"\n-- \ngitgitgadget\n\n"},{"id":"487475","messageId":"dd9395bda322e3a84f6669f350e6892280cf6b35.1706472173.git.gitgitgadget@gmail.com","threadId":"60803","inReplyTo":"pull.1660.git.git.1706472173.gitgitgadget@gmail.com","subject":"[PATCH 3/5] completion: add and use __git_compute_first_level_config_vars_for_section","fromName":"Philippe Blain via GitGitGadget","fromEmail":"gitgitgadget@gmail.com","sentAt":"2024-01-28T20:02:51Z","receivedAt":"2024-01-28T20:02:59Z","isPatch":true,"sender":{"key":"levraiphilippeblain@gmail.com","avatar":"https://avatars.githubusercontent.com/u/44212482?v=4"},"body":"From: Philippe Blain <levraiphilippeblain@gmail.com>\n\nThe function __git_complete_config_variable_name in the Bash completion\nscript hardcodes several config variable names. These variables are\nthose in config section where user-defined names can appear, such as\n\"branch.<name>\". These sections are treated first by the case statement,\nand the two last \"catch all\" cases are used for other sections, making\nuse of the __git_compute_config_vars and __git_compute_config_sections\nfunction, which omit listing any variables containing wildcards or\nplaceholders. Having hardcoded config variables introduces the risk of\nthe completion code becoming out of sync with the actual config\nvariables accepted by Git.\n\nTo avoid these hardcoded config variables, introduce a new function,\n__git_compute_first_level_config_vars_for_section, making use of the\nexisting __git_config_vars variable. This function takes as argument a\nconfig section name and computes the matching \"first level\" config\nvariables for that section, i.e. those _not_ containing any placeholder,\nlike 'branch.autoSetupMerge, 'remote.pushDefault', etc.  Use this\nfunction and the variables it defines in the 'branch.*', 'remote.*' and\n'submodule.*' switches of the case statement instead of hardcoding the\ncorresponding config variables.  Note that we use indirect expansion\ninstead of associative arrays because those are not supported in Bash 3,\non which macOS is stuck for licensing reasons.\n\nAdd a test to make sure the new function works correctly by verfying it\nlists all 'submodule' config variables. This has the downside that this\ntest must be updated when new 'submodule' configuration are added, but\nthis should be a small burden since it happens infrequently.\n\nSigned-off-by: Philippe Blain <levraiphilippeblain@gmail.com>\n---\n contrib/completion/git-completion.bash | 24 +++++++++++++++++++++---\n t/t9902-completion.sh                  | 11 +++++++++++\n 2 files changed, 32 insertions(+), 3 deletions(-)\n\ndiff --git a/contrib/completion/git-completion.bash b/contrib/completion/git-completion.bash\nindex 8af9bc3f4e1..2934ceb7637 100644\n--- a/contrib/completion/git-completion.bash\n+++ b/contrib/completion/git-completion.bash\n@@ -2596,6 +2596,15 @@ __git_compute_config_vars ()\n \t__git_config_vars=\"$(git help --config-for-completion)\"\n }\n \n+__git_compute_first_level_config_vars_for_section ()\n+{\n+\tsection=\"$1\"\n+\t__git_compute_config_vars\n+\tlocal this_section=\"__git_first_level_config_vars_for_section_${section}\"\n+\ttest -n \"${!this_section}\" ||\n+\tprintf -v \"__git_first_level_config_vars_for_section_${section}\" %s \"$(echo \"$__git_config_vars\" | grep -E \"^${section}\\.[a-z]\" | awk -F. '{print $2}')\"\n+}\n+\n __git_config_sections=\n __git_compute_config_sections ()\n {\n@@ -2749,8 +2758,11 @@ __git_complete_config_variable_name ()\n \tbranch.*)\n \t\tlocal pfx=\"${cur_%.*}.\"\n \t\tcur_=\"${cur_#*.}\"\n+\t\tlocal section=\"${pfx%.}\"\n \t\t__gitcomp_direct \"$(__git_heads \"$pfx\" \"$cur_\" \".\")\"\n-\t\t__gitcomp_nl_append $'autoSetupMerge\\nautoSetupRebase\\n' \"$pfx\" \"$cur_\" \"${sfx:- }\"\n+\t\t__git_compute_first_level_config_vars_for_section \"${section}\"\n+\t\tlocal this_section=\"__git_first_level_config_vars_for_section_${section}\"\n+\t\t__gitcomp_nl_append \"${!this_section}\" \"$pfx\" \"$cur_\" \"${sfx:- }\"\n \t\treturn\n \t\t;;\n \tguitool.*.*)\n@@ -2799,8 +2811,11 @@ __git_complete_config_variable_name ()\n \tremote.*)\n \t\tlocal pfx=\"${cur_%.*}.\"\n \t\tcur_=\"${cur_#*.}\"\n+\t\tlocal section=\"${pfx%.}\"\n \t\t__gitcomp_nl \"$(__git_remotes)\" \"$pfx\" \"$cur_\" \".\"\n-\t\t__gitcomp_nl_append \"pushDefault\" \"$pfx\" \"$cur_\" \"${sfx:- }\"\n+\t\t__git_compute_first_level_config_vars_for_section \"${section}\"\n+\t\tlocal this_section=\"__git_first_level_config_vars_for_section_${section}\"\n+\t\t__gitcomp_nl_append \"${!this_section}\" \"$pfx\" \"$cur_\" \"${sfx:- }\"\n \t\treturn\n \t\t;;\n \tsubmodule.*.*)\n@@ -2812,8 +2827,11 @@ __git_complete_config_variable_name ()\n \tsubmodule.*)\n \t\tlocal pfx=\"${cur_%.*}.\"\n \t\tcur_=\"${cur_#*.}\"\n+\t\tlocal section=\"${pfx%.}\"\n \t\t__gitcomp_nl \"$(__git config -f \"$(__git rev-parse --show-toplevel)/.gitmodules\" --get-regexp 'submodule.*.path' | awk -F. '{print $2}')\" \"$pfx\" \"$cur_\" \".\"\n-\t\t__gitcomp_nl_append $'alternateErrorStrategy\\nfetchJobs\\nactive\\nalternateLocation\\nrecurse\\npropagateBranches' \"$pfx\" \"$cur_\" \"${sfx:- }\"\n+\t\t__git_compute_first_level_config_vars_for_section \"${section}\"\n+\t\tlocal this_section=\"__git_first_level_config_vars_for_section_${section}\"\n+\t\t__gitcomp_nl_append \"${!this_section}\" \"$pfx\" \"$cur_\" \"${sfx:- }\"\n \t\treturn\n \t\t;;\n \turl.*.*)\ndiff --git a/t/t9902-completion.sh b/t/t9902-completion.sh\nindex 35eb534fdda..f28d8f531b7 100755\n--- a/t/t9902-completion.sh\n+++ b/t/t9902-completion.sh\n@@ -2583,6 +2583,17 @@ test_expect_success 'git config - variable name include' '\n \tEOF\n '\n \n+test_expect_success 'git config - variable name - __git_compute_first_level_config_vars_for_section' '\n+\ttest_completion \"git config submodule.\" <<-\\EOF\n+\tsubmodule.active Z\n+\tsubmodule.alternateErrorStrategy Z\n+\tsubmodule.alternateLocation Z\n+\tsubmodule.fetchJobs Z\n+\tsubmodule.propagateBranches Z\n+\tsubmodule.recurse Z\n+\tEOF\n+'\n+\n test_expect_success 'git config - value' '\n \ttest_completion \"git config color.pager \" <<-\\EOF\n \tfalse Z\n-- \ngitgitgadget\n\n"},{"id":"487476","messageId":"3e83f21eb4e35be0b43e2e40f79920d1b0d00dc1.1706472173.git.gitgitgadget@gmail.com","threadId":"60803","inReplyTo":"pull.1660.git.git.1706472173.gitgitgadget@gmail.com","subject":"[PATCH 4/5] builtin/help: add --config-all-for-completion","fromName":"Philippe Blain via GitGitGadget","fromEmail":"gitgitgadget@gmail.com","sentAt":"2024-01-28T20:02:52Z","receivedAt":"2024-01-28T20:03:01Z","isPatch":true,"sender":{"key":"levraiphilippeblain@gmail.com","avatar":"https://avatars.githubusercontent.com/u/44212482?v=4"},"body":"From: Philippe Blain <levraiphilippeblain@gmail.com>\n\nThere is currently no machine-friendly way to show _all_ configuration\nvariables from the command line. 'git help --config' does show them all,\nbut it also sets up the pager. 'git help --config-for-completion' omits\nsome variables (those containing wildcards, for example) and 'git help\n--config-section-for-completion' shows only top-level section names.\n\nIn a following commit we will want to have access to a list of all\nconfiguration variables from the Bash completion script. As such, add a\nnew mode for the command, HELP_ACTION_CONFIG_ALL_FOR_COMPLETION,\ntriggered by the new option '--config-all-for-completion'. In this mode,\nshow all variables, just as HELP_ACTION_CONFIG, but do not set up the\npager.\n\nSigned-off-by: Philippe Blain <levraiphilippeblain@gmail.com>\n---\n builtin/help.c | 7 +++++++\n 1 file changed, 7 insertions(+)\n\ndiff --git a/builtin/help.c b/builtin/help.c\nindex dc1fbe2b986..dacaeb10bf4 100644\n--- a/builtin/help.c\n+++ b/builtin/help.c\n@@ -50,6 +50,7 @@ static enum help_action {\n \tHELP_ACTION_DEVELOPER_INTERFACES,\n \tHELP_ACTION_CONFIG_FOR_COMPLETION,\n \tHELP_ACTION_CONFIG_SECTIONS_FOR_COMPLETION,\n+\tHELP_ACTION_CONFIG_ALL_FOR_COMPLETION,\n } cmd_mode;\n \n static const char *html_path;\n@@ -86,6 +87,8 @@ static struct option builtin_help_options[] = {\n \t\t    HELP_ACTION_CONFIG_FOR_COMPLETION, PARSE_OPT_HIDDEN),\n \tOPT_CMDMODE_F(0, \"config-sections-for-completion\", &cmd_mode, \"\",\n \t\t    HELP_ACTION_CONFIG_SECTIONS_FOR_COMPLETION, PARSE_OPT_HIDDEN),\n+\tOPT_CMDMODE_F(0, \"config-all-for-completion\", &cmd_mode, \"\",\n+\t\t    HELP_ACTION_CONFIG_ALL_FOR_COMPLETION, PARSE_OPT_HIDDEN),\n \n \tOPT_END(),\n };\n@@ -670,6 +673,10 @@ int cmd_help(int argc, const char **argv, const char *prefix)\n \t\topt_mode_usage(argc, \"--config-for-completion\", help_format);\n \t\tlist_config_help(SHOW_CONFIG_VARS);\n \t\treturn 0;\n+\tcase HELP_ACTION_CONFIG_ALL_FOR_COMPLETION:\n+\t\topt_mode_usage(argc, \"--config-all-for-completion\", help_format);\n+\t\tlist_config_help(SHOW_CONFIG_HUMAN);\n+\t\treturn 0;\n \tcase HELP_ACTION_USER_INTERFACES:\n \t\topt_mode_usage(argc, \"--user-interfaces\", help_format);\n \t\tlist_user_interfaces_help();\n-- \ngitgitgadget\n\n"},{"id":"487477","messageId":"b41844cd86e74a7d4af84487d4a6f9cb72655e47.1706472173.git.gitgitgadget@gmail.com","threadId":"60803","inReplyTo":"pull.1660.git.git.1706472173.gitgitgadget@gmail.com","subject":"[PATCH 5/5] completion: add an use __git_compute_second_level_config_vars_for_section","fromName":"Philippe Blain via GitGitGadget","fromEmail":"gitgitgadget@gmail.com","sentAt":"2024-01-28T20:02:53Z","receivedAt":"2024-01-28T20:03:01Z","isPatch":true,"sender":{"key":"levraiphilippeblain@gmail.com","avatar":"https://avatars.githubusercontent.com/u/44212482?v=4"},"body":"From: Philippe Blain <levraiphilippeblain@gmail.com>\n\nIn a previous commit we removed some hardcoded config variable names from\nfunction __git_complete_config_variable_name in the completion script by\nintroducing a new function,\n__git_compute_first_level_config_vars_for_section.\n\nThe remaining hardcoded config variables are \"second level\"\nconfiguration variables, meaning 'branch.<name>.upstream',\n'remote.<name>.url', etc. where <name> is a user-defined name.\n\nMaking use of the new --config-all-for-completion flag to 'git help'\nintroduced in the previous commit, add a new function,\n__git_compute_second_level_config_vars_for_section. This function takes\nas argument a config section name and computes the corresponding\nsecond-level config variables, i.e. those that contain a '<' which\nindicates the start of a placeholder. Note that as in\n__git_compute_first_level_config_vars_for_section added previsouly, we\nuse indirect expansion instead of associative arrays to stay compatible\nwith Bash 3 on which macOS is stuck for licensing reasons.\n\nUse this new function and the variables it defines in\n__git_complete_config_variable_name to remove hardcoded config\nvariables, and add a test to verify the new function.  Use a single\n'case' for all sections with second-level variables names, since the\ncode for each of them is now exactly the same.\n\nSigned-off-by: Philippe Blain <levraiphilippeblain@gmail.com>\n---\n contrib/completion/git-completion.bash | 71 ++++++++------------------\n t/t9902-completion.sh                  | 10 ++++\n 2 files changed, 31 insertions(+), 50 deletions(-)\n\ndiff --git a/contrib/completion/git-completion.bash b/contrib/completion/git-completion.bash\nindex 2934ceb7637..0e8fd63bfdb 100644\n--- a/contrib/completion/git-completion.bash\n+++ b/contrib/completion/git-completion.bash\n@@ -2596,6 +2596,13 @@ __git_compute_config_vars ()\n \t__git_config_vars=\"$(git help --config-for-completion)\"\n }\n \n+__git_config_vars_all=\n+__git_compute_config_vars_all ()\n+{\n+\ttest -n \"$__git_config_vars_all\" ||\n+\t__git_config_vars_all=\"$(git help --config-all-for-completion)\"\n+}\n+\n __git_compute_first_level_config_vars_for_section ()\n {\n \tsection=\"$1\"\n@@ -2605,6 +2612,15 @@ __git_compute_first_level_config_vars_for_section ()\n \tprintf -v \"__git_first_level_config_vars_for_section_${section}\" %s \"$(echo \"$__git_config_vars\" | grep -E \"^${section}\\.[a-z]\" | awk -F. '{print $2}')\"\n }\n \n+__git_compute_second_level_config_vars_for_section ()\n+{\n+\tsection=\"$1\"\n+\t__git_compute_config_vars_all\n+\tlocal this_section=\"__git_second_level_config_vars_for_section_${section}\"\n+\ttest -n \"${!this_section}\" ||\n+\tprintf -v \"__git_second_level_config_vars_for_section_${section}\" %s \"$(echo \"$__git_config_vars_all\" | grep -E \"^${section}\\.<\" | awk -F. '{print $3}')\"\n+}\n+\n __git_config_sections=\n __git_compute_config_sections ()\n {\n@@ -2749,10 +2765,13 @@ __git_complete_config_variable_name ()\n \tdone\n \n \tcase \"$cur_\" in\n-\tbranch.*.*)\n+\tbranch.*.*|guitool.*.*|difftool.*.*|man.*.*|mergetool.*.*|remote.*.*|submodule.*.*|url.*.*)\n \t\tlocal pfx=\"${cur_%.*}.\"\n \t\tcur_=\"${cur_##*.}\"\n-\t\t__gitcomp \"remote pushRemote merge mergeOptions rebase\" \"$pfx\" \"$cur_\" \"$sfx\"\n+\t\tlocal section=\"${pfx%.*.}\"\n+\t\t__git_compute_second_level_config_vars_for_section \"${section}\"\n+\t\tlocal this_section=\"__git_second_level_config_vars_for_section_${section}\"\n+\t\t__gitcomp \"${!this_section}\" \"$pfx\" \"$cur_\" \"$sfx\"\n \t\treturn\n \t\t;;\n \tbranch.*)\n@@ -2765,33 +2784,6 @@ __git_complete_config_variable_name ()\n \t\t__gitcomp_nl_append \"${!this_section}\" \"$pfx\" \"$cur_\" \"${sfx:- }\"\n \t\treturn\n \t\t;;\n-\tguitool.*.*)\n-\t\tlocal pfx=\"${cur_%.*}.\"\n-\t\tcur_=\"${cur_##*.}\"\n-\t\t__gitcomp \"\n-\t\t\targPrompt cmd confirm needsFile noConsole noRescan\n-\t\t\tprompt revPrompt revUnmerged title\n-\t\t\t\" \"$pfx\" \"$cur_\" \"$sfx\"\n-\t\treturn\n-\t\t;;\n-\tdifftool.*.*)\n-\t\tlocal pfx=\"${cur_%.*}.\"\n-\t\tcur_=\"${cur_##*.}\"\n-\t\t__gitcomp \"cmd path\" \"$pfx\" \"$cur_\" \"$sfx\"\n-\t\treturn\n-\t\t;;\n-\tman.*.*)\n-\t\tlocal pfx=\"${cur_%.*}.\"\n-\t\tcur_=\"${cur_##*.}\"\n-\t\t__gitcomp \"cmd path\" \"$pfx\" \"$cur_\" \"$sfx\"\n-\t\treturn\n-\t\t;;\n-\tmergetool.*.*)\n-\t\tlocal pfx=\"${cur_%.*}.\"\n-\t\tcur_=\"${cur_##*.}\"\n-\t\t__gitcomp \"cmd path trustExitCode\" \"$pfx\" \"$cur_\" \"$sfx\"\n-\t\treturn\n-\t\t;;\n \tpager.*)\n \t\tlocal pfx=\"${cur_%.*}.\"\n \t\tcur_=\"${cur_#*.}\"\n@@ -2799,15 +2791,6 @@ __git_complete_config_variable_name ()\n \t\t__gitcomp_nl \"$__git_all_commands\" \"$pfx\" \"$cur_\" \"${sfx:- }\"\n \t\treturn\n \t\t;;\n-\tremote.*.*)\n-\t\tlocal pfx=\"${cur_%.*}.\"\n-\t\tcur_=\"${cur_##*.}\"\n-\t\t__gitcomp \"\n-\t\t\turl proxy fetch push mirror skipDefaultUpdate\n-\t\t\treceivepack uploadpack tagOpt pushurl\n-\t\t\t\" \"$pfx\" \"$cur_\" \"$sfx\"\n-\t\treturn\n-\t\t;;\n \tremote.*)\n \t\tlocal pfx=\"${cur_%.*}.\"\n \t\tcur_=\"${cur_#*.}\"\n@@ -2818,12 +2801,6 @@ __git_complete_config_variable_name ()\n \t\t__gitcomp_nl_append \"${!this_section}\" \"$pfx\" \"$cur_\" \"${sfx:- }\"\n \t\treturn\n \t\t;;\n-\tsubmodule.*.*)\n-\t\tlocal pfx=\"${cur_%.*}.\"\n-\t\tcur_=\"${cur_##*.}\"\n-\t\t__gitcomp \"url update branch fetchRecurseSubmodules ignore active\" \"$pfx\" \"$cur_\" \"$sfx\"\n-\t\treturn\n-\t\t;;\n \tsubmodule.*)\n \t\tlocal pfx=\"${cur_%.*}.\"\n \t\tcur_=\"${cur_#*.}\"\n@@ -2834,12 +2811,6 @@ __git_complete_config_variable_name ()\n \t\t__gitcomp_nl_append \"${!this_section}\" \"$pfx\" \"$cur_\" \"${sfx:- }\"\n \t\treturn\n \t\t;;\n-\turl.*.*)\n-\t\tlocal pfx=\"${cur_%.*}.\"\n-\t\tcur_=\"${cur_##*.}\"\n-\t\t__gitcomp \"insteadOf pushInsteadOf\" \"$pfx\" \"$cur_\" \"$sfx\"\n-\t\treturn\n-\t\t;;\n \t*.*)\n \t\t__git_compute_config_vars\n \t\t__gitcomp \"$__git_config_vars\" \"\" \"$cur_\" \"$sfx\"\ndiff --git a/t/t9902-completion.sh b/t/t9902-completion.sh\nindex f28d8f531b7..24ff786b273 100755\n--- a/t/t9902-completion.sh\n+++ b/t/t9902-completion.sh\n@@ -2593,6 +2593,16 @@ test_expect_success 'git config - variable name - __git_compute_first_level_conf\n \tsubmodule.recurse Z\n \tEOF\n '\n+test_expect_success 'git config - variable name - __git_compute_second_level_config_vars_for_section' '\n+\ttest_completion \"git config branch.main.\" <<-\\EOF\n+\tbranch.main.description Z\n+\tbranch.main.remote Z\n+\tbranch.main.pushRemote Z\n+\tbranch.main.merge Z\n+\tbranch.main.mergeOptions Z\n+\tbranch.main.rebase Z\n+\tEOF\n+'\n \n test_expect_success 'git config - value' '\n \ttest_completion \"git config color.pager \" <<-\\EOF\n-- \ngitgitgadget\n"},{"id":"487518","messageId":"pull.1660.v2.git.git.1706534881.gitgitgadget@gmail.com","threadId":"60803","inReplyTo":"pull.1660.git.git.1706472173.gitgitgadget@gmail.com","subject":"[PATCH v2 0/5] completion: remove hardcoded config variable names","fromName":"Philippe Blain via GitGitGadget","fromEmail":"gitgitgadget@gmail.com","sentAt":"2024-01-29T13:27:56Z","receivedAt":"2024-01-29T13:28:05Z","isPatch":true,"sender":{"key":"levraiphilippeblain@gmail.com","avatar":"https://avatars.githubusercontent.com/u/44212482?v=4"},"body":"Changes since v1:\n\n * Corrected my email in PATCH 2/5 (sorry for the noise)\n\nv1: This series removes hardcoded config variable names in the\n__git_complete_config_variable_name function, partly by adding a new mode to\n'git help'. It also adds completion for 'submodule.*' config variables,\nwhich were previously missing.\n\nI think it makes sense to do that in the same series since it's closely\nrelated, and splitting it would result in textual conflicts between both\nseries if one does not build on top of the other, but I'm open to other\nsuggestions.\n\nThanks,\n\nPhilippe.\n\nPhilippe Blain (5):\n  completion: add space after config variable names also in Bash 3\n  completion: complete 'submodule.*' config variables\n  completion: add and use\n    __git_compute_first_level_config_vars_for_section\n  builtin/help: add --config-all-for-completion\n  completion: add an use\n    __git_compute_second_level_config_vars_for_section\n\n builtin/help.c                         |  7 ++\n contrib/completion/git-completion.bash | 90 +++++++++++++-------------\n t/t9902-completion.sh                  | 21 ++++++\n 3 files changed, 74 insertions(+), 44 deletions(-)\n\n\nbase-commit: b50a608ba20348cb3dfc16a696816d51780e3f0f\nPublished-As: https://github.com/gitgitgadget/git/releases/tag/pr-git-1660%2Fphil-blain%2Fcompletion-submodule-config-v2\nFetch-It-Via: git fetch https://github.com/gitgitgadget/git pr-git-1660/phil-blain/completion-submodule-config-v2\nPull-Request: https://github.com/git/git/pull/1660\n\nRange-diff vs v1:\n\n 1:  837d92a6c27 = 1:  837d92a6c27 completion: add space after config variable names also in Bash 3\n 2:  2dd3085f8d8 ! 2:  426374ff9b3 completion: complete 'submodule.*' config variables\n     @@\n       ## Metadata ##\n     -Author: Philippe Blain <philippe.blain@canada.ca>\n     +Author: Philippe Blain <levraiphilippeblain@gmail.com>\n      \n       ## Commit message ##\n          completion: complete 'submodule.*' config variables\n 3:  dd9395bda32 = 3:  838aabf2858 completion: add and use __git_compute_first_level_config_vars_for_section\n 4:  3e83f21eb4e = 4:  d442a039b27 builtin/help: add --config-all-for-completion\n 5:  b41844cd86e = 5:  a2e792c911e completion: add an use __git_compute_second_level_config_vars_for_section\n\n-- \ngitgitgadget\n"},{"id":"487519","messageId":"837d92a6c277015fc8633ca84557124465390548.1706534882.git.gitgitgadget@gmail.com","threadId":"60803","inReplyTo":"pull.1660.v2.git.git.1706534881.gitgitgadget@gmail.com","subject":"[PATCH v2 1/5] completion: add space after config variable names also in Bash 3","fromName":"Philippe Blain via GitGitGadget","fromEmail":"gitgitgadget@gmail.com","sentAt":"2024-01-29T13:27:57Z","receivedAt":"2024-01-29T13:28:06Z","isPatch":true,"sender":{"key":"levraiphilippeblain@gmail.com","avatar":"https://avatars.githubusercontent.com/u/44212482?v=4"},"body":"From: Philippe Blain <levraiphilippeblain@gmail.com>\n\nIn be6444d1ca (completion: bash: add correct suffix in variables,\n2021-08-16), __git_complete_config_variable_name was changed to use\n\"${sfx- }\" instead of \"$sfx\" as the fourth argument of _gitcomp_nl and\n_gitcomp_nl_append, such that this argument evaluates to a space if sfx\nis unset. This was to ensure that e.g.\n\n\tgit config branch.autoSetupMe[TAB]\n\ncorrectly completes to 'branch.autoSetupMerge ' with the trailing space.\nThis commits notes that the fix only works in Bash 4 because in Bash 3\nthe 'local sfx' construct at the beginning of\n__git_complete_config_variable_name creates an empty string.\n\nMake the fix also work for Bash 3 by using the \"unset or null' parameter\nexpansion syntax (\"${sfx:- }\"), such that the parameter is also expanded\nto a space if it is set but null, as is the behaviour of 'local sfx' in\nBash 3.\n\nSigned-off-by: Philippe Blain <levraiphilippeblain@gmail.com>\n---\n contrib/completion/git-completion.bash | 6 +++---\n 1 file changed, 3 insertions(+), 3 deletions(-)\n\ndiff --git a/contrib/completion/git-completion.bash b/contrib/completion/git-completion.bash\nindex 6662db221df..159a4fd8add 100644\n--- a/contrib/completion/git-completion.bash\n+++ b/contrib/completion/git-completion.bash\n@@ -2750,7 +2750,7 @@ __git_complete_config_variable_name ()\n \t\tlocal pfx=\"${cur_%.*}.\"\n \t\tcur_=\"${cur_#*.}\"\n \t\t__gitcomp_direct \"$(__git_heads \"$pfx\" \"$cur_\" \".\")\"\n-\t\t__gitcomp_nl_append $'autoSetupMerge\\nautoSetupRebase\\n' \"$pfx\" \"$cur_\" \"${sfx- }\"\n+\t\t__gitcomp_nl_append $'autoSetupMerge\\nautoSetupRebase\\n' \"$pfx\" \"$cur_\" \"${sfx:- }\"\n \t\treturn\n \t\t;;\n \tguitool.*.*)\n@@ -2784,7 +2784,7 @@ __git_complete_config_variable_name ()\n \t\tlocal pfx=\"${cur_%.*}.\"\n \t\tcur_=\"${cur_#*.}\"\n \t\t__git_compute_all_commands\n-\t\t__gitcomp_nl \"$__git_all_commands\" \"$pfx\" \"$cur_\" \"${sfx- }\"\n+\t\t__gitcomp_nl \"$__git_all_commands\" \"$pfx\" \"$cur_\" \"${sfx:- }\"\n \t\treturn\n \t\t;;\n \tremote.*.*)\n@@ -2800,7 +2800,7 @@ __git_complete_config_variable_name ()\n \t\tlocal pfx=\"${cur_%.*}.\"\n \t\tcur_=\"${cur_#*.}\"\n \t\t__gitcomp_nl \"$(__git_remotes)\" \"$pfx\" \"$cur_\" \".\"\n-\t\t__gitcomp_nl_append \"pushDefault\" \"$pfx\" \"$cur_\" \"${sfx- }\"\n+\t\t__gitcomp_nl_append \"pushDefault\" \"$pfx\" \"$cur_\" \"${sfx:- }\"\n \t\treturn\n \t\t;;\n \turl.*.*)\n-- \ngitgitgadget\n\n"},{"id":"487520","messageId":"426374ff9b3820512f73ef094f9533e6a1ea5cad.1706534882.git.gitgitgadget@gmail.com","threadId":"60803","inReplyTo":"pull.1660.v2.git.git.1706534881.gitgitgadget@gmail.com","subject":"[PATCH v2 2/5] completion: complete 'submodule.*' config variables","fromName":"Philippe Blain via GitGitGadget","fromEmail":"gitgitgadget@gmail.com","sentAt":"2024-01-29T13:27:58Z","receivedAt":"2024-01-29T13:28:07Z","isPatch":true,"sender":{"key":"levraiphilippeblain@gmail.com","avatar":"https://avatars.githubusercontent.com/u/44212482?v=4"},"body":"From: Philippe Blain <levraiphilippeblain@gmail.com>\n\nIn the Bash completion script, function\n__git_complete_config_variable_name completes config variables and has\nspecial logic to deal with config variables involving user-defined\nnames, like branch.<name>.* and remote.<name>.*.\n\nThis special logic is missing for submodule-related config variables.\nAdd the appropriate branches to the case statement, making use of the\nin-tree '.gitmodules' to list relevant submodules.\n\nSigned-off-by: Philippe Blain <levraiphilippeblain@gmail.com>\n---\n contrib/completion/git-completion.bash | 13 +++++++++++++\n 1 file changed, 13 insertions(+)\n\ndiff --git a/contrib/completion/git-completion.bash b/contrib/completion/git-completion.bash\nindex 159a4fd8add..8af9bc3f4e1 100644\n--- a/contrib/completion/git-completion.bash\n+++ b/contrib/completion/git-completion.bash\n@@ -2803,6 +2803,19 @@ __git_complete_config_variable_name ()\n \t\t__gitcomp_nl_append \"pushDefault\" \"$pfx\" \"$cur_\" \"${sfx:- }\"\n \t\treturn\n \t\t;;\n+\tsubmodule.*.*)\n+\t\tlocal pfx=\"${cur_%.*}.\"\n+\t\tcur_=\"${cur_##*.}\"\n+\t\t__gitcomp \"url update branch fetchRecurseSubmodules ignore active\" \"$pfx\" \"$cur_\" \"$sfx\"\n+\t\treturn\n+\t\t;;\n+\tsubmodule.*)\n+\t\tlocal pfx=\"${cur_%.*}.\"\n+\t\tcur_=\"${cur_#*.}\"\n+\t\t__gitcomp_nl \"$(__git config -f \"$(__git rev-parse --show-toplevel)/.gitmodules\" --get-regexp 'submodule.*.path' | awk -F. '{print $2}')\" \"$pfx\" \"$cur_\" \".\"\n+\t\t__gitcomp_nl_append $'alternateErrorStrategy\\nfetchJobs\\nactive\\nalternateLocation\\nrecurse\\npropagateBranches' \"$pfx\" \"$cur_\" \"${sfx:- }\"\n+\t\treturn\n+\t\t;;\n \turl.*.*)\n \t\tlocal pfx=\"${cur_%.*}.\"\n \t\tcur_=\"${cur_##*.}\"\n-- \ngitgitgadget\n\n"},{"id":"487521","messageId":"838aabf2858b73361be8e8579bc80826e1cfd4c3.1706534882.git.gitgitgadget@gmail.com","threadId":"60803","inReplyTo":"pull.1660.v2.git.git.1706534881.gitgitgadget@gmail.com","subject":"[PATCH v2 3/5] completion: add and use __git_compute_first_level_config_vars_for_section","fromName":"Philippe Blain via GitGitGadget","fromEmail":"gitgitgadget@gmail.com","sentAt":"2024-01-29T13:27:59Z","receivedAt":"2024-01-29T13:28:08Z","isPatch":true,"sender":{"key":"levraiphilippeblain@gmail.com","avatar":"https://avatars.githubusercontent.com/u/44212482?v=4"},"body":"From: Philippe Blain <levraiphilippeblain@gmail.com>\n\nThe function __git_complete_config_variable_name in the Bash completion\nscript hardcodes several config variable names. These variables are\nthose in config section where user-defined names can appear, such as\n\"branch.<name>\". These sections are treated first by the case statement,\nand the two last \"catch all\" cases are used for other sections, making\nuse of the __git_compute_config_vars and __git_compute_config_sections\nfunction, which omit listing any variables containing wildcards or\nplaceholders. Having hardcoded config variables introduces the risk of\nthe completion code becoming out of sync with the actual config\nvariables accepted by Git.\n\nTo avoid these hardcoded config variables, introduce a new function,\n__git_compute_first_level_config_vars_for_section, making use of the\nexisting __git_config_vars variable. This function takes as argument a\nconfig section name and computes the matching \"first level\" config\nvariables for that section, i.e. those _not_ containing any placeholder,\nlike 'branch.autoSetupMerge, 'remote.pushDefault', etc.  Use this\nfunction and the variables it defines in the 'branch.*', 'remote.*' and\n'submodule.*' switches of the case statement instead of hardcoding the\ncorresponding config variables.  Note that we use indirect expansion\ninstead of associative arrays because those are not supported in Bash 3,\non which macOS is stuck for licensing reasons.\n\nAdd a test to make sure the new function works correctly by verfying it\nlists all 'submodule' config variables. This has the downside that this\ntest must be updated when new 'submodule' configuration are added, but\nthis should be a small burden since it happens infrequently.\n\nSigned-off-by: Philippe Blain <levraiphilippeblain@gmail.com>\n---\n contrib/completion/git-completion.bash | 24 +++++++++++++++++++++---\n t/t9902-completion.sh                  | 11 +++++++++++\n 2 files changed, 32 insertions(+), 3 deletions(-)\n\ndiff --git a/contrib/completion/git-completion.bash b/contrib/completion/git-completion.bash\nindex 8af9bc3f4e1..2934ceb7637 100644\n--- a/contrib/completion/git-completion.bash\n+++ b/contrib/completion/git-completion.bash\n@@ -2596,6 +2596,15 @@ __git_compute_config_vars ()\n \t__git_config_vars=\"$(git help --config-for-completion)\"\n }\n \n+__git_compute_first_level_config_vars_for_section ()\n+{\n+\tsection=\"$1\"\n+\t__git_compute_config_vars\n+\tlocal this_section=\"__git_first_level_config_vars_for_section_${section}\"\n+\ttest -n \"${!this_section}\" ||\n+\tprintf -v \"__git_first_level_config_vars_for_section_${section}\" %s \"$(echo \"$__git_config_vars\" | grep -E \"^${section}\\.[a-z]\" | awk -F. '{print $2}')\"\n+}\n+\n __git_config_sections=\n __git_compute_config_sections ()\n {\n@@ -2749,8 +2758,11 @@ __git_complete_config_variable_name ()\n \tbranch.*)\n \t\tlocal pfx=\"${cur_%.*}.\"\n \t\tcur_=\"${cur_#*.}\"\n+\t\tlocal section=\"${pfx%.}\"\n \t\t__gitcomp_direct \"$(__git_heads \"$pfx\" \"$cur_\" \".\")\"\n-\t\t__gitcomp_nl_append $'autoSetupMerge\\nautoSetupRebase\\n' \"$pfx\" \"$cur_\" \"${sfx:- }\"\n+\t\t__git_compute_first_level_config_vars_for_section \"${section}\"\n+\t\tlocal this_section=\"__git_first_level_config_vars_for_section_${section}\"\n+\t\t__gitcomp_nl_append \"${!this_section}\" \"$pfx\" \"$cur_\" \"${sfx:- }\"\n \t\treturn\n \t\t;;\n \tguitool.*.*)\n@@ -2799,8 +2811,11 @@ __git_complete_config_variable_name ()\n \tremote.*)\n \t\tlocal pfx=\"${cur_%.*}.\"\n \t\tcur_=\"${cur_#*.}\"\n+\t\tlocal section=\"${pfx%.}\"\n \t\t__gitcomp_nl \"$(__git_remotes)\" \"$pfx\" \"$cur_\" \".\"\n-\t\t__gitcomp_nl_append \"pushDefault\" \"$pfx\" \"$cur_\" \"${sfx:- }\"\n+\t\t__git_compute_first_level_config_vars_for_section \"${section}\"\n+\t\tlocal this_section=\"__git_first_level_config_vars_for_section_${section}\"\n+\t\t__gitcomp_nl_append \"${!this_section}\" \"$pfx\" \"$cur_\" \"${sfx:- }\"\n \t\treturn\n \t\t;;\n \tsubmodule.*.*)\n@@ -2812,8 +2827,11 @@ __git_complete_config_variable_name ()\n \tsubmodule.*)\n \t\tlocal pfx=\"${cur_%.*}.\"\n \t\tcur_=\"${cur_#*.}\"\n+\t\tlocal section=\"${pfx%.}\"\n \t\t__gitcomp_nl \"$(__git config -f \"$(__git rev-parse --show-toplevel)/.gitmodules\" --get-regexp 'submodule.*.path' | awk -F. '{print $2}')\" \"$pfx\" \"$cur_\" \".\"\n-\t\t__gitcomp_nl_append $'alternateErrorStrategy\\nfetchJobs\\nactive\\nalternateLocation\\nrecurse\\npropagateBranches' \"$pfx\" \"$cur_\" \"${sfx:- }\"\n+\t\t__git_compute_first_level_config_vars_for_section \"${section}\"\n+\t\tlocal this_section=\"__git_first_level_config_vars_for_section_${section}\"\n+\t\t__gitcomp_nl_append \"${!this_section}\" \"$pfx\" \"$cur_\" \"${sfx:- }\"\n \t\treturn\n \t\t;;\n \turl.*.*)\ndiff --git a/t/t9902-completion.sh b/t/t9902-completion.sh\nindex 35eb534fdda..f28d8f531b7 100755\n--- a/t/t9902-completion.sh\n+++ b/t/t9902-completion.sh\n@@ -2583,6 +2583,17 @@ test_expect_success 'git config - variable name include' '\n \tEOF\n '\n \n+test_expect_success 'git config - variable name - __git_compute_first_level_config_vars_for_section' '\n+\ttest_completion \"git config submodule.\" <<-\\EOF\n+\tsubmodule.active Z\n+\tsubmodule.alternateErrorStrategy Z\n+\tsubmodule.alternateLocation Z\n+\tsubmodule.fetchJobs Z\n+\tsubmodule.propagateBranches Z\n+\tsubmodule.recurse Z\n+\tEOF\n+'\n+\n test_expect_success 'git config - value' '\n \ttest_completion \"git config color.pager \" <<-\\EOF\n \tfalse Z\n-- \ngitgitgadget\n\n"},{"id":"487522","messageId":"d442a039b27820dbd44e604df75ec026b8243d47.1706534882.git.gitgitgadget@gmail.com","threadId":"60803","inReplyTo":"pull.1660.v2.git.git.1706534881.gitgitgadget@gmail.com","subject":"[PATCH v2 4/5] builtin/help: add --config-all-for-completion","fromName":"Philippe Blain via GitGitGadget","fromEmail":"gitgitgadget@gmail.com","sentAt":"2024-01-29T13:28:00Z","receivedAt":"2024-01-29T13:28:10Z","isPatch":true,"sender":{"key":"levraiphilippeblain@gmail.com","avatar":"https://avatars.githubusercontent.com/u/44212482?v=4"},"body":"From: Philippe Blain <levraiphilippeblain@gmail.com>\n\nThere is currently no machine-friendly way to show _all_ configuration\nvariables from the command line. 'git help --config' does show them all,\nbut it also sets up the pager. 'git help --config-for-completion' omits\nsome variables (those containing wildcards, for example) and 'git help\n--config-section-for-completion' shows only top-level section names.\n\nIn a following commit we will want to have access to a list of all\nconfiguration variables from the Bash completion script. As such, add a\nnew mode for the command, HELP_ACTION_CONFIG_ALL_FOR_COMPLETION,\ntriggered by the new option '--config-all-for-completion'. In this mode,\nshow all variables, just as HELP_ACTION_CONFIG, but do not set up the\npager.\n\nSigned-off-by: Philippe Blain <levraiphilippeblain@gmail.com>\n---\n builtin/help.c | 7 +++++++\n 1 file changed, 7 insertions(+)\n\ndiff --git a/builtin/help.c b/builtin/help.c\nindex dc1fbe2b986..dacaeb10bf4 100644\n--- a/builtin/help.c\n+++ b/builtin/help.c\n@@ -50,6 +50,7 @@ static enum help_action {\n \tHELP_ACTION_DEVELOPER_INTERFACES,\n \tHELP_ACTION_CONFIG_FOR_COMPLETION,\n \tHELP_ACTION_CONFIG_SECTIONS_FOR_COMPLETION,\n+\tHELP_ACTION_CONFIG_ALL_FOR_COMPLETION,\n } cmd_mode;\n \n static const char *html_path;\n@@ -86,6 +87,8 @@ static struct option builtin_help_options[] = {\n \t\t    HELP_ACTION_CONFIG_FOR_COMPLETION, PARSE_OPT_HIDDEN),\n \tOPT_CMDMODE_F(0, \"config-sections-for-completion\", &cmd_mode, \"\",\n \t\t    HELP_ACTION_CONFIG_SECTIONS_FOR_COMPLETION, PARSE_OPT_HIDDEN),\n+\tOPT_CMDMODE_F(0, \"config-all-for-completion\", &cmd_mode, \"\",\n+\t\t    HELP_ACTION_CONFIG_ALL_FOR_COMPLETION, PARSE_OPT_HIDDEN),\n \n \tOPT_END(),\n };\n@@ -670,6 +673,10 @@ int cmd_help(int argc, const char **argv, const char *prefix)\n \t\topt_mode_usage(argc, \"--config-for-completion\", help_format);\n \t\tlist_config_help(SHOW_CONFIG_VARS);\n \t\treturn 0;\n+\tcase HELP_ACTION_CONFIG_ALL_FOR_COMPLETION:\n+\t\topt_mode_usage(argc, \"--config-all-for-completion\", help_format);\n+\t\tlist_config_help(SHOW_CONFIG_HUMAN);\n+\t\treturn 0;\n \tcase HELP_ACTION_USER_INTERFACES:\n \t\topt_mode_usage(argc, \"--user-interfaces\", help_format);\n \t\tlist_user_interfaces_help();\n-- \ngitgitgadget\n\n"},{"id":"487523","messageId":"a2e792c911e1b9fa77d27ec327f6a9dfe06d4de4.1706534882.git.gitgitgadget@gmail.com","threadId":"60803","inReplyTo":"pull.1660.v2.git.git.1706534881.gitgitgadget@gmail.com","subject":"[PATCH v2 5/5] completion: add an use __git_compute_second_level_config_vars_for_section","fromName":"Philippe Blain via GitGitGadget","fromEmail":"gitgitgadget@gmail.com","sentAt":"2024-01-29T13:28:01Z","receivedAt":"2024-01-29T13:28:30Z","isPatch":true,"sender":{"key":"levraiphilippeblain@gmail.com","avatar":"https://avatars.githubusercontent.com/u/44212482?v=4"},"body":"From: Philippe Blain <levraiphilippeblain@gmail.com>\n\nIn a previous commit we removed some hardcoded config variable names from\nfunction __git_complete_config_variable_name in the completion script by\nintroducing a new function,\n__git_compute_first_level_config_vars_for_section.\n\nThe remaining hardcoded config variables are \"second level\"\nconfiguration variables, meaning 'branch.<name>.upstream',\n'remote.<name>.url', etc. where <name> is a user-defined name.\n\nMaking use of the new --config-all-for-completion flag to 'git help'\nintroduced in the previous commit, add a new function,\n__git_compute_second_level_config_vars_for_section. This function takes\nas argument a config section name and computes the corresponding\nsecond-level config variables, i.e. those that contain a '<' which\nindicates the start of a placeholder. Note that as in\n__git_compute_first_level_config_vars_for_section added previsouly, we\nuse indirect expansion instead of associative arrays to stay compatible\nwith Bash 3 on which macOS is stuck for licensing reasons.\n\nUse this new function and the variables it defines in\n__git_complete_config_variable_name to remove hardcoded config\nvariables, and add a test to verify the new function.  Use a single\n'case' for all sections with second-level variables names, since the\ncode for each of them is now exactly the same.\n\nSigned-off-by: Philippe Blain <levraiphilippeblain@gmail.com>\n---\n contrib/completion/git-completion.bash | 71 ++++++++------------------\n t/t9902-completion.sh                  | 10 ++++\n 2 files changed, 31 insertions(+), 50 deletions(-)\n\ndiff --git a/contrib/completion/git-completion.bash b/contrib/completion/git-completion.bash\nindex 2934ceb7637..0e8fd63bfdb 100644\n--- a/contrib/completion/git-completion.bash\n+++ b/contrib/completion/git-completion.bash\n@@ -2596,6 +2596,13 @@ __git_compute_config_vars ()\n \t__git_config_vars=\"$(git help --config-for-completion)\"\n }\n \n+__git_config_vars_all=\n+__git_compute_config_vars_all ()\n+{\n+\ttest -n \"$__git_config_vars_all\" ||\n+\t__git_config_vars_all=\"$(git help --config-all-for-completion)\"\n+}\n+\n __git_compute_first_level_config_vars_for_section ()\n {\n \tsection=\"$1\"\n@@ -2605,6 +2612,15 @@ __git_compute_first_level_config_vars_for_section ()\n \tprintf -v \"__git_first_level_config_vars_for_section_${section}\" %s \"$(echo \"$__git_config_vars\" | grep -E \"^${section}\\.[a-z]\" | awk -F. '{print $2}')\"\n }\n \n+__git_compute_second_level_config_vars_for_section ()\n+{\n+\tsection=\"$1\"\n+\t__git_compute_config_vars_all\n+\tlocal this_section=\"__git_second_level_config_vars_for_section_${section}\"\n+\ttest -n \"${!this_section}\" ||\n+\tprintf -v \"__git_second_level_config_vars_for_section_${section}\" %s \"$(echo \"$__git_config_vars_all\" | grep -E \"^${section}\\.<\" | awk -F. '{print $3}')\"\n+}\n+\n __git_config_sections=\n __git_compute_config_sections ()\n {\n@@ -2749,10 +2765,13 @@ __git_complete_config_variable_name ()\n \tdone\n \n \tcase \"$cur_\" in\n-\tbranch.*.*)\n+\tbranch.*.*|guitool.*.*|difftool.*.*|man.*.*|mergetool.*.*|remote.*.*|submodule.*.*|url.*.*)\n \t\tlocal pfx=\"${cur_%.*}.\"\n \t\tcur_=\"${cur_##*.}\"\n-\t\t__gitcomp \"remote pushRemote merge mergeOptions rebase\" \"$pfx\" \"$cur_\" \"$sfx\"\n+\t\tlocal section=\"${pfx%.*.}\"\n+\t\t__git_compute_second_level_config_vars_for_section \"${section}\"\n+\t\tlocal this_section=\"__git_second_level_config_vars_for_section_${section}\"\n+\t\t__gitcomp \"${!this_section}\" \"$pfx\" \"$cur_\" \"$sfx\"\n \t\treturn\n \t\t;;\n \tbranch.*)\n@@ -2765,33 +2784,6 @@ __git_complete_config_variable_name ()\n \t\t__gitcomp_nl_append \"${!this_section}\" \"$pfx\" \"$cur_\" \"${sfx:- }\"\n \t\treturn\n \t\t;;\n-\tguitool.*.*)\n-\t\tlocal pfx=\"${cur_%.*}.\"\n-\t\tcur_=\"${cur_##*.}\"\n-\t\t__gitcomp \"\n-\t\t\targPrompt cmd confirm needsFile noConsole noRescan\n-\t\t\tprompt revPrompt revUnmerged title\n-\t\t\t\" \"$pfx\" \"$cur_\" \"$sfx\"\n-\t\treturn\n-\t\t;;\n-\tdifftool.*.*)\n-\t\tlocal pfx=\"${cur_%.*}.\"\n-\t\tcur_=\"${cur_##*.}\"\n-\t\t__gitcomp \"cmd path\" \"$pfx\" \"$cur_\" \"$sfx\"\n-\t\treturn\n-\t\t;;\n-\tman.*.*)\n-\t\tlocal pfx=\"${cur_%.*}.\"\n-\t\tcur_=\"${cur_##*.}\"\n-\t\t__gitcomp \"cmd path\" \"$pfx\" \"$cur_\" \"$sfx\"\n-\t\treturn\n-\t\t;;\n-\tmergetool.*.*)\n-\t\tlocal pfx=\"${cur_%.*}.\"\n-\t\tcur_=\"${cur_##*.}\"\n-\t\t__gitcomp \"cmd path trustExitCode\" \"$pfx\" \"$cur_\" \"$sfx\"\n-\t\treturn\n-\t\t;;\n \tpager.*)\n \t\tlocal pfx=\"${cur_%.*}.\"\n \t\tcur_=\"${cur_#*.}\"\n@@ -2799,15 +2791,6 @@ __git_complete_config_variable_name ()\n \t\t__gitcomp_nl \"$__git_all_commands\" \"$pfx\" \"$cur_\" \"${sfx:- }\"\n \t\treturn\n \t\t;;\n-\tremote.*.*)\n-\t\tlocal pfx=\"${cur_%.*}.\"\n-\t\tcur_=\"${cur_##*.}\"\n-\t\t__gitcomp \"\n-\t\t\turl proxy fetch push mirror skipDefaultUpdate\n-\t\t\treceivepack uploadpack tagOpt pushurl\n-\t\t\t\" \"$pfx\" \"$cur_\" \"$sfx\"\n-\t\treturn\n-\t\t;;\n \tremote.*)\n \t\tlocal pfx=\"${cur_%.*}.\"\n \t\tcur_=\"${cur_#*.}\"\n@@ -2818,12 +2801,6 @@ __git_complete_config_variable_name ()\n \t\t__gitcomp_nl_append \"${!this_section}\" \"$pfx\" \"$cur_\" \"${sfx:- }\"\n \t\treturn\n \t\t;;\n-\tsubmodule.*.*)\n-\t\tlocal pfx=\"${cur_%.*}.\"\n-\t\tcur_=\"${cur_##*.}\"\n-\t\t__gitcomp \"url update branch fetchRecurseSubmodules ignore active\" \"$pfx\" \"$cur_\" \"$sfx\"\n-\t\treturn\n-\t\t;;\n \tsubmodule.*)\n \t\tlocal pfx=\"${cur_%.*}.\"\n \t\tcur_=\"${cur_#*.}\"\n@@ -2834,12 +2811,6 @@ __git_complete_config_variable_name ()\n \t\t__gitcomp_nl_append \"${!this_section}\" \"$pfx\" \"$cur_\" \"${sfx:- }\"\n \t\treturn\n \t\t;;\n-\turl.*.*)\n-\t\tlocal pfx=\"${cur_%.*}.\"\n-\t\tcur_=\"${cur_##*.}\"\n-\t\t__gitcomp \"insteadOf pushInsteadOf\" \"$pfx\" \"$cur_\" \"$sfx\"\n-\t\treturn\n-\t\t;;\n \t*.*)\n \t\t__git_compute_config_vars\n \t\t__gitcomp \"$__git_config_vars\" \"\" \"$cur_\" \"$sfx\"\ndiff --git a/t/t9902-completion.sh b/t/t9902-completion.sh\nindex f28d8f531b7..24ff786b273 100755\n--- a/t/t9902-completion.sh\n+++ b/t/t9902-completion.sh\n@@ -2593,6 +2593,16 @@ test_expect_success 'git config - variable name - __git_compute_first_level_conf\n \tsubmodule.recurse Z\n \tEOF\n '\n+test_expect_success 'git config - variable name - __git_compute_second_level_config_vars_for_section' '\n+\ttest_completion \"git config branch.main.\" <<-\\EOF\n+\tbranch.main.description Z\n+\tbranch.main.remote Z\n+\tbranch.main.pushRemote Z\n+\tbranch.main.merge Z\n+\tbranch.main.mergeOptions Z\n+\tbranch.main.rebase Z\n+\tEOF\n+'\n \n test_expect_success 'git config - value' '\n \ttest_completion \"git config color.pager \" <<-\\EOF\n-- \ngitgitgadget\n"},{"id":"488189","messageId":"xmqq8r3w53nc.fsf@gitster.g","threadId":"60803","inReplyTo":"pull.1660.v2.git.git.1706534881.gitgitgadget@gmail.com","subject":"Re: [PATCH v2 0/5] completion: remove hardcoded config variable names","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2024-02-07T22:08:07Z","receivedAt":"2024-02-07T22:08:12Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"\"Philippe Blain via GitGitGadget\" <gitgitgadget@gmail.com> writes:\n\n> Changes since v1:\n>\n>  * Corrected my email in PATCH 2/5 (sorry for the noise)\n>\n> v1: This series removes hardcoded config variable names in the\n> __git_complete_config_variable_name function, partly by adding a new mode to\n> 'git help'. It also adds completion for 'submodule.*' config variables,\n> which were previously missing.\n>\n> I think it makes sense to do that in the same series since it's closely\n> related, and splitting it would result in textual conflicts between both\n> series if one does not build on top of the other, but I'm open to other\n> suggestions.\n>\n> Thanks,\n\nNeither rounds of this series unfortunately got any review.\nComments from anybody interested in helping to improve completion\nscripts?\n\nThanks.\n"},{"id":"488212","messageId":"ZcSFy864re825MZu@tanuki","threadId":"60803","inReplyTo":"xmqq8r3w53nc.fsf@gitster.g","subject":"Re: [PATCH v2 0/5] completion: remove hardcoded config variable names","fromName":"Patrick Steinhardt","fromEmail":"ps@pks.im","sentAt":"2024-02-08T07:42:03Z","receivedAt":"2024-02-08T07:42:11Z","isPatch":true,"sender":{"key":"ps@pks.im","avatar":"https://avatars.githubusercontent.com/u/4056630?v=4"},"body":"On Wed, Feb 07, 2024 at 02:08:07PM -0800, Junio C Hamano wrote:\n> \"Philippe Blain via GitGitGadget\" <gitgitgadget@gmail.com> writes:\n> \n> > Changes since v1:\n> >\n> >  * Corrected my email in PATCH 2/5 (sorry for the noise)\n> >\n> > v1: This series removes hardcoded config variable names in the\n> > __git_complete_config_variable_name function, partly by adding a new mode to\n> > 'git help'. It also adds completion for 'submodule.*' config variables,\n> > which were previously missing.\n> >\n> > I think it makes sense to do that in the same series since it's closely\n> > related, and splitting it would result in textual conflicts between both\n> > series if one does not build on top of the other, but I'm open to other\n> > suggestions.\n> >\n> > Thanks,\n> \n> Neither rounds of this series unfortunately got any review.\n> Comments from anybody interested in helping to improve completion\n> scripts?\n\nWell, I've spent some time with Bash completion recently, so let me give\nit a go. I was trying to avoid the dense Bash logic and thus shied away\nfrom reviewing it. But the end result of having less hardcoded values is\nquite nice indeed.\n\nPatrick\n"},{"id":"488213","messageId":"ZcSF0Uw0xxlJXRlH@tanuki","threadId":"60803","inReplyTo":"426374ff9b3820512f73ef094f9533e6a1ea5cad.1706534882.git.gitgitgadget@gmail.com","subject":"Re: [PATCH v2 2/5] completion: complete 'submodule.*' config variables","fromName":"Patrick Steinhardt","fromEmail":"ps@pks.im","sentAt":"2024-02-08T07:42:09Z","receivedAt":"2024-02-08T07:42:13Z","isPatch":true,"sender":{"key":"ps@pks.im","avatar":"https://avatars.githubusercontent.com/u/4056630?v=4"},"body":"On Mon, Jan 29, 2024 at 01:27:58PM +0000, Philippe Blain via GitGitGadget wrote:\n> From: Philippe Blain <levraiphilippeblain@gmail.com>\n> \n> In the Bash completion script, function\n> __git_complete_config_variable_name completes config variables and has\n> special logic to deal with config variables involving user-defined\n> names, like branch.<name>.* and remote.<name>.*.\n> \n> This special logic is missing for submodule-related config variables.\n> Add the appropriate branches to the case statement, making use of the\n> in-tree '.gitmodules' to list relevant submodules.\n> \n> Signed-off-by: Philippe Blain <levraiphilippeblain@gmail.com>\n> ---\n>  contrib/completion/git-completion.bash | 13 +++++++++++++\n>  1 file changed, 13 insertions(+)\n> \n> diff --git a/contrib/completion/git-completion.bash b/contrib/completion/git-completion.bash\n> index 159a4fd8add..8af9bc3f4e1 100644\n> --- a/contrib/completion/git-completion.bash\n> +++ b/contrib/completion/git-completion.bash\n> @@ -2803,6 +2803,19 @@ __git_complete_config_variable_name ()\n>  \t\t__gitcomp_nl_append \"pushDefault\" \"$pfx\" \"$cur_\" \"${sfx:- }\"\n>  \t\treturn\n>  \t\t;;\n> +\tsubmodule.*.*)\n> +\t\tlocal pfx=\"${cur_%.*}.\"\n> +\t\tcur_=\"${cur_##*.}\"\n> +\t\t__gitcomp \"url update branch fetchRecurseSubmodules ignore active\" \"$pfx\" \"$cur_\" \"$sfx\"\n> +\t\treturn\n> +\t\t;;\n> +\tsubmodule.*)\n> +\t\tlocal pfx=\"${cur_%.*}.\"\n> +\t\tcur_=\"${cur_#*.}\"\n> +\t\t__gitcomp_nl \"$(__git config -f \"$(__git rev-parse --show-toplevel)/.gitmodules\" --get-regexp 'submodule.*.path' | awk -F. '{print $2}')\" \"$pfx\" \"$cur_\" \".\"\n> +\t\t__gitcomp_nl_append $'alternateErrorStrategy\\nfetchJobs\\nactive\\nalternateLocation\\nrecurse\\npropagateBranches' \"$pfx\" \"$cur_\" \"${sfx:- }\"\n> +\t\treturn\n> +\t\t;;\n\nHm, it feels quite awkward that we have to manually massage the\ngitmodules config like this. But the closest tool I could find is\n`git submodule status`, which would also end up describing commits in\neach of the submodules and thus do needless work. And second, it prints\nsubmodule paths and not submodule names, so it surfaces the wrong info\nin the first place.\n\nIdeally, we would create such a tool that makes the information more\naccessible to us. But that certainly seems out of scope of this patch\nseries.\n\nIn any case though it would be nice to add some tests for these new\ncompletions.\n\nPatrick\n\n>  \turl.*.*)\n>  \t\tlocal pfx=\"${cur_%.*}.\"\n>  \t\tcur_=\"${cur_##*.}\"\n> -- \n> gitgitgadget\n> \n> \n"},{"id":"488214","messageId":"ZcSF1mJ-JXQLmoZ5@tanuki","threadId":"60803","inReplyTo":"838aabf2858b73361be8e8579bc80826e1cfd4c3.1706534882.git.gitgitgadget@gmail.com","subject":"Re: [PATCH v2 3/5] completion: add and use __git_compute_first_level_config_vars_for_section","fromName":"Patrick Steinhardt","fromEmail":"ps@pks.im","sentAt":"2024-02-08T07:42:14Z","receivedAt":"2024-02-08T07:42:17Z","isPatch":true,"sender":{"key":"ps@pks.im","avatar":"https://avatars.githubusercontent.com/u/4056630?v=4"},"body":"On Mon, Jan 29, 2024 at 01:27:59PM +0000, Philippe Blain via GitGitGadget wrote:\n> From: Philippe Blain <levraiphilippeblain@gmail.com>\n> \n> The function __git_complete_config_variable_name in the Bash completion\n> script hardcodes several config variable names. These variables are\n> those in config section where user-defined names can appear, such as\n> \"branch.<name>\". These sections are treated first by the case statement,\n> and the two last \"catch all\" cases are used for other sections, making\n> use of the __git_compute_config_vars and __git_compute_config_sections\n> function, which omit listing any variables containing wildcards or\n> placeholders. Having hardcoded config variables introduces the risk of\n> the completion code becoming out of sync with the actual config\n> variables accepted by Git.\n> \n> To avoid these hardcoded config variables, introduce a new function,\n> __git_compute_first_level_config_vars_for_section, making use of the\n> existing __git_config_vars variable. This function takes as argument a\n> config section name and computes the matching \"first level\" config\n> variables for that section, i.e. those _not_ containing any placeholder,\n> like 'branch.autoSetupMerge, 'remote.pushDefault', etc.  Use this\n> function and the variables it defines in the 'branch.*', 'remote.*' and\n> 'submodule.*' switches of the case statement instead of hardcoding the\n> corresponding config variables.  Note that we use indirect expansion\n> instead of associative arrays because those are not supported in Bash 3,\n> on which macOS is stuck for licensing reasons.\n> \n> Add a test to make sure the new function works correctly by verfying it\n> lists all 'submodule' config variables. This has the downside that this\n> test must be updated when new 'submodule' configuration are added, but\n> this should be a small burden since it happens infrequently.\n> \n> Signed-off-by: Philippe Blain <levraiphilippeblain@gmail.com>\n> ---\n>  contrib/completion/git-completion.bash | 24 +++++++++++++++++++++---\n>  t/t9902-completion.sh                  | 11 +++++++++++\n>  2 files changed, 32 insertions(+), 3 deletions(-)\n> \n> diff --git a/contrib/completion/git-completion.bash b/contrib/completion/git-completion.bash\n> index 8af9bc3f4e1..2934ceb7637 100644\n> --- a/contrib/completion/git-completion.bash\n> +++ b/contrib/completion/git-completion.bash\n> @@ -2596,6 +2596,15 @@ __git_compute_config_vars ()\n>  \t__git_config_vars=\"$(git help --config-for-completion)\"\n>  }\n>  \n> +__git_compute_first_level_config_vars_for_section ()\n> +{\n> +\tsection=\"$1\"\n\nSection needs to be `local`, right?\n\n> +\t__git_compute_config_vars\n> +\tlocal this_section=\"__git_first_level_config_vars_for_section_${section}\"\n> +\ttest -n \"${!this_section}\" ||\n> +\tprintf -v \"__git_first_level_config_vars_for_section_${section}\" %s \"$(echo \"$__git_config_vars\" | grep -E \"^${section}\\.[a-z]\" | awk -F. '{print $2}')\"\n> +}\n\nI've been wondering a bit why we store the result in a global variable.\nThe value certainly isn't reused in the completion scripts here. It took\nme quite some time to realize though that it's going to end up in the\nuser's shell environment even after completion finishes so that it can\nbe reused the next time we invoke the completion function.\n\nWhile this does feel a tad weird to me to be stateful like this across\ncompletion calls, we use the same pattern for `__git_config_vars` and\n`__git_config_sections`. So I guess it should be fine given that there\nis precedent.\n\n>  __git_config_sections=\n>  __git_compute_config_sections ()\n>  {\n> @@ -2749,8 +2758,11 @@ __git_complete_config_variable_name ()\n>  \tbranch.*)\n>  \t\tlocal pfx=\"${cur_%.*}.\"\n>  \t\tcur_=\"${cur_#*.}\"\n> +\t\tlocal section=\"${pfx%.}\"\n>  \t\t__gitcomp_direct \"$(__git_heads \"$pfx\" \"$cur_\" \".\")\"\n> -\t\t__gitcomp_nl_append $'autoSetupMerge\\nautoSetupRebase\\n' \"$pfx\" \"$cur_\" \"${sfx:- }\"\n> +\t\t__git_compute_first_level_config_vars_for_section \"${section}\"\n> +\t\tlocal this_section=\"__git_first_level_config_vars_for_section_${section}\"\n> +\t\t__gitcomp_nl_append \"${!this_section}\" \"$pfx\" \"$cur_\" \"${sfx:- }\"\n>  \t\treturn\n>  \t\t;;\n>  \tguitool.*.*)\n> @@ -2799,8 +2811,11 @@ __git_complete_config_variable_name ()\n>  \tremote.*)\n>  \t\tlocal pfx=\"${cur_%.*}.\"\n>  \t\tcur_=\"${cur_#*.}\"\n> +\t\tlocal section=\"${pfx%.}\"\n>  \t\t__gitcomp_nl \"$(__git_remotes)\" \"$pfx\" \"$cur_\" \".\"\n> -\t\t__gitcomp_nl_append \"pushDefault\" \"$pfx\" \"$cur_\" \"${sfx:- }\"\n> +\t\t__git_compute_first_level_config_vars_for_section \"${section}\"\n> +\t\tlocal this_section=\"__git_first_level_config_vars_for_section_${section}\"\n> +\t\t__gitcomp_nl_append \"${!this_section}\" \"$pfx\" \"$cur_\" \"${sfx:- }\"\n>  \t\treturn\n>  \t\t;;\n>  \tsubmodule.*.*)\n> @@ -2812,8 +2827,11 @@ __git_complete_config_variable_name ()\n>  \tsubmodule.*)\n>  \t\tlocal pfx=\"${cur_%.*}.\"\n>  \t\tcur_=\"${cur_#*.}\"\n> +\t\tlocal section=\"${pfx%.}\"\n>  \t\t__gitcomp_nl \"$(__git config -f \"$(__git rev-parse --show-toplevel)/.gitmodules\" --get-regexp 'submodule.*.path' | awk -F. '{print $2}')\" \"$pfx\" \"$cur_\" \".\"\n> -\t\t__gitcomp_nl_append $'alternateErrorStrategy\\nfetchJobs\\nactive\\nalternateLocation\\nrecurse\\npropagateBranches' \"$pfx\" \"$cur_\" \"${sfx:- }\"\n> +\t\t__git_compute_first_level_config_vars_for_section \"${section}\"\n> +\t\tlocal this_section=\"__git_first_level_config_vars_for_section_${section}\"\n> +\t\t__gitcomp_nl_append \"${!this_section}\" \"$pfx\" \"$cur_\" \"${sfx:- }\"\n>  \t\treturn\n>  \t\t;;\n>  \turl.*.*)\n> diff --git a/t/t9902-completion.sh b/t/t9902-completion.sh\n> index 35eb534fdda..f28d8f531b7 100755\n> --- a/t/t9902-completion.sh\n> +++ b/t/t9902-completion.sh\n> @@ -2583,6 +2583,17 @@ test_expect_success 'git config - variable name include' '\n>  \tEOF\n>  '\n>  \n> +test_expect_success 'git config - variable name - __git_compute_first_level_config_vars_for_section' '\n> +\ttest_completion \"git config submodule.\" <<-\\EOF\n> +\tsubmodule.active Z\n> +\tsubmodule.alternateErrorStrategy Z\n> +\tsubmodule.alternateLocation Z\n> +\tsubmodule.fetchJobs Z\n> +\tsubmodule.propagateBranches Z\n> +\tsubmodule.recurse Z\n> +\tEOF\n> +'\n> +\n\nShouldn't we verify that we know to complete both first-level config\nvars as well as the user-specified submodule names here?\n\nPatrick\n\n>  test_expect_success 'git config - value' '\n>  \ttest_completion \"git config color.pager \" <<-\\EOF\n>  \tfalse Z\n> -- \n> gitgitgadget\n> \n> \n"},{"id":"488215","messageId":"ZcSF2mw-zR1d38UG@tanuki","threadId":"60803","inReplyTo":"d442a039b27820dbd44e604df75ec026b8243d47.1706534882.git.gitgitgadget@gmail.com","subject":"Re: [PATCH v2 4/5] builtin/help: add --config-all-for-completion","fromName":"Patrick Steinhardt","fromEmail":"ps@pks.im","sentAt":"2024-02-08T07:42:18Z","receivedAt":"2024-02-08T07:42:22Z","isPatch":true,"sender":{"key":"ps@pks.im","avatar":"https://avatars.githubusercontent.com/u/4056630?v=4"},"body":"On Mon, Jan 29, 2024 at 01:28:00PM +0000, Philippe Blain via GitGitGadget wrote:\n> From: Philippe Blain <levraiphilippeblain@gmail.com>\n> \n> There is currently no machine-friendly way to show _all_ configuration\n> variables from the command line. 'git help --config' does show them all,\n> but it also sets up the pager. 'git help --config-for-completion' omits\n> some variables (those containing wildcards, for example) and 'git help\n> --config-section-for-completion' shows only top-level section names.\n\nYou can invoke `git --no-pager help --config` so that Git does not set\nup the pager. Is there a reason why we can't use that?\n\n> In a following commit we will want to have access to a list of all\n> configuration variables from the Bash completion script. As such, add a\n> new mode for the command, HELP_ACTION_CONFIG_ALL_FOR_COMPLETION,\n> triggered by the new option '--config-all-for-completion'. In this mode,\n> show all variables, just as HELP_ACTION_CONFIG, but do not set up the\n> pager.\n> \n> Signed-off-by: Philippe Blain <levraiphilippeblain@gmail.com>\n> ---\n>  builtin/help.c | 7 +++++++\n>  1 file changed, 7 insertions(+)\n> \n> diff --git a/builtin/help.c b/builtin/help.c\n> index dc1fbe2b986..dacaeb10bf4 100644\n> --- a/builtin/help.c\n> +++ b/builtin/help.c\n> @@ -50,6 +50,7 @@ static enum help_action {\n>  \tHELP_ACTION_DEVELOPER_INTERFACES,\n>  \tHELP_ACTION_CONFIG_FOR_COMPLETION,\n>  \tHELP_ACTION_CONFIG_SECTIONS_FOR_COMPLETION,\n> +\tHELP_ACTION_CONFIG_ALL_FOR_COMPLETION,\n>  } cmd_mode;\n>  \n>  static const char *html_path;\n> @@ -86,6 +87,8 @@ static struct option builtin_help_options[] = {\n>  \t\t    HELP_ACTION_CONFIG_FOR_COMPLETION, PARSE_OPT_HIDDEN),\n>  \tOPT_CMDMODE_F(0, \"config-sections-for-completion\", &cmd_mode, \"\",\n>  \t\t    HELP_ACTION_CONFIG_SECTIONS_FOR_COMPLETION, PARSE_OPT_HIDDEN),\n> +\tOPT_CMDMODE_F(0, \"config-all-for-completion\", &cmd_mode, \"\",\n> +\t\t    HELP_ACTION_CONFIG_ALL_FOR_COMPLETION, PARSE_OPT_HIDDEN),\n>  \n>  \tOPT_END(),\n>  };\n> @@ -670,6 +673,10 @@ int cmd_help(int argc, const char **argv, const char *prefix)\n>  \t\topt_mode_usage(argc, \"--config-for-completion\", help_format);\n>  \t\tlist_config_help(SHOW_CONFIG_VARS);\n>  \t\treturn 0;\n> +\tcase HELP_ACTION_CONFIG_ALL_FOR_COMPLETION:\n> +\t\topt_mode_usage(argc, \"--config-all-for-completion\", help_format);\n> +\t\tlist_config_help(SHOW_CONFIG_HUMAN);\n> +\t\treturn 0;\n>  \tcase HELP_ACTION_USER_INTERFACES:\n>  \t\topt_mode_usage(argc, \"--user-interfaces\", help_format);\n>  \t\tlist_user_interfaces_help();\n\nWe should add a testcase to \"t0012-help.sh\" to exercise this new\nfeature. That would also help show the reviewer what exactly it will end\nup printing.\n\nPatrick\n"},{"id":"488216","messageId":"ZcSF4fv_a16Ziwyy@tanuki","threadId":"60803","inReplyTo":"a2e792c911e1b9fa77d27ec327f6a9dfe06d4de4.1706534882.git.gitgitgadget@gmail.com","subject":"Re: [PATCH v2 5/5] completion: add an use __git_compute_second_level_config_vars_for_section","fromName":"Patrick Steinhardt","fromEmail":"ps@pks.im","sentAt":"2024-02-08T07:42:25Z","receivedAt":"2024-02-08T07:42:28Z","isPatch":true,"sender":{"key":"ps@pks.im","avatar":"https://avatars.githubusercontent.com/u/4056630?v=4"},"body":"On Mon, Jan 29, 2024 at 01:28:01PM +0000, Philippe Blain via GitGitGadget wrote:\n> From: Philippe Blain <levraiphilippeblain@gmail.com>\n[snip]\n> diff --git a/contrib/completion/git-completion.bash b/contrib/completion/git-completion.bash\n> index 2934ceb7637..0e8fd63bfdb 100644\n> --- a/contrib/completion/git-completion.bash\n> +++ b/contrib/completion/git-completion.bash\n> @@ -2605,6 +2612,15 @@ __git_compute_first_level_config_vars_for_section ()\n>  \tprintf -v \"__git_first_level_config_vars_for_section_${section}\" %s \"$(echo \"$__git_config_vars\" | grep -E \"^${section}\\.[a-z]\" | awk -F. '{print $2}')\"\n>  }\n>  \n> +__git_compute_second_level_config_vars_for_section ()\n> +{\n> +\tsection=\"$1\"\n\nThis should be `local section`, as well.\n\n> +\t__git_compute_config_vars_all\n> +\tlocal this_section=\"__git_second_level_config_vars_for_section_${section}\"\n> +\ttest -n \"${!this_section}\" ||\n> +\tprintf -v \"__git_second_level_config_vars_for_section_${section}\" %s \"$(echo \"$__git_config_vars_all\" | grep -E \"^${section}\\.<\" | awk -F. '{print $3}')\"\n> +}\n> +\n>  __git_config_sections=\n>  __git_compute_config_sections ()\n>  {\n> @@ -2749,10 +2765,13 @@ __git_complete_config_variable_name ()\n>  \tdone\n>  \n>  \tcase \"$cur_\" in\n> -\tbranch.*.*)\n> +\tbranch.*.*|guitool.*.*|difftool.*.*|man.*.*|mergetool.*.*|remote.*.*|submodule.*.*|url.*.*)\n>  \t\tlocal pfx=\"${cur_%.*}.\"\n>  \t\tcur_=\"${cur_##*.}\"\n> -\t\t__gitcomp \"remote pushRemote merge mergeOptions rebase\" \"$pfx\" \"$cur_\" \"$sfx\"\n> +\t\tlocal section=\"${pfx%.*.}\"\n> +\t\t__git_compute_second_level_config_vars_for_section \"${section}\"\n> +\t\tlocal this_section=\"__git_second_level_config_vars_for_section_${section}\"\n> +\t\t__gitcomp \"${!this_section}\" \"$pfx\" \"$cur_\" \"$sfx\"\n>  \t\treturn\n>  \t\t;;\n\nNice.\n\n[snip]\n> diff --git a/t/t9902-completion.sh b/t/t9902-completion.sh\n> index f28d8f531b7..24ff786b273 100755\n> --- a/t/t9902-completion.sh\n> +++ b/t/t9902-completion.sh\n> @@ -2593,6 +2593,16 @@ test_expect_success 'git config - variable name - __git_compute_first_level_conf\n>  \tsubmodule.recurse Z\n>  \tEOF\n>  '\n\nMissing a newline.\n\n> +test_expect_success 'git config - variable name - __git_compute_second_level_config_vars_for_section' '\n> +\ttest_completion \"git config branch.main.\" <<-\\EOF\n> +\tbranch.main.description Z\n> +\tbranch.main.remote Z\n> +\tbranch.main.pushRemote Z\n> +\tbranch.main.merge Z\n> +\tbranch.main.mergeOptions Z\n> +\tbranch.main.rebase Z\n> +\tEOF\n> +'\n\nPatrick\n"},{"id":"488351","messageId":"14b31a82-6c16-025c-3a85-41424dd47417@gmail.com","threadId":"60803","inReplyTo":"ZcSF0Uw0xxlJXRlH@tanuki","subject":"Re: [PATCH v2 2/5] completion: complete 'submodule.*' config variables","fromName":"Philippe Blain","fromEmail":"levraiphilippeblain@gmail.com","sentAt":"2024-02-10T15:39:33Z","receivedAt":"2024-02-10T15:39:37Z","isPatch":true,"sender":{"key":"levraiphilippeblain@gmail.com","avatar":"https://avatars.githubusercontent.com/u/44212482?v=4"},"body":"Hi Patrick,\n\nLe 2024-02-08 à 02:42, Patrick Steinhardt a écrit :\n> On Mon, Jan 29, 2024 at 01:27:58PM +0000, Philippe Blain via GitGitGadget wrote:\n>> From: Philippe Blain <levraiphilippeblain@gmail.com>\n>>\n>> In the Bash completion script, function\n>> __git_complete_config_variable_name completes config variables and has\n>> special logic to deal with config variables involving user-defined\n>> names, like branch.<name>.* and remote.<name>.*.\n>>\n>> This special logic is missing for submodule-related config variables.\n>> Add the appropriate branches to the case statement, making use of the\n>> in-tree '.gitmodules' to list relevant submodules.\n>>\n>> Signed-off-by: Philippe Blain <levraiphilippeblain@gmail.com>\n>> ---\n>>  contrib/completion/git-completion.bash | 13 +++++++++++++\n>>  1 file changed, 13 insertions(+)\n>>\n>> diff --git a/contrib/completion/git-completion.bash b/contrib/completion/git-completion.bash\n>> index 159a4fd8add..8af9bc3f4e1 100644\n>> --- a/contrib/completion/git-completion.bash\n>> +++ b/contrib/completion/git-completion.bash\n>> @@ -2803,6 +2803,19 @@ __git_complete_config_variable_name ()\n>>  \t\t__gitcomp_nl_append \"pushDefault\" \"$pfx\" \"$cur_\" \"${sfx:- }\"\n>>  \t\treturn\n>>  \t\t;;\n>> +\tsubmodule.*.*)\n>> +\t\tlocal pfx=\"${cur_%.*}.\"\n>> +\t\tcur_=\"${cur_##*.}\"\n>> +\t\t__gitcomp \"url update branch fetchRecurseSubmodules ignore active\" \"$pfx\" \"$cur_\" \"$sfx\"\n>> +\t\treturn\n>> +\t\t;;\n>> +\tsubmodule.*)\n>> +\t\tlocal pfx=\"${cur_%.*}.\"\n>> +\t\tcur_=\"${cur_#*.}\"\n>> +\t\t__gitcomp_nl \"$(__git config -f \"$(__git rev-parse --show-toplevel)/.gitmodules\" --get-regexp 'submodule.*.path' | awk -F. '{print $2}')\" \"$pfx\" \"$cur_\" \".\"\n>> +\t\t__gitcomp_nl_append $'alternateErrorStrategy\\nfetchJobs\\nactive\\nalternateLocation\\nrecurse\\npropagateBranches' \"$pfx\" \"$cur_\" \"${sfx:- }\"\n>> +\t\treturn\n>> +\t\t;;\n> \n> Hm, it feels quite awkward that we have to manually massage the\n> gitmodules config like this. But the closest tool I could find is\n> `git submodule status`, which would also end up describing commits in\n> each of the submodules and thus do needless work. And second, it prints\n> submodule paths and not submodule names, so it surfaces the wrong info\n> in the first place.\n> \n> Ideally, we would create such a tool that makes the information more\n> accessible to us. But that certainly seems out of scope of this patch\n> series.\n> \n> In any case though it would be nice to add some tests for these new\n> completions.\n\nOK, I end up testing them in 3/5 via the __git_compute_first_level_config_vars_for_section\nfunction I'm adding. But it's true I could add the test directly\nin 2/5, if it makes more sense.\n\nThanks for your review !\n\nPhilippe.\n"},{"id":"488352","messageId":"e8642ad8-bdc9-00d6-39b5-81dd399e60ec@gmail.com","threadId":"60803","inReplyTo":"ZcSF1mJ-JXQLmoZ5@tanuki","subject":"Re: [PATCH v2 3/5] completion: add and use __git_compute_first_level_config_vars_for_section","fromName":"Philippe Blain","fromEmail":"levraiphilippeblain@gmail.com","sentAt":"2024-02-10T16:06:23Z","receivedAt":"2024-02-10T16:06:26Z","isPatch":true,"sender":{"key":"levraiphilippeblain@gmail.com","avatar":"https://avatars.githubusercontent.com/u/44212482?v=4"},"body":"\n\nLe 2024-02-08 à 02:42, Patrick Steinhardt a écrit :\n> On Mon, Jan 29, 2024 at 01:27:59PM +0000, Philippe Blain via GitGitGadget wrote:\n>> From: Philippe Blain <levraiphilippeblain@gmail.com>\n>>\n>> The function __git_complete_config_variable_name in the Bash completion\n>> script hardcodes several config variable names. These variables are\n>> those in config section where user-defined names can appear, such as\n>> \"branch.<name>\". These sections are treated first by the case statement,\n>> and the two last \"catch all\" cases are used for other sections, making\n>> use of the __git_compute_config_vars and __git_compute_config_sections\n>> function, which omit listing any variables containing wildcards or\n>> placeholders. Having hardcoded config variables introduces the risk of\n>> the completion code becoming out of sync with the actual config\n>> variables accepted by Git.\n>>\n>> To avoid these hardcoded config variables, introduce a new function,\n>> __git_compute_first_level_config_vars_for_section, making use of the\n>> existing __git_config_vars variable. This function takes as argument a\n>> config section name and computes the matching \"first level\" config\n>> variables for that section, i.e. those _not_ containing any placeholder,\n>> like 'branch.autoSetupMerge, 'remote.pushDefault', etc.  Use this\n>> function and the variables it defines in the 'branch.*', 'remote.*' and\n>> 'submodule.*' switches of the case statement instead of hardcoding the\n>> corresponding config variables.  Note that we use indirect expansion\n>> instead of associative arrays because those are not supported in Bash 3,\n>> on which macOS is stuck for licensing reasons.\n>>\n>> Add a test to make sure the new function works correctly by verfying it\n>> lists all 'submodule' config variables. This has the downside that this\n>> test must be updated when new 'submodule' configuration are added, but\n>> this should be a small burden since it happens infrequently.\n>>\n>> Signed-off-by: Philippe Blain <levraiphilippeblain@gmail.com>\n>> ---\n>>  contrib/completion/git-completion.bash | 24 +++++++++++++++++++++---\n>>  t/t9902-completion.sh                  | 11 +++++++++++\n>>  2 files changed, 32 insertions(+), 3 deletions(-)\n>>\n>> diff --git a/contrib/completion/git-completion.bash b/contrib/completion/git-completion.bash\n>> index 8af9bc3f4e1..2934ceb7637 100644\n>> --- a/contrib/completion/git-completion.bash\n>> +++ b/contrib/completion/git-completion.bash\n>> @@ -2596,6 +2596,15 @@ __git_compute_config_vars ()\n>>  \t__git_config_vars=\"$(git help --config-for-completion)\"\n>>  }\n>>  \n>> +__git_compute_first_level_config_vars_for_section ()\n>> +{\n>> +\tsection=\"$1\"\n> \n> Section needs to be `local`, right?\n\nGood eyes, I'll fix that in v3.\n\n>> +\t__git_compute_config_vars\n>> +\tlocal this_section=\"__git_first_level_config_vars_for_section_${section}\"\n>> +\ttest -n \"${!this_section}\" ||\n>> +\tprintf -v \"__git_first_level_config_vars_for_section_${section}\" %s \"$(echo \"$__git_config_vars\" | grep -E \"^${section}\\.[a-z]\" | awk -F. '{print $2}')\"\n>> +}\n> \n> I've been wondering a bit why we store the result in a global variable.\n> The value certainly isn't reused in the completion scripts here. It took\n> me quite some time to realize though that it's going to end up in the\n> user's shell environment even after completion finishes so that it can\n> be reused the next time we invoke the completion function.\n> \n> While this does feel a tad weird to me to be stateful like this across\n> completion calls, we use the same pattern for `__git_config_vars` and\n> `__git_config_sections`. So I guess it should be fine given that there\n> is precedent.\n\nYes, I used this pattern because it was already used for other variables in \nthe script, __git_config_vars and __git_config_sections are some examples,\n\n    git grep 'test -n .* ||' contrib/completion/git-completion.bash\n\nfinds also others. I think the idea is to cache these lists to avoid \ncomputing them everytime they are needed (probably most useful on Windows \nwhere process creation is longer). I'll mention that in the \ncommit message.\n\n\n>>  __git_config_sections=\n>>  __git_compute_config_sections ()\n>>  {\n>> @@ -2749,8 +2758,11 @@ __git_complete_config_variable_name ()\n>>  \tbranch.*)\n>>  \t\tlocal pfx=\"${cur_%.*}.\"\n>>  \t\tcur_=\"${cur_#*.}\"\n>> +\t\tlocal section=\"${pfx%.}\"\n>>  \t\t__gitcomp_direct \"$(__git_heads \"$pfx\" \"$cur_\" \".\")\"\n>> -\t\t__gitcomp_nl_append $'autoSetupMerge\\nautoSetupRebase\\n' \"$pfx\" \"$cur_\" \"${sfx:- }\"\n>> +\t\t__git_compute_first_level_config_vars_for_section \"${section}\"\n>> +\t\tlocal this_section=\"__git_first_level_config_vars_for_section_${section}\"\n>> +\t\t__gitcomp_nl_append \"${!this_section}\" \"$pfx\" \"$cur_\" \"${sfx:- }\"\n>>  \t\treturn\n>>  \t\t;;\n>>  \tguitool.*.*)\n>> @@ -2799,8 +2811,11 @@ __git_complete_config_variable_name ()\n>>  \tremote.*)\n>>  \t\tlocal pfx=\"${cur_%.*}.\"\n>>  \t\tcur_=\"${cur_#*.}\"\n>> +\t\tlocal section=\"${pfx%.}\"\n>>  \t\t__gitcomp_nl \"$(__git_remotes)\" \"$pfx\" \"$cur_\" \".\"\n>> -\t\t__gitcomp_nl_append \"pushDefault\" \"$pfx\" \"$cur_\" \"${sfx:- }\"\n>> +\t\t__git_compute_first_level_config_vars_for_section \"${section}\"\n>> +\t\tlocal this_section=\"__git_first_level_config_vars_for_section_${section}\"\n>> +\t\t__gitcomp_nl_append \"${!this_section}\" \"$pfx\" \"$cur_\" \"${sfx:- }\"\n>>  \t\treturn\n>>  \t\t;;\n>>  \tsubmodule.*.*)\n>> @@ -2812,8 +2827,11 @@ __git_complete_config_variable_name ()\n>>  \tsubmodule.*)\n>>  \t\tlocal pfx=\"${cur_%.*}.\"\n>>  \t\tcur_=\"${cur_#*.}\"\n>> +\t\tlocal section=\"${pfx%.}\"\n>>  \t\t__gitcomp_nl \"$(__git config -f \"$(__git rev-parse --show-toplevel)/.gitmodules\" --get-regexp 'submodule.*.path' | awk -F. '{print $2}')\" \"$pfx\" \"$cur_\" \".\"\n>> -\t\t__gitcomp_nl_append $'alternateErrorStrategy\\nfetchJobs\\nactive\\nalternateLocation\\nrecurse\\npropagateBranches' \"$pfx\" \"$cur_\" \"${sfx:- }\"\n>> +\t\t__git_compute_first_level_config_vars_for_section \"${section}\"\n>> +\t\tlocal this_section=\"__git_first_level_config_vars_for_section_${section}\"\n>> +\t\t__gitcomp_nl_append \"${!this_section}\" \"$pfx\" \"$cur_\" \"${sfx:- }\"\n>>  \t\treturn\n>>  \t\t;;\n>>  \turl.*.*)\n>> diff --git a/t/t9902-completion.sh b/t/t9902-completion.sh\n>> index 35eb534fdda..f28d8f531b7 100755\n>> --- a/t/t9902-completion.sh\n>> +++ b/t/t9902-completion.sh\n>> @@ -2583,6 +2583,17 @@ test_expect_success 'git config - variable name include' '\n>>  \tEOF\n>>  '\n>>  \n>> +test_expect_success 'git config - variable name - __git_compute_first_level_config_vars_for_section' '\n>> +\ttest_completion \"git config submodule.\" <<-\\EOF\n>> +\tsubmodule.active Z\n>> +\tsubmodule.alternateErrorStrategy Z\n>> +\tsubmodule.alternateLocation Z\n>> +\tsubmodule.fetchJobs Z\n>> +\tsubmodule.propagateBranches Z\n>> +\tsubmodule.recurse Z\n>> +\tEOF\n>> +'\n>> +\n> \n> Shouldn't we verify that we know to complete both first-level config\n> vars as well as the user-specified submodule names here?\n\nYes that would be more complete indeed, but it would then make more\nsense to add that test in 2/5 since __git_compute_first_level_config_vars_for_section\nis not involved in determining submodule names.\n\nI'll make that change, thanks.\n\nPhilippe.\n"},{"id":"488353","messageId":"527a643d-5d63-da05-70ad-99200a7b85d1@gmail.com","threadId":"60803","inReplyTo":"ZcSF2mw-zR1d38UG@tanuki","subject":"Re: [PATCH v2 4/5] builtin/help: add --config-all-for-completion","fromName":"Philippe Blain","fromEmail":"levraiphilippeblain@gmail.com","sentAt":"2024-02-10T16:13:34Z","receivedAt":"2024-02-10T16:13:37Z","isPatch":true,"sender":{"key":"levraiphilippeblain@gmail.com","avatar":"https://avatars.githubusercontent.com/u/44212482?v=4"},"body":"\n\nLe 2024-02-08 à 02:42, Patrick Steinhardt a écrit :\n> On Mon, Jan 29, 2024 at 01:28:00PM +0000, Philippe Blain via GitGitGadget wrote:\n>> From: Philippe Blain <levraiphilippeblain@gmail.com>\n>>\n>> There is currently no machine-friendly way to show _all_ configuration\n>> variables from the command line. 'git help --config' does show them all,\n>> but it also sets up the pager. 'git help --config-for-completion' omits\n>> some variables (those containing wildcards, for example) and 'git help\n>> --config-section-for-completion' shows only top-level section names.\n> \n> You can invoke `git --no-pager help --config` so that Git does not set\n> up the pager. Is there a reason why we can't use that?\n\nI'm glad to say there is no reason we can't use that! I just did not\nthink of it and dived straight into the C code. I'll use that in v3 and\njust drop this patch from the series.\n\nThanks!\n\nPhilippe.\n"},{"id":"488354","messageId":"418cb344-8e8c-9603-6e3e-d9fb23ac6141@gmail.com","threadId":"60803","inReplyTo":"ZcSF4fv_a16Ziwyy@tanuki","subject":"Re: [PATCH v2 5/5] completion: add an use __git_compute_second_level_config_vars_for_section","fromName":"Philippe Blain","fromEmail":"levraiphilippeblain@gmail.com","sentAt":"2024-02-10T16:19:46Z","receivedAt":"2024-02-10T16:19:48Z","isPatch":true,"sender":{"key":"levraiphilippeblain@gmail.com","avatar":"https://avatars.githubusercontent.com/u/44212482?v=4"},"body":"\n\nLe 2024-02-08 à 02:42, Patrick Steinhardt a écrit :\n> On Mon, Jan 29, 2024 at 01:28:01PM +0000, Philippe Blain via GitGitGadget wrote:\n>> From: Philippe Blain <levraiphilippeblain@gmail.com>\n> [snip]\n>> diff --git a/contrib/completion/git-completion.bash b/contrib/completion/git-completion.bash\n>> index 2934ceb7637..0e8fd63bfdb 100644\n>> --- a/contrib/completion/git-completion.bash\n>> +++ b/contrib/completion/git-completion.bash\n>> @@ -2605,6 +2612,15 @@ __git_compute_first_level_config_vars_for_section ()\n>>  \tprintf -v \"__git_first_level_config_vars_for_section_${section}\" %s \"$(echo \"$__git_config_vars\" | grep -E \"^${section}\\.[a-z]\" | awk -F. '{print $2}')\"\n>>  }\n>>  \n>> +__git_compute_second_level_config_vars_for_section ()\n>> +{\n>> +\tsection=\"$1\"\n> \n> This should be `local section`, as well.\n\nThanks, fixed.\n\n \n> [snip]\n>> diff --git a/t/t9902-completion.sh b/t/t9902-completion.sh\n>> index f28d8f531b7..24ff786b273 100755\n>> --- a/t/t9902-completion.sh\n>> +++ b/t/t9902-completion.sh\n>> @@ -2593,6 +2593,16 @@ test_expect_success 'git config - variable name - __git_compute_first_level_conf\n>>  \tsubmodule.recurse Z\n>>  \tEOF\n>>  '\n> \n> Missing a newline.\n\nFixed. \n\nThank you again for your review Patrick, much appreciated.\n\nPhilippe.\n"},{"id":"488356","messageId":"xmqqwmrcb5q8.fsf@gitster.g","threadId":"60803","inReplyTo":"e8642ad8-bdc9-00d6-39b5-81dd399e60ec@gmail.com","subject":"Re: [PATCH v2 3/5] completion: add and use __git_compute_first_level_config_vars_for_section","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2024-02-10T17:15:43Z","receivedAt":"2024-02-10T17:15:47Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Philippe Blain <levraiphilippeblain@gmail.com> writes:\n\n>>> +\t__git_compute_config_vars\n>>> +\tlocal this_section=\"__git_first_level_config_vars_for_section_${section}\"\n>>> +\ttest -n \"${!this_section}\" ||\n>>> +\tprintf -v \"__git_first_level_config_vars_for_section_${section}\" %s \"$(echo \"$__git_config_vars\" | grep -E \"^${section}\\.[a-z]\" | awk -F. '{print $2}')\"\n>>> +}\n\nA silly question (primarily because I do not much use the indirect\nreference construct ${!name}).  Does the assignment with printf need\nto spell out the long variable name with \"_${section}\"?  Can it be\n\n    printf -v \"$this_section\" ...\n\ninstead, as we already have the short-hand for it?\n\n> finds also others. I think the idea is to cache these lists to avoid \n> computing them everytime they are needed (probably most useful on Windows \n> where process creation is longer). I'll mention that in the \n> commit message.\n\nYup, as long as the contents of the list stays stable (e.g., list of\nGit subcommands, list of options a Git subcommand takes, list of\nconfiguration variable names that do not have end-user customization\npart, etc.), it is a viable optimization technique.  The available\n<slot> for color.branch.<slot> and color.diff.<slot> do not change\n(unless you talk about new version of Git adding support for more\nslots) and is a good idea to cache.  remote.<name>.url takes its\n<name> component out of an unbound set of end-user controlled names,\nso unless we somehow have a method to invalidate cached values, the\nlist can go stale as remotes are added and removed.\n\nThanks.\n\n\n\n"},{"id":"488360","messageId":"996fab96-82b1-0b54-3a09-0ecc18d68a11@gmail.com","threadId":"60803","inReplyTo":"xmqqwmrcb5q8.fsf@gitster.g","subject":"Re: [PATCH v2 3/5] completion: add and use __git_compute_first_level_config_vars_for_section","fromName":"Philippe Blain","fromEmail":"levraiphilippeblain@gmail.com","sentAt":"2024-02-10T17:27:05Z","receivedAt":"2024-02-10T17:27:07Z","isPatch":true,"sender":{"key":"levraiphilippeblain@gmail.com","avatar":"https://avatars.githubusercontent.com/u/44212482?v=4"},"body":"Hi Junio,\n\nLe 2024-02-10 à 12:15, Junio C Hamano a écrit :\n> Philippe Blain <levraiphilippeblain@gmail.com> writes:\n> \n>>>> +\t__git_compute_config_vars\n>>>> +\tlocal this_section=\"__git_first_level_config_vars_for_section_${section}\"\n>>>> +\ttest -n \"${!this_section}\" ||\n>>>> +\tprintf -v \"__git_first_level_config_vars_for_section_${section}\" %s \"$(echo \"$__git_config_vars\" | grep -E \"^${section}\\.[a-z]\" | awk -F. '{print $2}')\"\n>>>> +}\n> \n> A silly question (primarily because I do not much use the indirect\n> reference construct ${!name}).  Does the assignment with printf need\n> to spell out the long variable name with \"_${section}\"?  Can it be\n> \n>     printf -v \"$this_section\" ...\n> \n> instead, as we already have the short-hand for it?\n\nNo, unfortunately neither \"$this_section\" nor \"${!this_section}\"\nwork, so we must use the long name.\n\n> \n>> finds also others. I think the idea is to cache these lists to avoid \n>> computing them everytime they are needed (probably most useful on Windows \n>> where process creation is longer). I'll mention that in the \n>> commit message.\n> \n> Yup, as long as the contents of the list stays stable (e.g., list of\n> Git subcommands, list of options a Git subcommand takes, list of\n> configuration variable names that do not have end-user customization\n> part, etc.), it is a viable optimization technique.  The available\n> <slot> for color.branch.<slot> and color.diff.<slot> do not change\n> (unless you talk about new version of Git adding support for more\n> slots) and is a good idea to cache.  remote.<name>.url takes its\n> <name> component out of an unbound set of end-user controlled names,\n> so unless we somehow have a method to invalidate cached values, the\n> list can go stale as remotes are added and removed.\n\nIndeed. Here I'm caching Git config variables, not any user-defined names,\nso these are stable.\n\nThanks,\n\nPhilippe.\n \n"},{"id":"488363","messageId":"837d92a6c277015fc8633ca84557124465390548.1707589943.git.gitgitgadget@gmail.com","threadId":"60803","inReplyTo":"pull.1660.v3.git.git.1707589943.gitgitgadget@gmail.com","subject":"[PATCH v3 1/4] completion: add space after config variable names also in Bash 3","fromName":"Philippe Blain via GitGitGadget","fromEmail":"gitgitgadget@gmail.com","sentAt":"2024-02-10T18:32:20Z","receivedAt":"2024-02-10T18:32:27Z","isPatch":true,"sender":{"key":"levraiphilippeblain@gmail.com","avatar":"https://avatars.githubusercontent.com/u/44212482?v=4"},"body":"From: Philippe Blain <levraiphilippeblain@gmail.com>\n\nIn be6444d1ca (completion: bash: add correct suffix in variables,\n2021-08-16), __git_complete_config_variable_name was changed to use\n\"${sfx- }\" instead of \"$sfx\" as the fourth argument of _gitcomp_nl and\n_gitcomp_nl_append, such that this argument evaluates to a space if sfx\nis unset. This was to ensure that e.g.\n\n\tgit config branch.autoSetupMe[TAB]\n\ncorrectly completes to 'branch.autoSetupMerge ' with the trailing space.\nThis commits notes that the fix only works in Bash 4 because in Bash 3\nthe 'local sfx' construct at the beginning of\n__git_complete_config_variable_name creates an empty string.\n\nMake the fix also work for Bash 3 by using the \"unset or null' parameter\nexpansion syntax (\"${sfx:- }\"), such that the parameter is also expanded\nto a space if it is set but null, as is the behaviour of 'local sfx' in\nBash 3.\n\nSigned-off-by: Philippe Blain <levraiphilippeblain@gmail.com>\n---\n contrib/completion/git-completion.bash | 6 +++---\n 1 file changed, 3 insertions(+), 3 deletions(-)\n\ndiff --git a/contrib/completion/git-completion.bash b/contrib/completion/git-completion.bash\nindex 6662db221df..159a4fd8add 100644\n--- a/contrib/completion/git-completion.bash\n+++ b/contrib/completion/git-completion.bash\n@@ -2750,7 +2750,7 @@ __git_complete_config_variable_name ()\n \t\tlocal pfx=\"${cur_%.*}.\"\n \t\tcur_=\"${cur_#*.}\"\n \t\t__gitcomp_direct \"$(__git_heads \"$pfx\" \"$cur_\" \".\")\"\n-\t\t__gitcomp_nl_append $'autoSetupMerge\\nautoSetupRebase\\n' \"$pfx\" \"$cur_\" \"${sfx- }\"\n+\t\t__gitcomp_nl_append $'autoSetupMerge\\nautoSetupRebase\\n' \"$pfx\" \"$cur_\" \"${sfx:- }\"\n \t\treturn\n \t\t;;\n \tguitool.*.*)\n@@ -2784,7 +2784,7 @@ __git_complete_config_variable_name ()\n \t\tlocal pfx=\"${cur_%.*}.\"\n \t\tcur_=\"${cur_#*.}\"\n \t\t__git_compute_all_commands\n-\t\t__gitcomp_nl \"$__git_all_commands\" \"$pfx\" \"$cur_\" \"${sfx- }\"\n+\t\t__gitcomp_nl \"$__git_all_commands\" \"$pfx\" \"$cur_\" \"${sfx:- }\"\n \t\treturn\n \t\t;;\n \tremote.*.*)\n@@ -2800,7 +2800,7 @@ __git_complete_config_variable_name ()\n \t\tlocal pfx=\"${cur_%.*}.\"\n \t\tcur_=\"${cur_#*.}\"\n \t\t__gitcomp_nl \"$(__git_remotes)\" \"$pfx\" \"$cur_\" \".\"\n-\t\t__gitcomp_nl_append \"pushDefault\" \"$pfx\" \"$cur_\" \"${sfx- }\"\n+\t\t__gitcomp_nl_append \"pushDefault\" \"$pfx\" \"$cur_\" \"${sfx:- }\"\n \t\treturn\n \t\t;;\n \turl.*.*)\n-- \ngitgitgadget\n\n"},{"id":"488364","messageId":"pull.1660.v3.git.git.1707589943.gitgitgadget@gmail.com","threadId":"60803","inReplyTo":"pull.1660.v2.git.git.1706534881.gitgitgadget@gmail.com","subject":"[PATCH v3 0/4] completion: remove hardcoded config variable names","fromName":"Philippe Blain via GitGitGadget","fromEmail":"gitgitgadget@gmail.com","sentAt":"2024-02-10T18:32:19Z","receivedAt":"2024-02-10T18:32:27Z","isPatch":true,"sender":{"key":"levraiphilippeblain@gmail.com","avatar":"https://avatars.githubusercontent.com/u/44212482?v=4"},"body":"Changes since v2:\n\n * Moved the addition of the tests to 2/4, and tweaked 3/4 and 4/4 so they\n   simply adjust the test names\n * Added a test for user-defined submodule names, as suggested by Patrick\n * Added more details in the commit message of 3/4 around the use of global\n   variables as caches\n * Slightly improved commit message wording and fixed typos\n * Added 'local' where suggested\n * Dropped 4/5 which modified 'git help', since it's not needed (thanks\n   Patrick!)\n\nChanges since v1:\n\n * Corrected my email in PATCH 2/5 (sorry for the noise)\n\nv1: This series removes hardcoded config variable names in the\n__git_complete_config_variable_name function, partly by adding a new mode to\n'git help'. It also adds completion for 'submodule.*' config variables,\nwhich were previously missing.\n\nI think it makes sense to do that in the same series since it's closely\nrelated, and splitting it would result in textual conflicts between both\nseries if one does not build on top of the other, but I'm open to other\nsuggestions.\n\nThanks,\n\nPhilippe.\n\nPhilippe Blain (4):\n  completion: add space after config variable names also in Bash 3\n  completion: complete 'submodule.*' config variables\n  completion: add and use\n    __git_compute_first_level_config_vars_for_section\n  completion: add and use\n    __git_compute_second_level_config_vars_for_section\n\n contrib/completion/git-completion.bash | 90 +++++++++++++-------------\n t/t9902-completion.sh                  | 29 +++++++++\n 2 files changed, 75 insertions(+), 44 deletions(-)\n\n\nbase-commit: b50a608ba20348cb3dfc16a696816d51780e3f0f\nPublished-As: https://github.com/gitgitgadget/git/releases/tag/pr-git-1660%2Fphil-blain%2Fcompletion-submodule-config-v3\nFetch-It-Via: git fetch https://github.com/gitgitgadget/git pr-git-1660/phil-blain/completion-submodule-config-v3\nPull-Request: https://github.com/git/git/pull/1660\n\nRange-diff vs v2:\n\n 1:  837d92a6c27 = 1:  837d92a6c27 completion: add space after config variable names also in Bash 3\n 2:  426374ff9b3 ! 2:  6b75582ee35 completion: complete 'submodule.*' config variables\n     @@ Commit message\n          Add the appropriate branches to the case statement, making use of the\n          in-tree '.gitmodules' to list relevant submodules.\n      \n     +    Add corresponding tests in t9902-completion.sh, making sure we complete\n     +    both first level submodule config variables as well as second level\n     +    variables involving submodule names.\n     +\n          Signed-off-by: Philippe Blain <levraiphilippeblain@gmail.com>\n      \n       ## contrib/completion/git-completion.bash ##\n     @@ contrib/completion/git-completion.bash: __git_complete_config_variable_name ()\n       \turl.*.*)\n       \t\tlocal pfx=\"${cur_%.*}.\"\n       \t\tcur_=\"${cur_##*.}\"\n     +\n     + ## t/t9902-completion.sh ##\n     +@@ t/t9902-completion.sh: test_expect_success 'git config - variable name include' '\n     + \tEOF\n     + '\n     + \n     ++test_expect_success 'setup for git config submodule tests' '\n     ++\ttest_create_repo sub &&\n     ++\ttest_commit -C sub initial &&\n     ++\tgit submodule add ./sub\n     ++'\n     ++\n     ++test_expect_success 'git config - variable name - submodule' '\n     ++\ttest_completion \"git config submodule.\" <<-\\EOF\n     ++\tsubmodule.active Z\n     ++\tsubmodule.alternateErrorStrategy Z\n     ++\tsubmodule.alternateLocation Z\n     ++\tsubmodule.fetchJobs Z\n     ++\tsubmodule.propagateBranches Z\n     ++\tsubmodule.recurse Z\n     ++\tsubmodule.sub.Z\n     ++\tEOF\n     ++'\n     ++\n     ++test_expect_success 'git config - variable name - submodule names' '\n     ++\ttest_completion \"git config submodule.sub.\" <<-\\EOF\n     ++\tsubmodule.sub.url Z\n     ++\tsubmodule.sub.update Z\n     ++\tsubmodule.sub.branch Z\n     ++\tsubmodule.sub.fetchRecurseSubmodules Z\n     ++\tsubmodule.sub.ignore Z\n     ++\tsubmodule.sub.active Z\n     ++\tEOF\n     ++'\n     ++\n     + test_expect_success 'git config - value' '\n     + \ttest_completion \"git config color.pager \" <<-\\EOF\n     + \tfalse Z\n 3:  838aabf2858 ! 3:  fb210325394 completion: add and use __git_compute_first_level_config_vars_for_section\n     @@ Commit message\n      \n          The function __git_complete_config_variable_name in the Bash completion\n          script hardcodes several config variable names. These variables are\n     -    those in config section where user-defined names can appear, such as\n     +    those in config sections where user-defined names can appear, such as\n          \"branch.<name>\". These sections are treated first by the case statement,\n          and the two last \"catch all\" cases are used for other sections, making\n          use of the __git_compute_config_vars and __git_compute_config_sections\n     @@ Commit message\n          like 'branch.autoSetupMerge, 'remote.pushDefault', etc.  Use this\n          function and the variables it defines in the 'branch.*', 'remote.*' and\n          'submodule.*' switches of the case statement instead of hardcoding the\n     -    corresponding config variables.  Note that we use indirect expansion\n     -    instead of associative arrays because those are not supported in Bash 3,\n     -    on which macOS is stuck for licensing reasons.\n     +    corresponding config variables.  Note that we use indirect expansion to\n     +    create a variable for each section, instead of using a single\n     +    associative array indexed by section names, because associative arrays\n     +    are not supported in Bash 3, on which macOS is stuck for licensing\n     +    reasons.\n      \n     -    Add a test to make sure the new function works correctly by verfying it\n     -    lists all 'submodule' config variables. This has the downside that this\n     -    test must be updated when new 'submodule' configuration are added, but\n     -    this should be a small burden since it happens infrequently.\n     +    Use the existing pattern in the completion script of using global\n     +    variables to cache the list of config variables for each section. The\n     +    rationale for such caching is explained in eaa4e6ee2a (Speed up bash\n     +    completion loading, 2009-11-17), and the current approach to using and\n     +    defining them via 'test -n' is explained in cf0ff02a38 (completion: work\n     +    around zsh option propagation bug, 2012-02-02).\n     +\n     +    Adjust the name of one of the tests added in the previous commit,\n     +    reflecting that it now also tests the new function.\n      \n          Signed-off-by: Philippe Blain <levraiphilippeblain@gmail.com>\n      \n     @@ contrib/completion/git-completion.bash: __git_compute_config_vars ()\n       \n      +__git_compute_first_level_config_vars_for_section ()\n      +{\n     -+\tsection=\"$1\"\n     ++\tlocal section=\"$1\"\n      +\t__git_compute_config_vars\n      +\tlocal this_section=\"__git_first_level_config_vars_for_section_${section}\"\n      +\ttest -n \"${!this_section}\" ||\n     @@ contrib/completion/git-completion.bash: __git_complete_config_variable_name ()\n       \turl.*.*)\n      \n       ## t/t9902-completion.sh ##\n     -@@ t/t9902-completion.sh: test_expect_success 'git config - variable name include' '\n     - \tEOF\n     +@@ t/t9902-completion.sh: test_expect_success 'setup for git config submodule tests' '\n     + \tgit submodule add ./sub\n       '\n       \n     -+test_expect_success 'git config - variable name - __git_compute_first_level_config_vars_for_section' '\n     -+\ttest_completion \"git config submodule.\" <<-\\EOF\n     -+\tsubmodule.active Z\n     -+\tsubmodule.alternateErrorStrategy Z\n     -+\tsubmodule.alternateLocation Z\n     -+\tsubmodule.fetchJobs Z\n     -+\tsubmodule.propagateBranches Z\n     -+\tsubmodule.recurse Z\n     -+\tEOF\n     -+'\n     -+\n     - test_expect_success 'git config - value' '\n     - \ttest_completion \"git config color.pager \" <<-\\EOF\n     - \tfalse Z\n     +-test_expect_success 'git config - variable name - submodule' '\n     ++test_expect_success 'git config - variable name - submodule and __git_compute_first_level_config_vars_for_section' '\n     + \ttest_completion \"git config submodule.\" <<-\\EOF\n     + \tsubmodule.active Z\n     + \tsubmodule.alternateErrorStrategy Z\n 4:  d442a039b27 < -:  ----------- builtin/help: add --config-all-for-completion\n 5:  a2e792c911e ! 4:  69fc02bb6b4 completion: add an use __git_compute_second_level_config_vars_for_section\n     @@ Metadata\n      Author: Philippe Blain <levraiphilippeblain@gmail.com>\n      \n       ## Commit message ##\n     -    completion: add an use __git_compute_second_level_config_vars_for_section\n     +    completion: add and use __git_compute_second_level_config_vars_for_section\n      \n          In a previous commit we removed some hardcoded config variable names from\n          function __git_complete_config_variable_name in the completion script by\n     @@ Commit message\n          configuration variables, meaning 'branch.<name>.upstream',\n          'remote.<name>.url', etc. where <name> is a user-defined name.\n      \n     -    Making use of the new --config-all-for-completion flag to 'git help'\n     -    introduced in the previous commit, add a new function,\n     -    __git_compute_second_level_config_vars_for_section. This function takes\n     -    as argument a config section name and computes the corresponding\n     -    second-level config variables, i.e. those that contain a '<' which\n     -    indicates the start of a placeholder. Note that as in\n     +    Making use of the new existing --config flag to 'git help', add a new\n     +    function, __git_compute_second_level_config_vars_for_section. This\n     +    function takes as argument a config section name and computes the\n     +    corresponding second-level config variables, i.e. those that contain a\n     +    '<' which indicates the start of a placeholder. Note that as in\n          __git_compute_first_level_config_vars_for_section added previsouly, we\n          use indirect expansion instead of associative arrays to stay compatible\n          with Bash 3 on which macOS is stuck for licensing reasons.\n      \n     +    As explained in the previous commit, we use the existing pattern in the\n     +    completion script of using global variables to cache the list of\n     +    variables for each section.\n     +\n          Use this new function and the variables it defines in\n          __git_complete_config_variable_name to remove hardcoded config\n          variables, and add a test to verify the new function.  Use a single\n          'case' for all sections with second-level variables names, since the\n          code for each of them is now exactly the same.\n      \n     +    Adjust the name of a test added in a previous commit to reflect that it\n     +    now tests the added function.\n     +\n          Signed-off-by: Philippe Blain <levraiphilippeblain@gmail.com>\n      \n       ## contrib/completion/git-completion.bash ##\n     @@ contrib/completion/git-completion.bash: __git_compute_config_vars ()\n      +__git_compute_config_vars_all ()\n      +{\n      +\ttest -n \"$__git_config_vars_all\" ||\n     -+\t__git_config_vars_all=\"$(git help --config-all-for-completion)\"\n     ++\t__git_config_vars_all=\"$(git --no-pager help --config)\"\n      +}\n      +\n       __git_compute_first_level_config_vars_for_section ()\n       {\n     - \tsection=\"$1\"\n     + \tlocal section=\"$1\"\n      @@ contrib/completion/git-completion.bash: __git_compute_first_level_config_vars_for_section ()\n       \tprintf -v \"__git_first_level_config_vars_for_section_${section}\" %s \"$(echo \"$__git_config_vars\" | grep -E \"^${section}\\.[a-z]\" | awk -F. '{print $2}')\"\n       }\n       \n      +__git_compute_second_level_config_vars_for_section ()\n      +{\n     -+\tsection=\"$1\"\n     ++\tlocal section=\"$1\"\n      +\t__git_compute_config_vars_all\n      +\tlocal this_section=\"__git_second_level_config_vars_for_section_${section}\"\n      +\ttest -n \"${!this_section}\" ||\n     @@ contrib/completion/git-completion.bash: __git_complete_config_variable_name ()\n       \t\t__gitcomp \"$__git_config_vars\" \"\" \"$cur_\" \"$sfx\"\n      \n       ## t/t9902-completion.sh ##\n     -@@ t/t9902-completion.sh: test_expect_success 'git config - variable name - __git_compute_first_level_conf\n     - \tsubmodule.recurse Z\n     +@@ t/t9902-completion.sh: test_expect_success 'git config - variable name - submodule and __git_compute_fi\n       \tEOF\n       '\n     -+test_expect_success 'git config - variable name - __git_compute_second_level_config_vars_for_section' '\n     -+\ttest_completion \"git config branch.main.\" <<-\\EOF\n     -+\tbranch.main.description Z\n     -+\tbranch.main.remote Z\n     -+\tbranch.main.pushRemote Z\n     -+\tbranch.main.merge Z\n     -+\tbranch.main.mergeOptions Z\n     -+\tbranch.main.rebase Z\n     -+\tEOF\n     -+'\n       \n     - test_expect_success 'git config - value' '\n     - \ttest_completion \"git config color.pager \" <<-\\EOF\n     +-test_expect_success 'git config - variable name - submodule names' '\n     ++test_expect_success 'git config - variable name - __git_compute_second_level_config_vars_for_section' '\n     + \ttest_completion \"git config submodule.sub.\" <<-\\EOF\n     + \tsubmodule.sub.url Z\n     + \tsubmodule.sub.update Z\n\n-- \ngitgitgadget\n"},{"id":"488365","messageId":"6b75582ee35f0e535928cdb716935565864c2205.1707589943.git.gitgitgadget@gmail.com","threadId":"60803","inReplyTo":"pull.1660.v3.git.git.1707589943.gitgitgadget@gmail.com","subject":"[PATCH v3 2/4] completion: complete 'submodule.*' config variables","fromName":"Philippe Blain via GitGitGadget","fromEmail":"gitgitgadget@gmail.com","sentAt":"2024-02-10T18:32:21Z","receivedAt":"2024-02-10T18:32:27Z","isPatch":true,"sender":{"key":"levraiphilippeblain@gmail.com","avatar":"https://avatars.githubusercontent.com/u/44212482?v=4"},"body":"From: Philippe Blain <levraiphilippeblain@gmail.com>\n\nIn the Bash completion script, function\n__git_complete_config_variable_name completes config variables and has\nspecial logic to deal with config variables involving user-defined\nnames, like branch.<name>.* and remote.<name>.*.\n\nThis special logic is missing for submodule-related config variables.\nAdd the appropriate branches to the case statement, making use of the\nin-tree '.gitmodules' to list relevant submodules.\n\nAdd corresponding tests in t9902-completion.sh, making sure we complete\nboth first level submodule config variables as well as second level\nvariables involving submodule names.\n\nSigned-off-by: Philippe Blain <levraiphilippeblain@gmail.com>\n---\n contrib/completion/git-completion.bash | 13 ++++++++++++\n t/t9902-completion.sh                  | 29 ++++++++++++++++++++++++++\n 2 files changed, 42 insertions(+)\n\ndiff --git a/contrib/completion/git-completion.bash b/contrib/completion/git-completion.bash\nindex 159a4fd8add..8af9bc3f4e1 100644\n--- a/contrib/completion/git-completion.bash\n+++ b/contrib/completion/git-completion.bash\n@@ -2803,6 +2803,19 @@ __git_complete_config_variable_name ()\n \t\t__gitcomp_nl_append \"pushDefault\" \"$pfx\" \"$cur_\" \"${sfx:- }\"\n \t\treturn\n \t\t;;\n+\tsubmodule.*.*)\n+\t\tlocal pfx=\"${cur_%.*}.\"\n+\t\tcur_=\"${cur_##*.}\"\n+\t\t__gitcomp \"url update branch fetchRecurseSubmodules ignore active\" \"$pfx\" \"$cur_\" \"$sfx\"\n+\t\treturn\n+\t\t;;\n+\tsubmodule.*)\n+\t\tlocal pfx=\"${cur_%.*}.\"\n+\t\tcur_=\"${cur_#*.}\"\n+\t\t__gitcomp_nl \"$(__git config -f \"$(__git rev-parse --show-toplevel)/.gitmodules\" --get-regexp 'submodule.*.path' | awk -F. '{print $2}')\" \"$pfx\" \"$cur_\" \".\"\n+\t\t__gitcomp_nl_append $'alternateErrorStrategy\\nfetchJobs\\nactive\\nalternateLocation\\nrecurse\\npropagateBranches' \"$pfx\" \"$cur_\" \"${sfx:- }\"\n+\t\treturn\n+\t\t;;\n \turl.*.*)\n \t\tlocal pfx=\"${cur_%.*}.\"\n \t\tcur_=\"${cur_##*.}\"\ndiff --git a/t/t9902-completion.sh b/t/t9902-completion.sh\nindex 35eb534fdda..23d0e71324c 100755\n--- a/t/t9902-completion.sh\n+++ b/t/t9902-completion.sh\n@@ -2583,6 +2583,35 @@ test_expect_success 'git config - variable name include' '\n \tEOF\n '\n \n+test_expect_success 'setup for git config submodule tests' '\n+\ttest_create_repo sub &&\n+\ttest_commit -C sub initial &&\n+\tgit submodule add ./sub\n+'\n+\n+test_expect_success 'git config - variable name - submodule' '\n+\ttest_completion \"git config submodule.\" <<-\\EOF\n+\tsubmodule.active Z\n+\tsubmodule.alternateErrorStrategy Z\n+\tsubmodule.alternateLocation Z\n+\tsubmodule.fetchJobs Z\n+\tsubmodule.propagateBranches Z\n+\tsubmodule.recurse Z\n+\tsubmodule.sub.Z\n+\tEOF\n+'\n+\n+test_expect_success 'git config - variable name - submodule names' '\n+\ttest_completion \"git config submodule.sub.\" <<-\\EOF\n+\tsubmodule.sub.url Z\n+\tsubmodule.sub.update Z\n+\tsubmodule.sub.branch Z\n+\tsubmodule.sub.fetchRecurseSubmodules Z\n+\tsubmodule.sub.ignore Z\n+\tsubmodule.sub.active Z\n+\tEOF\n+'\n+\n test_expect_success 'git config - value' '\n \ttest_completion \"git config color.pager \" <<-\\EOF\n \tfalse Z\n-- \ngitgitgadget\n\n"},{"id":"488366","messageId":"fb210325394af2cc3389a780736d236bf9ac4f93.1707589943.git.gitgitgadget@gmail.com","threadId":"60803","inReplyTo":"pull.1660.v3.git.git.1707589943.gitgitgadget@gmail.com","subject":"[PATCH v3 3/4] completion: add and use __git_compute_first_level_config_vars_for_section","fromName":"Philippe Blain via GitGitGadget","fromEmail":"gitgitgadget@gmail.com","sentAt":"2024-02-10T18:32:22Z","receivedAt":"2024-02-10T18:32:28Z","isPatch":true,"sender":{"key":"levraiphilippeblain@gmail.com","avatar":"https://avatars.githubusercontent.com/u/44212482?v=4"},"body":"From: Philippe Blain <levraiphilippeblain@gmail.com>\n\nThe function __git_complete_config_variable_name in the Bash completion\nscript hardcodes several config variable names. These variables are\nthose in config sections where user-defined names can appear, such as\n\"branch.<name>\". These sections are treated first by the case statement,\nand the two last \"catch all\" cases are used for other sections, making\nuse of the __git_compute_config_vars and __git_compute_config_sections\nfunction, which omit listing any variables containing wildcards or\nplaceholders. Having hardcoded config variables introduces the risk of\nthe completion code becoming out of sync with the actual config\nvariables accepted by Git.\n\nTo avoid these hardcoded config variables, introduce a new function,\n__git_compute_first_level_config_vars_for_section, making use of the\nexisting __git_config_vars variable. This function takes as argument a\nconfig section name and computes the matching \"first level\" config\nvariables for that section, i.e. those _not_ containing any placeholder,\nlike 'branch.autoSetupMerge, 'remote.pushDefault', etc.  Use this\nfunction and the variables it defines in the 'branch.*', 'remote.*' and\n'submodule.*' switches of the case statement instead of hardcoding the\ncorresponding config variables.  Note that we use indirect expansion to\ncreate a variable for each section, instead of using a single\nassociative array indexed by section names, because associative arrays\nare not supported in Bash 3, on which macOS is stuck for licensing\nreasons.\n\nUse the existing pattern in the completion script of using global\nvariables to cache the list of config variables for each section. The\nrationale for such caching is explained in eaa4e6ee2a (Speed up bash\ncompletion loading, 2009-11-17), and the current approach to using and\ndefining them via 'test -n' is explained in cf0ff02a38 (completion: work\naround zsh option propagation bug, 2012-02-02).\n\nAdjust the name of one of the tests added in the previous commit,\nreflecting that it now also tests the new function.\n\nSigned-off-by: Philippe Blain <levraiphilippeblain@gmail.com>\n---\n contrib/completion/git-completion.bash | 24 +++++++++++++++++++++---\n t/t9902-completion.sh                  |  2 +-\n 2 files changed, 22 insertions(+), 4 deletions(-)\n\ndiff --git a/contrib/completion/git-completion.bash b/contrib/completion/git-completion.bash\nindex 8af9bc3f4e1..57a8da7ca1a 100644\n--- a/contrib/completion/git-completion.bash\n+++ b/contrib/completion/git-completion.bash\n@@ -2596,6 +2596,15 @@ __git_compute_config_vars ()\n \t__git_config_vars=\"$(git help --config-for-completion)\"\n }\n \n+__git_compute_first_level_config_vars_for_section ()\n+{\n+\tlocal section=\"$1\"\n+\t__git_compute_config_vars\n+\tlocal this_section=\"__git_first_level_config_vars_for_section_${section}\"\n+\ttest -n \"${!this_section}\" ||\n+\tprintf -v \"__git_first_level_config_vars_for_section_${section}\" %s \"$(echo \"$__git_config_vars\" | grep -E \"^${section}\\.[a-z]\" | awk -F. '{print $2}')\"\n+}\n+\n __git_config_sections=\n __git_compute_config_sections ()\n {\n@@ -2749,8 +2758,11 @@ __git_complete_config_variable_name ()\n \tbranch.*)\n \t\tlocal pfx=\"${cur_%.*}.\"\n \t\tcur_=\"${cur_#*.}\"\n+\t\tlocal section=\"${pfx%.}\"\n \t\t__gitcomp_direct \"$(__git_heads \"$pfx\" \"$cur_\" \".\")\"\n-\t\t__gitcomp_nl_append $'autoSetupMerge\\nautoSetupRebase\\n' \"$pfx\" \"$cur_\" \"${sfx:- }\"\n+\t\t__git_compute_first_level_config_vars_for_section \"${section}\"\n+\t\tlocal this_section=\"__git_first_level_config_vars_for_section_${section}\"\n+\t\t__gitcomp_nl_append \"${!this_section}\" \"$pfx\" \"$cur_\" \"${sfx:- }\"\n \t\treturn\n \t\t;;\n \tguitool.*.*)\n@@ -2799,8 +2811,11 @@ __git_complete_config_variable_name ()\n \tremote.*)\n \t\tlocal pfx=\"${cur_%.*}.\"\n \t\tcur_=\"${cur_#*.}\"\n+\t\tlocal section=\"${pfx%.}\"\n \t\t__gitcomp_nl \"$(__git_remotes)\" \"$pfx\" \"$cur_\" \".\"\n-\t\t__gitcomp_nl_append \"pushDefault\" \"$pfx\" \"$cur_\" \"${sfx:- }\"\n+\t\t__git_compute_first_level_config_vars_for_section \"${section}\"\n+\t\tlocal this_section=\"__git_first_level_config_vars_for_section_${section}\"\n+\t\t__gitcomp_nl_append \"${!this_section}\" \"$pfx\" \"$cur_\" \"${sfx:- }\"\n \t\treturn\n \t\t;;\n \tsubmodule.*.*)\n@@ -2812,8 +2827,11 @@ __git_complete_config_variable_name ()\n \tsubmodule.*)\n \t\tlocal pfx=\"${cur_%.*}.\"\n \t\tcur_=\"${cur_#*.}\"\n+\t\tlocal section=\"${pfx%.}\"\n \t\t__gitcomp_nl \"$(__git config -f \"$(__git rev-parse --show-toplevel)/.gitmodules\" --get-regexp 'submodule.*.path' | awk -F. '{print $2}')\" \"$pfx\" \"$cur_\" \".\"\n-\t\t__gitcomp_nl_append $'alternateErrorStrategy\\nfetchJobs\\nactive\\nalternateLocation\\nrecurse\\npropagateBranches' \"$pfx\" \"$cur_\" \"${sfx:- }\"\n+\t\t__git_compute_first_level_config_vars_for_section \"${section}\"\n+\t\tlocal this_section=\"__git_first_level_config_vars_for_section_${section}\"\n+\t\t__gitcomp_nl_append \"${!this_section}\" \"$pfx\" \"$cur_\" \"${sfx:- }\"\n \t\treturn\n \t\t;;\n \turl.*.*)\ndiff --git a/t/t9902-completion.sh b/t/t9902-completion.sh\nindex 23d0e71324c..8600b9e0dd9 100755\n--- a/t/t9902-completion.sh\n+++ b/t/t9902-completion.sh\n@@ -2589,7 +2589,7 @@ test_expect_success 'setup for git config submodule tests' '\n \tgit submodule add ./sub\n '\n \n-test_expect_success 'git config - variable name - submodule' '\n+test_expect_success 'git config - variable name - submodule and __git_compute_first_level_config_vars_for_section' '\n \ttest_completion \"git config submodule.\" <<-\\EOF\n \tsubmodule.active Z\n \tsubmodule.alternateErrorStrategy Z\n-- \ngitgitgadget\n\n"},{"id":"488367","messageId":"69fc02bb6b493451f092c81a0cceedfc38d59f7f.1707589943.git.gitgitgadget@gmail.com","threadId":"60803","inReplyTo":"pull.1660.v3.git.git.1707589943.gitgitgadget@gmail.com","subject":"[PATCH v3 4/4] completion: add and use __git_compute_second_level_config_vars_for_section","fromName":"Philippe Blain via GitGitGadget","fromEmail":"gitgitgadget@gmail.com","sentAt":"2024-02-10T18:32:23Z","receivedAt":"2024-02-10T18:32:29Z","isPatch":true,"sender":{"key":"levraiphilippeblain@gmail.com","avatar":"https://avatars.githubusercontent.com/u/44212482?v=4"},"body":"From: Philippe Blain <levraiphilippeblain@gmail.com>\n\nIn a previous commit we removed some hardcoded config variable names from\nfunction __git_complete_config_variable_name in the completion script by\nintroducing a new function,\n__git_compute_first_level_config_vars_for_section.\n\nThe remaining hardcoded config variables are \"second level\"\nconfiguration variables, meaning 'branch.<name>.upstream',\n'remote.<name>.url', etc. where <name> is a user-defined name.\n\nMaking use of the new existing --config flag to 'git help', add a new\nfunction, __git_compute_second_level_config_vars_for_section. This\nfunction takes as argument a config section name and computes the\ncorresponding second-level config variables, i.e. those that contain a\n'<' which indicates the start of a placeholder. Note that as in\n__git_compute_first_level_config_vars_for_section added previsouly, we\nuse indirect expansion instead of associative arrays to stay compatible\nwith Bash 3 on which macOS is stuck for licensing reasons.\n\nAs explained in the previous commit, we use the existing pattern in the\ncompletion script of using global variables to cache the list of\nvariables for each section.\n\nUse this new function and the variables it defines in\n__git_complete_config_variable_name to remove hardcoded config\nvariables, and add a test to verify the new function.  Use a single\n'case' for all sections with second-level variables names, since the\ncode for each of them is now exactly the same.\n\nAdjust the name of a test added in a previous commit to reflect that it\nnow tests the added function.\n\nSigned-off-by: Philippe Blain <levraiphilippeblain@gmail.com>\n---\n contrib/completion/git-completion.bash | 71 ++++++++------------------\n t/t9902-completion.sh                  |  2 +-\n 2 files changed, 22 insertions(+), 51 deletions(-)\n\ndiff --git a/contrib/completion/git-completion.bash b/contrib/completion/git-completion.bash\nindex 57a8da7ca1a..87678a5bb36 100644\n--- a/contrib/completion/git-completion.bash\n+++ b/contrib/completion/git-completion.bash\n@@ -2596,6 +2596,13 @@ __git_compute_config_vars ()\n \t__git_config_vars=\"$(git help --config-for-completion)\"\n }\n \n+__git_config_vars_all=\n+__git_compute_config_vars_all ()\n+{\n+\ttest -n \"$__git_config_vars_all\" ||\n+\t__git_config_vars_all=\"$(git --no-pager help --config)\"\n+}\n+\n __git_compute_first_level_config_vars_for_section ()\n {\n \tlocal section=\"$1\"\n@@ -2605,6 +2612,15 @@ __git_compute_first_level_config_vars_for_section ()\n \tprintf -v \"__git_first_level_config_vars_for_section_${section}\" %s \"$(echo \"$__git_config_vars\" | grep -E \"^${section}\\.[a-z]\" | awk -F. '{print $2}')\"\n }\n \n+__git_compute_second_level_config_vars_for_section ()\n+{\n+\tlocal section=\"$1\"\n+\t__git_compute_config_vars_all\n+\tlocal this_section=\"__git_second_level_config_vars_for_section_${section}\"\n+\ttest -n \"${!this_section}\" ||\n+\tprintf -v \"__git_second_level_config_vars_for_section_${section}\" %s \"$(echo \"$__git_config_vars_all\" | grep -E \"^${section}\\.<\" | awk -F. '{print $3}')\"\n+}\n+\n __git_config_sections=\n __git_compute_config_sections ()\n {\n@@ -2749,10 +2765,13 @@ __git_complete_config_variable_name ()\n \tdone\n \n \tcase \"$cur_\" in\n-\tbranch.*.*)\n+\tbranch.*.*|guitool.*.*|difftool.*.*|man.*.*|mergetool.*.*|remote.*.*|submodule.*.*|url.*.*)\n \t\tlocal pfx=\"${cur_%.*}.\"\n \t\tcur_=\"${cur_##*.}\"\n-\t\t__gitcomp \"remote pushRemote merge mergeOptions rebase\" \"$pfx\" \"$cur_\" \"$sfx\"\n+\t\tlocal section=\"${pfx%.*.}\"\n+\t\t__git_compute_second_level_config_vars_for_section \"${section}\"\n+\t\tlocal this_section=\"__git_second_level_config_vars_for_section_${section}\"\n+\t\t__gitcomp \"${!this_section}\" \"$pfx\" \"$cur_\" \"$sfx\"\n \t\treturn\n \t\t;;\n \tbranch.*)\n@@ -2765,33 +2784,6 @@ __git_complete_config_variable_name ()\n \t\t__gitcomp_nl_append \"${!this_section}\" \"$pfx\" \"$cur_\" \"${sfx:- }\"\n \t\treturn\n \t\t;;\n-\tguitool.*.*)\n-\t\tlocal pfx=\"${cur_%.*}.\"\n-\t\tcur_=\"${cur_##*.}\"\n-\t\t__gitcomp \"\n-\t\t\targPrompt cmd confirm needsFile noConsole noRescan\n-\t\t\tprompt revPrompt revUnmerged title\n-\t\t\t\" \"$pfx\" \"$cur_\" \"$sfx\"\n-\t\treturn\n-\t\t;;\n-\tdifftool.*.*)\n-\t\tlocal pfx=\"${cur_%.*}.\"\n-\t\tcur_=\"${cur_##*.}\"\n-\t\t__gitcomp \"cmd path\" \"$pfx\" \"$cur_\" \"$sfx\"\n-\t\treturn\n-\t\t;;\n-\tman.*.*)\n-\t\tlocal pfx=\"${cur_%.*}.\"\n-\t\tcur_=\"${cur_##*.}\"\n-\t\t__gitcomp \"cmd path\" \"$pfx\" \"$cur_\" \"$sfx\"\n-\t\treturn\n-\t\t;;\n-\tmergetool.*.*)\n-\t\tlocal pfx=\"${cur_%.*}.\"\n-\t\tcur_=\"${cur_##*.}\"\n-\t\t__gitcomp \"cmd path trustExitCode\" \"$pfx\" \"$cur_\" \"$sfx\"\n-\t\treturn\n-\t\t;;\n \tpager.*)\n \t\tlocal pfx=\"${cur_%.*}.\"\n \t\tcur_=\"${cur_#*.}\"\n@@ -2799,15 +2791,6 @@ __git_complete_config_variable_name ()\n \t\t__gitcomp_nl \"$__git_all_commands\" \"$pfx\" \"$cur_\" \"${sfx:- }\"\n \t\treturn\n \t\t;;\n-\tremote.*.*)\n-\t\tlocal pfx=\"${cur_%.*}.\"\n-\t\tcur_=\"${cur_##*.}\"\n-\t\t__gitcomp \"\n-\t\t\turl proxy fetch push mirror skipDefaultUpdate\n-\t\t\treceivepack uploadpack tagOpt pushurl\n-\t\t\t\" \"$pfx\" \"$cur_\" \"$sfx\"\n-\t\treturn\n-\t\t;;\n \tremote.*)\n \t\tlocal pfx=\"${cur_%.*}.\"\n \t\tcur_=\"${cur_#*.}\"\n@@ -2818,12 +2801,6 @@ __git_complete_config_variable_name ()\n \t\t__gitcomp_nl_append \"${!this_section}\" \"$pfx\" \"$cur_\" \"${sfx:- }\"\n \t\treturn\n \t\t;;\n-\tsubmodule.*.*)\n-\t\tlocal pfx=\"${cur_%.*}.\"\n-\t\tcur_=\"${cur_##*.}\"\n-\t\t__gitcomp \"url update branch fetchRecurseSubmodules ignore active\" \"$pfx\" \"$cur_\" \"$sfx\"\n-\t\treturn\n-\t\t;;\n \tsubmodule.*)\n \t\tlocal pfx=\"${cur_%.*}.\"\n \t\tcur_=\"${cur_#*.}\"\n@@ -2834,12 +2811,6 @@ __git_complete_config_variable_name ()\n \t\t__gitcomp_nl_append \"${!this_section}\" \"$pfx\" \"$cur_\" \"${sfx:- }\"\n \t\treturn\n \t\t;;\n-\turl.*.*)\n-\t\tlocal pfx=\"${cur_%.*}.\"\n-\t\tcur_=\"${cur_##*.}\"\n-\t\t__gitcomp \"insteadOf pushInsteadOf\" \"$pfx\" \"$cur_\" \"$sfx\"\n-\t\treturn\n-\t\t;;\n \t*.*)\n \t\t__git_compute_config_vars\n \t\t__gitcomp \"$__git_config_vars\" \"\" \"$cur_\" \"$sfx\"\ndiff --git a/t/t9902-completion.sh b/t/t9902-completion.sh\nindex 8600b9e0dd9..64031a9eff8 100755\n--- a/t/t9902-completion.sh\n+++ b/t/t9902-completion.sh\n@@ -2601,7 +2601,7 @@ test_expect_success 'git config - variable name - submodule and __git_compute_fi\n \tEOF\n '\n \n-test_expect_success 'git config - variable name - submodule names' '\n+test_expect_success 'git config - variable name - __git_compute_second_level_config_vars_for_section' '\n \ttest_completion \"git config submodule.sub.\" <<-\\EOF\n \tsubmodule.sub.url Z\n \tsubmodule.sub.update Z\n-- \ngitgitgadget\n"},{"id":"488523","messageId":"Zcs34kGTqTbIana6@tanuki","threadId":"60803","inReplyTo":"pull.1660.v3.git.git.1707589943.gitgitgadget@gmail.com","subject":"Re: [PATCH v3 0/4] completion: remove hardcoded config variable names","fromName":"Patrick Steinhardt","fromEmail":"ps@pks.im","sentAt":"2024-02-13T09:35:30Z","receivedAt":"2024-02-13T09:35:35Z","isPatch":true,"sender":{"key":"ps@pks.im","avatar":"https://avatars.githubusercontent.com/u/4056630?v=4"},"body":"On Sat, Feb 10, 2024 at 06:32:19PM +0000, Philippe Blain via GitGitGadget wrote:\n> Changes since v2:\n> \n>  * Moved the addition of the tests to 2/4, and tweaked 3/4 and 4/4 so they\n>    simply adjust the test names\n>  * Added a test for user-defined submodule names, as suggested by Patrick\n>  * Added more details in the commit message of 3/4 around the use of global\n>    variables as caches\n>  * Slightly improved commit message wording and fixed typos\n>  * Added 'local' where suggested\n>  * Dropped 4/5 which modified 'git help', since it's not needed (thanks\n>    Patrick!)\n> \n> Changes since v1:\n> \n>  * Corrected my email in PATCH 2/5 (sorry for the noise)\n> \n> v1: This series removes hardcoded config variable names in the\n> __git_complete_config_variable_name function, partly by adding a new mode to\n> 'git help'. It also adds completion for 'submodule.*' config variables,\n> which were previously missing.\n> \n> I think it makes sense to do that in the same series since it's closely\n> related, and splitting it would result in textual conflicts between both\n> series if one does not build on top of the other, but I'm open to other\n> suggestions.\n> \n> Thanks,\n> \n> Philippe.\n\nI ain't got anything else to add to this patch series. Thanks!\n\nPatrick\n"},{"id":"488541","messageId":"xmqq8r3o8f67.fsf@gitster.g","threadId":"60803","inReplyTo":"Zcs34kGTqTbIana6@tanuki","subject":"Re: [PATCH v3 0/4] completion: remove hardcoded config variable names","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2024-02-13T17:09:04Z","receivedAt":"2024-02-13T17:09:09Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Patrick Steinhardt <ps@pks.im> writes:\n\n> On Sat, Feb 10, 2024 at 06:32:19PM +0000, Philippe Blain via GitGitGadget wrote:\n>> Changes since v2:\n>> \n>>  * Moved the addition of the tests to 2/4, and tweaked 3/4 and 4/4 so they\n>>    simply adjust the test names\n>>  * Added a test for user-defined submodule names, as suggested by Patrick\n>>  * Added more details in the commit message of 3/4 around the use of global\n>>    variables as caches\n>>  * Slightly improved commit message wording and fixed typos\n>>  * Added 'local' where suggested\n>>  * Dropped 4/5 which modified 'git help', since it's not needed (thanks\n>>    Patrick!)\n>> \n>> Changes since v1:\n>> \n>>  * Corrected my email in PATCH 2/5 (sorry for the noise)\n>> \n>> v1: This series removes hardcoded config variable names in the\n>> __git_complete_config_variable_name function, partly by adding a new mode to\n>> 'git help'. It also adds completion for 'submodule.*' config variables,\n>> which were previously missing.\n>> \n>> I think it makes sense to do that in the same series since it's closely\n>> related, and splitting it would result in textual conflicts between both\n>> series if one does not build on top of the other, but I'm open to other\n>> suggestions.\n>> \n>> Thanks,\n>> \n>> Philippe.\n>\n> I ain't got anything else to add to this patch series. Thanks!\n\nThanks, both.  Let's mark it for 'next' so that it can be one of the\ntopics to graduate first after the current cycle.\n"},{"id":"488606","messageId":"xmqqa5o328r8.fsf@gitster.g","threadId":"60803","inReplyTo":"996fab96-82b1-0b54-3a09-0ecc18d68a11@gmail.com","subject":"Re: [PATCH v2 3/5] completion: add and use __git_compute_first_level_config_vars_for_section","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2024-02-14T00:24:11Z","receivedAt":"2024-02-14T00:24:15Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Philippe Blain <levraiphilippeblain@gmail.com> writes:\n\n>> A silly question (primarily because I do not much use the indirect\n>> reference construct ${!name}).  Does the assignment with printf need\n>> to spell out the long variable name with \"_${section}\"?  Can it be\n>> \n>>     printf -v \"$this_section\" ...\n>> \n>> instead, as we already have the short-hand for it?\n>\n> No, unfortunately neither \"$this_section\" nor \"${!this_section}\"\n> work, so we must use the long name.\n\nHmph, this does not match my experiment, though.  What am I doing\nwrong?\n\n        bash$ vname=foo\n        bash$ foo=bar\n        bash$ set | grep foo\n        foo=bar\n        vname=foo\n        bash$ printf -v \"$vname\" \"%d\" 1234\n        bash$ set | grep foo\n        foo=1234\n        vname=foo\n        bash$ echo $BASH_VERSION\n        5.2.21(1)-release\n\n"}]}