From: Junio C Hamano Date: Wed, 19 Feb 2014 20:20:36 GMT Subject: Re: [PATCH v3 23/25] checkout: detach if the branch is already checked out elsewhere Message-ID: In-Reply-To: <1392730814-19656-24-git-send-email-pclouds@gmail.com> Nguyễn Thái Ngọc Duy writes: > The normal rule is anything outside refs/heads/ is detached. This > strictens the rule a bit more: if the branch is checked out (either in > $GIT_COMMON_DIR/HEAD or any $GIT_DIR/repos/.../HEAD) then it's > detached as well. > > A hint is given so the user knows where to go and do something there > if they still want to checkout undetached here. > > Signed-off-by: Nguyễn Thái Ngọc Duy (Only nitpicks during this round of review). > diff --git a/t/t2025-checkout-to.sh b/t/t2025-checkout-to.sh > index 76eae4a..f6a5c47 100755 > --- a/t/t2025-checkout-to.sh > +++ b/t/t2025-checkout-to.sh > @@ -13,13 +13,14 @@ test_expect_success 'checkout --to not updating paths' ' > ' > > test_expect_success 'checkout --to a new worktree' ' > + git rev-parse HEAD >expect && > git checkout --to here master && > ( > cd here && > test_cmp ../init.t init.t && > - git symbolic-ref HEAD >actual && > - echo refs/heads/master >expect && > - test_cmp expect actual && > + ! git symbolic-ref HEAD && test_must_fail?