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,T_SCC_BODY_TEXT_LINE 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 88E3F1F4DA for ; Thu, 7 Jul 2022 23:58:03 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236983AbiGGXyY (ORCPT ); Thu, 7 Jul 2022 19:54:24 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51234 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236449AbiGGXyX (ORCPT ); Thu, 7 Jul 2022 19:54:23 -0400 Received: from cloud.peff.net (cloud.peff.net [104.130.231.41]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 52A376D551 for ; Thu, 7 Jul 2022 16:54:22 -0700 (PDT) Received: (qmail 6914 invoked by uid 109); 7 Jul 2022 23:54:22 -0000 Received: from Unknown (HELO peff.net) (10.0.1.2) by cloud.peff.net (qpsmtpd/0.94) with ESMTP; Thu, 07 Jul 2022 23:54:21 +0000 Authentication-Results: cloud.peff.net; auth=none Received: (qmail 5866 invoked by uid 111); 7 Jul 2022 23:54:21 -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; Thu, 07 Jul 2022 19:54:21 -0400 Authentication-Results: peff.net; auth=none Date: Thu, 7 Jul 2022 19:54:21 -0400 From: Jeff King To: Junio C Hamano Cc: git@vger.kernel.org, Jonathan Tan Subject: [PATCH v2 0/3] cloning unborn HEAD when other branches are present 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 Thu, Jul 07, 2022 at 11:50:34AM -0700, Junio C Hamano wrote: > Jeff King writes: > > > If so, do you prefer to go straight there in patch 3 (and drop patch 2, > > keeping the unborn setup inline), or do you prefer to see it on top? > > Normally I'd suggest the former, but I worry that doing it all in one > > patch means it's reorganizing the code _and_ changing the behavior all > > at once, which is harder to reason about. And I don't see an easy way to > > reorganize the code without changing the behavior. > > Either way is fine, but the "go straight there" approach may work > better, I suspect. Yeah, the diff turned out less noisy than I'd feared. So here's a v2. It does the refactoring we've been discussing, which is now in patch 2 (since the extra function is no longer needed). And then it was actually pretty easy to fix the other weird "your unborn master does not match the remote's master" problem on top. I _think_ that's the right thing to be doing, but see the discussion in patch 3. I'll skip the range diff, which is mostly unreadable (the only readable part is that I did s/empty/unborn/ in the tests, as discussed). [1/3]: clone: drop extra newline from warning message [2/3]: clone: propagate empty remote HEAD even with other branches [3/3]: clone: use remote branch if it matches default HEAD builtin/clone.c | 58 ++++++++++++++++++++++------------------- t/t5605-clone-local.sh | 16 +++++++++--- t/t5702-protocol-v2.sh | 59 ++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 104 insertions(+), 29 deletions(-) -Peff