1
0
Fork 0

Git-plugin: Get the remote branch manually

The remote branch's name should be obtained manually, not with git status
pull/40/head
Colin Hebert 13 years ago
parent f41485a296
commit 3ed6f12591

@ -172,6 +172,7 @@ function git-info() {
local git_info_var local git_info_var
local -A git_info_vars local -A git_info_vars
local status_cmd local status_cmd
local remote_cmd
local ignore_submodule local ignore_submodule
local ignore_submodule_when local ignore_submodule_when
@ -205,6 +206,8 @@ function git-info() {
# Use short status for easy parsing. # Use short status for easy parsing.
status_cmd='git status --short --branch' status_cmd='git status --short --branch'
# Get remote's name.
remote_cmd='git rev-parse --verify HEAD@{upstream} --symbolic-full-name'
# Ignore submodule status. # Ignore submodule status.
zstyle -b \ zstyle -b \
@ -290,26 +293,23 @@ function git-info() {
zformat -f branch_formatted "$branch_format" "b:$branch" zformat -f branch_formatted "$branch_format" "b:$branch"
# Format remote. # Format remote.
if [[ -z "$remote" ]]; then remote=${$(${(z)remote_cmd} 2>/dev/null)##refs/remotes/}
remote="${$( \ if [[ -n "$remote" ]]; then
git rev-parse \ zstyle -s ':omz:plugin:git:prompt' remote 'remote_format'
--verify ${branch}@{upstream} \ zformat -f remote_formatted "$remote_format" "R:$remote"
--symbolic-full-name 2>/dev/null)#refs/remotes/}"
fi fi
zstyle -s ':omz:plugin:git:prompt' remote 'remote_format'
zformat -f remote_formatted "$remote_format" "R:$remote"
fi
# Format ahead. # Format ahead.
if [[ -n "$ahead" ]]; then if [[ -n "$ahead" ]]; then
zstyle -s ':omz:plugin:git:prompt' ahead 'ahead_format' zstyle -s ':omz:plugin:git:prompt' ahead 'ahead_format'
zformat -f ahead_formatted "$ahead_format" "A:$ahead" zformat -f ahead_formatted "$ahead_format" "A:$ahead"
fi fi
# Format behind. # Format behind.
if [[ -n "$behind" ]]; then if [[ -n "$behind" ]]; then
zstyle -s ':omz:plugin:git:prompt' behind 'behind_format' zstyle -s ':omz:plugin:git:prompt' behind 'behind_format'
zformat -f behind_formatted "$behind_format" "B:$behind" zformat -f behind_formatted "$behind_format" "B:$behind"
fi
fi fi
# Format added. # Format added.

Loading…
Cancel
Save