Fix missing -r in gc-checkout looking for existing tracking branches.
authorStephen Haberman <stephen@exigencecorp.com>
Tue, 26 Aug 2008 19:26:21 +0000 (14:26 -0500)
committerStephen Haberman <stephen@exigencecorp.com>
Tue, 26 Aug 2008 19:26:21 +0000 (14:26 -0500)
scripts/gc-checkout
tests/t5000-script-checkout.sh

index cdc5ab9..5f50c26 100644 (file)
@@ -3,14 +3,14 @@
 branch_name=$1
 
 # See if it already exists
-git rev-parse $branch_name >/dev/null
+git rev-parse --verify --quiet $branch_name >/dev/null 
 if [[ $? -eq 0 ]] ; then
        # Just checkout what they asked
        git checkout "$branch_name"
 else
        # Make sure we have the latest origin/$branch_name to branch
        git fetch
-       exists_remote=$(git branch | grep -x "  origin/$branch_name" | wc -l)
+       exists_remote=$(git branch -r | grep -x "  origin/$branch_name" | wc -l)
        if [[ $exists_remote -eq 0 ]] ; then
                # Specifying stable to get the last released code
                git checkout -b "$branch_name" origin/stable
index f162189..c9ce960 100644 (file)
@@ -27,14 +27,19 @@ test_expect_success 'checkout a new branch clones stable' '
 test_expect_success 'checkout an existing remote branch' '
        cd server &&
        git checkout -b topic2 stable &&
-       echo "$test_name" >a &&
+       echo "$test_name on server" >a &&
        git commit -a -m "Made topic2 on server" &&
        cd .. &&
 
-       gc-checkout topic2
-       git branch | grep topic2
-       git branch -r | grep origin/topic2
-       git config --list | grep "branch.topic2.merge=refs/heads/topic2"
+       ! git branch | grep topic2 &&
+       gc-checkout topic2 &&
+       git branch | grep topic2 &&
+       git branch -r | grep origin/topic2 &&
+       git config --list | grep "branch.topic2.merge=refs/heads/topic2" &&
+
+       echo "$test_name on client" >a &&
+       git commit -a -m "Move topic2 on client" &&
+       git push origin topic2
 '
 
 test_expect_success 'checkout an existing local branch' '