Skip to content

Commit

Permalink
contrib/completion: extract common diff/difftool options
Browse files Browse the repository at this point in the history
difftool parses its own options and then passes the remaining options
onto diff. As a result, they share common command-line options. Instead
of duplicating the list, use a shared $__git_diff_difftool_options list.

The completion for diff is missing --relative and the completion for
difftool is missing --no-index. Add both of these to the common list.

Signed-off-by: Denton Liu <liu.denton@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
  • Loading branch information
Denton-L authored and gitster committed Sep 17, 2020
1 parent a8fa6a0 commit 308d7a7
Showing 1 changed file with 6 additions and 9 deletions.
15 changes: 6 additions & 9 deletions contrib/completion/git-completion.bash
Expand Up @@ -1691,6 +1691,10 @@ __git_diff_common_options="--stat --numstat --shortstat --summary
--textconv --no-textconv
"

__git_diff_difftool_options="--cached --staged --pickaxe-all --pickaxe-regex
--base --ours --theirs --no-index --relative
$__git_diff_common_options"

_git_diff ()
{
__git_has_doubledash && return
Expand All @@ -1713,10 +1717,7 @@ _git_diff ()
return
;;
--*)
__gitcomp "--cached --staged --pickaxe-all --pickaxe-regex
--base --ours --theirs --no-index
$__git_diff_common_options
"
__gitcomp "$__git_diff_difftool_options"
return
;;
esac
Expand All @@ -1738,11 +1739,7 @@ _git_difftool ()
return
;;
--*)
__gitcomp_builtin difftool "$__git_diff_common_options
--base --cached --ours --theirs
--pickaxe-all --pickaxe-regex
--relative --staged
"
__gitcomp_builtin difftool "$__git_diff_difftool_options"
return
;;
esac
Expand Down

0 comments on commit 308d7a7

Please sign in to comment.