On 24.08.2016 00:29, Daniel Shahaf wrote:
> The following vcs_info hook adds an indication of whether the currently
> checked out branch is ahead or behind its upstream branch:
Thanks for sharing!
I am using something more advanced, which also has numbers and notifies you in case
the revisions inbetween contain fixup/squash commits:
From https://github.com/blueyed/oh-my-zsh/blob/5228d6e/themes/blueyed.zsh-theme#L766-L789,
where it is buried in my +vi-git-st hook, which also abbreviates branch names etc:
# Gets the commit difference counts between local and remote.
ahead_and_behind_cmd="$_git_cmd rev-list --count --left-right HEAD...@{upstream}"
# Get ahead and behind counts.
ahead_and_behind="$(${(z)ahead_and_behind_cmd} 2> /dev/null)"
ahead="$ahead_and_behind[(w)1]"
if (( $ahead )); then
ahead="${normtext}+${ahead}"
# Display a warning if there are fixup/squash commits that are usually
# meant to be interactively rebased.
if $_git_cmd log --pretty=format:%s @{upstream}.. | \grep -Eq '^(fixup|squash)!'; then
ahead+="${hitext}(f!)"
fi
gitstatus+=($ahead)
fi
behind="$ahead_and_behind[(w)2]"
if (( $behind )); then
# Display hint for fixup/squash commits, but in normal text.
if $_git_cmd log --pretty=format:%s ..@{upstream} | \grep -Eq '^(fixup|squash)!'; then
behind+="${dimmedtext}(f)"
fi
gitstatus+=( "${alerttext}-${behind}" )
fi
Cheers,
Daniel.
Attachment:
signature.asc
Description: OpenPGP digital signature