mirror of
https://github.com/fish-shell/fish-shell
synced 2024-12-27 05:13:10 +00:00
git_prompt: Reorder show_upstream to match original
This makes it easier to see if there are any changes. Also it puts all of the extra functionality together instead of mixed in with everything else.
This commit is contained in:
parent
222e36ee3e
commit
31b01f8de3
1 changed files with 20 additions and 15 deletions
|
@ -78,30 +78,36 @@
|
||||||
set -g ___fish_git_prompt_status_order stagedstate invalidstate dirtystate untrackedfiles
|
set -g ___fish_git_prompt_status_order stagedstate invalidstate dirtystate untrackedfiles
|
||||||
|
|
||||||
function __fish_git_prompt_show_upstream --description "Helper function for __fish_git_prompt"
|
function __fish_git_prompt_show_upstream --description "Helper function for __fish_git_prompt"
|
||||||
# Ask git-config for some config options
|
set -l show_upstream $__fish_git_prompt_showupstream
|
||||||
set -l svn_remote
|
set -l svn_prefix # For better SVN upstream information
|
||||||
set -l svn_prefix
|
set -l informative
|
||||||
|
|
||||||
|
set -l svn_url_pattern
|
||||||
|
set -l count
|
||||||
set -l upstream git
|
set -l upstream git
|
||||||
set -l legacy
|
set -l legacy
|
||||||
set -l verbose
|
set -l verbose
|
||||||
set -l informative
|
|
||||||
set -l svn_url_pattern
|
set -l svn_remote
|
||||||
set -l show_upstream $__fish_git_prompt_showupstream
|
# get some config options from git-config
|
||||||
git config -z --get-regexp '^(svn-remote\..*\.url|bash\.showUpstream)$' ^/dev/null | tr '\0\n' '\n ' | while read -l key value
|
git config -z --get-regexp '^(svn-remote\..*\.url|bash\.showupstream)$' ^/dev/null | tr '\0\n' '\n ' | while read -l key value
|
||||||
switch $key
|
switch $key
|
||||||
case bash.showUpstream bash.showupstream
|
case bash.showupstream
|
||||||
set show_upstream $value
|
set show_upstream $value
|
||||||
test -n "$show_upstream"; or return
|
test -n "$show_upstream"; or return
|
||||||
case svn-remote.'*'.url
|
case svn-remote.'*'.url
|
||||||
set svn_remote $svn_remote $value
|
set svn_remote $svn_remote $value
|
||||||
set -l remote_prefix (/bin/sh -c 'echo "${1%.url}"' -- $key)
|
# Avoid adding \| to the beginning to avoid needing #?? later
|
||||||
set svn_prefix $svn_prefix $remote_prefix
|
|
||||||
if test -n "$svn_url_pattern"
|
if test -n "$svn_url_pattern"
|
||||||
set svn_url_pattern $svn_url_pattern"\|$value"
|
set svn_url_pattern $svn_url_pattern"\\|$value"
|
||||||
else
|
else
|
||||||
set svn_url_pattern $value
|
set svn_url_pattern $value
|
||||||
end
|
end
|
||||||
set upstream svn+git # default upstream is SVN if available, else git
|
set upstream svn+git # default upstream is SVN if available, else git
|
||||||
|
|
||||||
|
# Save the config key (without .url) for later use
|
||||||
|
set -l remote_prefix (/bin/sh -c 'echo "${1%.url}"' -- $key)
|
||||||
|
set svn_prefix $svn_prefix $remote_prefix
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -151,6 +157,8 @@ function __fish_git_prompt_show_upstream --description "Helper function for __fi
|
||||||
end
|
end
|
||||||
else
|
else
|
||||||
set upstream (/bin/sh -c 'val=${1#/branches}; echo "${val#/}"' -- $svn_upstream)
|
set upstream (/bin/sh -c 'val=${1#/branches}; echo "${val#/}"' -- $svn_upstream)
|
||||||
|
|
||||||
|
# Use fetch config to fix upstream
|
||||||
set -l fetch_val (git config "$cur_prefix".fetch)
|
set -l fetch_val (git config "$cur_prefix".fetch)
|
||||||
if test -n "$fetch_val"
|
if test -n "$fetch_val"
|
||||||
set -l IFS :
|
set -l IFS :
|
||||||
|
@ -158,13 +166,12 @@ function __fish_git_prompt_show_upstream --description "Helper function for __fi
|
||||||
set upstream (/bin/sh -c 'echo "${1%/$2}"' -- $pattern $trunk)/$upstream
|
set upstream (/bin/sh -c 'echo "${1%/$2}"' -- $pattern $trunk)/$upstream
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
else if test $upstream = svn+git
|
else if test $upstream = svn+git
|
||||||
set upstream '@{upstream}'
|
set upstream '@{upstream}'
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
# Find how many commits we are ahead/behind our upstream
|
# Find how many commits we are ahead/behind our upstream
|
||||||
set -l count
|
|
||||||
if test -z "$legacy"
|
if test -z "$legacy"
|
||||||
set count (git rev-list --count --left-right $upstream...HEAD ^/dev/null)
|
set count (git rev-list --count --left-right $upstream...HEAD ^/dev/null)
|
||||||
else
|
else
|
||||||
|
@ -238,7 +245,6 @@ function __fish_git_prompt --description "Prompt function for Git"
|
||||||
__fish_git_prompt_validate_chars
|
__fish_git_prompt_validate_chars
|
||||||
|
|
||||||
if test "true" = (git rev-parse --is-inside-work-tree ^/dev/null)
|
if test "true" = (git rev-parse --is-inside-work-tree ^/dev/null)
|
||||||
|
|
||||||
if test -n "$__fish_git_prompt_show_informative_status"
|
if test -n "$__fish_git_prompt_show_informative_status"
|
||||||
set informative_status "|"(__fish_git_prompt_informative_status)
|
set informative_status "|"(__fish_git_prompt_informative_status)
|
||||||
else
|
else
|
||||||
|
@ -265,7 +271,6 @@ function __fish_git_prompt --description "Prompt function for Git"
|
||||||
if test -n "$__fish_git_prompt_showupstream"
|
if test -n "$__fish_git_prompt_showupstream"
|
||||||
set p (__fish_git_prompt_show_upstream)
|
set p (__fish_git_prompt_show_upstream)
|
||||||
end
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
__fish_git_prompt_validate_colors
|
__fish_git_prompt_validate_colors
|
||||||
|
|
Loading…
Reference in a new issue