bug-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

bug#60126: 30.0.50; vc-git-checkin: Offer to unstage conflicting changes


From: Sean Whitton
Subject: bug#60126: 30.0.50; vc-git-checkin: Offer to unstage conflicting changes
Date: Mon, 19 Dec 2022 23:43:44 -0700
User-agent: Gnus/5.13 (Gnus v5.13)

Hello,

On Tue 20 Dec 2022 at 02:53AM +02, Dmitry Gutov wrote:

> On 20/12/2022 00:30, Sean Whitton wrote:
>> This is a nice suggestion.  A step further would be to unconditionally
>> stash and unstash.  Given how committing patches with C-x v v works, I
>> don't believe it can ever be the case that the stash is not applicable
>> afterwards?
>
> I'm not sure that's 100% true, given that we'll want to stage the contents of
> the staging area (which are supposedly represented as diffs against the last
> committed state), and our command, while keeping the contents of files on disk
> intact, moves the last commit to a new state.

Good point about the representation of the index.

In addition, you can't stash just the content of the staging area, and
not also the working tree, without hacks -- see `magit-stash-save' as
called by `magit-stash-index'.  I don't want to reproduce those hacks,
so I was thinking we would be stashing both the worktree and the index
for any and all files that have any changes staged.  However ...

>> If that's wrong, I'll implement what you suggest.
>
> ...but we might as well try and experiment. Worst case: the stash won't apply
> cleanly and the user will have to do it by hand. That would mean no big loss
> of information, at least.

... for files that are modified by the patch to be committed, it's very
easy to generate situations where git can't or won't apply the stash.
It's true that there isn't a loss of information, but it's a frustrating
context switch for the user, who might not have even realised a stash
would be created, and now has to untangle things.

So, I'm now thinking:

- automatically stash index+worktree for any files with changes staged
  that are *not* modified by the patch to be committed

- offer to unstage any files with changes staged that *are* modified by
  the patch to be committed.

This way, we have to prompt the user only when files involved in the
patch have staged changes, and we shouldn't ever force the user into
dealing with a stash that won't apply.

-- 
Sean Whitton





reply via email to

[Prev in Thread] Current Thread [Next in Thread]