unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
From: Dmitry Gutov <dgutov@yandex.ru>
To: Juri Linkov <juri@linkov.net>
Cc: Manuel Uberti <manuel.uberti@inventati.org>, 52349@debbugs.gnu.org
Subject: bug#52349: 29.0.50; vc-git and diff-mode: stage hunks
Date: Fri, 10 Dec 2021 02:17:18 +0300	[thread overview]
Message-ID: <95d2d999-49ad-13c4-9f25-0935650a1e42@yandex.ru> (raw)
In-Reply-To: <86fsr3uen2.fsf@mail.linkov.net>

On 08.12.2021 21:57, Juri Linkov wrote:
>>> The problem is that 'git apply --cached' doesn't perform the merge
>>> with other changes in the same file, whereas 'git stash pop'
>>> merges committed changes with uncommitted changes.
>>
>> This seems to address our previous discussion, rather than the difference
>> vs. diff-hl.
>>
>> Anyway, I don't know if it is a problem.
>>
>> E.g., you might want to edit a diff (if you know how, which is
>> a significant "if") to commit a slightly different change than what the
>> current file contents show.
> 
> Actually, not quite edit, but only to delete unneeded hunks with ‘k’.

Then it will probably be fine, most of the time?

> The intention is to emulate the interactive command `git add --patch`
> that has many keys:
> 
>    y - stage this hunk
>    n - do not stage this hunk
>    q - quit; do not stage this hunk or any of the remaining ones
>    a - stage this hunk and all later hunks in the file
>    d - do not stage this hunk or any of the later hunks in the file
>    g - select a hunk to go to
>    / - search for a hunk matching the given regex
>    j - leave this hunk undecided, see next undecided hunk
>    J - leave this hunk undecided, see next hunk
>    k - leave this hunk undecided, see previous undecided hunk
>    K - leave this hunk undecided, see previous hunk
>    s - split the current hunk into smaller hunks
>    e - manually edit the current hunk
>    ? - print help
> 
> Instead of these numerous keys, in Emacs it should be sufficient
> just to type ‘k’ (diff-hunk-kill) a few times on the output of ‘C-x v D’
> in the *vc-diff* buffer (and maybe some splitting).

Yes, the commit-patch (external package) workflow. It totally sounds 
fine to me, though it might require some additional explanation when a 
random user tries to take advantage of it (Git's interactive command UI 
is more self-explanatory).

>> But then, I'm not sure you'll want the applied change to be reflected in
>> the file on disk too (as opposed to being saved in the commit). I probably
>> won't (and it would let us avoid the awkward step of seeing the stashing
>> operation temporarily reflected in the file contents, as well as any
>> possible conflicts).
>>
>> Either way, the editing of the diff that's more complex than splitting
>> hunks and deleting some of them will probably be very rare. So the behavior
>> in this scenario doesn't have to affect our choice of implementation.
> 
> I had in mind a different scenario: when you have uncommitted changes
> in one part of the file, and receive an external patch from outside of the repo
> with changes in another part of the file, and need to commit it.

Couldn't you 'git apply external/patch/file/name.ext' first?

> But I admit such scenario is very rare.
>
> So if using ‘git apply --cached’ is the preferred solution,
> then I could finish the patch with it.

I don't have a particularly strong opinion, but the approach with 'git 
apply --cached' followed by 'git commit' seems easier to implement and 
avoids changing the file contents on disk, or risking any of the 
stashes. So I'd try implementing it first and then see if the remaining 
problems are worth the trouble of doing it in a more difficult way.





  reply	other threads:[~2021-12-09 23:17 UTC|newest]

Thread overview: 41+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-12-07  8:59 bug#52349: 29.0.50; vc-git and diff-mode: stage hunks Manuel Uberti via Bug reports for GNU Emacs, the Swiss army knife of text editors
2021-12-07 17:03 ` Juri Linkov
2021-12-07 17:08   ` Manuel Uberti via Bug reports for GNU Emacs, the Swiss army knife of text editors
2021-12-07 19:04     ` Juri Linkov
2021-12-07 17:10 ` Dmitry Gutov
2021-12-07 19:06   ` Juri Linkov
2021-12-08  2:29     ` Dmitry Gutov
2021-12-08 18:57       ` Juri Linkov
2021-12-09 23:17         ` Dmitry Gutov [this message]
2022-02-08 19:57           ` Juri Linkov
2022-02-12  1:43             ` Dmitry Gutov
2022-02-12 19:42               ` Juri Linkov
2022-02-13  1:32                 ` Dmitry Gutov
2022-02-13 19:48                   ` Juri Linkov
2022-02-13 22:51                     ` Dmitry Gutov
2022-02-13 19:56                   ` Juri Linkov
2022-02-13 22:41                     ` Dmitry Gutov
2022-08-21 16:07                       ` Juri Linkov
2022-02-13 22:37                   ` Dmitry Gutov
2022-08-21 18:53                     ` Juri Linkov
2022-08-24  2:06                       ` Dmitry Gutov
2022-08-24 18:20                         ` Juri Linkov
2022-08-24 20:20                           ` Dmitry Gutov
2022-08-27 20:07                             ` Juri Linkov
2022-08-28  0:40                               ` Dmitry Gutov
2022-08-28 19:45                                 ` Juri Linkov
2022-08-28 23:34                                   ` Dmitry Gutov
2022-09-08 19:29                             ` Juri Linkov
2022-09-08 22:48                               ` Sean Whitton
2022-09-10  1:36                                 ` Dmitry Gutov
2022-09-11 15:05                                   ` Juri Linkov
2022-09-11 21:57                                     ` Dmitry Gutov
2022-09-12 18:19                                       ` Juri Linkov
2022-09-19  2:09                                         ` Dmitry Gutov
2022-09-19  6:50                                           ` Juri Linkov
2022-09-19 12:57                                             ` Dmitry Gutov
2022-10-02 18:51                                               ` Juri Linkov
2022-11-04  1:32                                                 ` Dmitry Gutov
2022-08-26 17:11                       ` Filipp Gunbin
2022-08-27 19:56                         ` Juri Linkov
2021-12-07 20:07 ` Lars Ingebrigtsen

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

  List information: https://www.gnu.org/software/emacs/

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

  git send-email \
    --in-reply-to=95d2d999-49ad-13c4-9f25-0935650a1e42@yandex.ru \
    --to=dgutov@yandex.ru \
    --cc=52349@debbugs.gnu.org \
    --cc=juri@linkov.net \
    --cc=manuel.uberti@inventati.org \
    /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.
Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).