* [PATCH] Wrap completions in `type git' conditional statement.
@ 2009-11-12 9:56 Sung Pae
2009-12-29 11:05 ` Nanako Shiraishi
0 siblings, 1 reply; 5+ messages in thread
From: Sung Pae @ 2009-11-12 9:56 UTC (permalink / raw)
To: spearce; +Cc: git
[-- Attachment #1: Type: text/plain, Size: 611 bytes --]
Hello,
I don't know if this has come up before (I didn't notice in a casual grep of git log), but attached is a little patch to wrap the bash completion script in a `type git' check.
From the patch header:
--
The onus for checking if a command exists before loading its completions
properly falls on individual completion files since they are normally
sourced from a completions directory (e.g. source /etc/bash_completion.d/*),
or perhaps from a single file concatenated from other completion files.
Also, this is standard practice with other bash-completion scripts.
--
Cheers,
Sung Pae
[-- Attachment #2: 0001-completion-Wrap-completions-in-type-git-conditional-.patch --]
[-- Type: application/octet-stream, Size: 2323 bytes --]
From 5e9d29fa1938554903631a4b560e08211b8efab3 Mon Sep 17 00:00:00 2001
From: Sung Pae <sung@metablu.com>
Date: Thu, 12 Nov 2009 02:55:28 -0600
Subject: [PATCH] completion: Wrap completions in `type git' conditional statement
The onus for checking if a command exists before loading its completions
properly falls on the individual completion files since they are normally
sourced from a completions directory (e.g. source /etc/bash_completion.d/*), or
perhaps from a single file concatenated from other completion files.
Also, this is standard practice with other bash-completion scripts.
---
contrib/completion/git-completion.bash | 15 ++++++++-------
1 files changed, 8 insertions(+), 7 deletions(-)
diff --git a/contrib/completion/git-completion.bash b/contrib/completion/git-completion.bash
index e3ddecc..f1f9fb8 100755
--- a/contrib/completion/git-completion.bash
+++ b/contrib/completion/git-completion.bash
@@ -18,16 +18,13 @@
# To use these routines:
#
# 1) Copy this file to somewhere (e.g. ~/.git-completion.sh).
-# 2) Added the following line to your .bashrc:
+# 2) Add the following line to your .bashrc:
# source ~/.git-completion.sh
#
-# 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.
+# Note that git must be available in your PATH or as an alias at the
+# time of sourcing.
#
-# 4) Consider changing your PS1 to also show the current branch:
+# 3) 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
@@ -60,6 +57,8 @@
# git@vger.kernel.org
#
+{ type git || type git.exe; } &>/dev/null && {
+
case "$COMP_WORDBREAKS" in
*:*) : great ;;
*) COMP_WORDBREAKS="$COMP_WORDBREAKS:"
@@ -2242,3 +2241,5 @@ if [ Cygwin = "$(uname -o 2>/dev/null)" ]; then
complete -o bashdefault -o default -o nospace -F _git git.exe 2>/dev/null \
|| complete -o default -o nospace -F _git git.exe
fi
+
+} # type git
--
1.6.5
^ permalink raw reply related [flat|nested] 5+ messages in thread
* Re: [PATCH] Wrap completions in `type git' conditional statement.
2009-11-12 9:56 [PATCH] Wrap completions in `type git' conditional statement Sung Pae
@ 2009-12-29 11:05 ` Nanako Shiraishi
2009-12-29 15:02 ` Shawn O. Pearce
0 siblings, 1 reply; 5+ messages in thread
From: Nanako Shiraishi @ 2009-12-29 11:05 UTC (permalink / raw)
To: Junio C Hamano; +Cc: Sung Pae, git, spearce
Junio, could you tell us what happened to this thread?
The patch avoids failing completion script when git is not there.
No discussion.
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] Wrap completions in `type git' conditional statement.
2009-12-29 11:05 ` Nanako Shiraishi
@ 2009-12-29 15:02 ` Shawn O. Pearce
2009-12-29 16:58 ` Junio C Hamano
2009-12-29 21:54 ` Nanako Shiraishi
0 siblings, 2 replies; 5+ messages in thread
From: Shawn O. Pearce @ 2009-12-29 15:02 UTC (permalink / raw)
To: Nanako Shiraishi; +Cc: Junio C Hamano, Sung Pae, git
Nanako Shiraishi <nanako3@lavabit.com> wrote:
> Junio, could you tell us what happened to this thread?
>
> The patch avoids failing completion script when git is not there.
> No discussion.
Actually, that's probably my fault. I never sent an ack or nak,
or anything else really, on this thread.
Originally this was because the completion was trying to run git
as it loaded. In 1.6.6 this is no longer true, the completion list
is generated lazily on demand during the first completion attempt.
With the lazy loading, I didn't see a reason to add this ugly block
around the entire script.
--
Shawn.
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] Wrap completions in `type git' conditional statement.
2009-12-29 15:02 ` Shawn O. Pearce
@ 2009-12-29 16:58 ` Junio C Hamano
2009-12-29 21:54 ` Nanako Shiraishi
1 sibling, 0 replies; 5+ messages in thread
From: Junio C Hamano @ 2009-12-29 16:58 UTC (permalink / raw)
To: Shawn O. Pearce; +Cc: Nanako Shiraishi, Junio C Hamano, Sung Pae, git
"Shawn O. Pearce" <spearce@spearce.org> writes:
> Nanako Shiraishi <nanako3@lavabit.com> wrote:
>> Junio, could you tell us what happened to this thread?
>>
>> The patch avoids failing completion script when git is not there.
>> No discussion.
>
> Actually, that's probably my fault. I never sent an ack or nak,
> or anything else really, on this thread.
>
> Originally this was because the completion was trying to run git
> as it loaded. In 1.6.6 this is no longer true, the completion list
> is generated lazily on demand during the first completion attempt.
>
> With the lazy loading, I didn't see a reason to add this ugly block
> around the entire script.
Thanks, both.
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] Wrap completions in `type git' conditional statement.
2009-12-29 15:02 ` Shawn O. Pearce
2009-12-29 16:58 ` Junio C Hamano
@ 2009-12-29 21:54 ` Nanako Shiraishi
1 sibling, 0 replies; 5+ messages in thread
From: Nanako Shiraishi @ 2009-12-29 21:54 UTC (permalink / raw)
To: Shawn O. Pearce; +Cc: Junio C Hamano, Sung Pae, git
Quoting Shawn O. Pearce <spearce@spearce.org>:
> Nanako Shiraishi <nanako3@lavabit.com> wrote:
>> Junio, could you tell us what happened to this thread?
>>
>> The patch avoids failing completion script when git is not there.
>> No discussion.
>
> Actually, that's probably my fault. I never sent an ack or nak,
> or anything else really, on this thread.
>
> Originally this was because the completion was trying to run git
> as it loaded. In 1.6.6 this is no longer true, the completion list
> is generated lazily on demand during the first completion attempt.
>
> With the lazy loading, I didn't see a reason to add this ugly block
> around the entire script.
>
> --
> Shawn.
Thank you for your explanation.
--
Nanako Shiraishi
http://ivory.ap.teacup.com/nanako3/
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2009-12-29 21:55 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2009-11-12 9:56 [PATCH] Wrap completions in `type git' conditional statement Sung Pae
2009-12-29 11:05 ` Nanako Shiraishi
2009-12-29 15:02 ` Shawn O. Pearce
2009-12-29 16:58 ` Junio C Hamano
2009-12-29 21:54 ` Nanako Shiraishi
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).