{"thread":{"id":"54874","subject":"[PATCH v2 1/4] completion: bash: fix prefix detection in branch.*","startedAt":"2020-12-23T14:49:45Z","lastAt":"2020-12-23T14:49:45Z","messageCount":5,"participants":["Felipe Contreras"],"isPatch":true,"patchVersion":2,"patchTotal":4},"messages":[{"id":"412931","messageId":"20201223144845.143039-2-felipe.contreras@gmail.com","threadId":"54874","inReplyTo":"20201223144845.143039-1-felipe.contreras@gmail.com","subject":"[PATCH v2 1/4] completion: bash: fix prefix detection in branch.*","fromName":"Felipe Contreras","fromEmail":"felipe.contreras@gmail.com","sentAt":"2020-12-23T14:48:42Z","receivedAt":"2020-12-23T14:49:45Z","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 463a3124da..10d225cc9c 100644\n--- a/contrib/completion/git-completion.bash\n+++ b/contrib/completion/git-completion.bash\n@@ -2633,8 +2633,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.30.0.rc1\n\n"},{"id":"412932","messageId":"20201223144845.143039-1-felipe.contreras@gmail.com","threadId":"54874","inReplyTo":null,"subject":"[PATCH v2 0/4] completion: bash: a bunch of fixes","fromName":"Felipe Contreras","fromEmail":"felipe.contreras@gmail.com","sentAt":"2020-12-23T14:48:41Z","receivedAt":"2020-12-23T14:49:45Z","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\nChanges since v1:\n\n * Removed test for suffix in variable names\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:  26bbb19677 = 1:  dd49b0e680 completion: bash: fix prefix detection in branch.*\n3:  aad0bc6a0f = 2:  6ac184b9a4 completion: bash: fix for suboptions with value\n4:  77a4b0b0d0 = 3:  960a692fda completion: bash: fix for multiple dash commands\n2:  4bcc8a5fca ! 4:  a95c3edaf9 completion: bash: add correct suffix in variables\n    @@ Commit message\n     \n           git config branch.autoSetupMe<tab>\n     \n    +    This fix only works for versions of bash greater than 4.0, before that\n    +    \"local sfx\" creates an empty string, therefore the unset expansion\n    +    doesn't work. The same happens in zsh.\n    +\n    +    Therefore we don't add the test for that for now.\n    +\n    +    The correct fix for all shells requires semantic changes in __gitcomp,\n    +    but that can be done later.\n    +\n    +    Cc: SZEDER Gábor <szeder.dev@gmail.com>\n         Signed-off-by: Felipe Contreras <felipe.contreras@gmail.com>\n     \n      ## contrib/completion/git-completion.bash ##\n    @@ contrib/completion/git-completion.bash: __git_complete_config_variable_name ()\n      \t\treturn\n      \t\t;;\n      \turl.*.*)\n    -\n    - ## t/t9902-completion.sh ##\n    -@@ t/t9902-completion.sh: 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.30.0.rc1\n\n"},{"id":"412933","messageId":"20201223144845.143039-4-felipe.contreras@gmail.com","threadId":"54874","inReplyTo":"20201223144845.143039-1-felipe.contreras@gmail.com","subject":"[PATCH v2 3/4] completion: bash: fix for multiple dash commands","fromName":"Felipe Contreras","fromEmail":"felipe.contreras@gmail.com","sentAt":"2020-12-23T14:48:44Z","receivedAt":"2020-12-23T14:49:45Z","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 10e69af9ed..64cf35ba04 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.30.0.rc1\n\n"},{"id":"412934","messageId":"20201223144845.143039-5-felipe.contreras@gmail.com","threadId":"54874","inReplyTo":"20201223144845.143039-1-felipe.contreras@gmail.com","subject":"[PATCH v2 4/4] completion: bash: add correct suffix in variables","fromName":"Felipe Contreras","fromEmail":"felipe.contreras@gmail.com","sentAt":"2020-12-23T14:48:45Z","receivedAt":"2020-12-23T14:49:45Z","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>\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 64cf35ba04..926e9ceb56 100644\n--- a/contrib/completion/git-completion.bash\n+++ b/contrib/completion/git-completion.bash\n@@ -2636,7 +2636,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@@ -2670,7 +2670,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@@ -2686,7 +2686,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.30.0.rc1\n\n"},{"id":"412935","messageId":"20201223144845.143039-3-felipe.contreras@gmail.com","threadId":"54874","inReplyTo":"20201223144845.143039-1-felipe.contreras@gmail.com","subject":"[PATCH v2 2/4] completion: bash: fix for suboptions with value","fromName":"Felipe Contreras","fromEmail":"felipe.contreras@gmail.com","sentAt":"2020-12-23T14:48:43Z","receivedAt":"2020-12-23T14:49:45Z","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 10d225cc9c..10e69af9ed 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 81a728c743..c41030b6cc 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@@ -2354,6 +2363,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.30.0.rc1\n\n"}]}