@matheusbsbs / matheus-bagliano / commits / 20bf729231
Fork 0

bash completion: refactor diff options

diff, log and show all take the same diff options. Refactor them from __git_diff and __git_log into a variable, and complete them in __git_show too. Signed-off-by: Thomas Rast <trast@student.ethz.ch> Signed-off-by: Junio C Hamano <gitster@pobox.com>

Thomas Rast committed Jan 19, 2009 at 22:18 UTC 20bf7292314972d4c418056ad94c28c6363058d7
1 file changed +21 -15
contrib/completion/git-completion.bash
+21 -15
@@ -773,14 +773,7 @@ _git_describe ()
773 __gitcomp "$(__git_refs)"
774 }
775
776 -_git_diff ()
777 -{
778 - __git_has_doubledash && return
779 -
780 - local cur="${COMP_WORDS[COMP_CWORD]}"
781 - case "$cur" in
782 - --*)
783 - __gitcomp "--cached --stat --numstat --shortstat --summary
776 +__git_diff_common_options="--stat --numstat --shortstat --summary
777 --patch-with-stat --name-only --name-status --color
778 --no-color --color-words --no-renames --check
779 --full-index --binary --abbrev --diff-filter=
@@ -789,8 +782,20 @@ _git_diff ()
782 --ignore-all-space --exit-code --quiet --ext-diff
783 --no-ext-diff
784 --no-prefix --src-prefix= --dst-prefix=
792 - --base --ours --theirs
785 --inter-hunk-context=
786 + --raw
787 +"
788 +
789 +_git_diff ()
790 +{
791 + __git_has_doubledash && return
792 +
793 + local cur="${COMP_WORDS[COMP_CWORD]}"
794 + case "$cur" in
795 + --*)
796 + __gitcomp "--cached --pickaxe-all --pickaxe-regex
797 + --base --ours --theirs
798 + $__git_diff_common_options
799 "
800 return
801 ;;
@@ -976,16 +981,15 @@ _git_log ()
981 --relative-date --date=
982 --author= --committer= --grep=
983 --all-match
979 - --pretty= --name-status --name-only --raw
984 + --pretty=
985 --not --all
986 --left-right --cherry-pick
987 --graph
983 - --stat --numstat --shortstat
984 - --decorate --diff-filter=
985 - --color-words --walk-reflogs
988 + --decorate
989 + --walk-reflogs
990 --parents --children --full-history
991 --merge
988 - --inter-hunk-context=
992 + $__git_diff_common_options
993 --pickaxe-all --pickaxe-regex
994 "
995 return
@@ -1490,7 +1494,9 @@ _git_show ()
1494 return
1495 ;;
1496 --*)
1493 - __gitcomp "--pretty="
1497 + __gitcomp "--pretty=
1498 + $__git_diff_common_options
1499 + "
1500 return
1501 ;;
1502 esac