{"thread":{"id":"53855","subject":"[PATCH] completion: add show --color-moved[-ws]","startedAt":"2020-07-14T07:45:08Z","lastAt":"2020-07-15T21:08:35Z","messageCount":2,"participants":["Michal Privoznik","Junio C Hamano"],"isPatch":true,"patchVersion":1,"patchTotal":null},"messages":[{"id":"401541","messageId":"da0bef7b856388d7f4613c30d3a7c962ddba96b2.1594712582.git.mprivozn@redhat.com","threadId":"53855","inReplyTo":null,"subject":"[PATCH] completion: add show --color-moved[-ws]","fromName":"Michal Privoznik","fromEmail":"mprivozn@redhat.com","sentAt":"2020-07-14T07:44:51Z","receivedAt":"2020-07-14T07:45:08Z","isPatch":true,"sender":{"key":"mprivozn@redhat.com","avatar":"https://avatars.githubusercontent.com/u/12559331?v=4"},"body":"The completion for diff command was added in fd0bc175576 but\nmissed the show command which also supports --color-moved[-ws].\n\nThis suffers from the very same problem [1] as the referenced\ncommit: no comma-separated list completion for --color-moved-ws.\n\n[1]: https://github.com/scop/bash-completion/issues/240\n\nSigned-off-by: Michal Privoznik <mprivozn@redhat.com>\n---\n contrib/completion/git-completion.bash | 8 ++++++++\n 1 file changed, 8 insertions(+)\n\ndiff --git a/contrib/completion/git-completion.bash b/contrib/completion/git-completion.bash\nindex c21786f2fd..d23cf181ef 100644\n--- a/contrib/completion/git-completion.bash\n+++ b/contrib/completion/git-completion.bash\n@@ -2732,6 +2732,14 @@ _git_show ()\n \t\t__gitcomp \"$__git_diff_submodule_formats\" \"\" \"${cur##--submodule=}\"\n \t\treturn\n \t\t;;\n+\t--color-moved=*)\n+\t\t__gitcomp \"$__git_color_moved_opts\" \"\" \"${cur##--color-moved=}\"\n+\t\treturn\n+\t\t;;\n+\t--color-moved-ws=*)\n+\t\t__gitcomp \"$__git_color_moved_ws_opts\" \"\" \"${cur##--color-moved-ws=}\"\n+\t\treturn\n+\t\t;;\n \t--*)\n \t\t__gitcomp \"--pretty= --format= --abbrev-commit --no-abbrev-commit\n \t\t\t--oneline --show-signature --patch\n-- \n2.26.2\n\n"},{"id":"401609","messageId":"xmqqtuy8ij01.fsf@gitster.c.googlers.com","threadId":"53855","inReplyTo":"da0bef7b856388d7f4613c30d3a7c962ddba96b2.1594712582.git.mprivozn@redhat.com","subject":"Re: [PATCH] completion: add show --color-moved[-ws]","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2020-07-15T21:08:30Z","receivedAt":"2020-07-15T21:08:35Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Michal Privoznik <mprivozn@redhat.com> writes:\n\n> The completion for diff command was added in fd0bc175576 but\n> missed the show command which also supports --color-moved[-ws].\n\nA block line this\n\n> +\t--color-moved=*)\n> +\t\t__gitcomp \"$__git_color_moved_opts\" \"\" \"${cur##--color-moved=}\"\n> +\t\treturn\n> +\t\t;;\n> +\t--color-moved-ws=*)\n> +\t\t__gitcomp \"$__git_color_moved_ws_opts\" \"\" \"${cur##--color-moved-ws=}\"\n> +\t\treturn\n> +\t\t;;\n\nappear twice in the file, once in _git_diff and again in _git_show.\n\nIt is disturbing that we need to keep duplicating these same options\nover and over again.  Granted, the duplication exists before this\npatch (the case arms for --diff-algorithm=* and --submodule=* are\nalready duplicated), but this patch makes it worse X-<.\n\nAnd the next person who notices that this patch only added these to\n\"show\" would want to further duplicate them to _git_log.  Yuck X-<.\n\nWill apply as-is for now, but at some point we may want to clean\nthese up.  With a new helper, along the lines of this, perhaps?\n\nThanks.\n\n\n contrib/completion/git-completion.bash | 79 +++++++++++++++++-----------------\n 1 file changed, 39 insertions(+), 40 deletions(-)\n\ndiff --git a/contrib/completion/git-completion.bash b/contrib/completion/git-completion.bash\nindex 0fdb5da83b..e2d6d17bfe 100644\n--- a/contrib/completion/git-completion.bash\n+++ b/contrib/completion/git-completion.bash\n@@ -1683,23 +1683,12 @@ _git_diff ()\n {\n \t__git_has_doubledash && return\n \n-\tcase \"$cur\" in\n-\t--diff-algorithm=*)\n-\t\t__gitcomp \"$__git_diff_algorithms\" \"\" \"${cur##--diff-algorithm=}\"\n-\t\treturn\n-\t\t;;\n-\t--submodule=*)\n-\t\t__gitcomp \"$__git_diff_submodule_formats\" \"\" \"${cur##--submodule=}\"\n-\t\treturn\n-\t\t;;\n-\t--color-moved=*)\n-\t\t__gitcomp \"$__git_color_moved_opts\" \"\" \"${cur##--color-moved=}\"\n-\t\treturn\n-\t\t;;\n-\t--color-moved-ws=*)\n-\t\t__gitcomp \"$__git_color_moved_ws_opts\" \"\" \"${cur##--color-moved-ws=}\"\n+\tif __git_complete_common_diff_option_args\n+\tthen\n \t\treturn\n-\t\t;;\n+\tfi\n+\n+\tcase \"$cur\" in\n \t--*)\n \t\t__gitcomp \"--cached --staged --pickaxe-all --pickaxe-regex\n \t\t\t--base --ours --theirs --no-index\n@@ -1949,6 +1938,29 @@ __git_log_shortlog_options=\"\n __git_log_pretty_formats=\"oneline short medium full fuller reference email raw format: tformat: mboxrd\"\n __git_log_date_formats=\"relative iso8601 iso8601-strict rfc2822 short local default raw unix format:\"\n \n+__git_complete_common_diff_option_args ()\n+{\n+\tcase \"$cur\" in\n+\t--diff-algorithm=*)\n+\t\t__gitcomp \"$__git_diff_algorithms\" \"\" \"${cur##--diff-algorithm=}\"\n+\t\treturn 0\n+\t\t;;\n+\t--submodule=*)\n+\t\t__gitcomp \"$__git_diff_submodule_formats\" \"\" \"${cur##--submodule=}\"\n+\t\treturn 0\n+\t\t;;\n+\t--color-moved=*)\n+\t\t__gitcomp \"$__git_color_moved_opts\" \"\" \"${cur##--color-moved=}\"\n+\t\treturn 0\n+\t\t;;\n+\t--color-moved-ws=*)\n+\t\t__gitcomp \"$__git_color_moved_ws_opts\" \"\" \"${cur##--color-moved-ws=}\"\n+\t\treturn 0\n+\t\t;;\n+\tesac\n+\treturn 1\n+}\n+\n _git_log ()\n {\n \t__git_has_doubledash && return\n@@ -1971,6 +1983,12 @@ _git_log ()\n \t\treturn\n \t\t;;\n \tesac\n+\n+\tif __git_complete_common_diff_option_args\n+\tthen\n+\t\treturn\n+\tfi\n+\n \tcase \"$cur\" in\n \t--pretty=*|--format=*)\n \t\t__gitcomp \"$__git_log_pretty_formats $(__git_pretty_aliases)\n@@ -1985,14 +2003,6 @@ _git_log ()\n \t\t__gitcomp \"full short no\" \"\" \"${cur##--decorate=}\"\n \t\treturn\n \t\t;;\n-\t--diff-algorithm=*)\n-\t\t__gitcomp \"$__git_diff_algorithms\" \"\" \"${cur##--diff-algorithm=}\"\n-\t\treturn\n-\t\t;;\n-\t--submodule=*)\n-\t\t__gitcomp \"$__git_diff_submodule_formats\" \"\" \"${cur##--submodule=}\"\n-\t\treturn\n-\t\t;;\n \t--no-walk=*)\n \t\t__gitcomp \"sorted unsorted\" \"\" \"${cur##--no-walk=}\"\n \t\treturn\n@@ -2893,28 +2903,17 @@ _git_show ()\n {\n \t__git_has_doubledash && return\n \n+\tif __git_complete_common_diff_option_args\n+\tthen\n+\t\treturn\n+\tfi\n+\n \tcase \"$cur\" in\n \t--pretty=*|--format=*)\n \t\t__gitcomp \"$__git_log_pretty_formats $(__git_pretty_aliases)\n \t\t\t\" \"\" \"${cur#*=}\"\n \t\treturn\n \t\t;;\n-\t--diff-algorithm=*)\n-\t\t__gitcomp \"$__git_diff_algorithms\" \"\" \"${cur##--diff-algorithm=}\"\n-\t\treturn\n-\t\t;;\n-\t--submodule=*)\n-\t\t__gitcomp \"$__git_diff_submodule_formats\" \"\" \"${cur##--submodule=}\"\n-\t\treturn\n-\t\t;;\n-\t--color-moved=*)\n-\t\t__gitcomp \"$__git_color_moved_opts\" \"\" \"${cur##--color-moved=}\"\n-\t\treturn\n-\t\t;;\n-\t--color-moved-ws=*)\n-\t\t__gitcomp \"$__git_color_moved_ws_opts\" \"\" \"${cur##--color-moved-ws=}\"\n-\t\treturn\n-\t\t;;\n \t--*)\n \t\t__gitcomp \"--pretty= --format= --abbrev-commit --no-abbrev-commit\n \t\t\t--oneline --show-signature --patch\n"}]}