contrib/completion: extract common diff/difftool options
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>
Denton Liu committed
Sep 17, 2020 at 00:44 UTC
308d7a7dc99043c90a9eff6916cad1abe0d473aa
1 file changed
+6
-9
contrib/completion/git-completion.bash
+6
-9
@@ -1691,6 +1691,10 @@ __git_diff_common_options="--stat --numstat --shortstat --summary
1691
--textconv --no-textconv
1692
"
1693
1694
+__git_diff_difftool_options="--cached --staged --pickaxe-all --pickaxe-regex
1695
+ --base --ours --theirs --no-index --relative
1696
+ $__git_diff_common_options"
1697
+
1698
_git_diff ()
1699
{
1700
__git_has_doubledash && return
@@ -1713,10 +1717,7 @@ _git_diff ()
1717
return
1718
;;
1719
--*)
1716
- __gitcomp "--cached --staged --pickaxe-all --pickaxe-regex
1717
- --base --ours --theirs --no-index
1718
- $__git_diff_common_options
1719
- "
1720
+ __gitcomp "$__git_diff_difftool_options"
1721
return
1722
;;
1723
esac
@@ -1738,11 +1739,7 @@ _git_difftool ()
1739
return
1740
;;
1741
--*)
1741
- __gitcomp_builtin difftool "$__git_diff_common_options
1742
- --base --cached --ours --theirs
1743
- --pickaxe-all --pickaxe-regex
1744
- --relative --staged
1745
- "
1742
+ __gitcomp_builtin difftool "$__git_diff_difftool_options"
1743
return
1744
;;
1745
esac