{"thread":{"id":"27188","subject":"[PATCH] Refactor git-completion to allow ZSH usage of PS1 functions","startedAt":"2011-04-26T13:24:48Z","lastAt":"2011-04-27T03:23:35Z","messageCount":11,"participants":["Marius Storm-Olsen","Junio C Hamano","Matthieu Moy","Felipe Contreras"],"isPatch":true,"patchVersion":1,"patchTotal":null},"messages":[{"id":"166378","messageId":"1303824288-15591-1-git-send-email-mstormo@gmail.com","threadId":"27188","inReplyTo":null,"subject":"[PATCH] Refactor git-completion to allow ZSH usage of PS1 functions","fromName":"Marius Storm-Olsen","fromEmail":"marius@storm-olsen.com","sentAt":"2011-04-26T13:24:48Z","receivedAt":"2011-04-26T13:24:48Z","isPatch":true,"sender":{"key":"marius@storm-olsen.com","avatar":"https://avatars.githubusercontent.com/u/1500?v=4"},"body":"The PS1 functions in git-completion are simple functions which\nwork just as well for ZSH as for Bash. So, refactoring them out\nallows ZSH users to also use them, 'standardizing' the prompt\\\nfor Git.\n\nThe only thing not supported by ZSH is the\n    __git_ps1_show_upstream\nfunction, so this functionality is simply forced disabled there.\n\nSigned-off-by: Marius Storm-Olsen <mstormo@gmail.com>\n---\n This patch is mainly just moving the two functions\n     __gitdir\n     __git_ps1\n out into a new file. However, the most \"nasty\" is the way this\n file is then included from the original git-completion.bash\n file, with\n     GIT_COMPLETION_BASH_ONLY=1\n     source $(dirname ${BASH_SOURCE[0]})/git-prompt-functions\n where the variable ensures that only Bash will include the\n     __git_ps1_show_upstream\n function call, and then the PS1 functions are loaded via a\n dirname'd BASH_SOURCE[0]. I am by no means a Bash guru, so\n others will have to evaluate the compatability of using this\n technique outside of Bash on Linux. Relying on $0 at least,\n does not work.\n\n Someone will also have to verify the RPM part at the bottom.\n\n\n contrib/completion/git-completion.bash  |  117 +-----------------------\n contrib/completion/git-prompt-functions |  149 +++++++++++++++++++++++++++++++\n git.spec.in                             |    1 +\n 3 files changed, 153 insertions(+), 114 deletions(-)\n create mode 100755 contrib/completion/git-prompt-functions\n\ndiff --git a/contrib/completion/git-completion.bash b/contrib/completion/git-completion.bash\nindex 840ae38..417cb0a 100755\n--- a/contrib/completion/git-completion.bash\n+++ b/contrib/completion/git-completion.bash\n@@ -82,25 +82,6 @@ case \"$COMP_WORDBREAKS\" in\n *)   COMP_WORDBREAKS=\"$COMP_WORDBREAKS:\"\n esac\n \n-# __gitdir accepts 0 or 1 arguments (i.e., location)\n-# returns location of .git repo\n-__gitdir ()\n-{\n-\tif [ -z \"${1-}\" ]; then\n-\t\tif [ -n \"${__git_dir-}\" ]; then\n-\t\t\techo \"$__git_dir\"\n-\t\telif [ -d .git ]; then\n-\t\t\techo .git\n-\t\telse\n-\t\t\tgit rev-parse --git-dir 2>/dev/null\n-\t\tfi\n-\telif [ -d \"$1/.git\" ]; then\n-\t\techo \"$1/.git\"\n-\telse\n-\t\techo \"$1\"\n-\tfi\n-}\n-\n # stores the divergence from upstream in $p\n # used by GIT_PS1_SHOWUPSTREAM\n __git_ps1_show_upstream ()\n@@ -220,101 +201,9 @@ __git_ps1_show_upstream ()\n \n }\n \n-\n-# __git_ps1 accepts 0 or 1 arguments (i.e., format string)\n-# returns text to add to bash PS1 prompt (includes branch name)\n-__git_ps1 ()\n-{\n-\tlocal g=\"$(__gitdir)\"\n-\tif [ -n \"$g\" ]; then\n-\t\tlocal r=\"\"\n-\t\tlocal b=\"\"\n-\t\tif [ -f \"$g/rebase-merge/interactive\" ]; then\n-\t\t\tr=\"|REBASE-i\"\n-\t\t\tb=\"$(cat \"$g/rebase-merge/head-name\")\"\n-\t\telif [ -d \"$g/rebase-merge\" ]; then\n-\t\t\tr=\"|REBASE-m\"\n-\t\t\tb=\"$(cat \"$g/rebase-merge/head-name\")\"\n-\t\telse\n-\t\t\tif [ -d \"$g/rebase-apply\" ]; then\n-\t\t\t\tif [ -f \"$g/rebase-apply/rebasing\" ]; then\n-\t\t\t\t\tr=\"|REBASE\"\n-\t\t\t\telif [ -f \"$g/rebase-apply/applying\" ]; then\n-\t\t\t\t\tr=\"|AM\"\n-\t\t\t\telse\n-\t\t\t\t\tr=\"|AM/REBASE\"\n-\t\t\t\tfi\n-\t\t\telif [ -f \"$g/MERGE_HEAD\" ]; then\n-\t\t\t\tr=\"|MERGING\"\n-\t\t\telif [ -f \"$g/CHERRY_PICK_HEAD\" ]; then\n-\t\t\t\tr=\"|CHERRY-PICKING\"\n-\t\t\telif [ -f \"$g/BISECT_LOG\" ]; then\n-\t\t\t\tr=\"|BISECTING\"\n-\t\t\tfi\n-\n-\t\t\tb=\"$(git symbolic-ref HEAD 2>/dev/null)\" || {\n-\n-\t\t\t\tb=\"$(\n-\t\t\t\tcase \"${GIT_PS1_DESCRIBE_STYLE-}\" in\n-\t\t\t\t(contains)\n-\t\t\t\t\tgit describe --contains HEAD ;;\n-\t\t\t\t(branch)\n-\t\t\t\t\tgit describe --contains --all HEAD ;;\n-\t\t\t\t(describe)\n-\t\t\t\t\tgit describe HEAD ;;\n-\t\t\t\t(* | default)\n-\t\t\t\t\tgit describe --tags --exact-match HEAD ;;\n-\t\t\t\tesac 2>/dev/null)\" ||\n-\n-\t\t\t\tb=\"$(cut -c1-7 \"$g/HEAD\" 2>/dev/null)...\" ||\n-\t\t\t\tb=\"unknown\"\n-\t\t\t\tb=\"($b)\"\n-\t\t\t}\n-\t\tfi\n-\n-\t\tlocal w=\"\"\n-\t\tlocal i=\"\"\n-\t\tlocal s=\"\"\n-\t\tlocal u=\"\"\n-\t\tlocal c=\"\"\n-\t\tlocal p=\"\"\n-\n-\t\tif [ \"true\" = \"$(git rev-parse --is-inside-git-dir 2>/dev/null)\" ]; then\n-\t\t\tif [ \"true\" = \"$(git rev-parse --is-bare-repository 2>/dev/null)\" ]; then\n-\t\t\t\tc=\"BARE:\"\n-\t\t\telse\n-\t\t\t\tb=\"GIT_DIR!\"\n-\t\t\tfi\n-\t\telif [ \"true\" = \"$(git rev-parse --is-inside-work-tree 2>/dev/null)\" ]; then\n-\t\t\tif [ -n \"${GIT_PS1_SHOWDIRTYSTATE-}\" ]; then\n-\t\t\t\tif [ \"$(git config --bool bash.showDirtyState)\" != \"false\" ]; then\n-\t\t\t\t\tgit diff --no-ext-diff --quiet --exit-code || w=\"*\"\n-\t\t\t\t\tif git rev-parse --quiet --verify HEAD >/dev/null; then\n-\t\t\t\t\t\tgit diff-index --cached --quiet HEAD -- || i=\"+\"\n-\t\t\t\t\telse\n-\t\t\t\t\t\ti=\"#\"\n-\t\t\t\t\tfi\n-\t\t\t\tfi\n-\t\t\tfi\n-\t\t\tif [ -n \"${GIT_PS1_SHOWSTASHSTATE-}\" ]; then\n-\t\t\t        git rev-parse --verify refs/stash >/dev/null 2>&1 && s=\"$\"\n-\t\t\tfi\n-\n-\t\t\tif [ -n \"${GIT_PS1_SHOWUNTRACKEDFILES-}\" ]; then\n-\t\t\t   if [ -n \"$(git ls-files --others --exclude-standard)\" ]; then\n-\t\t\t      u=\"%\"\n-\t\t\t   fi\n-\t\t\tfi\n-\n-\t\t\tif [ -n \"${GIT_PS1_SHOWUPSTREAM-}\" ]; then\n-\t\t\t\t__git_ps1_show_upstream\n-\t\t\tfi\n-\t\tfi\n-\n-\t\tlocal f=\"$w$i$s$u\"\n-\t\tprintf \"${1:- (%s)}\" \"$c${b##refs/heads/}${f:+ $f}$r$p\"\n-\tfi\n-}\n+# load the __git_ps1 functionality\n+GIT_COMPLETION_BASH_ONLY=1\n+source $(dirname ${BASH_SOURCE[0]})/git-prompt-functions\n \n # __gitcomp_1 requires 2 arguments\n __gitcomp_1 ()\ndiff --git a/contrib/completion/git-prompt-functions b/contrib/completion/git-prompt-functions\nnew file mode 100755\nindex 0000000..89d9449\n--- /dev/null\n+++ b/contrib/completion/git-prompt-functions\n@@ -0,0 +1,149 @@\n+#!bash\n+#\n+# bash/zsh prompt functions for core Git.\n+#\n+# Copyright (C) 2006,2007 Shawn O. Pearce <spearce@spearce.org>\n+#\n+# This code was originially in git-completion.bash. However,\n+# since this code works just fine also for ZSH, it was refactored\n+# out, to allow ZSH users to source only the prompt functionality,\n+# given that ZSH already comes with git completion of its own.\n+#\n+# Bash users might consider setting\n+#     PS1='[\\u@\\h \\W$(__git_ps1 \" (%s)\")]\\$ '\n+# while the ZSH equivalent would be\n+#     PS1='[%n@%m %c$(__git_ps1 \" (%s)\")]\\$ '\n+#\n+# You may set the following values to tweak the output of the\n+# __git_ps1() function:\n+#\n+#  GIT_PS1_SHOWDIRTYSTATE=true\n+#     Reports if in a dirty state\n+#      '*' means modified file(s)\n+#      '+' means added file(s)\n+#\n+#  GIT_PS1_SHOWSTASHSTATE=true\n+#     Reports the current stash state\n+#\n+#  GIT_PS1_SHOWUNTRACKEDFILES=true\n+#     Reports if there are untracked files in the repo\n+#\n+#  GIT_PS1_SHOWUPSTREAM=auto\n+#     Places the divergence of repo against upstream, in variable 'p'\n+#     (Use $p in Bash prompts. Not available in ZSH prompts)\n+#\n+# See git-completion.bash for other details\n+\n+# __gitdir accepts 0 or 1 arguments (i.e., location)\n+# returns location of .git repo\n+__gitdir ()\n+{\n+\tif [ -z \"${1-}\" ]; then\n+\t\tif [ -n \"${__git_dir-}\" ]; then\n+\t\t\techo \"$__git_dir\"\n+\t\telif [ -d .git ]; then\n+\t\t\techo .git\n+\t\telse\n+\t\t\tgit rev-parse --git-dir 2>/dev/null\n+\t\tfi\n+\telif [ -d \"$1/.git\" ]; then\n+\t\techo \"$1/.git\"\n+\telse\n+\t\techo \"$1\"\n+\tfi\n+}\n+\n+# __git_ps1 accepts 0 or 1 arguments (i.e., format string)\n+# returns text to add to bash PS1 prompt (includes branch name)\n+__git_ps1 ()\n+{\n+\tlocal g=\"$(__gitdir)\"\n+\tif [ -n \"$g\" ]; then\n+\t\tlocal r=\"\"\n+\t\tlocal b=\"\"\n+\t\tif [ -f \"$g/rebase-merge/interactive\" ]; then\n+\t\t\tr=\"|REBASE-i\"\n+\t\t\tb=\"$(cat \"$g/rebase-merge/head-name\")\"\n+\t\telif [ -d \"$g/rebase-merge\" ]; then\n+\t\t\tr=\"|REBASE-m\"\n+\t\t\tb=\"$(cat \"$g/rebase-merge/head-name\")\"\n+\t\telse\n+\t\t\tif [ -d \"$g/rebase-apply\" ]; then\n+\t\t\t\tif [ -f \"$g/rebase-apply/rebasing\" ]; then\n+\t\t\t\t\tr=\"|REBASE\"\n+\t\t\t\telif [ -f \"$g/rebase-apply/applying\" ]; then\n+\t\t\t\t\tr=\"|AM\"\n+\t\t\t\telse\n+\t\t\t\t\tr=\"|AM/REBASE\"\n+\t\t\t\tfi\n+\t\t\telif [ -f \"$g/MERGE_HEAD\" ]; then\n+\t\t\t\tr=\"|MERGING\"\n+\t\t\telif [ -f \"$g/CHERRY_PICK_HEAD\" ]; then\n+\t\t\t\tr=\"|CHERRY-PICKING\"\n+\t\t\telif [ -f \"$g/BISECT_LOG\" ]; then\n+\t\t\t\tr=\"|BISECTING\"\n+\t\t\tfi\n+\n+\t\t\tb=\"$(git symbolic-ref HEAD 2>/dev/null)\" || {\n+\n+\t\t\t\tb=\"$(\n+\t\t\t\tcase \"${GIT_PS1_DESCRIBE_STYLE-}\" in\n+\t\t\t\t(contains)\n+\t\t\t\t\tgit describe --contains HEAD ;;\n+\t\t\t\t(branch)\n+\t\t\t\t\tgit describe --contains --all HEAD ;;\n+\t\t\t\t(describe)\n+\t\t\t\t\tgit describe HEAD ;;\n+\t\t\t\t(* | default)\n+\t\t\t\t\tgit describe --tags --exact-match HEAD ;;\n+\t\t\t\tesac 2>/dev/null)\" ||\n+\n+\t\t\t\tb=\"$(cut -c1-7 \"$g/HEAD\" 2>/dev/null)...\" ||\n+\t\t\t\tb=\"unknown\"\n+\t\t\t\tb=\"($b)\"\n+\t\t\t}\n+\t\tfi\n+\n+\t\tlocal w=\"\"\n+\t\tlocal i=\"\"\n+\t\tlocal s=\"\"\n+\t\tlocal u=\"\"\n+\t\tlocal c=\"\"\n+\t\tlocal p=\"\"\n+\n+\t\tif [ \"true\" = \"$(git rev-parse --is-inside-git-dir 2>/dev/null)\" ]; then\n+\t\t\tif [ \"true\" = \"$(git rev-parse --is-bare-repository 2>/dev/null)\" ]; then\n+\t\t\t\tc=\"BARE:\"\n+\t\t\telse\n+\t\t\t\tb=\"GIT_DIR!\"\n+\t\t\tfi\n+\t\telif [ \"true\" = \"$(git rev-parse --is-inside-work-tree 2>/dev/null)\" ]; then\n+\t\t\tif [ -n \"${GIT_PS1_SHOWDIRTYSTATE-}\" ]; then\n+\t\t\t\tif [ \"$(git config --bool bash.showDirtyState)\" != \"false\" ]; then\n+\t\t\t\t\tgit diff --no-ext-diff --quiet --exit-code || w=\"*\"\n+\t\t\t\t\tif git rev-parse --quiet --verify HEAD >/dev/null; then\n+\t\t\t\t\t\tgit diff-index --cached --quiet HEAD -- || i=\"+\"\n+\t\t\t\t\telse\n+\t\t\t\t\t\ti=\"#\"\n+\t\t\t\t\tfi\n+\t\t\t\tfi\n+\t\t\tfi\n+\t\t\tif [ -n \"${GIT_PS1_SHOWSTASHSTATE-}\" ]; then\n+\t\t\t\tgit rev-parse --verify refs/stash >/dev/null 2>&1 && s=\"$\"\n+\t\t\tfi\n+\n+\t\t\tif [ -n \"${GIT_PS1_SHOWUNTRACKEDFILES-}\" ]; then\n+\t\t\t   if [ -n \"$(git ls-files --others --exclude-standard)\" ]; then\n+\t\t\t      u=\"%\"\n+\t\t\t   fi\n+\t\t\tfi\n+\n+\t\t\tif [ -n \"${GIT_COMPLETION_BASH_ONLY-}\" ] && [ -n \"${GIT_PS1_SHOWUPSTREAM-}\" ]; then\n+\t\t\t\t__git_ps1_show_upstream\n+\t\t\tfi\n+\t\tfi\n+\n+\t\tlocal f=\"$w$i$s$u\"\n+\t\tprintf \"${1:- (%s)}\" \"$c${b##refs/heads/}${f:+ $f}$r$p\"\n+\tfi\n+}\ndiff --git a/git.spec.in b/git.spec.in\nindex 91c8462..c81385e 100644\n--- a/git.spec.in\n+++ b/git.spec.in\n@@ -137,6 +137,7 @@ rm -rf $RPM_BUILD_ROOT%{_mandir}\n \n mkdir -p $RPM_BUILD_ROOT%{_sysconfdir}/bash_completion.d\n install -m 644 -T contrib/completion/git-completion.bash $RPM_BUILD_ROOT%{_sysconfdir}/bash_completion.d/git\n+install -m 644 -T contrib/completion/git-prompt-functions $RPM_BUILD_ROOT%{_sysconfdir}/bash_completion.d/git-prompt-functions\n \n %clean\n rm -rf $RPM_BUILD_ROOT\n-- \n1.7.5.rc2.4.g4d8b3\n"},{"id":"166397","messageId":"7v62q1exnj.fsf@alter.siamese.dyndns.org","threadId":"27188","inReplyTo":"1303824288-15591-1-git-send-email-mstormo@gmail.com","subject":"Re: [PATCH] Refactor git-completion to allow ZSH usage of PS1 functions","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2011-04-26T17:21:36Z","receivedAt":"2011-04-26T17:21:36Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"I'd be very negative on splitting this file into more than one files.\n"},{"id":"166401","messageId":"4DB702E6.5090105@gmail.com","threadId":"27188","inReplyTo":"7v62q1exnj.fsf@alter.siamese.dyndns.org","subject":"Re: [PATCH] Refactor git-completion to allow ZSH usage of PS1 functions","fromName":"Marius Storm-Olsen","fromEmail":"mstormo@gmail.com","sentAt":"2011-04-26T17:37:42Z","receivedAt":"2011-04-26T17:37:42Z","isPatch":true,"sender":{"key":"mstormo@gmail.com","avatar":"https://avatars.githubusercontent.com/u/1500?v=4"},"body":"Junio C Hamano said the following on 26.04.2011 12:21:\n> I'd be very negative on splitting this file into more than one files.\n\nThe only other option would be duplication. Is that preferred?\n\nI was hoping to more easily keep the implementations in sync, given \nthat the code is trivial enough for both shells to interpret. However, \nhaving two separate implementations would allow for more advanced \noptions in the ZSH PSx handling, I guess.\n\n-- \n.marius\n"},{"id":"166407","messageId":"7vtydkddto.fsf@alter.siamese.dyndns.org","threadId":"27188","inReplyTo":"4DB702E6.5090105@gmail.com","subject":"Re: [PATCH] Refactor git-completion to allow ZSH usage of PS1 functions","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2011-04-26T19:15:15Z","receivedAt":"2011-04-26T19:15:15Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Marius Storm-Olsen <mstormo@gmail.com> writes:\n\n> Junio C Hamano said the following on 26.04.2011 12:21:\n>> I'd be very negative on splitting this file into more than one files.\n>\n> The only other option would be duplication. Is that preferred?\n\nThat is not the answer I was hoping to hear.  Can't we think of a way to\nshare without duplication the common parts and have tweaks per two shell\nimplementations?\n\nA conditional that says \"Do this part only if I am zsh\" in a single file\nis fine.  Makefile that concatenates the common one and specific one among\ntwo would also be acceptable, even though it makes things more cumbersome\nto the user.  But no matter what you do, I would really prefer for the\nuser to have to copy just _one_ file, not two.\n"},{"id":"166409","messageId":"1303849690-20894-1-git-send-email-mstormo@gmail.com","threadId":"27188","inReplyTo":"7vtydkddto.fsf@alter.siamese.dyndns.org","subject":"[PATCH] Automatically autoload bashcompinit for ZSH, when needed","fromName":"Marius Storm-Olsen","fromEmail":"marius@storm-olsen.com","sentAt":"2011-04-26T20:28:10Z","receivedAt":"2011-04-26T20:28:10Z","isPatch":true,"sender":{"key":"marius@storm-olsen.com","avatar":"https://avatars.githubusercontent.com/u/1500?v=4"},"body":"If bashcompinit has not already been autoloaded, do so\nautomatically, as it is required to properly parse the\ngit-completion file with ZSH.\n\nSigned-off-by: Marius Storm-Olsen <mstormo@gmail.com>\n---\n Since I rebased the previous version, I didn't notice that some\n effort had already gone into making git-completion.bash parsable\n with ZSH.\n \n I've therefore dropped everything from the previous patch, and\n rather added some code to automatically do the required steps\n for ZSH, should it not have been done already; as well as\n simplified the 'documentation'.\n \n My appologies for not more closely inspecting the recent changes\n to the file.\n \n contrib/completion/git-completion.bash |   19 +++++++++++--------\n 1 files changed, 11 insertions(+), 8 deletions(-)\n\ndiff --git a/contrib/completion/git-completion.bash b/contrib/completion/git-completion.bash\nindex 840ae38..35d1c9b 100755\n--- a/contrib/completion/git-completion.bash\n+++ b/contrib/completion/git-completion.bash\n@@ -1,6 +1,6 @@\n #!bash\n #\n-# bash completion support for core Git.\n+# bash/zsh completion support for core Git.\n #\n # Copyright (C) 2006,2007 Shawn O. Pearce <spearce@spearce.org>\n # Conceptually based on gitcompletion (http://gitweb.hawaga.org.uk/).\n@@ -18,16 +18,12 @@\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-#        source ~/.git-completion.sh\n-#\n-#       Or, add the following lines to your .zshrc:\n-#        autoload bashcompinit\n-#        bashcompinit\n+#    2) Added the following line to your .bashrc/.zshrc:\n #        source ~/.git-completion.sh\n #\n #    3) Consider changing your PS1 to also show the current branch:\n-#        PS1='[\\u@\\h \\W$(__git_ps1 \" (%s)\")]\\$ '\n+#         Bash: PS1='[\\u@\\h \\W$(__git_ps1 \" (%s)\")]\\$ '\n+#         ZSH:  PS1='[%n@%m %c$(__git_ps1 \" (%s)\")]\\$ '\n #\n #       The argument to __git_ps1 will be displayed only if you\n #       are currently in a git repository.  The %s token will be\n@@ -77,6 +73,13 @@\n #       git@vger.kernel.org\n #\n \n+if [[ -n ${ZSH_VERSION-} ]]; then\n+\tif ! bashcompinit >/dev/null 2>&1; then\n+\t\tautoload -U bashcompinit\n+\t\tbashcompinit\n+\tfi\n+fi\n+\n case \"$COMP_WORDBREAKS\" in\n *:*) : great ;;\n *)   COMP_WORDBREAKS=\"$COMP_WORDBREAKS:\"\n-- \n1.7.5.rc2.4.g4d8b3\n"},{"id":"166410","messageId":"vpqbozszqnu.fsf@bauges.imag.fr","threadId":"27188","inReplyTo":"1303849690-20894-1-git-send-email-mstormo@gmail.com","subject":"Re: [PATCH] Automatically autoload bashcompinit for ZSH, when needed","fromName":"Matthieu Moy","fromEmail":"matthieu.moy@grenoble-inp.fr","sentAt":"2011-04-26T20:47:01Z","receivedAt":"2011-04-26T20:47:01Z","isPatch":true,"sender":{"key":"matthieu.moy@grenoble-inp.fr","avatar":"https://gravatar.com/avatar/72c8a2705971a25dfaff23cece15130d405685845d911aedd5667ace277f3fc5?d=mp&s=160"},"body":"Marius Storm-Olsen <marius@storm-olsen.com> writes:\n\n> -#    2) Added the following line to your .bashrc:\n\n> +#    2) Added the following line to your .bashrc/.zshrc:\n\nWhile you're there: shouldn't this be \"Add\", not \"Added\"?\n\n-- \nMatthieu Moy\nhttp://www-verimag.imag.fr/~moy/\n"},{"id":"166411","messageId":"1303851177.9740.2.camel@Nokia-N900","threadId":"27188","inReplyTo":"vpqbozszqnu.fsf@bauges.imag.fr","subject":"Re: [PATCH] Automatically autoload bashcompinit for ZSH, when needed","fromName":"Marius Storm-Olsen","fromEmail":"marius@storm-olsen.com","sentAt":"2011-04-26T20:52:57Z","receivedAt":"2011-04-26T20:52:57Z","isPatch":true,"sender":{"key":"marius@storm-olsen.com","avatar":"https://avatars.githubusercontent.com/u/1500?v=4"},"body":"Agreed.\n\nI'm away from my machines right now, so if anyone feels like rerolling the patch with that update, that'd be great.\n\nOr Junio could just fix it up when/if picking it.\n\nIf not, I'll reroll later tonight.\n\nThanks!\n\n-- \n.marius @ N900\n----- Original message -----\n> Marius Storm-Olsen <marius@storm-olsen.com> writes:\n> \n> > -#       2) Added the following line to your .bashrc:\n> \n> > +#       2) Added the following line to your .bashrc/.zshrc:\n> \n> While you're there: shouldn't this be \"Add\", not \"Added\"?\n> \n> -- \n> Matthieu Moy\n> http://www-verimag.imag.fr/~moy/\n"},{"id":"166415","messageId":"7vd3k8d6eq.fsf@alter.siamese.dyndns.org","threadId":"27188","inReplyTo":"1303851177.9740.2.camel@Nokia-N900","subject":"Re: [PATCH] Automatically autoload bashcompinit for ZSH, when needed","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2011-04-26T21:55:25Z","receivedAt":"2011-04-26T21:55:25Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Marius Storm-Olsen <marius@storm-olsen.com> writes:\n\n> Or Junio could just fix it up when/if picking it.\n\nSurely, no problem.\n\nI do not use zsh myself, so unless a real zsh user complains, I'll queue\nit directly on 'master' as part of the batch for the first week.\n\nThanks.\n"},{"id":"166423","messageId":"BANLkTindtTVcLetYs1wJ0K9BcQO7YNYpvw@mail.gmail.com","threadId":"27188","inReplyTo":"1303849690-20894-1-git-send-email-mstormo@gmail.com","subject":"Re: [PATCH] Automatically autoload bashcompinit for ZSH, when needed","fromName":"Felipe Contreras","fromEmail":"felipe.contreras@gmail.com","sentAt":"2011-04-27T01:11:26Z","receivedAt":"2011-04-27T01:11:26Z","isPatch":true,"sender":{"key":"felipe.contreras@gmail.com","avatar":"https://avatars.githubusercontent.com/u/8358?v=4"},"body":"On Tue, Apr 26, 2011 at 11:28 PM, Marius Storm-Olsen\n<marius@storm-olsen.com> wrote:\n> If bashcompinit has not already been autoloaded, do so\n> automatically, as it is required to properly parse the\n> git-completion file with ZSH.\n>\n> Signed-off-by: Marius Storm-Olsen <mstormo@gmail.com>\n> ---\n\n> +if [[ -n ${ZSH_VERSION-} ]]; then\n> +       if ! bashcompinit >/dev/null 2>&1; then\n> +               autoload -U bashcompinit\n> +               bashcompinit\n> +       fi\n\nHow about this instead?\nautoload -UX bashcompinit && bashcompinit\n\n-- \nFelipe Contreras\n"},{"id":"166425","messageId":"BANLkTi=qzBGmp80088hVrc+yicH2ofDGEg@mail.gmail.com","threadId":"27188","inReplyTo":"BANLkTindtTVcLetYs1wJ0K9BcQO7YNYpvw@mail.gmail.com","subject":"Re: [PATCH] Automatically autoload bashcompinit for ZSH, when needed","fromName":"Felipe Contreras","fromEmail":"felipe.contreras@gmail.com","sentAt":"2011-04-27T01:22:21Z","receivedAt":"2011-04-27T01:22:21Z","isPatch":true,"sender":{"key":"felipe.contreras@gmail.com","avatar":"https://avatars.githubusercontent.com/u/8358?v=4"},"body":"On Wed, Apr 27, 2011 at 4:11 AM, Felipe Contreras\n<felipe.contreras@gmail.com> wrote:\n> On Tue, Apr 26, 2011 at 11:28 PM, Marius Storm-Olsen\n> <marius@storm-olsen.com> wrote:\n>> If bashcompinit has not already been autoloaded, do so\n>> automatically, as it is required to properly parse the\n>> git-completion file with ZSH.\n>>\n>> Signed-off-by: Marius Storm-Olsen <mstormo@gmail.com>\n>> ---\n>\n>> +if [[ -n ${ZSH_VERSION-} ]]; then\n>> +       if ! bashcompinit >/dev/null 2>&1; then\n>> +               autoload -U bashcompinit\n>> +               bashcompinit\n>> +       fi\n>\n> How about this instead?\n> autoload -UX bashcompinit && bashcompinit\n\nEr, autoload -U +X.\n\n-- \nFelipe Contreras\n"},{"id":"166443","messageId":"1303874615-24718-1-git-send-email-mstormo@gmail.com","threadId":"27188","inReplyTo":"BANLkTi=qzBGmp80088hVrc+yicH2ofDGEg@mail.gmail.com","subject":"[PATCH v2] Automatically autoload bashcompinit for ZSH, when needed","fromName":"Marius Storm-Olsen","fromEmail":"marius@storm-olsen.com","sentAt":"2011-04-27T03:23:35Z","receivedAt":"2011-04-27T03:23:35Z","isPatch":true,"sender":{"key":"marius@storm-olsen.com","avatar":"https://avatars.githubusercontent.com/u/1500?v=4"},"body":"If bashcompinit has not already been autoloaded, do so\nautomatically, as it is required to properly parse the\ngit-completion file with ZSH.\n\nSigned-off-by: Marius Storm-Olsen <mstormo@gmail.com>\n---\n Changes since v2:\n -----------------\n 'Added' -> 'Add'\n Simplified test for bashcompinit, as per advice from Felipe Contreras\n\n contrib/completion/git-completion.bash |   16 ++++++++--------\n 1 files changed, 8 insertions(+), 8 deletions(-)\n\ndiff --git a/contrib/completion/git-completion.bash b/contrib/completion/git-completion.bash\nindex 840ae38..9150ea6 100755\n--- a/contrib/completion/git-completion.bash\n+++ b/contrib/completion/git-completion.bash\n@@ -1,6 +1,6 @@\n #!bash\n #\n-# bash completion support for core Git.\n+# bash/zsh completion support for core Git.\n #\n # Copyright (C) 2006,2007 Shawn O. Pearce <spearce@spearce.org>\n # Conceptually based on gitcompletion (http://gitweb.hawaga.org.uk/).\n@@ -18,16 +18,12 @@\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-#        source ~/.git-completion.sh\n-#\n-#       Or, add the following lines to your .zshrc:\n-#        autoload bashcompinit\n-#        bashcompinit\n+#    2) Add the following line to your .bashrc/.zshrc:\n #        source ~/.git-completion.sh\n #\n #    3) Consider changing your PS1 to also show the current branch:\n-#        PS1='[\\u@\\h \\W$(__git_ps1 \" (%s)\")]\\$ '\n+#         Bash: PS1='[\\u@\\h \\W$(__git_ps1 \" (%s)\")]\\$ '\n+#         ZSH:  PS1='[%n@%m %c$(__git_ps1 \" (%s)\")]\\$ '\n #\n #       The argument to __git_ps1 will be displayed only if you\n #       are currently in a git repository.  The %s token will be\n@@ -77,6 +73,10 @@\n #       git@vger.kernel.org\n #\n \n+if [[ -n ${ZSH_VERSION-} ]]; then\n+\tautoload -U +X bashcompinit && bashcompinit\n+fi\n+\n case \"$COMP_WORDBREAKS\" in\n *:*) : great ;;\n *)   COMP_WORDBREAKS=\"$COMP_WORDBREAKS:\"\n-- \n1.7.5.rc2.4.g4d8b3\n"}]}