summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: ce1e39d)
raw | patch | inline | side by side (parent: ce1e39d)
author | Shawn O. Pearce <spearce@spearce.org> | |
Mon, 27 Nov 2006 20:11:52 +0000 (15:11 -0500) | ||
committer | Junio C Hamano <junkio@cox.net> | |
Mon, 27 Nov 2006 20:57:21 +0000 (12:57 -0800) |
Since the user's git installation is not likely to grow a new command
or merge strategy in the lifespan of the current shell process we can
save time during completion operations by caching these lists during
sourcing of the completion support.
If the git executable is not available or we run into errors while
caching at load time then we defer these to runtime and generate
the list on the fly. This might happen if the user doesn't put git
into their PATH until after the completion script gets sourced.
Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
Signed-off-by: Junio C Hamano <junkio@cox.net>
or merge strategy in the lifespan of the current shell process we can
save time during completion operations by caching these lists during
sourcing of the completion support.
If the git executable is not available or we run into errors while
caching at load time then we defer these to runtime and generate
the list on the fly. This might happen if the user doesn't put git
into their PATH until after the completion script gets sourced.
Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
Signed-off-by: Junio C Hamano <junkio@cox.net>
contrib/completion/git-completion.bash | patch | blob | history |
index 16b8dda17dbe1e3c09f3b1377e4a98b9c19900f7..902f80b937fed7581fed1d967dde130411b13fb1 100755 (executable)
# 2) Added the following line to your .bashrc:
# source ~/.git-completion.sh
#
-# 3) Consider changing your PS1 to also show the current branch:
+# 3) You may want to make sure the git executable is available
+# in your PATH before this script is sourced, as some caching
+# is performed while the script loads. If git isn't found
+# at source time then all lookups will be done on demand,
+# which may be slightly slower.
+#
+# 4) Consider changing your PS1 to also show the current branch:
# PS1='[\u@\h \W$(__git_ps1 " (%s)")]\$ '
#
# The argument to __git_ps1 will be displayed only if you
__git_merge_strategies ()
{
+ if [ -n "$__git_merge_strategylist" ]; then
+ echo "$__git_merge_strategylist"
+ return
+ fi
sed -n "/^all_strategies='/{
s/^all_strategies='//
s/'//
q
}" "$(git --exec-path)/git-merge"
}
+__git_merge_strategylist=
+__git_merge_strategylist="$(__git_merge_strategies 2>/dev/null)"
__git_complete_file ()
{
__git_commands ()
{
+ if [ -n "$__git_commandlist" ]; then
+ echo "$__git_commandlist"
+ return
+ fi
local i IFS=" "$'\n'
for i in $(git help -a|egrep '^ ')
do
esac
done
}
+__git_commandlist=
+__git_commandlist="$(__git_commands 2>/dev/null)"
__git_aliases ()
{