Skip to content

Commit

Permalink
fixes bug with git-sync
Browse files Browse the repository at this point in the history
  • Loading branch information
jeremytregunna committed Jul 4, 2011
1 parent 8cfa5d8 commit 82efd4e
Showing 1 changed file with 8 additions and 7 deletions.
15 changes: 8 additions & 7 deletions git-sync
Original file line number Diff line number Diff line change
Expand Up @@ -3,17 +3,20 @@
. git-simple-common.sh

if [ X"$1" = X"-h" ]; then
echo "Usage: git sync [branch]"
echo " Synchronizes [branch] with its published counterpart, or if [branch] is not"
echo " supplied, assumes your current branch."
echo "Usage: git sync [branch] [remote]"
echo " Synchronizes [branch] with its published counterpart on [remote], or if"
echo " [branch] is not supplied, assumes your current branch. If [remote] is not"
echo " supplied, assumes origin."
exit 0
fi

BRANCH=$1
REMOTE_NAME=$2
[ -z ${BRANCH} ] && BRANCH=`current_branch_name`
[ -z ${REMOTE_NAME} ] && REMOTE_NAME="origin"

FOUND_REMOTE_BRANCH=0
for br in `remote_branch_names`; do
for br in `remote_branch_names | grep ${REMOTE_NAME}`; do
branch=`echo $br | sed -e s,.*/,,g`
[ X"$branch" = X"$BRANCH" ] && FOUND_REMOTE_BRANCH=1
done
Expand All @@ -24,13 +27,11 @@ stash_it "synching branches"

git fetch origin

REMOTE_NAME=`git remote`

MERGES=`git log --merges ${REMOTE_NAME}/${BRANCH}..${BRANCH} | grep commit`
if [[ -n ${MERGES} ]]; then
git merge ${REMOTE_NAME}/${BRANCH}
else
git rebase ${REMOTE_NAME}/${BRANCH}
fi

git push ${REMOTE_NAME} ${BRANCH}
git push ${REMOTE_NAME} ${BRANCH}

0 comments on commit 82efd4e

Please sign in to comment.