Permalink
Browse files

Updated branching logic thanks to prompting by hiroshi.

  • Loading branch information...
1 parent fff4d5d commit 8c3ff6d1043194fc8edc1009197e443347055007 @wayneeseguin wayneeseguin committed Apr 1, 2011
Showing with 27 additions and 29 deletions.
  1. +3 −3 contrib/ps1_functions
  2. +24 −26 scripts/manage
View
@@ -137,8 +137,8 @@ ps4_set()
export PS4="+ \${BASH_SOURCE##\${rvm_path:-}} : \${FUNCNAME[0]:+\${FUNCNAME[0]}()} \${LINENO} > "
}
-# WARNING: This clobbers your PROMPT_COMMAND so if you need to write your own, call
-# ps1_update within your PROMPT_COMMAND with the same arguments you pass
+# WARNING: This clobbers your PROMPT_COMMAND so if you need to write your own, call
+# ps1_update within your PROMPT_COMMAND with the same arguments you pass
# to ps1_set
#
# The PROMPT_COMMAND is used to help the prompt work if the separator is not a new line.
@@ -153,6 +153,6 @@ ps4_set()
#
ps1_set()
{
- PROMPT_COMMAND="ps1_update $@"
+ PROMPT_COMMAND="ps1_update $@"
}
View
@@ -1407,38 +1407,36 @@ __rvm_fetch_ruby()
# Use the selected branch.
(
- remote="${remote:-origin}"
-
cd "${rvm_repos_path}/$rvm_ruby_string"
+ remote="${remote:-origin}"
+ branch=$(git symbolic-ref -q HEAD 2>/dev/null)
+ branch=${branch##refs/heads/}
+
git reset --hard HEAD # Ensure we are in a good state.
git fetch "${remote}" # Download the latest updates locally.
- branches="$(git branch)" # Grab a list of the local branches
-
- case "$branches" in
- (*\*[[:space:]]${rvm_ruby_repo_branch}*)
- # On desired branch, pull!
- git pull "$remote" "${rvm_ruby_repo_branch}"
- ;;
-
- (*[[:space:]]${rvm_ruby_repo_branch}*)
- # Not already on the desired branch, but it does exist locally.
- git checkout "${rvm_ruby_repo_branch}" # Branch is local, checkout
- git pull "$remote" "${rvm_ruby_repo_branch}" # Bring local to latest
- ;;
-
- *)
- # Desired branch does not exist locally.
- if ! git checkout -t "${remote}/${rvm_ruby_repo_branch}" ; then
- result=$?
-
- rvm_error "Branch $remote/$rvm_ruby_repo_branch not found."
- return $result
- fi
- ;;
- esac
+ if [[ "$branch" == "${rvm_ruby_repo_branch}" ]] ; then
+ git pull "${remote}" "${rvm_ruby_repo_branch}"
+ else
+ case "$(git branch 2>/dev/null)" in
+ (*[[:space:]]${rvm_ruby_repo_branch}*)
+ # Not already on the desired branch, but it does exist locally.
+ git checkout "${rvm_ruby_repo_branch}" # Branch is local, checkout
+ git pull "$remote" "${rvm_ruby_repo_branch}" # Bring local to latest
+ ;;
+ *)
+ # Desired branch does not exist locally.
+ if ! git checkout -t "${remote}/${rvm_ruby_repo_branch}" ; then
+ result=$?
+ rvm_error "Branch $remote/$rvm_ruby_repo_branch not found."
+ return $result
+ fi
+ ;;
+ esac
+ fi
+ return $?
)
result=$?

0 comments on commit 8c3ff6d

Please sign in to comment.