All of lore.kernel.org
 help / color / mirror / Atom feed
From: Junio C Hamano <gitster@pobox.com>
To: Phillip Wood <phillip.wood123@gmail.com>
Cc: Kris Point <KrisPointCSGO@outlook.com>,
	 "git@vger.kernel.org" <git@vger.kernel.org>
Subject: Re: [PATCH] merge --abort: don't delete autostash before reset succeeds
Date: Wed, 08 Jul 2026 10:46:34 -0700	[thread overview]
Message-ID: <xmqq8q7lv0g5.fsf@gitster.g> (raw)
In-Reply-To: <0b7e6d74-0287-4be5-a19f-ed8c5fbc9217@gmail.com> (Phillip Wood's message of "Wed, 8 Jul 2026 14:35:32 +0100")

Phillip Wood <phillip.wood123@gmail.com> 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.

      reply	other threads:[~2026-07-08 17:46 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-07-08  1:51 [PATCH] merge --abort: don't delete autostash before reset succeeds Kris Point
2026-07-08 13:35 ` Phillip Wood
2026-07-08 17:46   ` Junio C Hamano [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=xmqq8q7lv0g5.fsf@gitster.g \
    --to=gitster@pobox.com \
    --cc=KrisPointCSGO@outlook.com \
    --cc=git@vger.kernel.org \
    --cc=phillip.wood123@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.