Skip to content

Commit

Permalink
bash: support pretty format aliases
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
SZEDER Gábor authored and Junio C Hamano committed Oct 13, 2010
1 parent 2a5da75 commit c389811
Showing 1 changed file with 17 additions and 4 deletions.
21 changes: 17 additions & 4 deletions contrib/completion/git-completion.bash
Original file line number Diff line number Diff line change
Expand Up @@ -750,6 +750,19 @@ __git_compute_porcelain_commands ()
: ${__git_porcelain_commands:=$(__git_list_porcelain_commands)}
}

__git_pretty_aliases ()
{
local i IFS=$'\n'
for i in $(git --git-dir="$(__gitdir)" config --get-regexp "pretty\..*" 2>/dev/null); do
case "$i" in
pretty.*)
i="${i#pretty.}"
echo "${i/ */}"
;;
esac
done
}

__git_aliases ()
{
local i IFS=$'\n'
Expand Down Expand Up @@ -1372,12 +1385,12 @@ _git_log ()
fi
case "$cur" in
--pretty=*)
__gitcomp "$__git_log_pretty_formats
__gitcomp "$__git_log_pretty_formats $(__git_pretty_aliases)
" "" "${cur##--pretty=}"
return
;;
--format=*)
__gitcomp "$__git_log_pretty_formats
__gitcomp "$__git_log_pretty_formats $(__git_pretty_aliases)
" "" "${cur##--format=}"
return
;;
Expand Down Expand Up @@ -2136,12 +2149,12 @@ _git_show ()
local cur="${COMP_WORDS[COMP_CWORD]}"
case "$cur" in
--pretty=*)
__gitcomp "$__git_log_pretty_formats
__gitcomp "$__git_log_pretty_formats $(__git_pretty_aliases)
" "" "${cur##--pretty=}"
return
;;
--format=*)
__gitcomp "$__git_log_pretty_formats
__gitcomp "$__git_log_pretty_formats $(__git_pretty_aliases)
" "" "${cur##--format=}"
return
;;
Expand Down

0 comments on commit c389811

Please sign in to comment.