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.2 required=3.0 tests=AWL,BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,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 1A6121F670 for ; Fri, 11 Mar 2022 06:04:18 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1346618AbiCKGAR (ORCPT ); Fri, 11 Mar 2022 01:00:17 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42682 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1347111AbiCKF6C (ORCPT ); Fri, 11 Mar 2022 00:58:02 -0500 Received: from pb-smtp21.pobox.com (pb-smtp21.pobox.com [173.228.157.53]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E2F4B1AD94D for ; Thu, 10 Mar 2022 21:55:42 -0800 (PST) Received: from pb-smtp21.pobox.com (unknown [127.0.0.1]) by pb-smtp21.pobox.com (Postfix) with ESMTP id 4D7651871F5; Fri, 11 Mar 2022 00:55:42 -0500 (EST) (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; s=sasl; bh=j6j+4d6G2BuUJjkQMhy/WnygmmhH7J5gsKKCuN V1i0U=; b=Mv00VD6H+npksYpTYagIZmh0PkIMSJ0hU2Gw7C0KzSa0wNZwjIj28k nueZwvCzZOt85hBpwtoqZaYMWlcwQUURWKeiXjJwakeidGgE+Prjrm8Gogh8HEbX 7Bib2dJWE6xJidRSMYEPNoR71R+dXD9zPD4sVHx1Y1sy4meOGGfj8= Received: from pb-smtp21.sea.icgroup.com (unknown [127.0.0.1]) by pb-smtp21.pobox.com (Postfix) with ESMTP id 468681871F4; Fri, 11 Mar 2022 00:55:42 -0500 (EST) (envelope-from junio@pobox.com) Received: from pobox.com (unknown [35.247.14.241]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by pb-smtp21.pobox.com (Postfix) with ESMTPSA id C8DC01871F3; Fri, 11 Mar 2022 00:55:39 -0500 (EST) (envelope-from junio@pobox.com) From: Junio C Hamano To: "John Cai via GitGitGadget" Cc: git@vger.kernel.org, John Cai Subject: Re: [PATCH] rebase: set REF_HEAD_DETACH in checkout_up_to_date() References: Date: Thu, 10 Mar 2022 21:55:38 -0800 In-Reply-To: (John Cai via GitGitGadget's message of "Fri, 11 Mar 2022 05:05:44 +0000") Message-ID: User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/27.2 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain X-Pobox-Relay-ID: E1484ACA-A0FF-11EC-B615-CBA7845BAAA9-77302942!pb-smtp21.pobox.com Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org "John Cai via GitGitGadget" writes: > This is happening because on a fast foward with an oid as a , > update_refs() will only call update_ref() with REF_NO_DEREF if > RESET_HEAD_DETACH is set. This change was made in 176f5d96 (built-in rebase > --autostash: leave the current branch alone if possible, > 2018-11-07). In rebase, we are not setting the RESET_HEAD_DETACH flag, > which means that the update_ref() call ends up dereferencing > HEAD and updating it to the oid used as . > > The correct behavior is that git rebase should update HEAD to $(git > rev-parse topic) without dereferencing it. It is unintuitive that unconditionally setting the RESET_HEAD_DETACH bit is the right solution. If the command weren't "rebase master side^0" but "rebase master side", i.e. "please rebase the side branch itself, not an unnamed branch created out of the side branch, on master", according to , we ought to end up being on a detached HEAD, as reset_head() with the bit /* Request a detached checkout */ #define RESET_HEAD_DETACH (1<<0) requests a detached checkout. But that apparently is not what would happen with your patch applied. Puzzled. The solution to the puzzle probably deserves to be in the proposed log message. Thanks.