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=-0.3 required=3.0 tests=AWL,BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI,SPF_HELO_NONE,SPF_PASS, T_SCC_BODY_TEXT_LINE,URIBL_CSS,URIBL_CSS_A 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 24E721F8C4 for ; Thu, 17 Mar 2022 15:35:05 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235918AbiCQPgH (ORCPT ); Thu, 17 Mar 2022 11:36:07 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49774 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234055AbiCQPgG (ORCPT ); Thu, 17 Mar 2022 11:36:06 -0400 Received: from pb-smtp2.pobox.com (pb-smtp2.pobox.com [64.147.108.71]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 455641817B6 for ; Thu, 17 Mar 2022 08:34:50 -0700 (PDT) Received: from pb-smtp2.pobox.com (unknown [127.0.0.1]) by pb-smtp2.pobox.com (Postfix) with ESMTP id 563BE128094; Thu, 17 Mar 2022 11:34:49 -0400 (EDT) (envelope-from junio@pobox.com) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed; d=pobox.com; h=from:to:cc :subject:references:date:in-reply-to:message-id:mime-version :content-type:content-transfer-encoding; s=sasl; bh=HVOysu6m3D+m 7oge3XLKj5iUBm8QpQ/WOVTAdjjqzis=; b=cMOUbnEI7hvH2ZY2KY4ALdlbhv+W xyeHYoQdq6NYSIwpi4Wog/8KoIqcYSNL3IthkkfJgCrM00NfAnjtZroLGxWil9YR w3H+rsk3EfVr/O4Til2n40herlGKefjtaoy2Zg1SLfQ8cN526MdLho+qUXFmulPa H+iHYL3PPNBE6xI= Received: from pb-smtp2.nyi.icgroup.com (unknown [127.0.0.1]) by pb-smtp2.pobox.com (Postfix) with ESMTP id 4DA66128093; Thu, 17 Mar 2022 11:34:49 -0400 (EDT) (envelope-from junio@pobox.com) Received: from pobox.com (unknown [34.82.80.254]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by pb-smtp2.pobox.com (Postfix) with ESMTPSA id A3B2A128092; Thu, 17 Mar 2022 11:34:48 -0400 (EDT) (envelope-from junio@pobox.com) From: Junio C Hamano To: =?utf-8?B?w4Z2YXIgQXJuZmrDtnLDsA==?= Bjarmason Cc: John Cai via GitGitGadget , git@vger.kernel.org, Phillip Wood , John Cai Subject: Re: [PATCH v3 2/2] rebase: set REF_HEAD_DETACH in checkout_up_to_date() References: <220317.86r170d6zs.gmgdl@evledraar.gmail.com> Date: Thu, 17 Mar 2022 08:34:47 -0700 In-Reply-To: <220317.86r170d6zs.gmgdl@evledraar.gmail.com> (=?utf-8?B?IsOG?= =?utf-8?B?dmFyIEFybmZqw7Zyw7A=?= Bjarmason"'s message of "Thu, 17 Mar 2022 14:42:53 +0100") Message-ID: User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/27.2 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 X-Pobox-Relay-ID: C7B12494-A607-11EC-A43C-CB998F0A682E-77302942!pb-smtp2.pobox.com Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org =C3=86var Arnfj=C3=B6r=C3=B0 Bjarmason writes: >> @@ -827,8 +827,11 @@ static int checkout_up_to_date(struct rebase_opti= ons *options) >> getenv(GIT_REFLOG_ACTION_ENVIRONMENT), >> options->switch_to); >> ropts.oid =3D &options->orig_head; >> - ropts.branch =3D options->head_name; >> ropts.flags =3D RESET_HEAD_RUN_POST_CHECKOUT_HOOK; >> + if (options->head_name) >> + ropts.branch =3D options->head_name; >> + else >> + ropts.flags |=3D RESET_HEAD_DETACH; >> ropts.head_msg =3D buf.buf; >> if (reset_head(the_repository, &ropts) < 0) >> ret =3D error(_("could not switch to %s"), options->switch_to); > > In this case a smaller change of: > > if (!ropts.branch) > ropts.flags |=3D RESET_HEAD_DETACH; > > will do the same. Thanks. That is much easier to read and simpler to follow. > I wonder if just converting it to a designated initializer while we're > at it (or a pre-cleanup commit) would be better, i.e.: I do not think it easier to follow than even the original or the improvement above, especially the part that computes .flags member.