zsh-users
 help / color / mirror / code / Atom feed
* Misc/vcs_info-examples - "git-st" snippet broken?
@ 2011-10-19 10:44 Suraj N. Kurapati
  2011-10-19 11:26 ` Frank Terbeck
  0 siblings, 1 reply; 5+ messages in thread
From: Suraj N. Kurapati @ 2011-10-19 10:44 UTC (permalink / raw)
  To: zsh-users

[-- Attachment #1: Type: text/plain, Size: 1903 bytes --]

Hello,

I'm using zsh 4.3.12 (x86_64-unknown-linux-gnu) and have added the
"git-st" snippet shown below to my .zshrc file from the ZSH git
repository's Misc/vcs_info-examples file.  The problem is that
+vi-git-st() isn't being called automatically by vcs_info().

What am I doing wrong?

Thanks for your consideration.

####################################################################

# my "sunaku" prompt from oh-my-zsh (see http://ompldr.org/vOHcwZg)
local prompt_user_color='green'
test $UID -eq 0 && prompt_user_color='red'
PROMPT='%(?..%B%F{red}exit %?%f%b
)'\
'$(vcs_info && echo $vcs_info_msg_0_)'\
'%F{$prompt_user_color}%~%b'\
'%(!.#.>) '
RPROMPT='%F{cyan}%@%f'

# VCS integration for ZSH command prompt
autoload -Uz vcs_info
zstyle ':vcs_info:*' stagedstr '%F{green}+%f'
zstyle ':vcs_info:*' unstagedstr '%F{yellow}!%f'
zstyle ':vcs_info:*' check-for-changes true
local prompt_vcs_branch='%m%B%c%u%%b%b'
zstyle ':vcs_info:*' formats "$prompt_vcs_branch "
zstyle ':vcs_info:*' actionformats "$prompt_vcs_branch
%B%F{red}%s:%a%f%%b "

### git: Show +N/-N when your local branch is ahead-of or behind remote
HEAD. # Make sure you have added misc to your 'formats':  %m
zstyle ':vcs_info:git*+set-message:*' hooks git-st
function +vi-git-st() {
    local ahead behind
    local -a gitstatus

    # for git prior to 1.7
    # ahead=$(git rev-list origin/${hook_com[branch]}..HEAD | wc -l)
    ahead=$(git rev-list ${hook_com[branch]}@{upstream}..HEAD
    2>/dev/null | wc -l) (( $ahead )) && gitstatus+=( "+${ahead}" )

    # for git prior to 1.7
    # behind=$(git rev-list HEAD..origin/${hook_com[branch]} | wc -l)
    behind=$(git rev-list HEAD..${hook_com[branch]}@{upstream}
    2>/dev/null | wc -l) (( $behind )) && gitstatus+=( "-${behind}" )

    hook_com[misc]+=${(j:/:)gitstatus}
}

-- 
Cobol programmers are down in the dumps.

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 198 bytes --]

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: Misc/vcs_info-examples - "git-st" snippet broken?
  2011-10-19 10:44 Misc/vcs_info-examples - "git-st" snippet broken? Suraj N. Kurapati
@ 2011-10-19 11:26 ` Frank Terbeck
  2011-10-19 18:08   ` Suraj N. Kurapati
  0 siblings, 1 reply; 5+ messages in thread
From: Frank Terbeck @ 2011-10-19 11:26 UTC (permalink / raw)
  To: zsh-users

Suraj N. Kurapati wrote:
> I'm using zsh 4.3.12 (x86_64-unknown-linux-gnu) and have added the
> "git-st" snippet shown below to my .zshrc file from the ZSH git
> repository's Misc/vcs_info-examples file.  The problem is that
> +vi-git-st() isn't being called automatically by vcs_info().

Did you try turning on debugging within `vcs_info'? That should show you
which hooks are being processed and which functions are considered.

zstyle ':vcs_info:*+*:*' debug true

Regards, Frank

-- 
In protocol design, perfection has been reached not when there is
nothing left to add, but when there is nothing left to take away.
                                                  -- RFC 1925


^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: Misc/vcs_info-examples - "git-st" snippet broken?
  2011-10-19 11:26 ` Frank Terbeck
@ 2011-10-19 18:08   ` Suraj N. Kurapati
  2011-10-19 18:17     ` Frank Terbeck
  0 siblings, 1 reply; 5+ messages in thread
From: Suraj N. Kurapati @ 2011-10-19 18:08 UTC (permalink / raw)
  To: Frank Terbeck; +Cc: zsh-users

[-- Attachment #1: Type: text/plain, Size: 2788 bytes --]

On Wed 19 Oct 2011 01:26:24 PM PDT, Frank Terbeck wrote:
> Suraj N. Kurapati wrote:
> > I'm using zsh 4.3.12 (x86_64-unknown-linux-gnu) and have added
> > the "git-st" snippet shown below to my .zshrc file from the ZSH
> > git repository's Misc/vcs_info-examples file.  The problem is
> > that +vi-git-st() isn't being called automatically by
> > vcs_info().
>
> Did you try turning on debugging within `vcs_info'? That should
> show you which hooks are being processed and which functions are
> considered.
>
> zstyle ':vcs_info:*+*:*' debug true

Thank you!  I should have RTFM as that was stated explicitly in the
Misc/vcs_info-examples file.  After seeing the debugging output, my
problem seems to be that only the last hook function in my vimrc
seems to be executed.  So does hook registration really override?

.zshrc:

    zstyle ':vcs_info:git*+set-message:*' hooks git-untracked
    +vi-git-untracked(){}

    zstyle ':vcs_info:git*+set-message:*' hooks git-st
    function +vi-git-st() {}

    zstyle ':vcs_info:git*+set-message:*' hooks git-remotebranch
    function +vi-git-remotebranch() {}

    zstyle ':vcs_info:git*+set-message:*' hooks foobar
    function +vi-foobar() {echo 'foobar'}

output:

    +!master git:rebase-i ~/.oh-my-zsh> pwd
    /home/sunny/.oh-my-zsh
    VCS_INFO_hook: running hook: "start-up"
    VCS_INFO_hook: current context: ":vcs_info:-init-+start-up:default:-all-"
    VCS_INFO_hook: static context: ":vcs_info-static_hooks:start-up"
    + static hooks:
    + context hooks:
    VCS_INFO_hook: running hook: "pre-get-data"
    VCS_INFO_hook: current context: ":vcs_info:git+pre-get-data:default:-all-"
    VCS_INFO_hook: static context: ":vcs_info-static_hooks:pre-get-data"
    + static hooks:
    + context hooks:
    VCS_INFO_hook: running hook: "post-backend"
    VCS_INFO_hook: current context: ":vcs_info:git+post-backend:default:.oh-my-zsh"
    VCS_INFO_hook: static context: ":vcs_info-static_hooks:post-backend"
    + static hooks:
    + context hooks:
    VCS_INFO_hook: running hook: "pre-addon-quilt"
    VCS_INFO_hook: current context: ":vcs_info:git+pre-addon-quilt:default:.oh-my-zsh"
    VCS_INFO_hook: static context: ":vcs_info-static_hooks:pre-addon-quilt"
    + static hooks:
    + context hooks:
    VCS_INFO_hook: running hook: "set-message"
    VCS_INFO_hook: current context: ":vcs_info:git+set-message:default:.oh-my-zsh"
    VCS_INFO_hook: static context: ":vcs_info-static_hooks:set-message"
    + static hooks:
    + context hooks: foobar
      + Running function: "+vi-foobar"
    foobar

-- 
And it should be the law: If you use the word `paradigm' without knowing
what the dictionary says it means, you go to jail.  No exceptions.
		-- David Jones

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 198 bytes --]

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: Misc/vcs_info-examples - "git-st" snippet broken?
  2011-10-19 18:08   ` Suraj N. Kurapati
@ 2011-10-19 18:17     ` Frank Terbeck
  2011-10-19 18:37       ` Suraj N. Kurapati
  0 siblings, 1 reply; 5+ messages in thread
From: Frank Terbeck @ 2011-10-19 18:17 UTC (permalink / raw)
  To: zsh-users

Suraj N. Kurapati wrote:
> On Wed 19 Oct 2011 01:26:24 PM PDT, Frank Terbeck wrote:
[...]
>> zstyle ':vcs_info:*+*:*' debug true
>
> Thank you!  I should have RTFM as that was stated explicitly in the
> Misc/vcs_info-examples file.  After seeing the debugging output, my
> problem seems to be that only the last hook function in my vimrc
> seems to be executed.  So does hook registration really override?
>
> .zshrc:
>
>     zstyle ':vcs_info:git*+set-message:*' hooks git-untracked
>     +vi-git-untracked(){}
>
>     zstyle ':vcs_info:git*+set-message:*' hooks git-st
>     function +vi-git-st() {}
>
>     zstyle ':vcs_info:git*+set-message:*' hooks git-remotebranch
>     function +vi-git-remotebranch() {}
>
>     zstyle ':vcs_info:git*+set-message:*' hooks foobar
>     function +vi-foobar() {echo 'foobar'}

`hooks' is a list style. I don't think there is a way to add items to a
list style in a given context, without looking it up first...

So, try:

zstyle ':vcs_info:git*+set-message:*' hooks git-untracked git-st \
                                            git-remotebranch foobar

Regards, Frank


^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: Misc/vcs_info-examples - "git-st" snippet broken?
  2011-10-19 18:17     ` Frank Terbeck
@ 2011-10-19 18:37       ` Suraj N. Kurapati
  0 siblings, 0 replies; 5+ messages in thread
From: Suraj N. Kurapati @ 2011-10-19 18:37 UTC (permalink / raw)
  To: Frank Terbeck; +Cc: zsh-users

[-- Attachment #1: Type: text/plain, Size: 1065 bytes --]

On Wed 19 Oct 2011 08:17:11 PM PDT, Frank Terbeck wrote:
> Suraj N. Kurapati wrote:
> > does hook registration really override?
> >
> > .zshrc:
> >
> >     zstyle ':vcs_info:git*+set-message:*' hooks git-untracked
> >     +vi-git-untracked(){}
> >
> >     zstyle ':vcs_info:git*+set-message:*' hooks git-st function
> >     +vi-git-st() {}
> >
> >     zstyle ':vcs_info:git*+set-message:*' hooks git-remotebranch
> >     function +vi-git-remotebranch() {}
> >
> >     zstyle ':vcs_info:git*+set-message:*' hooks foobar function
> >     +vi-foobar() {echo 'foobar'}
>
> `hooks' is a list style. I don't think there is a way to add items
> to a list style in a given context, without looking it up first...
>
> So, try:
>
> zstyle ':vcs_info:git*+set-message:*' hooks git-untracked git-st \
> git-remotebranch foobar

Yay!  That solved it, thanks.  :)

Please add this caveat to the Misc/vcs_info-examples file because I
just copied and pasted from there expecting things to "Just Work".

-- 
Computer programmers do it byte by byte.

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 198 bytes --]

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2011-10-19 18:38 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-10-19 10:44 Misc/vcs_info-examples - "git-st" snippet broken? Suraj N. Kurapati
2011-10-19 11:26 ` Frank Terbeck
2011-10-19 18:08   ` Suraj N. Kurapati
2011-10-19 18:17     ` Frank Terbeck
2011-10-19 18:37       ` Suraj N. Kurapati

Code repositories for project(s) associated with this public inbox

	https://git.vuxu.org/mirror/zsh/

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).