{"thread":{"id":"21589","subject":"[PATCH] Wrap completions in `type git' conditional statement.","startedAt":"2009-11-12T09:56:38Z","lastAt":"2009-12-29T21:54:32Z","messageCount":5,"participants":["Sung Pae","Nanako Shiraishi","Shawn O. Pearce","Junio C Hamano"],"isPatch":true,"patchVersion":1,"patchTotal":null},"messages":[{"id":"127433","messageId":"44A6FDEB-71B6-42E1-99E3-D6A595FF1B58@metablu.com","threadId":"21589","inReplyTo":null,"subject":"[PATCH] Wrap completions in `type git' conditional statement.","fromName":"Sung Pae","fromEmail":"sung@metablu.com","sentAt":"2009-11-12T09:56:38Z","receivedAt":"2009-11-12T09:56:38Z","isPatch":true,"sender":{"key":"sung@metablu.com","avatar":null},"body":"Hello,\n\nI 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.\n\nFrom the patch header:\n--\nThe onus for checking if a command exists before loading its completions\nproperly falls on individual completion files since they are normally\nsourced from a completions directory (e.g. source /etc/bash_completion.d/*),\nor perhaps from a single file concatenated from other completion files.\n\nAlso, this is standard practice with other bash-completion scripts.\n--\n\n\nCheers,\nSung Pae\n\n\nFrom 5e9d29fa1938554903631a4b560e08211b8efab3 Mon Sep 17 00:00:00 2001\nFrom: Sung Pae <sung@metablu.com>\nDate: Thu, 12 Nov 2009 02:55:28 -0600\nSubject: [PATCH] completion: Wrap completions in `type git' conditional statement\n\nThe onus for checking if a command exists before loading its completions\nproperly falls on the individual completion files since they are normally\nsourced from a completions directory (e.g. source /etc/bash_completion.d/*), or\nperhaps from a single file concatenated from other completion files.\n\nAlso, this is standard practice with other bash-completion scripts.\n---\n contrib/completion/git-completion.bash |   15 ++++++++-------\n 1 files changed, 8 insertions(+), 7 deletions(-)\n\ndiff --git a/contrib/completion/git-completion.bash b/contrib/completion/git-completion.bash\nindex e3ddecc..f1f9fb8 100755\n--- a/contrib/completion/git-completion.bash\n+++ b/contrib/completion/git-completion.bash\n@@ -18,16 +18,13 @@\n # To use these routines:\n #\n #    1) Copy this file to somewhere (e.g. ~/.git-completion.sh).\n-#    2) Added the following line to your .bashrc:\n+#    2) Add the following line to your .bashrc:\n #        source ~/.git-completion.sh\n #\n-#    3) You may want to make sure the git executable is available\n-#       in your PATH before this script is sourced, as some caching\n-#       is performed while the script loads.  If git isn't found\n-#       at source time then all lookups will be done on demand,\n-#       which may be slightly slower.\n+#       Note that git must be available in your PATH or as an alias at the\n+#       time of sourcing.\n #\n-#    4) Consider changing your PS1 to also show the current branch:\n+#    3) Consider changing your PS1 to also show the current branch:\n #        PS1='[\\u@\\h \\W$(__git_ps1 \" (%s)\")]\\$ '\n #\n #       The argument to __git_ps1 will be displayed only if you\n@@ -60,6 +57,8 @@\n #       git@vger.kernel.org\n #\n \n+{ type git || type git.exe; } &>/dev/null && {\n+\n case \"$COMP_WORDBREAKS\" in\n *:*) : great ;;\n *)   COMP_WORDBREAKS=\"$COMP_WORDBREAKS:\"\n@@ -2242,3 +2241,5 @@ if [ Cygwin = \"$(uname -o 2>/dev/null)\" ]; then\n complete -o bashdefault -o default -o nospace -F _git git.exe 2>/dev/null \\\n \t|| complete -o default -o nospace -F _git git.exe\n fi\n+\n+} # type git\n-- \n1.6.5\n\n"},{"id":"130447","messageId":"20091229200530.6117@nanako3.lavabit.com","threadId":"21589","inReplyTo":"44A6FDEB-71B6-42E1-99E3-D6A595FF1B58@metablu.com","subject":"Re: [PATCH] Wrap completions in `type git' conditional statement.","fromName":"Nanako Shiraishi","fromEmail":"nanako3@lavabit.com","sentAt":"2009-12-29T11:05:30Z","receivedAt":"2009-12-29T11:05:30Z","isPatch":true,"sender":{"key":"nanako3@lavabit.com","avatar":"https://gravatar.com/avatar/3777b9e201c5883a62b1a6fdf7c53f2d712d1d80989146063ea861e33aad72a8?d=mp&s=160"},"body":"Junio, could you tell us what happened to this thread?\n\nThe patch avoids failing completion script when git is not there.\nNo discussion.\n"},{"id":"130461","messageId":"20091229150217.GB6152@spearce.org","threadId":"21589","inReplyTo":"20091229200530.6117@nanako3.lavabit.com","subject":"Re: [PATCH] Wrap completions in `type git' conditional statement.","fromName":"Shawn O. Pearce","fromEmail":"spearce@spearce.org","sentAt":"2009-12-29T15:02:17Z","receivedAt":"2009-12-29T15:02:17Z","isPatch":true,"sender":{"key":"spearce@spearce.org","avatar":"https://avatars.githubusercontent.com/u/34844?v=4"},"body":"Nanako Shiraishi <nanako3@lavabit.com> wrote:\n> Junio, could you tell us what happened to this thread?\n> \n> The patch avoids failing completion script when git is not there.\n> No discussion.\n\nActually, that's probably my fault.  I never sent an ack or nak,\nor anything else really, on this thread.\n\nOriginally this was because the completion was trying to run git\nas it loaded.  In 1.6.6 this is no longer true, the completion list\nis generated lazily on demand during the first completion attempt.\n\nWith the lazy loading, I didn't see a reason to add this ugly block\naround the entire script.\n\n-- \nShawn.\n"},{"id":"130471","messageId":"7vpr5xg1j8.fsf@alter.siamese.dyndns.org","threadId":"21589","inReplyTo":"20091229150217.GB6152@spearce.org","subject":"Re: [PATCH] Wrap completions in `type git' conditional statement.","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2009-12-29T16:58:35Z","receivedAt":"2009-12-29T16:58:35Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"\"Shawn O. Pearce\" <spearce@spearce.org> writes:\n\n> Nanako Shiraishi <nanako3@lavabit.com> wrote:\n>> Junio, could you tell us what happened to this thread?\n>> \n>> The patch avoids failing completion script when git is not there.\n>> No discussion.\n>\n> Actually, that's probably my fault.  I never sent an ack or nak,\n> or anything else really, on this thread.\n>\n> Originally this was because the completion was trying to run git\n> as it loaded.  In 1.6.6 this is no longer true, the completion list\n> is generated lazily on demand during the first completion attempt.\n>\n> With the lazy loading, I didn't see a reason to add this ugly block\n> around the entire script.\n\nThanks, both.\n"},{"id":"130493","messageId":"20091230065432.6117@nanako3.lavabit.com","threadId":"21589","inReplyTo":"20091229150217.GB6152@spearce.org","subject":"Re: [PATCH] Wrap completions in `type git' conditional statement.","fromName":"Nanako Shiraishi","fromEmail":"nanako3@lavabit.com","sentAt":"2009-12-29T21:54:32Z","receivedAt":"2009-12-29T21:54:32Z","isPatch":true,"sender":{"key":"nanako3@lavabit.com","avatar":"https://gravatar.com/avatar/3777b9e201c5883a62b1a6fdf7c53f2d712d1d80989146063ea861e33aad72a8?d=mp&s=160"},"body":"Quoting Shawn O. Pearce <spearce@spearce.org>:\n\n> Nanako Shiraishi <nanako3@lavabit.com> wrote:\n>> Junio, could you tell us what happened to this thread?\n>> \n>> The patch avoids failing completion script when git is not there.\n>> No discussion.\n>\n> Actually, that's probably my fault.  I never sent an ack or nak,\n> or anything else really, on this thread.\n>\n> Originally this was because the completion was trying to run git\n> as it loaded.  In 1.6.6 this is no longer true, the completion list\n> is generated lazily on demand during the first completion attempt.\n>\n> With the lazy loading, I didn't see a reason to add this ugly block\n> around the entire script.\n>\n> -- \n> Shawn.\n\nThank you for your explanation.\n\n-- \nNanako Shiraishi\nhttp://ivory.ap.teacup.com/nanako3/\n"}]}