GNU bug report logs -
#60126
30.0.50; vc-git-checkin: Offer to unstage conflicting changes
Previous Next
Reported by: Sean Whitton <spwhitton <at> spwhitton.name>
Date: Fri, 16 Dec 2022 18:34:01 UTC
Severity: normal
Found in version 30.0.50
Done: Sean Whitton <spwhitton <at> spwhitton.name>
Bug is archived. No further changes may be made.
Full log
Message #41 received at 60126 <at> debbugs.gnu.org (full text, mbox):
Hello,
On Tue 20 Dec 2022 at 10:04AM -07, Sean Whitton wrote:
> On Tue 20 Dec 2022 at 05:13PM +02, Dmitry Gutov wrote:
>
>> On 20/12/2022 08:43, Sean Whitton wrote:
>>> 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
>>
>> I think it's possible to just skip those when checking the index area. And
>> then, when committing, specify individual files to commit from the index.
>
> Ah, so it is!
It turns out this doesn't work: if you specify individual files to
commit from the index, then git also includes any changes to those files
in the worktree too, and you can't ask it not to, because --only is
implied whenever files are supplied on the command line.
In other words, when vc-git-patch-string is non-nil, we mustn't pass a
list of files to git. So if there are files not involved in the commit
with staged changes, we need to stash those.
I tried implementing that, which is not hard, but then we pop that
stash, the staged changes aren't restored to the index. The result is
that if the user has a mixture of staged and unstaged changes to a file
which is not part of the commit, then afterwards the unstaged changes
will have been unstaged, mixed in with the staged changes again. In
some circumstances this could constitute a loss of work.
There are a few ways to overcome this. We can use the --staged option,
but that's only available in very recent versions of git. We could
perform a complex double-stash:
- git stash push -k -- foo
- git reset -- foo
- git stash push -k -- foo
- [commit]
- git stash pop
- git add -- foo
- git stash pop
Or we could do something like what Magit does to stash only the index.
Any thoughts on what would be best?
In the meantime, I've pushed a version of my previous patch, as I think
it makes sense to implement the stashing, if we do, as a second change.
--
Sean Whitton
This bug report was last modified 2 years and 150 days ago.
Previous Next
GNU bug tracking system
Copyright (C) 1999 Darren O. Benham,
1997,2003 nCipher Corporation Ltd,
1994-97 Ian Jackson.