bash: support pretty format aliases
Users can have their own pretty format aliases since 8028184 (pretty: add aliases for pretty formats, 2010-05-02), so let's offer those after '--pretty=' and '--format=' for 'log' and 'show', too. Similar to the completion of aliases, this will invoke 'git config' each time pretty aliases needs to be completed, so changes in pretty.* configuration will be reflected immediately. Signed-off-by: SZEDER Gábor <szeder@ira.uka.de> Signed-off-by: Junio C Hamano <gitster@pobox.com>
SZEDER Gábor committed
Oct 11, 2010 at 00:06 UTC
c3898111ac65c6703691db5c984b0f8493ba40ee
1 file changed
+17
-4
contrib/completion/git-completion.bash
+17
-4
@@ -750,6 +750,19 @@ __git_compute_porcelain_commands ()
750
: ${__git_porcelain_commands:=$(__git_list_porcelain_commands)}
751
}
752
753
+__git_pretty_aliases ()
754
+{
755
+ local i IFS=$'\n'
756
+ for i in $(git --git-dir="$(__gitdir)" config --get-regexp "pretty\..*" 2>/dev/null); do
757
+ case "$i" in
758
+ pretty.*)
759
+ i="${i#pretty.}"
760
+ echo "${i/ */}"
761
+ ;;
762
+ esac
763
+ done
764
+}
765
+
766
__git_aliases ()
767
{
768
local i IFS=$'\n'
@@ -1372,12 +1385,12 @@ _git_log ()
1385
fi
1386
case "$cur" in
1387
--pretty=*)
1375
- __gitcomp "$__git_log_pretty_formats
1388
+ __gitcomp "$__git_log_pretty_formats $(__git_pretty_aliases)
1389
" "" "${cur##--pretty=}"
1390
return
1391
;;
1392
--format=*)
1380
- __gitcomp "$__git_log_pretty_formats
1393
+ __gitcomp "$__git_log_pretty_formats $(__git_pretty_aliases)
1394
" "" "${cur##--format=}"
1395
return
1396
;;
@@ -2136,12 +2149,12 @@ _git_show ()
2149
local cur="${COMP_WORDS[COMP_CWORD]}"
2150
case "$cur" in
2151
--pretty=*)
2139
- __gitcomp "$__git_log_pretty_formats
2152
+ __gitcomp "$__git_log_pretty_formats $(__git_pretty_aliases)
2153
" "" "${cur##--pretty=}"
2154
return
2155
;;
2156
--format=*)
2144
- __gitcomp "$__git_log_pretty_formats
2157
+ __gitcomp "$__git_log_pretty_formats $(__git_pretty_aliases)
2158
" "" "${cur##--format=}"
2159
return
2160
;;