From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on dcvr.yhbt.net X-Spam-Level: X-Spam-ASN: AS3215 2.6.0.0/16 X-Spam-Status: No, score=-3.8 required=3.0 tests=AWL,BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,SPF_HELO_NONE, SPF_PASS shortcircuit=no autolearn=ham autolearn_force=no version=3.4.2 Received: from out1.vger.email (out1.vger.email [IPv6:2620:137:e000::1:20]) by dcvr.yhbt.net (Postfix) with ESMTP id 924241F910 for ; Tue, 1 Nov 2022 21:45:42 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229782AbiKAVpm (ORCPT ); Tue, 1 Nov 2022 17:45:42 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55644 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229531AbiKAVpj (ORCPT ); Tue, 1 Nov 2022 17:45:39 -0400 Received: from cloud.peff.net (cloud.peff.net [104.130.231.41]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D9222101E0 for ; Tue, 1 Nov 2022 14:45:38 -0700 (PDT) Received: (qmail 7581 invoked by uid 109); 1 Nov 2022 21:45:38 -0000 Received: from Unknown (HELO peff.net) (10.0.1.2) by cloud.peff.net (qpsmtpd/0.94) with ESMTP; Tue, 01 Nov 2022 21:45:38 +0000 Authentication-Results: cloud.peff.net; auth=none Received: (qmail 29448 invoked by uid 111); 1 Nov 2022 21:45:38 -0000 Received: from coredump.intra.peff.net (HELO sigill.intra.peff.net) (10.0.0.2) by peff.net (qpsmtpd/0.94) with (TLS_AES_256_GCM_SHA384 encrypted) ESMTPS; Tue, 01 Nov 2022 17:45:38 -0400 Authentication-Results: peff.net; auth=none Date: Tue, 1 Nov 2022 17:45:36 -0400 From: Jeff King To: Taylor Blau Cc: Martin von Zweigbergk , Junio C Hamano , Git Mailing List Subject: Re: Bug in `git branch --delete main` when on other orphan brancht Message-ID: References: MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org On Tue, Nov 01, 2022 at 04:14:40PM -0400, Taylor Blau wrote: > Actually, the test doesn't need "other" here, since we aren't actually > going to delete the target branch (for the exact same reason that you > pointed out to Martin earlier in the thread). > > So it could actually be as small as something like this: > > --- >8 --- > diff --git a/t/t3200-branch.sh b/t/t3200-branch.sh > index 7f605f865b..464d3f610b 100755 > --- a/t/t3200-branch.sh > +++ b/t/t3200-branch.sh > @@ -279,6 +279,13 @@ test_expect_success 'git branch -M and -C fail on detached HEAD' ' > test_cmp expect err > ' > > +test_expect_success 'git branch -d on detached HEAD' ' > + test_when_finished git checkout main && > + git checkout --orphan orphan && > + test_must_fail git branch -d main 2>err && > + grep "not fully merged" err > +' I think there's a more interesting case, which is when "main" has a configured upstream to which it's fully merged. And then the deletion actually succeeds (and the bug is not just giving us a crappy message, but actually doing causing the wrong outcome). And for that we'd probably not want to use "main", since a successful test will actually delete it. ;) I'll try later tonight to integrate that test into the patch you've written. -Peff