Permalink
Browse files

Cleanup

  • Loading branch information...
1 parent bc92dbd commit b4caca5892cd5e247c54bbebb6750dd2dd058596 @jamiew committed Feb 8, 2012
Showing with 13 additions and 6 deletions.
  1. +6 −2 pull
  2. +7 −4 push
View
@@ -7,13 +7,17 @@
#
branch=$(git branch --no-color 2> /dev/null | sed -e '/^[^*]/d' -e 's/* \(.*\)/\1/') || exit $?
-remote=$(git config "branch.${branch}.remote") || exit $?
-remote_branch=$(git config "branch.${branch}.merge" | awk -F '/' '{ print $3 }') || exit $?
+default_remote="origin"
+remote=$(git config "branch.${branch}.remote" || echo "$default_remote")
+remote_branch=$( (git config "branch.${branch}.merge" || echo "refs/heads/$branch") | awk -F '/' '{ print $3 }' )
+
+echo "branch=$branch remote=$remote/$remote_branch"
# Stash any local changes
stash=$(git stash)
# Update our remote
+echo "Fetching from $remote ..."
git fetch $remote || exit $?
# Pull, using rebase if configured
View
@@ -10,9 +10,13 @@
# e.g. for doing "push -f"
#
+# TODO DRY this b/w pull and push
branch=$(git branch --no-color 2> /dev/null | sed -e '/^[^*]/d' -e 's/* \(.*\)/\1/') || exit $?
-remote=$(git config "branch.${branch}.remote") || exit $?
-remote_branch=$(git config "branch.${branch}.merge" | awk -F '/' '{ print $3 }') || exit $?
+default_remote="origin"
+remote=$(git config "branch.${branch}.remote" || echo "$default_remote")
+remote_branch=$( (git config "branch.${branch}.merge" || echo "refs/heads/$branch") | awk -F '/' '{ print $3 }' )
+
+echo "branch=$branch remote=$remote/$remote_branch"
# Push & save output
push=$(git push --set-upstream $* $remote $remote_branch 2>&1)
@@ -43,9 +47,8 @@ if [[ "$remote_url" =~ "github.com" ]]; then
repo_name=$(echo $remote_url | sed 's/.*\:\(.*\)\.git/\1/')
github_url="https://github.com/$repo_name/compare/$refs"
copied="Compare URL copied to clipboard!"
- which -s pbcopy >& /dev/null && echo $github_url | pbcopy && echo $copied
+ which pbcopy >& /dev/null && echo $github_url | pbcopy && echo $copied
which xclip >& /dev/null && echo $github_url | xclip -selection clipboard && echo $copied
- # which -s open && open -g $github_url
echo $github_url
echo

0 comments on commit b4caca5

Please sign in to comment.