* [PATCH] completion: add show --color-moved[-ws]
@ 2020-07-14 7:44 Michal Privoznik
2020-07-15 21:08 ` Junio C Hamano
0 siblings, 1 reply; 2+ messages in thread
From: Michal Privoznik @ 2020-07-14 7:44 UTC (permalink / raw)
To: git; +Cc: matheus.bernardino, kolyshkin, gitster
The completion for diff command was added in fd0bc175576 but
missed the show command which also supports --color-moved[-ws].
This suffers from the very same problem [1] as the referenced
commit: no comma-separated list completion for --color-moved-ws.
[1]: https://github.com/scop/bash-completion/issues/240
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
---
contrib/completion/git-completion.bash | 8 ++++++++
1 file changed, 8 insertions(+)
diff --git a/contrib/completion/git-completion.bash b/contrib/completion/git-completion.bash
index c21786f2fd..d23cf181ef 100644
--- a/contrib/completion/git-completion.bash
+++ b/contrib/completion/git-completion.bash
@@ -2732,6 +2732,14 @@ _git_show ()
__gitcomp "$__git_diff_submodule_formats" "" "${cur##--submodule=}"
return
;;
+ --color-moved=*)
+ __gitcomp "$__git_color_moved_opts" "" "${cur##--color-moved=}"
+ return
+ ;;
+ --color-moved-ws=*)
+ __gitcomp "$__git_color_moved_ws_opts" "" "${cur##--color-moved-ws=}"
+ return
+ ;;
--*)
__gitcomp "--pretty= --format= --abbrev-commit --no-abbrev-commit
--oneline --show-signature --patch
--
2.26.2
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH] completion: add show --color-moved[-ws]
2020-07-14 7:44 [PATCH] completion: add show --color-moved[-ws] Michal Privoznik
@ 2020-07-15 21:08 ` Junio C Hamano
0 siblings, 0 replies; 2+ messages in thread
From: Junio C Hamano @ 2020-07-15 21:08 UTC (permalink / raw)
To: Michal Privoznik; +Cc: git, matheus.bernardino, kolyshkin
Michal Privoznik <mprivozn@redhat.com> writes:
> The completion for diff command was added in fd0bc175576 but
> missed the show command which also supports --color-moved[-ws].
A block line this
> + --color-moved=*)
> + __gitcomp "$__git_color_moved_opts" "" "${cur##--color-moved=}"
> + return
> + ;;
> + --color-moved-ws=*)
> + __gitcomp "$__git_color_moved_ws_opts" "" "${cur##--color-moved-ws=}"
> + return
> + ;;
appear twice in the file, once in _git_diff and again in _git_show.
It is disturbing that we need to keep duplicating these same options
over and over again. Granted, the duplication exists before this
patch (the case arms for --diff-algorithm=* and --submodule=* are
already duplicated), but this patch makes it worse X-<.
And the next person who notices that this patch only added these to
"show" would want to further duplicate them to _git_log. Yuck X-<.
Will apply as-is for now, but at some point we may want to clean
these up. With a new helper, along the lines of this, perhaps?
Thanks.
contrib/completion/git-completion.bash | 79 +++++++++++++++++-----------------
1 file changed, 39 insertions(+), 40 deletions(-)
diff --git a/contrib/completion/git-completion.bash b/contrib/completion/git-completion.bash
index 0fdb5da83b..e2d6d17bfe 100644
--- a/contrib/completion/git-completion.bash
+++ b/contrib/completion/git-completion.bash
@@ -1683,23 +1683,12 @@ _git_diff ()
{
__git_has_doubledash && return
- case "$cur" in
- --diff-algorithm=*)
- __gitcomp "$__git_diff_algorithms" "" "${cur##--diff-algorithm=}"
- return
- ;;
- --submodule=*)
- __gitcomp "$__git_diff_submodule_formats" "" "${cur##--submodule=}"
- return
- ;;
- --color-moved=*)
- __gitcomp "$__git_color_moved_opts" "" "${cur##--color-moved=}"
- return
- ;;
- --color-moved-ws=*)
- __gitcomp "$__git_color_moved_ws_opts" "" "${cur##--color-moved-ws=}"
+ if __git_complete_common_diff_option_args
+ then
return
- ;;
+ fi
+
+ case "$cur" in
--*)
__gitcomp "--cached --staged --pickaxe-all --pickaxe-regex
--base --ours --theirs --no-index
@@ -1949,6 +1938,29 @@ __git_log_shortlog_options="
__git_log_pretty_formats="oneline short medium full fuller reference email raw format: tformat: mboxrd"
__git_log_date_formats="relative iso8601 iso8601-strict rfc2822 short local default raw unix format:"
+__git_complete_common_diff_option_args ()
+{
+ case "$cur" in
+ --diff-algorithm=*)
+ __gitcomp "$__git_diff_algorithms" "" "${cur##--diff-algorithm=}"
+ return 0
+ ;;
+ --submodule=*)
+ __gitcomp "$__git_diff_submodule_formats" "" "${cur##--submodule=}"
+ return 0
+ ;;
+ --color-moved=*)
+ __gitcomp "$__git_color_moved_opts" "" "${cur##--color-moved=}"
+ return 0
+ ;;
+ --color-moved-ws=*)
+ __gitcomp "$__git_color_moved_ws_opts" "" "${cur##--color-moved-ws=}"
+ return 0
+ ;;
+ esac
+ return 1
+}
+
_git_log ()
{
__git_has_doubledash && return
@@ -1971,6 +1983,12 @@ _git_log ()
return
;;
esac
+
+ if __git_complete_common_diff_option_args
+ then
+ return
+ fi
+
case "$cur" in
--pretty=*|--format=*)
__gitcomp "$__git_log_pretty_formats $(__git_pretty_aliases)
@@ -1985,14 +2003,6 @@ _git_log ()
__gitcomp "full short no" "" "${cur##--decorate=}"
return
;;
- --diff-algorithm=*)
- __gitcomp "$__git_diff_algorithms" "" "${cur##--diff-algorithm=}"
- return
- ;;
- --submodule=*)
- __gitcomp "$__git_diff_submodule_formats" "" "${cur##--submodule=}"
- return
- ;;
--no-walk=*)
__gitcomp "sorted unsorted" "" "${cur##--no-walk=}"
return
@@ -2893,28 +2903,17 @@ _git_show ()
{
__git_has_doubledash && return
+ if __git_complete_common_diff_option_args
+ then
+ return
+ fi
+
case "$cur" in
--pretty=*|--format=*)
__gitcomp "$__git_log_pretty_formats $(__git_pretty_aliases)
" "" "${cur#*=}"
return
;;
- --diff-algorithm=*)
- __gitcomp "$__git_diff_algorithms" "" "${cur##--diff-algorithm=}"
- return
- ;;
- --submodule=*)
- __gitcomp "$__git_diff_submodule_formats" "" "${cur##--submodule=}"
- return
- ;;
- --color-moved=*)
- __gitcomp "$__git_color_moved_opts" "" "${cur##--color-moved=}"
- return
- ;;
- --color-moved-ws=*)
- __gitcomp "$__git_color_moved_ws_opts" "" "${cur##--color-moved-ws=}"
- return
- ;;
--*)
__gitcomp "--pretty= --format= --abbrev-commit --no-abbrev-commit
--oneline --show-signature --patch
^ permalink raw reply related [flat|nested] 2+ messages in thread
end of thread, other threads:[~2020-07-15 21:08 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-07-14 7:44 [PATCH] completion: add show --color-moved[-ws] Michal Privoznik
2020-07-15 21:08 ` Junio C Hamano
Code repositories for project(s) associated with this public inbox
https://80x24.org/mirrors/git.git
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).