{"thread":{"id":"54673","subject":"[PATCH 0/4] completion: bash: a bunch of fixes","startedAt":"2020-11-19T01:52:54Z","lastAt":"2020-11-19T01:52:55Z","messageCount":5,"participants":["Felipe Contreras"],"isPatch":true,"patchVersion":1,"patchTotal":4},"messages":[{"id":"410325","messageId":"20201119015209.1155170-1-felipe.contreras@gmail.com","threadId":"54673","inReplyTo":null,"subject":"[PATCH 0/4] completion: bash: a bunch of fixes","fromName":"Felipe Contreras","fromEmail":"felipe.contreras@gmail.com","sentAt":"2020-11-19T01:52:05Z","receivedAt":"2020-11-19T01:52:54Z","isPatch":true,"sender":{"key":"felipe.contreras@gmail.com","avatar":"https://avatars.githubusercontent.com/u/8358?v=4"},"body":"This is just the bug fixes from the previous series.\n\nThese should be pretty obvious and straightforward.\n\n\nFelipe Contreras (4):\n  completion: bash: fix prefix detection in branch.*\n  completion: bash: add correct suffix in variables\n  completion: bash: fix for suboptions with value\n  completion: bash: fix for multiple dash commands\n\n contrib/completion/git-completion.bash | 14 +++++++-------\n t/t9902-completion.sh                  | 22 ++++++++++++++++++++++\n 2 files changed, 29 insertions(+), 7 deletions(-)\n\n-- \n2.29.2\n\n"},{"id":"410326","messageId":"20201119015209.1155170-2-felipe.contreras@gmail.com","threadId":"54673","inReplyTo":"20201119015209.1155170-1-felipe.contreras@gmail.com","subject":"[PATCH 1/4] completion: bash: fix prefix detection in branch.*","fromName":"Felipe Contreras","fromEmail":"felipe.contreras@gmail.com","sentAt":"2020-11-19T01:52:06Z","receivedAt":"2020-11-19T01:52:54Z","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\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 7c81e4ba49..b866b68b3c 100644\n--- a/contrib/completion/git-completion.bash\n+++ b/contrib/completion/git-completion.bash\n@@ -2615,8 +2615,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.29.2\n\n"},{"id":"410327","messageId":"20201119015209.1155170-3-felipe.contreras@gmail.com","threadId":"54673","inReplyTo":"20201119015209.1155170-1-felipe.contreras@gmail.com","subject":"[PATCH 2/4] completion: bash: add correct suffix in variables","fromName":"Felipe Contreras","fromEmail":"felipe.contreras@gmail.com","sentAt":"2020-11-19T01:52:07Z","receivedAt":"2020-11-19T01:52:54Z","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\nSigned-off-by: Felipe Contreras <felipe.contreras@gmail.com>\n---\n contrib/completion/git-completion.bash | 6 +++---\n t/t9902-completion.sh                  | 7 +++++++\n 2 files changed, 10 insertions(+), 3 deletions(-)\n\ndiff --git a/contrib/completion/git-completion.bash b/contrib/completion/git-completion.bash\nindex b866b68b3c..bbdb46d87e 100644\n--- a/contrib/completion/git-completion.bash\n+++ b/contrib/completion/git-completion.bash\n@@ -2618,7 +2618,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@@ -2652,7 +2652,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@@ -2668,7 +2668,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.*.*)\ndiff --git a/t/t9902-completion.sh b/t/t9902-completion.sh\nindex 2be9190425..4a3d3d1597 100755\n--- a/t/t9902-completion.sh\n+++ b/t/t9902-completion.sh\n@@ -2293,6 +2293,13 @@ test_expect_success 'git config - value' '\n \tEOF\n '\n \n+test_expect_success 'git config - direct completions' '\n+\ttest_completion \"git config branch.autoSetup\" <<-\\EOF\n+\tbranch.autoSetupMerge Z\n+\tbranch.autoSetupRebase Z\n+\tEOF\n+'\n+\n test_expect_success 'git -c - section' '\n \ttest_completion \"git -c br\" <<-\\EOF\n \tbranch.Z\n-- \n2.29.2\n\n"},{"id":"410328","messageId":"20201119015209.1155170-4-felipe.contreras@gmail.com","threadId":"54673","inReplyTo":"20201119015209.1155170-1-felipe.contreras@gmail.com","subject":"[PATCH 3/4] completion: bash: fix for suboptions with value","fromName":"Felipe Contreras","fromEmail":"felipe.contreras@gmail.com","sentAt":"2020-11-19T01:52:08Z","receivedAt":"2020-11-19T01:52:55Z","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\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 bbdb46d87e..5b2dff150d 100644\n--- a/contrib/completion/git-completion.bash\n+++ b/contrib/completion/git-completion.bash\n@@ -347,7 +347,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 4a3d3d1597..4deda01153 100755\n--- a/t/t9902-completion.sh\n+++ b/t/t9902-completion.sh\n@@ -537,6 +537,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@@ -2342,6 +2351,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.29.2\n\n"},{"id":"410329","messageId":"20201119015209.1155170-5-felipe.contreras@gmail.com","threadId":"54673","inReplyTo":"20201119015209.1155170-1-felipe.contreras@gmail.com","subject":"[PATCH 4/4] completion: bash: fix for multiple dash commands","fromName":"Felipe Contreras","fromEmail":"felipe.contreras@gmail.com","sentAt":"2020-11-19T01:52:09Z","receivedAt":"2020-11-19T01:52:55Z","isPatch":true,"sender":{"key":"felipe.contreras@gmail.com","avatar":"https://avatars.githubusercontent.com/u/8358?v=4"},"body":"Otherwise commands like 'for-each-ref' are not completed.\n\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 5b2dff150d..7e893abf43 100644\n--- a/contrib/completion/git-completion.bash\n+++ b/contrib/completion/git-completion.bash\n@@ -412,7 +412,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.29.2\n\n"}]}