{"thread":{"id":"55861","subject":"[PATCH v2 try2 2/4] completion: bash: fix for suboptions with value","startedAt":"2021-06-06T18:47:45Z","lastAt":"2021-06-08T06:01:30Z","messageCount":16,"participants":["Felipe Contreras","David Aguilar","Junio C Hamano","SZEDER Gábor"],"isPatch":true,"patchVersion":2,"patchTotal":4},"messages":[{"id":"426540","messageId":"20210606184726.1018460-3-felipe.contreras@gmail.com","threadId":"55861","inReplyTo":"20210606184726.1018460-1-felipe.contreras@gmail.com","subject":"[PATCH v2 try2 2/4] completion: bash: fix for suboptions with value","fromName":"Felipe Contreras","fromEmail":"felipe.contreras@gmail.com","sentAt":"2021-06-06T18:47:24Z","receivedAt":"2021-06-06T18:47: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 47b48fbab6..05606609f9 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.31.1.2.g0532ba4bf6\n\n"},{"id":"426541","messageId":"20210606184726.1018460-1-felipe.contreras@gmail.com","threadId":"55861","inReplyTo":null,"subject":"[PATCH v2 try2 0/4] completion: bash: a bunch of fixes","fromName":"Felipe Contreras","fromEmail":"felipe.contreras@gmail.com","sentAt":"2021-06-06T18:47:22Z","receivedAt":"2021-06-06T18:48:36Z","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 the second time I'm sending this exact series, and the seventh time in almost\nexactly the same form.\n\nThe previous version was still applying without conflicts to master, and so does this one.\n\n * https://lore.kernel.org/git/xmqqv9cavcc5.fsf@gitster.c.googlers.com/\n * https://lore.kernel.org/git/6094a335c22dc_8ee520860@natae.notmuch/\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:  dd49b0e680 ! 1:  52de92cb06 completion: bash: fix prefix detection in branch.*\n    @@ Commit message\n     \n           git clone --config=branch.<tab>\n     \n    +    Reviewed-by: SZEDER Gábor <szeder.dev@gmail.com>\n         Signed-off-by: Felipe Contreras <felipe.contreras@gmail.com>\n     \n      ## contrib/completion/git-completion.bash ##\n2:  6ac184b9a4 = 2:  af2f17364d completion: bash: fix for suboptions with value\n3:  960a692fda = 3:  a3bcb70594 completion: bash: fix for multiple dash commands\n4:  a95c3edaf9 = 4:  6b3ef41c92 completion: bash: add correct suffix in variables\n-- \n2.31.1.2.g0532ba4bf6\n\n"},{"id":"426542","messageId":"20210606184726.1018460-2-felipe.contreras@gmail.com","threadId":"55861","inReplyTo":"20210606184726.1018460-1-felipe.contreras@gmail.com","subject":"[PATCH v2 try2 1/4] completion: bash: fix prefix detection in branch.*","fromName":"Felipe Contreras","fromEmail":"felipe.contreras@gmail.com","sentAt":"2021-06-06T18:47:23Z","receivedAt":"2021-06-06T18:48:53Z","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>\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 b50c5d0ea3..47b48fbab6 100644\n--- a/contrib/completion/git-completion.bash\n+++ b/contrib/completion/git-completion.bash\n@@ -2649,8 +2649,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.31.1.2.g0532ba4bf6\n\n"},{"id":"426543","messageId":"20210606184726.1018460-4-felipe.contreras@gmail.com","threadId":"55861","inReplyTo":"20210606184726.1018460-1-felipe.contreras@gmail.com","subject":"[PATCH v2 try2 3/4] completion: bash: fix for multiple dash commands","fromName":"Felipe Contreras","fromEmail":"felipe.contreras@gmail.com","sentAt":"2021-06-06T18:47:25Z","receivedAt":"2021-06-06T18:48:54Z","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 05606609f9..1feb2ee108 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.31.1.2.g0532ba4bf6\n\n"},{"id":"426544","messageId":"20210606184726.1018460-5-felipe.contreras@gmail.com","threadId":"55861","inReplyTo":"20210606184726.1018460-1-felipe.contreras@gmail.com","subject":"[PATCH v2 try2 4/4] completion: bash: add correct suffix in variables","fromName":"Felipe Contreras","fromEmail":"felipe.contreras@gmail.com","sentAt":"2021-06-06T18:47:26Z","receivedAt":"2021-06-06T18:49:01Z","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 1feb2ee108..c72b5465f9 100644\n--- a/contrib/completion/git-completion.bash\n+++ b/contrib/completion/git-completion.bash\n@@ -2652,7 +2652,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@@ -2686,7 +2686,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@@ -2702,7 +2702,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.31.1.2.g0532ba4bf6\n\n"},{"id":"426549","messageId":"CAJDDKr4Wm2FQ-kq8k8EU6wE20V6ghuKDrzC5PcsZ6We0bMz3uQ@mail.gmail.com","threadId":"55861","inReplyTo":"20210606184726.1018460-1-felipe.contreras@gmail.com","subject":"Re: [PATCH v2 try2 0/4] completion: bash: a bunch of fixes","fromName":"David Aguilar","fromEmail":"davvid@gmail.com","sentAt":"2021-06-07T00:46:06Z","receivedAt":"2021-06-07T00:47:57Z","isPatch":true,"sender":{"key":"davvid@gmail.com","avatar":"https://avatars.githubusercontent.com/u/13196?v=4"},"body":"On Sun, Jun 6, 2021 at 11:51 AM Felipe Contreras\n<felipe.contreras@gmail.com> wrote:\n>\n> These should be pretty obvious and straightforward.\n>\n> This is the second time I'm sending this exact series, and the seventh time in almost\n> exactly the same form.\n>\n> The previous version was still applying without conflicts to master, and so does this one.\n>\n>  * https://lore.kernel.org/git/xmqqv9cavcc5.fsf@gitster.c.googlers.com/\n>  * https://lore.kernel.org/git/6094a335c22dc_8ee520860@natae.notmuch/\n>\n> Felipe 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>\n> Range-diff:\n> 1:  dd49b0e680 ! 1:  52de92cb06 completion: bash: fix prefix detection in branch.*\n>     @@ Commit message\n>\n>            git clone --config=branch.<tab>\n>\n>     +    Reviewed-by: 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> 2:  6ac184b9a4 = 2:  af2f17364d completion: bash: fix for suboptions with value\n> 3:  960a692fda = 3:  a3bcb70594 completion: bash: fix for multiple dash commands\n> 4:  a95c3edaf9 = 4:  6b3ef41c92 completion: bash: add correct suffix in variables\n> --\n> 2.31.1.2.g0532ba4bf6\n>\n\nI tested this series on:\n- GNU bash, version 4.2.46(2)-release (x86_64-redhat-linux-gnu)\n- GNU bash, version 3.2.57(1)-release (x86_64-apple-darwin19)\n- zsh 5.0.2 (x86_64-redhat-linux-gnu)\n- zsh 5.7.1 (x86_64-apple-darwin19.0)\nand can confirm that it is an improvement.\n\nFWIW,\nTested-by: David Aguilar <davvid@gmail.com>\n\ncheers,\n-- \nDavid\n"},{"id":"426554","messageId":"xmqqfsxuwkfj.fsf@gitster.g","threadId":"55861","inReplyTo":"CAJDDKr4Wm2FQ-kq8k8EU6wE20V6ghuKDrzC5PcsZ6We0bMz3uQ@mail.gmail.com","subject":"Re: [PATCH v2 try2 0/4] completion: bash: a bunch of fixes","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2021-06-07T01:08:32Z","receivedAt":"2021-06-07T01:08:35Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"David Aguilar <davvid@gmail.com> writes:\n\n> On Sun, Jun 6, 2021 at 11:51 AM Felipe Contreras\n> ...\n> I tested this series on:\n> - GNU bash, version 4.2.46(2)-release (x86_64-redhat-linux-gnu)\n> - GNU bash, version 3.2.57(1)-release (x86_64-apple-darwin19)\n> - zsh 5.0.2 (x86_64-redhat-linux-gnu)\n> - zsh 5.7.1 (x86_64-apple-darwin19.0)\n> and can confirm that it is an improvement.\n>\n> FWIW,\n> Tested-by: David Aguilar <davvid@gmail.com>\n\nThanks, will queue (I haven't checked if there is any overlap with\nwhat is cooking above 'master', so it may not happen very soon,\nthough).\n"},{"id":"426650","messageId":"20210607190046.GB6312@szeder.dev","threadId":"55861","inReplyTo":"20210606184726.1018460-4-felipe.contreras@gmail.com","subject":"Re: [PATCH v2 try2 3/4] completion: bash: fix for multiple dash commands","fromName":"SZEDER Gábor","fromEmail":"szeder.dev@gmail.com","sentAt":"2021-06-07T19:00:46Z","receivedAt":"2021-06-07T19:01:51Z","isPatch":true,"sender":{"key":"szeder.dev@gmail.com","avatar":"https://avatars.githubusercontent.com/u/116324?v=4"},"body":"On Sun, Jun 06, 2021 at 01:47:25PM -0500, Felipe Contreras wrote:\n> Otherwise commands like 'for-each-ref' are not completed.\n\nI think you meant that options of commands like 'for-each-ref' are not\ncompleted.  The command itself can be completed just fine:\n\n  $ git for<TAB>\n  for-each-ref      format-patch      \n\n> Signed-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> \n> diff --git a/contrib/completion/git-completion.bash b/contrib/completion/git-completion.bash\n> index 05606609f9..1feb2ee108 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> -- \n> 2.31.1.2.g0532ba4bf6\n> \n"},{"id":"426653","messageId":"60be6f7fa4435_db80d208f2@natae.notmuch","threadId":"55861","inReplyTo":"20210607190046.GB6312@szeder.dev","subject":"Re: [PATCH v2 try2 3/4] completion: bash: fix for multiple dash commands","fromName":"Felipe Contreras","fromEmail":"felipe.contreras@gmail.com","sentAt":"2021-06-07T19:11:59Z","receivedAt":"2021-06-07T19:12:04Z","isPatch":true,"sender":{"key":"felipe.contreras@gmail.com","avatar":"https://avatars.githubusercontent.com/u/8358?v=4"},"body":"SZEDER Gábor wrote:\n> On Sun, Jun 06, 2021 at 01:47:25PM -0500, Felipe Contreras wrote:\n> > Otherwise commands like 'for-each-ref' are not completed.\n> \n> I think you meant that options of commands like 'for-each-ref' are not\n> completed.  The command itself can be completed just fine:\n> \n>   $ git for<TAB>\n>   for-each-ref      format-patch      \n\nYes, I meant commands like 'for-each-ref' are not completed correctly...\nby __gitcomp_builtin. Which in practical tearms means what you just\ndescribed above.\n\n-- \nFelipe Contreras"},{"id":"426701","messageId":"xmqq35ttq6na.fsf@gitster.g","threadId":"55861","inReplyTo":"60be6f7fa4435_db80d208f2@natae.notmuch","subject":"Re: [PATCH v2 try2 3/4] completion: bash: fix for multiple dash commands","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2021-06-08T05:15:05Z","receivedAt":"2021-06-08T05:15:08Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Felipe Contreras <felipe.contreras@gmail.com> writes:\n\n> SZEDER Gábor wrote:\n>> On Sun, Jun 06, 2021 at 01:47:25PM -0500, Felipe Contreras wrote:\n>> > Otherwise commands like 'for-each-ref' are not completed.\n>> \n>> I think you meant that options of commands like 'for-each-ref' are not\n>> completed.\n>> ...\n\n> Yes, I meant commands like 'for-each-ref' are not completed correctly...\n> by __gitcomp_builtin. Which in practical tearms means what you just\n> described above.\n\nI couldn't exactly tell if that's a roundabout way to say \"yes,\nyours is better and I'll use it in an update, thanks\".  I'll assume\nthat is the case and will mark the topic as expecting the final\nupdate (as it seemed that all the other patches in the series were\nreceived favourably).\n\nOr was it meant as \"no, the version you commented on was already\ncorrect (if you squint your eyes)\"?\n\nThanks.\n"},{"id":"426704","messageId":"60bf04d176fff_198ddf20859@natae.notmuch","threadId":"55861","inReplyTo":"xmqq35ttq6na.fsf@gitster.g","subject":"Re: [PATCH v2 try2 3/4] completion: bash: fix for multiple dash commands","fromName":"Felipe Contreras","fromEmail":"felipe.contreras@gmail.com","sentAt":"2021-06-08T05:49:05Z","receivedAt":"2021-06-08T05:50:09Z","isPatch":true,"sender":{"key":"felipe.contreras@gmail.com","avatar":"https://avatars.githubusercontent.com/u/8358?v=4"},"body":"Junio C Hamano wrote:\n> Felipe Contreras <felipe.contreras@gmail.com> writes:\n> \n> > SZEDER Gábor wrote:\n> >> On Sun, Jun 06, 2021 at 01:47:25PM -0500, Felipe Contreras wrote:\n> >> > Otherwise commands like 'for-each-ref' are not completed.\n> >> \n> >> I think you meant that options of commands like 'for-each-ref' are not\n> >> completed.\n> >> ...\n> \n> > Yes, I meant commands like 'for-each-ref' are not completed correctly...\n> > by __gitcomp_builtin. Which in practical tearms means what you just\n> > described above.\n> \n> I couldn't exactly tell if that's a roundabout way to say \"yes,\n> yours is better and I'll use it in an update, thanks\".\n\nI meant that I meant what he said I meant.\n\nBut meaning is not saying, and it's better to say what one means\n(implied), and since Szeder's version says what I meant, that's better.\n\n> I'll assume that is the case and will mark the topic as expecting the\n> final update (as it seemed that all the other patches in the series\n> were received favourably).\n\nI think it would be trivial to do s/commands/options of &/ when merging\nthe series, but fine, I'll reroll.\n\n> Or was it meant as \"no, the version you commented on was already\n> correct (if you squint your eyes)\"?\n\nNo, that's not what I meant.\n\n-- \nFelipe Contreras"},{"id":"426705","messageId":"20210608060010.1676208-1-felipe.contreras@gmail.com","threadId":"55861","inReplyTo":"20210606184726.1018460-1-felipe.contreras@gmail.com","subject":"[PATCH v3 0/4] completion: bash: a bunch of fixes","fromName":"Felipe Contreras","fromEmail":"felipe.contreras@gmail.com","sentAt":"2021-06-08T06:00:06Z","receivedAt":"2021-06-08T06:00:19Z","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\nSince v2 only a commit message was updated to say \"options of commands\"\ninsead of \"commands\".\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:  52de92cb06 ! 1:  4b73b26338 completion: bash: fix prefix detection in branch.*\n    @@ Commit message\n           git clone --config=branch.<tab>\n     \n         Reviewed-by: SZEDER Gábor <szeder.dev@gmail.com>\n    +    Tested-by: David Aguilar <davvid@gmail.com>\n         Signed-off-by: Felipe Contreras <felipe.contreras@gmail.com>\n     \n      ## contrib/completion/git-completion.bash ##\n2:  af2f17364d ! 2:  cb2fc1a7f2 completion: bash: fix for suboptions with value\n    @@ Commit message\n     \n           git merge -X diff-algorithm=<tab>\n     \n    +    Tested-by: David Aguilar <davvid@gmail.com>\n         Signed-off-by: Felipe Contreras <felipe.contreras@gmail.com>\n     \n      ## contrib/completion/git-completion.bash ##\n3:  a3bcb70594 ! 3:  ece06463a2 completion: bash: fix for multiple dash commands\n    @@ Metadata\n      ## Commit message ##\n         completion: bash: fix for multiple dash commands\n     \n    -    Otherwise commands like 'for-each-ref' are not completed.\n    +    Otherwise options of commands like 'for-each-ref' are not completed.\n     \n    +    Tested-by: David Aguilar <davvid@gmail.com>\n         Signed-off-by: Felipe Contreras <felipe.contreras@gmail.com>\n     \n      ## contrib/completion/git-completion.bash ##\n4:  6b3ef41c92 ! 4:  f9db132cbd completion: bash: add correct suffix in variables\n    @@ Commit message\n         but that can be done later.\n     \n         Cc: SZEDER Gábor <szeder.dev@gmail.com>\n    +    Tested-by: David Aguilar <davvid@gmail.com>\n         Signed-off-by: Felipe Contreras <felipe.contreras@gmail.com>\n     \n      ## contrib/completion/git-completion.bash ##\n-- \n2.32.0.2.g41be0a4e50\n\n"},{"id":"426706","messageId":"20210608060010.1676208-3-felipe.contreras@gmail.com","threadId":"55861","inReplyTo":"20210608060010.1676208-1-felipe.contreras@gmail.com","subject":"[PATCH v3 2/4] completion: bash: fix for suboptions with value","fromName":"Felipe Contreras","fromEmail":"felipe.contreras@gmail.com","sentAt":"2021-06-08T06:00:08Z","receivedAt":"2021-06-08T06:00:28Z","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 47b48fbab6..05606609f9 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.2.g41be0a4e50\n\n"},{"id":"426707","messageId":"20210608060010.1676208-4-felipe.contreras@gmail.com","threadId":"55861","inReplyTo":"20210608060010.1676208-1-felipe.contreras@gmail.com","subject":"[PATCH v3 3/4] completion: bash: fix for multiple dash commands","fromName":"Felipe Contreras","fromEmail":"felipe.contreras@gmail.com","sentAt":"2021-06-08T06:00:09Z","receivedAt":"2021-06-08T06:00:46Z","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 05606609f9..1feb2ee108 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.2.g41be0a4e50\n\n"},{"id":"426708","messageId":"20210608060010.1676208-2-felipe.contreras@gmail.com","threadId":"55861","inReplyTo":"20210608060010.1676208-1-felipe.contreras@gmail.com","subject":"[PATCH v3 1/4] completion: bash: fix prefix detection in branch.*","fromName":"Felipe Contreras","fromEmail":"felipe.contreras@gmail.com","sentAt":"2021-06-08T06:00:07Z","receivedAt":"2021-06-08T06:01:22Z","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 b50c5d0ea3..47b48fbab6 100644\n--- a/contrib/completion/git-completion.bash\n+++ b/contrib/completion/git-completion.bash\n@@ -2649,8 +2649,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.2.g41be0a4e50\n\n"},{"id":"426709","messageId":"20210608060010.1676208-5-felipe.contreras@gmail.com","threadId":"55861","inReplyTo":"20210608060010.1676208-1-felipe.contreras@gmail.com","subject":"[PATCH v3 4/4] completion: bash: add correct suffix in variables","fromName":"Felipe Contreras","fromEmail":"felipe.contreras@gmail.com","sentAt":"2021-06-08T06:00:10Z","receivedAt":"2021-06-08T06:01:30Z","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 1feb2ee108..c72b5465f9 100644\n--- a/contrib/completion/git-completion.bash\n+++ b/contrib/completion/git-completion.bash\n@@ -2652,7 +2652,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@@ -2686,7 +2686,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@@ -2702,7 +2702,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.2.g41be0a4e50\n\n"}]}