Fix pull in the case when we have no local changes.
authorStephen Haberman <stephen@exigencecorp.com>
Tue, 11 Nov 2008 23:06:43 +0000 (17:06 -0600)
committerStephen Haberman <stephen@exigencecorp.com>
Tue, 11 Nov 2008 23:06:43 +0000 (17:06 -0600)
scripts/pull
tests/t5200-pull.sh

index c2313ba..d448f38 100644 (file)
@@ -13,5 +13,9 @@ if [[ $? -ne 0 ]] ; then
        exit $?
 fi
 
-GIT_EDITOR=: git rebase -p -i "origin/$branch_name"
+if test $(git rev-parse HEAD) = $(git merge-base HEAD origin/$branch_name) ; then
+       git rebase "origin/$branch_name"
+else
+       GIT_EDITOR=: git rebase -p -i "origin/$branch_name"
+fi
 
index 6fdfb07..911f7a4 100644 (file)
@@ -63,7 +63,22 @@ test_expect_success 'pull does a rebase but does not fuck up merges' '
        # Merge stable locally too--should conflict
        git checkout topic2 &&
        pull &&
-       test 1 = $(git rev-list --all --pretty=oneline | grep "replayed" | wc -l)
+       test 1 = $(git rev-list --all --pretty=oneline | grep "replayed" | wc -l) &&
+       push
+'
+
+test_expect_success 'pull moves when we have no local changes' '
+       git checkout topic2 &&
+
+       # Move topic2 on the server
+       cd server &&
+       git checkout topic2 &&
+       echo "$test_name" > a.topic2.server &&
+       git commit -a -m "move topic2 on the server" &&
+       cd .. &&
+
+       pull &&
+       test $(git rev-parse HEAD) = $(git rev-parse origin/topic2)
 '
 
 test_done