GNU bug report logs - #52349
29.0.50; vc-git and diff-mode: stage hunks

Previous Next

Package: emacs;

Reported by: Manuel Uberti <manuel.uberti <at> inventati.org>

Date: Tue, 7 Dec 2021 09:00:02 UTC

Severity: normal

Fixed in version 29.0.50

Done: Juri Linkov <juri <at> linkov.net>

Bug is archived. No further changes may be made.

Full log


View this message in rfc822 format

From: Sean Whitton <spwhitton <at> spwhitton.name>
To: Juri Linkov <juri <at> linkov.net>, Dmitry Gutov <dgutov <at> yandex.ru>, 52349 <at> debbugs.gnu.org
Subject: bug#52349: 29.0.50; vc-git and diff-mode: stage hunks
Date: Thu, 08 Sep 2022 15:48:42 -0700
Hello,

On Thu 08 Sep 2022 at 10:29PM +03, Juri Linkov wrote:

>>>>>> Perhaps we should also check that there are no existing staged changes for
>>>>>> those files, and if so, abort? This way we won't commit anything else by
>>>>>> accident.
>>>>> Will do later.
>>>> Shouldn't be too hard, if we don't try to do it eagerly. Just add a check
>>>> inside (when vc-git-patch-string ...) in vc-git-checkin.
>>> +      (unless (eq (vc-git-command nil t nil "diff" "--cached" "--quiet") 0)
>>> +        (error "Index not empty"))
>>
>> user-error, maybe?
>
> Oh, it has a sad shortcoming: this feature can't be used when a new file
> is added with 'C-x v v' since new files get added directly to the index,
> and checking for the empty index raises the error for the whole changeset
> with modified old files and new files.

VC is a bit strange with adding and deleting files with Git -- doing so
stages the additions or deletions, whereas in every other case VC
doesn't use the staging area at all, except as an implementation detail
when actually committing.  So when you add or delete files you end up in
a sort of transient state that you aren't otherwise in.

What I've been doing is immediately committing any additions or
deletions and then preparing --amend commits with the changes to
existing files, using your new feature.

Would it be too disruptive to make "registering" a new file with Git a
no-op, and then require the user to commit it by going to VC Dir and
marking it?  That's the only alternative I can think of, given that it's
common to have lots of untracked, unignored files around you don't
intend ever to commit.

-- 
Sean Whitton




This bug report was last modified 2 years and 195 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.