1
0
Fork 0

Git-plugin: Get the branch name manually

The branch name shouldn't be extracted from the git status
pull/40/head
Colin Hebert 13 years ago
parent 2bbbfa4de0
commit 2db2b401e1

@ -244,16 +244,13 @@ function git-info() {
zformat -f action_formatted "$action_format" "s:$action" zformat -f action_formatted "$action_format" "s:$action"
fi fi
elif (( line_number == 1 )) \ elif (( line_number == 1 )) \
&& [[ "$line" == (#b)'## Initial commit on '(?##) ]]; && [[ "$line" == (#b)'## Initial commit on '(?##) ]]; then
then
branch="$match[1]"
elif (( line_number == 1 )); then elif (( line_number == 1 )); then
# Split the line into an array for parsing. # Split the line into an array for parsing.
branch_info=(${(s: :)line}) branch_info=(${(s: :)line})
# Match: master...origin/master # Match: master...origin/master
if [[ "$branch_info[2]" == (#b)(?##)...(?##/?##) ]]; then if [[ "$branch_info[2]" == (#b)(?##)...(?##/?##) ]]; then
branch="$match[1]"
remote="$match[2]" remote="$match[2]"
# Match: [ahead or [behind # Match: [ahead or [behind
@ -269,9 +266,6 @@ function git-info() {
behind="${branch_info[6]%\]}" behind="${branch_info[6]%\]}"
fi fi
fi fi
# Match: master
elif [[ "$branch_info[2]" == (#b)(?##) ]]; then
branch="$match[1]"
fi fi
fi fi
done < <("${(z)status_cmd}" 2>/dev/null) done < <("${(z)status_cmd}" 2>/dev/null)
@ -291,6 +285,7 @@ function git-info() {
done < <(${(z)status_cmd} 2>/dev/null) done < <(${(z)status_cmd} 2>/dev/null)
# Format branch. # Format branch.
branch=${$(git symbolic-ref -q HEAD)##refs/heads/}
if [[ -n "$branch" ]]; then if [[ -n "$branch" ]]; then
zstyle -s ':omz:plugin:git:prompt' branch 'branch_format' zstyle -s ':omz:plugin:git:prompt' branch 'branch_format'
zformat -f branch_formatted "$branch_format" "b:$branch" zformat -f branch_formatted "$branch_format" "b:$branch"

Loading…
Cancel
Save