From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 4117EC43334 for ; Tue, 19 Jul 2022 23:14:22 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231312AbiGSXOV (ORCPT ); Tue, 19 Jul 2022 19:14:21 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38474 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S237543AbiGSXOT (ORCPT ); Tue, 19 Jul 2022 19:14:19 -0400 Received: from pb-smtp20.pobox.com (pb-smtp20.pobox.com [173.228.157.52]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3243B6393D for ; Tue, 19 Jul 2022 16:14:18 -0700 (PDT) Received: from pb-smtp20.pobox.com (unknown [127.0.0.1]) by pb-smtp20.pobox.com (Postfix) with ESMTP id B9F9C19DD53; Tue, 19 Jul 2022 19:14:17 -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:message-id:mime-version:content-type; s=sasl; bh=g5jWVcMwGSADxCmb0VjJCt2z6izFN8WmkIcUCg/Ks6o=; b=Oajk s4aUwSXpDwrvFdZ2zjs58Z7kY5683Fgp6B/Rt8FD2vwSTsY/GMmBYLh2hwgi6cPa A1boyf87GPepY6/RMlMr8ZmUyZfv3m8QvasNhjZtWtXPxoBPfHbRbqlbLP9aJXlc Myz14vZ6T0WtBqcxhuMONG4d2WcIz6ZViFZN9ZM= Received: from pb-smtp20.sea.icgroup.com (unknown [127.0.0.1]) by pb-smtp20.pobox.com (Postfix) with ESMTP id B1F6C19DD51; Tue, 19 Jul 2022 19:14:17 -0400 (EDT) (envelope-from junio@pobox.com) Received: from pobox.com (unknown [34.83.92.57]) (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 4CA2019DD50; Tue, 19 Jul 2022 19:14:14 -0400 (EDT) (envelope-from junio@pobox.com) From: Junio C Hamano To: "Elijah Newren via GitGitGadget" Cc: git@vger.kernel.org, ZheNing Hu , Elijah Newren Subject: Re: [PATCH v2 4/6] merge: make restore_state() restore staged state too References: <4a8b7c9e06df36444b94b929b2558f40e3f72e81.1655621424.git.gitgitgadget@gmail.com> Date: Tue, 19 Jul 2022 16:14:13 -0700 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: 81508F40-07B8-11ED-B9F0-C85A9F429DF0-77302942!pb-smtp20.pobox.com Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org "Elijah Newren via GitGitGadget" writes: > From: Elijah Newren > > merge can be invoked with uncommitted changes, including staged changes. > merge is responsible for restoring this state if some of the merge > strategies make changes. However, it was not restoring staged changes > due to the lack of the "--index" option to "git stash apply". Add the > option to fix this shortcoming. Shouldn't this be testable? > Signed-off-by: Elijah Newren > --- > builtin/merge.c | 4 ++-- > 1 file changed, 2 insertions(+), 2 deletions(-) > > diff --git a/builtin/merge.c b/builtin/merge.c > index 8ce4336dd3f..2dc56fab70b 100644 > --- a/builtin/merge.c > +++ b/builtin/merge.c > @@ -383,14 +383,14 @@ static void reset_hard(const struct object_id *oid, int verbose) > static void restore_state(const struct object_id *head, > const struct object_id *stash) > { > - const char *args[] = { "stash", "apply", NULL, NULL }; > + const char *args[] = { "stash", "apply", "--index", NULL, NULL }; > > if (is_null_oid(stash)) > return; > > reset_hard(head, 1); > > - args[2] = oid_to_hex(stash); > + args[3] = oid_to_hex(stash); > > /* > * It is OK to ignore error here, for example when there was OK.