Fixed git_set_default_remote to use current branch for default

This commit is contained in:
Nathan Broadbent
2011-12-13 12:40:36 +08:00
parent 938c982e99
commit 6a757687c5

View File

@@ -33,7 +33,8 @@ git_remove_history() {
# Set default remote and merge for a git branch (pull and push) # Set default remote and merge for a git branch (pull and push)
# Usage: git_set_default_remote(branch = master, remote = origin) # Usage: git_set_default_remote(branch = master, remote = origin)
git_set_default_remote() { git_set_default_remote() {
if [ -n "$1" ]; then branch="$1"; else branch="master"; fi curr_branch=$(git branch 2> /dev/null | sed -e '/^[^*]/d' -e 's/* \(.*\)/\1/')
if [ -n "$1" ]; then branch="$1"; else branch="$curr_branch"; fi
if [ -n "$2" ]; then remote="$2"; else remote="origin"; fi if [ -n "$2" ]; then remote="$2"; else remote="origin"; fi
echo "branch.$branch.remote: $remote" echo "branch.$branch.remote: $remote"
echo "branch.$branch.merge: refs/heads/$branch" echo "branch.$branch.merge: refs/heads/$branch"