{"thread":{"id":"56291","subject":"[PATCH v3 try4 0/4] completion: bash: a bunch of fixes","startedAt":"2021-08-16T09:10:29Z","lastAt":"2021-08-16T09:10:47Z","messageCount":5,"participants":["Felipe Contreras"],"isPatch":true,"patchVersion":3,"patchTotal":4},"messages":[{"id":"432785","messageId":"20210816091025.548095-1-felipe.contreras@gmail.com","threadId":"56291","inReplyTo":null,"subject":"[PATCH v3 try4 0/4] completion: bash: a bunch of fixes","fromName":"Felipe Contreras","fromEmail":"felipe.contreras@gmail.com","sentAt":"2021-08-16T09:10:21Z","receivedAt":"2021-08-16T09:10:29Z","isPatch":true,"sender":{"key":"felipe.contreras@gmail.com","avatar":"https://avatars.githubusercontent.com/u/8358?v=4"},"body":"These should be pretty obvious and straightforward.\n\nThis is exactly the same as v3, which has been sent 4 times, and already\nincluded the minor adjustment to the commit message of one patch as\nsuggested by SZEDER Gábor, which was done nine minutes after in June 8,\nbut for some reason they had trouble getting into 'seen'. So I'm sending\nit yet again.\n\nFelipe Contreras (4):\n  completion: bash: fix prefix detection in branch.*\n  completion: bash: fix for suboptions with value\n  completion: bash: fix for multiple dash commands\n  completion: bash: add correct suffix in variables\n\n contrib/completion/git-completion.bash | 14 +++++++-------\n t/t9902-completion.sh                  | 15 +++++++++++++++\n 2 files changed, 22 insertions(+), 7 deletions(-)\n\nRange-diff:\n1:  4b73b26338 = 1:  e699c8be36 completion: bash: fix prefix detection in branch.*\n2:  cb2fc1a7f2 = 2:  7e800faaf1 completion: bash: fix for suboptions with value\n3:  ece06463a2 = 3:  523906fe1a completion: bash: fix for multiple dash commands\n4:  f9db132cbd = 4:  1cb7457af9 completion: bash: add correct suffix in variables\n-- \n2.32.0.48.g096519100f\n\n"},{"id":"432786","messageId":"20210816091025.548095-2-felipe.contreras@gmail.com","threadId":"56291","inReplyTo":"20210816091025.548095-1-felipe.contreras@gmail.com","subject":"[PATCH v3 try4 1/4] completion: bash: fix prefix detection in branch.*","fromName":"Felipe Contreras","fromEmail":"felipe.contreras@gmail.com","sentAt":"2021-08-16T09:10:22Z","receivedAt":"2021-08-16T09:10:30Z","isPatch":true,"sender":{"key":"felipe.contreras@gmail.com","avatar":"https://avatars.githubusercontent.com/u/8358?v=4"},"body":"Otherwise we are completely ignoring the --cur argument.\n\nThe issue can be tested with:\n\n  git clone --config=branch.<tab>\n\nReviewed-by: SZEDER Gábor <szeder.dev@gmail.com>\nTested-by: David Aguilar <davvid@gmail.com>\nSigned-off-by: Felipe Contreras <felipe.contreras@gmail.com>\n---\n contrib/completion/git-completion.bash | 4 ++--\n 1 file changed, 2 insertions(+), 2 deletions(-)\n\ndiff --git a/contrib/completion/git-completion.bash b/contrib/completion/git-completion.bash\nindex 4bdd27ddc8..6bcf97ce79 100644\n--- a/contrib/completion/git-completion.bash\n+++ b/contrib/completion/git-completion.bash\n@@ -2650,8 +2650,8 @@ __git_complete_config_variable_name ()\n \t\treturn\n \t\t;;\n \tbranch.*)\n-\t\tlocal pfx=\"${cur%.*}.\"\n-\t\tcur_=\"${cur#*.}\"\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\treturn\n-- \n2.32.0.48.g096519100f\n\n"},{"id":"432787","messageId":"20210816091025.548095-4-felipe.contreras@gmail.com","threadId":"56291","inReplyTo":"20210816091025.548095-1-felipe.contreras@gmail.com","subject":"[PATCH v3 try4 3/4] completion: bash: fix for multiple dash commands","fromName":"Felipe Contreras","fromEmail":"felipe.contreras@gmail.com","sentAt":"2021-08-16T09:10:24Z","receivedAt":"2021-08-16T09:10:34Z","isPatch":true,"sender":{"key":"felipe.contreras@gmail.com","avatar":"https://avatars.githubusercontent.com/u/8358?v=4"},"body":"Otherwise options of commands like 'for-each-ref' are not completed.\n\nTested-by: David Aguilar <davvid@gmail.com>\nSigned-off-by: Felipe Contreras <felipe.contreras@gmail.com>\n---\n contrib/completion/git-completion.bash | 2 +-\n 1 file changed, 1 insertion(+), 1 deletion(-)\n\ndiff --git a/contrib/completion/git-completion.bash b/contrib/completion/git-completion.bash\nindex 7aea1abda5..b7988f0485 100644\n--- a/contrib/completion/git-completion.bash\n+++ b/contrib/completion/git-completion.bash\n@@ -421,7 +421,7 @@ __gitcomp_builtin ()\n \tlocal incl=\"${2-}\"\n \tlocal excl=\"${3-}\"\n \n-\tlocal var=__gitcomp_builtin_\"${cmd/-/_}\"\n+\tlocal var=__gitcomp_builtin_\"${cmd//-/_}\"\n \tlocal options\n \teval \"options=\\${$var-}\"\n \n-- \n2.32.0.48.g096519100f\n\n"},{"id":"432788","messageId":"20210816091025.548095-3-felipe.contreras@gmail.com","threadId":"56291","inReplyTo":"20210816091025.548095-1-felipe.contreras@gmail.com","subject":"[PATCH v3 try4 2/4] completion: bash: fix for suboptions with value","fromName":"Felipe Contreras","fromEmail":"felipe.contreras@gmail.com","sentAt":"2021-08-16T09:10:23Z","receivedAt":"2021-08-16T09:10:34Z","isPatch":true,"sender":{"key":"felipe.contreras@gmail.com","avatar":"https://avatars.githubusercontent.com/u/8358?v=4"},"body":"We need to ignore options that don't start with -- as well.\n\nDepending on the value of COMP_WORDBREAKS the last word could be\nduplicated otherwise.\n\nCan be tested with:\n\n  git merge -X diff-algorithm=<tab>\n\nTested-by: David Aguilar <davvid@gmail.com>\nSigned-off-by: Felipe Contreras <felipe.contreras@gmail.com>\n---\n contrib/completion/git-completion.bash |  2 +-\n t/t9902-completion.sh                  | 15 +++++++++++++++\n 2 files changed, 16 insertions(+), 1 deletion(-)\n\ndiff --git a/contrib/completion/git-completion.bash b/contrib/completion/git-completion.bash\nindex 6bcf97ce79..7aea1abda5 100644\n--- a/contrib/completion/git-completion.bash\n+++ b/contrib/completion/git-completion.bash\n@@ -356,7 +356,7 @@ __gitcomp ()\n \tlocal cur_=\"${3-$cur}\"\n \n \tcase \"$cur_\" in\n-\t--*=)\n+\t*=)\n \t\t;;\n \t--no-*)\n \t\tlocal c i=0 IFS=$' \\t\\n'\ndiff --git a/t/t9902-completion.sh b/t/t9902-completion.sh\nindex cb057ef161..6b56e54fc3 100755\n--- a/t/t9902-completion.sh\n+++ b/t/t9902-completion.sh\n@@ -540,6 +540,15 @@ test_expect_success '__gitcomp - expand/narrow all negative options' '\n \tEOF\n '\n \n+test_expect_success '__gitcomp - equal skip' '\n+\ttest_gitcomp \"--option=\" \"--option=\" <<-\\EOF &&\n+\n+\tEOF\n+\ttest_gitcomp \"option=\" \"option=\" <<-\\EOF\n+\n+\tEOF\n+'\n+\n test_expect_success '__gitcomp - doesnt fail because of invalid variable name' '\n \t__gitcomp \"$invalid_variable_name\"\n '\n@@ -2380,6 +2389,12 @@ test_expect_success 'git clone --config= - value' '\n \tEOF\n '\n \n+test_expect_success 'options with value' '\n+\ttest_completion \"git merge -X diff-algorithm=\" <<-\\EOF\n+\n+\tEOF\n+'\n+\n test_expect_success 'sourcing the completion script clears cached commands' '\n \t__git_compute_all_commands &&\n \tverbose test -n \"$__git_all_commands\" &&\n-- \n2.32.0.48.g096519100f\n\n"},{"id":"432789","messageId":"20210816091025.548095-5-felipe.contreras@gmail.com","threadId":"56291","inReplyTo":"20210816091025.548095-1-felipe.contreras@gmail.com","subject":"[PATCH v3 try4 4/4] completion: bash: add correct suffix in variables","fromName":"Felipe Contreras","fromEmail":"felipe.contreras@gmail.com","sentAt":"2021-08-16T09:10:25Z","receivedAt":"2021-08-16T09:10:47Z","isPatch":true,"sender":{"key":"felipe.contreras@gmail.com","avatar":"https://avatars.githubusercontent.com/u/8358?v=4"},"body":"__gitcomp automatically adds a suffix, but __gitcomp_nl and others\ndon't, we need to specify a space by default.\n\nCan be tested with:\n\n  git config branch.autoSetupMe<tab>\n\nThis fix only works for versions of bash greater than 4.0, before that\n\"local sfx\" creates an empty string, therefore the unset expansion\ndoesn't work. The same happens in zsh.\n\nTherefore we don't add the test for that for now.\n\nThe correct fix for all shells requires semantic changes in __gitcomp,\nbut that can be done later.\n\nCc: SZEDER Gábor <szeder.dev@gmail.com>\nTested-by: David Aguilar <davvid@gmail.com>\nSigned-off-by: Felipe Contreras <felipe.contreras@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 b7988f0485..8108eda1e8 100644\n--- a/contrib/completion/git-completion.bash\n+++ b/contrib/completion/git-completion.bash\n@@ -2653,7 +2653,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@@ -2687,7 +2687,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@@ -2703,7 +2703,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-- \n2.32.0.48.g096519100f\n\n"}]}