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 #47 received at 60126 <at> debbugs.gnu.org (full text, mbox):
On 21/12/2022 01:10, Sean Whitton wrote:
> 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.
IIUC the --staged option is indeed limited to the very new Git, but that
option is used when creating a stash (when we want to stash the staging
area only).
When restoring a stash, to reinstate the stashed index, you would use
the option --index. It's older than --staged (e.g. it's available in Git
2.22.0, and that's as far back as the docs at git-scm.com/docs go). Not
sure if it's in Debian Stable or not.
Regarding the alternatives -- double stashing, or the Magit way, it's
hard to form a strong opinion before examining them in detail (I trust
you can make a good choice).
For completeness, though, here's a way to implement 'git push --staged'
with Git plumbing manually: https://stackoverflow.com/a/72582276/615245
And as for a 'git pop --index' substitute, if the stash contains only
the index area stuff, it might be as easy as
git diff stash@{0}^..stash@{0} > patch.diff
git apply --cached patch.diff
git stash drop
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.