Reproduce and fix with gc-pull the merge replay problem.
authorStephen Haberman <stephen@exigencecorp.com>
Wed, 24 Sep 2008 19:13:01 +0000 (14:13 -0500)
committerStephen Haberman <stephen@exigencecorp.com>
Wed, 24 Sep 2008 19:13:01 +0000 (14:13 -0500)
client/post-checkout-rebase
scripts/gc-pull
scripts/gc-push
tests/t5200-script-pull.sh

index 40ee523..a0fc533 100644 (file)
@@ -5,14 +5,14 @@
 # whether the checkout was a branch checkout (changing branches, flag=1) or a
 # file checkout (retrieving a file from the index, flag=0).
 
-branch=$(git symbolic-ref --quiet HEAD)
-if [ $? -ne 0 ] ; then
+branch=$(git symbolic-ref HEAD 2>/dev/null)
+if [[ $? -ne 0 ]] ; then
        exit 0
 fi
 
 branch=${branch/refs\/heads\//}
+
 git config --list | grep "branch.${branch}.rebase" > /dev/null
 if [ $? -ne 0 ] ; then
        git config --add "branch.${branch}.rebase" true
 fi
-
index 1844725..fcde7b9 100644 (file)
@@ -1,7 +1,18 @@
 #!/bin/sh
+#!/bin/sh
+
+branch_name=$(git symbolic-ref --quiet HEAD)
+if [[ $? -ne 0 ]] ; then
+       echo "not on a branch"
+       exit 1
+fi
+
+branch_name=${branch_name/refs\/heads\//}
+
+git fetch
+if [[ $? -ne 0 ]] ; then
+       exit $?
+fi
 
-#
-# Note: we should use `git pull --rebase origin <branch>`?
-#
-git pull --rebase $*
+GIT_EDITOR=: git rebase -p -i "origin/$branch_name"
 
index 32952b1..4e72fe5 100644 (file)
@@ -1,6 +1,12 @@
 #!/bin/sh
 
-branch_name=$(git-symbolic-ref HEAD)
+branch_name=$(git symbolic-ref --quiet HEAD)
+if [[ $? -ne 0 ]] ; then
+       echo "not on a branch"
+       exit 1
+fi
+
+branch_name=${branch_name/refs\/heads\//}
 
 git push origin $branch_name
 if [[ $? -ne 0 ]] ; then
index 3bfd5e4..39e660d 100644 (file)
@@ -32,46 +32,39 @@ test_expect_success 'pull does a rebase' '
 
        # Only one parent
        gc-pull &&
-       git cat-file commit $(git rev-parse HEAD) | grep parent | wc -l | grep 1
+       test 1 = $(git cat-file commit $(git rev-parse HEAD) | grep parent | wc -l)
 '
 
-#test_expect_success 'pull does a rebase but does not fuck up merges' '
-#      # Change "a" itself so we will eventually conflict
-#      gc-checkout topic2 &&
-#      echo "$test_name on topic2" >a &&
-#      git commit -a -m "move topic2" &&
-#
-#      # Change a.topic2 as well for another commit to continue rebasing after fixing the conflict
-#      echo "$test_name on topic2" >a.topic2 &&
-#      git add a.topic2 &&
-#      git commit -m "move a.topic2" &&
-#
-#      # Move stable
-#      git checkout stable &&
-#      echo "$test_name on stable" >a &&
-#      git commit -a -m "move stable" &&
-#      git push origin stable &&
-#
-#      # Move topic2 on the server, then merge stable
-#      cd server &&
-#      git checkout stable &&
-#      echo "$test_name on stable server" >a.stable.server &&
-#      git add a.stable.server &&
-#      git commit -m "move stable server" &&
-#      git checkout topic2 &&
-#      echo "$test_name" >a.topic2.server &&
-#      git add a.topic2.server &&
-#      git commit -m "move topic2 on the server" &&
-#      git merge stable &&
-#      cd .. &&
-#
-#      # Merge stable locally too--should conflict
-#      git checkout topic2 &&
-#      git merge origin/stable
-#
-#      # Now pull and see what happens
-#      # gc-pull
-#'
+test_expect_success 'pull does a rebase but does not fuck up merges' '
+       gc-checkout topic2 &&
+       echo "$test_name on topic2" >a.topic2 &&
+       git add a.topic2 &&
+       git commit -a -m "create topic2" &&
+       git push origin topic2 &&
+
+       # Move stable
+       git checkout stable &&
+       echo "$test_name on stable" >a &&
+       git commit -a -m "move stable that will not be replayed" &&
+       git push origin stable &&
+
+       # And merge stable into topic2
+       git checkout topic2 &&
+       git merge stable &&
+
+       # Move topic2 on the server
+       cd server &&
+       git checkout topic2 &&
+       echo "$test_name" >a.topic2.server &&
+       git add a.topic2.server &&
+       git commit -m "move topic2 on the server" &&
+       cd .. &&
+
+       # Merge stable locally too--should conflict
+       git checkout topic2 &&
+       gc-pull &&
+       test 1 = $(git rev-list --all --pretty=oneline | grep "replayed" | wc -l)
+'
 
 test_done