completion: add support for completing email aliases

Using the new --dump-aliases option from git-send-email, add completion for --to, --cc, --bcc, and --from with the available configured aliases. Signed-off-by: Jacob Keller <jacob.keller@gmail.com> Signed-off-by: Jeff King <peff@peff.net>

Jacob Keller committed Nov 19, 2015 at 14:52 UTC dfbe5eeb321c4887328f134afe09e98dc722a365
1 file changed +16
contrib/completion/git-completion.bash
+16
@@ -10,6 +10,7 @@
10 # *) local and remote tag names
11 # *) .git/remotes file names
12 # *) git 'subcommands'
13 +# *) git email aliases for git-send-email
14 # *) tree paths within 'ref:path/to/file' expressions
15 # *) file paths within current working directory and index
16 # *) common --long-options
@@ -1711,6 +1712,15 @@ __git_send_email_suppresscc_options="author self cc bodycc sob cccmd body all"
1712
1713 _git_send_email ()
1714 {
1715 + case "$prev" in
1716 + --to|--cc|--bcc|--from)
1717 + __gitcomp "
1718 + $(git --git-dir="$(__gitdir)" send-email --dump-aliases 2>/dev/null)
1719 + " "" ""
1720 + return
1721 + ;;
1722 + esac
1723 +
1724 case "$cur" in
1725 --confirm=*)
1726 __gitcomp "
@@ -1735,6 +1745,12 @@ _git_send_email ()
1745 " "" "${cur##--thread=}"
1746 return
1747 ;;
1748 + --to=*|--cc=*|--bcc=*|--from=*)
1749 + __gitcomp "
1750 + $(git --git-dir="$(__gitdir)" send-email --dump-aliases 2>/dev/null)
1751 + " "" "${cur#--*=}"
1752 + return
1753 + ;;
1754 --*)
1755 __gitcomp "--annotate --bcc --cc --cc-cmd --chain-reply-to
1756 --compose --confirm= --dry-run --envelope-sender