From: Ævar Arnfjörð Bjarmason Date: Sat, 31 Jul 2010 10:24:13 GMT Subject: Re: [PATCH 2/2 v2] checkout: add a test for creating a new branch with regexp as a starting point Message-ID: In-Reply-To: <20100731014449.GA19956@wo.int.altlinux.org> On Sat, Jul 31, 2010 at 01:44, Dmitry V. Levin wrote: > Reported-by: Ivan Zakharyaschev > Signed-off-by: Dmitry V. Levin > --- >  t/t2018-checkout-branch.sh |   25 +++++++++++++++++++++---- >  1 files changed, 21 insertions(+), 4 deletions(-) > > diff --git a/t/t2018-checkout-branch.sh b/t/t2018-checkout-branch.sh > index 1caffea..6ada870 100755 > --- a/t/t2018-checkout-branch.sh > +++ b/t/t2018-checkout-branch.sh > @@ -4,12 +4,13 @@ test_description='checkout ' > >  . ./test-lib.sh > > -# Arguments: [] > +# Arguments: [] >  # >  # Runs "git checkout" to switch to , testing that >  # >  #   1) we are on the specified branch, ; > -#   2) HEAD is ; if is not specified, the old HEAD is used. > +#   2) HEAD points to the same commit as does; > +#      if is not specified, the old HEAD is used. >  # >  # If is not specified, "git checkout" is run with -b. >  do_checkout() { > @@ -17,7 +18,8 @@ do_checkout() { >        exp_ref="refs/heads/$exp_branch" && > >        # if is not specified, use HEAD. > -       exp_sha=${2:-$(git rev-parse --verify HEAD)} && > +       start_point=${2:-HEAD} > +       exp_sha=$(git rev-parse --verify $start_point) && > >        # default options for git checkout: -b >        if [ -z "$3" ]; then > @@ -26,7 +28,7 @@ do_checkout() { >                opts="$3" >        fi > > -       git checkout $opts $exp_branch $exp_sha && > +       git checkout $opts $exp_branch $start_point && > >        test $exp_ref = $(git rev-parse --symbolic-full-name HEAD) && >        test $exp_sha = $(git rev-parse --verify HEAD) > @@ -118,7 +120,22 @@ test_expect_success 'checkout -b to an existing branch fails' ' >        test_must_fail do_checkout branch2 $HEAD2 >  ' > > +test_expect_failure 'checkout -b new_branch :/regexp' ' > +       # clean up from previous test > +       git reset --hard && > + > +       do_checkout old_regexp_branch branch1 && > +       # The first commit in this test should not be referenced by > +       # other branches or tags. > +       test_commit first a a "" && > +       test_commit second && > + > +       do_checkout new_regexp_branch :/first > +' > + >  test_expect_success 'checkout -B to an existing branch resets branch to HEAD' ' > +       # clean up from previous test > +       git reset --hard && >        git checkout branch1 && > >        do_checkout branch2 "" -B > -- > 1.7.2.1 Looks good, thanks. Acked-by: Ævar Arnfjörð Bjarmason