aboutsummaryrefslogtreecommitdiffhomepage
path: root/share
diff options
context:
space:
mode:
authorGravatar Kevin Ballard <kevin@sb.org>2012-07-13 18:56:37 -0700
committerGravatar ridiculousfish <corydoras@ridiculousfish.com>2012-07-13 21:46:57 -0700
commitb1281c3fb904c12b1710045c8084bc521e80d7f9 (patch)
treef01195ed3266ca45cf98f191c21e777320342c83 /share
parent257e9b04fe04603178e5ee9260072962af53b447 (diff)
Update __fish_git_prompt.fish to handle git-svn better
Git-svn remotes can have a prefix for their remotes. If I set a prefix of 'svn/' then my remote trunk branch is called svn/trunk. Update the script to use the svn-remote.*.fetch key to figure out how the 'trunk' branch is mapped into the remotes namespace and apply this to the current branch. This assumes branches are mapped into the same namespace, which is likely. It also doesn't work for tags, but neither did the old code.
Diffstat (limited to 'share')
-rw-r--r--share/functions/__fish_git_prompt.fish21
1 files changed, 19 insertions, 2 deletions
diff --git a/share/functions/__fish_git_prompt.fish b/share/functions/__fish_git_prompt.fish
index dd1f17ea..462300f8 100644
--- a/share/functions/__fish_git_prompt.fish
+++ b/share/functions/__fish_git_prompt.fish
@@ -78,6 +78,7 @@
function __fish_git_prompt_show_upstream --description "Helper function for __fish_git_prompt"
# Ask git-config for some config options
set -l svn_remote
+ set -l svn_prefix
set -l upstream git
set -l legacy
set -l verbose
@@ -90,6 +91,8 @@ function __fish_git_prompt_show_upstream --description "Helper function for __fi
test -n "$__fish_git_prompt_showupstream"; or return
case svn-remote.'*'.url
set svn_remote $svn_remote $value
+ set -l remote_prefix (/bin/sh -c 'echo "${1%.url}"' -- $key)
+ set svn_prefix $svn_prefix $remote_prefix
if test -n "$svn_url_pattern"
set svn_url_pattern $svn_url_pattern"\|$value"
else
@@ -122,8 +125,16 @@ function __fish_git_prompt_show_upstream --description "Helper function for __fi
if test (count $svn_upstream) -ne 0
echo $svn_upstream[-1] | read -l _ svn_upstream _
set svn_upstream (echo $svn_upstream | sed 's/@.*//')
- for remote in $svn_remote
- set svn_upstream (/bin/sh -c 'echo "${1#$2}"' -- $svn_upstream $remote)
+ set -l cur_prefix
+ for i in (seq (count $svn_remote))
+ set -l remote $svn_remote[$i]
+ set -l mod_upstream (/bin/sh -c 'echo "${1#$2}"' -- $svn_upstream $remote)
+ if test "$svn_upstream" != "$mod_upstream"
+ # we found a valid remote
+ set svn_upstream $mod_upstream
+ set cur_prefix $svn_prefix[$i]
+ break
+ end
end
if test -z "$svn_upstream"
@@ -139,6 +150,12 @@ function __fish_git_prompt_show_upstream --description "Helper function for __fi
else
set upstream $svn_upstream
end
+ set -l fetch_val (git config "$cur_prefix".fetch)
+ if test -n "$fetch_val"
+ set -l IFS :
+ echo "$fetch_val" | read -l trunk pattern
+ set upstream (/bin/sh -c 'echo "${1%/$2}"' -- $pattern $trunk)/$upstream
+ end
end
else
if test $upstream = svn+git