aboutsummaryrefslogtreecommitdiff
path: root/contrib
diff options
context:
space:
mode:
Diffstat (limited to 'contrib')
-rwxr-xr-xcontrib/completion/git-completion.bash29
-rw-r--r--contrib/emacs/vc-git.el2
2 files changed, 29 insertions, 2 deletions
diff --git a/contrib/completion/git-completion.bash b/contrib/completion/git-completion.bash
index d9cb17d0b..b074f4fe5 100755
--- a/contrib/completion/git-completion.bash
+++ b/contrib/completion/git-completion.bash
@@ -101,6 +101,23 @@ __git_complete_file ()
esac
}
+__git_aliases ()
+{
+ git repo-config --list | grep '^alias\.' \
+ | sed -e 's/^alias\.//' -e 's/=.*$//'
+}
+
+__git_aliased_command ()
+{
+ local cmdline=$(git repo-config alias.$1)
+ for word in $cmdline; do
+ if [ "${word##-*}" ]; then
+ echo $word
+ return
+ fi
+ done
+}
+
_git_branch ()
{
local cur="${COMP_WORDS[COMP_CWORD]}"
@@ -264,10 +281,18 @@ _git ()
{
if [ $COMP_CWORD = 1 ]; then
COMPREPLY=($(compgen \
- -W "--version $(git help -a|egrep '^ ')" \
+ -W "--version $(git help -a|egrep '^ ') \
+ $(__git_aliases)" \
-- "${COMP_WORDS[COMP_CWORD]}"))
else
- case "${COMP_WORDS[1]}" in
+ local command="${COMP_WORDS[1]}"
+ local expansion=$(__git_aliased_command "$command")
+
+ if [ "$expansion" ]; then
+ command="$expansion"
+ fi
+
+ case "$command" in
branch) _git_branch ;;
cat-file) _git_cat_file ;;
checkout) _git_checkout ;;
diff --git a/contrib/emacs/vc-git.el b/contrib/emacs/vc-git.el
index 80e767533..8b6361922 100644
--- a/contrib/emacs/vc-git.el
+++ b/contrib/emacs/vc-git.el
@@ -33,6 +33,8 @@
;; - working with revisions other than HEAD
;;
+(eval-when-compile (require 'cl))
+
(defvar git-commits-coding-system 'utf-8
"Default coding system for git commits.")