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: AS53758 23.128.96.0/24 X-Spam-Status: No, score=-4.0 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_PASS,SPF_PASS shortcircuit=no autolearn=ham autolearn_force=no version=3.4.2 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by dcvr.yhbt.net (Postfix) with ESMTP id 62E861F8C8 for ; Fri, 1 Oct 2021 21:19:09 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230138AbhJAVUw (ORCPT ); Fri, 1 Oct 2021 17:20:52 -0400 Received: from pb-smtp20.pobox.com ([173.228.157.52]:52632 "EHLO pb-smtp20.pobox.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229894AbhJAVUq (ORCPT ); Fri, 1 Oct 2021 17:20:46 -0400 Received: from pb-smtp20.pobox.com (unknown [127.0.0.1]) by pb-smtp20.pobox.com (Postfix) with ESMTP id AA04616455A; Fri, 1 Oct 2021 17:19:01 -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; s=sasl; bh=RGVHc5nMhS92i1D5PyZu+lQPtx2UzHy38UTQFZ SVwcw=; b=GOBkJ/lmDhJIf45mD1HY9SFRpZLVUPdwihYtZKWxwtn9jOiL1Scv/c mVSx+LJLajiNoYUh52hvqYpeUebkhGIA9jvrmK9sRv6F9Sf0movvJpYFTn4xtP32 ERrINNZ1j6r4sl+PX+XSXBuUM9WwEbBSjbBQvLKNdQYGtZyrhkuD0= Received: from pb-smtp20.sea.icgroup.com (unknown [127.0.0.1]) by pb-smtp20.pobox.com (Postfix) with ESMTP id A39C1164559; Fri, 1 Oct 2021 17:19:01 -0400 (EDT) (envelope-from junio@pobox.com) Received: from pobox.com (unknown [104.133.2.91]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by pb-smtp20.pobox.com (Postfix) with ESMTPSA id 39472164557; Fri, 1 Oct 2021 17:18:59 -0400 (EDT) (envelope-from junio@pobox.com) From: Junio C Hamano To: "Phillip Wood via GitGitGadget" Cc: git@vger.kernel.org, Philippe Blain , Johannes Schindelin , Elijah Newren , Phillip Wood Subject: Re: [PATCH 10/11] rebase --apply: set ORIG_HEAD correctly References: Date: Fri, 01 Oct 2021 14:18:57 -0700 In-Reply-To: (Phillip Wood via GitGitGadget's message of "Fri, 01 Oct 2021 10:05:01 +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: 3166EDBC-22FD-11EC-AF6F-F327CE9DA9D6-77302942!pb-smtp20.pobox.com Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org "Phillip Wood via GitGitGadget" writes: > From: Phillip Wood > > At the start of a rebase ORIG_HEAD is updated to tip of the branch > being rebased. Unfortunately reset_head() always uses the current > value of HEAD for this which is incorrect if the rebase is started > with 'git rebase ' as in that case ORIG_HEAD should > be updated to . This only affects the "apply" backend as the > "merge" backend does not yet use reset_head() for the initial > checkout. Fix this by passing in orig_head when calling reset_head() > and add some regression tests. All correct. It is somewhat surprising that this wasn't caught and reported as an issue for this long X-<. > + const struct object_id *orig_head; > /* Optional branch to switch to */ > const char *branch; > /* Flags defined above */ > diff --git a/t/t3418-rebase-continue.sh b/t/t3418-rebase-continue.sh > index 738fbae9b29..be63456c5b9 100755 > --- a/t/t3418-rebase-continue.sh > +++ b/t/t3418-rebase-continue.sh > @@ -323,4 +323,30 @@ test_expect_success 'there is no --no-reschedule-failed-exec in an ongoing rebas > test_expect_code 129 git rebase --edit-todo --no-reschedule-failed-exec > ' > > +test_orig_head_helper() { Need SP before "()" in addition to after it. Ditto for the other one. > + test_when_finished 'git rebase --abort && > + git checkout topic && > + git reset --hard commit-new-file-F2-on-topic-branch' && > + git update-ref -d ORIG_HEAD && > + test_must_fail git rebase "$@" && > + test_cmp_rev ORIG_HEAD commit-new-file-F2-on-topic-branch > +} > + > +test_orig_head() { > + type=$1 > + test_expect_success "rebase $type sets ORIG_HEAD correctly" ' > + git checkout topic && > + git reset --hard commit-new-file-F2-on-topic-branch && > + test_orig_head_helper $type main > + ' > + > + test_expect_success "rebase $type sets ORIG_HEAD correctly" ' > + git checkout main && > + test_orig_head_helper $type main topic > + ' > +} > + > +test_orig_head --apply > +test_orig_head --merge > + > test_done