From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from fhigh-a7-smtp.messagingengine.com (fhigh-a7-smtp.messagingengine.com [103.168.172.158]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 382BC439344 for ; Wed, 8 Jul 2026 17:46:37 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=103.168.172.158 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1783532798; cv=none; b=qXjaT2tPTySiw5myeYEr7emKH3mKMDVgen/9+QrYKsg3zYmxT/G+yqZ32XITmwoKQr7mVHOAEWMLfq5HNJIasum/1jqgYfBUrAHtbBg2a4hR+cCf1s09Z5T1I4fDqZhsUISl/aewPmKXH0YnrHfAkmPj1ZpKIKptuXVAUgDZLfw= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1783532798; c=relaxed/simple; bh=k85iYQarb3FDiQMi/UC9Hh49ixkXNInsmAuhQ1FFykg=; h=From:To:Cc:Subject:In-Reply-To:References:Date:Message-ID: MIME-Version:Content-Type; b=jb/KDP7GTBAKnOCXgh+ZIpSnEc/FQPXTOlkKXp2YfA6jqLyNdJLRoJN8CjFJr+jDKCG8ERtbN4vd4lPQ/09YZ9q44VfsgbgbnWUXT3yJfdreO1ZZNTISRAfQCq882HLX/yR0LiA5BcIKfKM3Sd4FVQ/wWSaRL0cgZ6ky0kG3raY= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=pobox.com; spf=pass smtp.mailfrom=pobox.com; dkim=pass (2048-bit key) header.d=pobox.com header.i=@pobox.com header.b=QtakAJP3; dkim=pass (2048-bit key) header.d=messagingengine.com header.i=@messagingengine.com header.b=g1mDO8Pq; arc=none smtp.client-ip=103.168.172.158 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=pobox.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=pobox.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=pobox.com header.i=@pobox.com header.b="QtakAJP3"; dkim=pass (2048-bit key) header.d=messagingengine.com header.i=@messagingengine.com header.b="g1mDO8Pq" Received: from phl-compute-05.internal (phl-compute-05.internal [10.202.2.45]) by mailfhigh.phl.internal (Postfix) with ESMTP id 693E11400059; Wed, 8 Jul 2026 13:46:36 -0400 (EDT) Received: from phl-frontend-01 ([10.202.2.160]) by phl-compute-05.internal (MEProxy); Wed, 08 Jul 2026 13:46:36 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=pobox.com; h=cc :cc:content-type:content-type:date:date:from:from:in-reply-to :in-reply-to:message-id:mime-version:references:reply-to:subject :subject:to:to; s=fm1; t=1783532796; x=1783619196; bh=8h7hRnWHQ7 EI0m5nM9mrgxuayRqwtLJLB0EZSzwYWt0=; b=QtakAJP33cYXP5H36TVgXHDSWg lrGZm4FvdruBNKbRaNzREAwuYB/LlqsuVaXrXgs3zMTz0yaCMDq65UlL5JTnLgw7 1QwGgyFOojKTL7+sTCVn2KtrE+LO82g3kCidD9F/0ZZHxIsjEGCh0VvyJAfD/s7n rZp4zYqyXKZ7CX37WF/teX4uJauAgO+x4zMagyMFr5TOJOMV67tTvoqnyMb3SQvH gH7g9KUpGvjOVy9rDRz7miJ9KYwAew0Kt3z5FevS19nMz+o/VoNjDTYYcdIxM5MH i10HzYf45PpXr9qJIdOvS02twmJCbchQzw0UX1/BOgoevN5wFc1nYyH0Mugw== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:cc:content-type:content-type:date:date :feedback-id:feedback-id:from:from:in-reply-to:in-reply-to :message-id:mime-version:references:reply-to:subject:subject:to :to:x-me-proxy:x-me-sender:x-me-sender:x-sasl-enc; s=fm2; t= 1783532796; x=1783619196; bh=8h7hRnWHQ7EI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OIL3uaXFIiGqWOilB+zKCcYEpEuQ X-ME-Proxy: Feedback-ID: if26b431b:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Wed, 8 Jul 2026 13:46:35 -0400 (EDT) From: Junio C Hamano To: Phillip Wood Cc: Kris Point , "git@vger.kernel.org" Subject: Re: [PATCH] merge --abort: don't delete autostash before reset succeeds In-Reply-To: <0b7e6d74-0287-4be5-a19f-ed8c5fbc9217@gmail.com> (Phillip Wood's message of "Wed, 8 Jul 2026 14:35:32 +0100") References: <0b7e6d74-0287-4be5-a19f-ed8c5fbc9217@gmail.com> Date: Wed, 08 Jul 2026 10:46:34 -0700 Message-ID: User-Agent: Gnus/5.13 (Gnus v5.13) Precedence: bulk X-Mailing-List: git@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain Phillip Wood writes: > I'm afraid I don't think this is the right solution. We only want to > save the stash if there are conflicts when we apply it - that is why > MERGE_AUTOSTASH is deleted before we do the reset - we want to prevent > remove_branch_state() from saving it. If the stash applies cleanly then > we should not save it. If the reset fails then we should keep > MERGE_AUTOSTASH along with the other merge state files rather than > saving the stash (which is actually what happens after this patch > because cmd_reset() dies before it calls remove_branch_state()). Thanks for pointing it out that reset calls remove_branch_state(), which in turn calls remove_merge_branch_state(), which in turn calls save_autostash_ref(). We end up (when cmd_reset() is successful) applying the autostash (which is good) but also saving a new stash. > I think the solution is probably to stop calling > builtin/reset.c:cmd_reset() and instead ... Great. In general, it is a bad pattern we should find and fix for cmd_A() to call cmd_B() in its implementation as a subroutine. To clean any such instance is a great thing to do. > ... > So we only delete MERGE_AUTOSTASH after a successful reset and we only > save the stash if it applies with conflicts. That's all a bit more > involved than the patch here - please do give me a shout if you want > some more information. > > Thanks > > Phillip Thanks.