From 3b43e14dd3df67abfbcf7d1f4a053cf78d651232 Mon Sep 17 00:00:00 2001 From: Stephen Haberman Date: Tue, 26 Aug 2008 14:26:21 -0500 Subject: [PATCH] Fix missing -r in gc-checkout looking for existing tracking branches. --- scripts/gc-checkout | 4 ++-- tests/t5000-script-checkout.sh | 15 ++++++++++----- 2 files changed, 12 insertions(+), 7 deletions(-) diff --git a/scripts/gc-checkout b/scripts/gc-checkout index cdc5ab9..5f50c26 100644 --- a/scripts/gc-checkout +++ b/scripts/gc-checkout @@ -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 diff --git a/tests/t5000-script-checkout.sh b/tests/t5000-script-checkout.sh index f162189..c9ce960 100644 --- a/tests/t5000-script-checkout.sh +++ b/tests/t5000-script-checkout.sh @@ -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' ' -- 2.20.1