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: 52349@debbugs.gnu.org
Subject: bug#52349: 29.0.50; vc-git and diff-mode: stage hunks
Date: Sun, 13 Feb 2022 03:32:19 +0200	[thread overview]
Message-ID: <b8c10195-8e8d-d456-d03a-911e2d5d0054@yandex.ru> (raw)
In-Reply-To: <86v8xjx45h.fsf@mail.linkov.net>

On 12.02.2022 21:42, Juri Linkov wrote:
>> But could you explain the case when the changes to 'vc-diff-internal' are
>> going to be used? If those are only for log-edit-show-diff, I think it'd be
>> better if the new logic was implemented in the new value of
>> log-edit-diff-function, rather than having it spliced into the common code
>> path. Would that result in a lot of code duplication?
> 
> Not much code duplication, thanks for the suggestion, the patch below
> sets log-edit-diff-function for log-edit-show-diff.

Nice.

>> It might also be worth it to thread the 'patch-buffer' value through the
>> backend method arguments (the actual value will be the patch string), so
>> that vc-git-checkin gets it in the 4th argument, rather than having it call
>> (derived-mode-p 'diff-mode) (this feels a little brittle: I suppose which
>> buffer is current during this call might change in the future). It would
>> also automatically weed out backends which don't support this feature,
>> rather than having an attempt to commit from a diff buffer using Hg fail
>> silently.
> 
> I agree that in the first version ‘(derived-mode-p 'diff-mode)’ was brittle.
> But changing the established API with a new argument doesn't look right.

We could make sure to call the function with the current number of 
arguments when a patch-buffer is not used, and with the additional one 
when it is used. Which would automatically force an abort when a backend 
does not support this feature.

> So the next version below uses the buffer-local variable ‘vc-patch-string’.
> In other backends such as Hg it shouldn't fail silently, but it will be
> just less granular, and will commit whole files instead of edited diffs.

That's not the worst approach, but it's bound to trip up some users who 
get used to the new feature's behavior with Git repos, and then try it 
with a different one that does not support this feature properly (such 
as Hg). Without any warning, they will see a different behavior.

What do people think? Is that not a problem?

> There is a new problem however.  After starting vc-log-edit from *vc-diff*,
> and using log-edit-show-diff, it reuses the original buffer *vc-diff*.
> This is not a problem, because the buffer-local variable ‘vc-patch-string’
> is saved in the *vc-log* buffer.  But after deleting *vc-diff*, log-edit-done
> fails on the deleted vc-parent-buffer with
> 
>    Debugger entered--Lisp error: (error "Selecting deleted buffer")
>      vc-finish-logentry()
>      funcall-interactively(vc-finish-logentry)
>      log-edit-done()
> 
> But this is an old problem.  The same error is signaled
> after typing ‘v’ in *vc-dir* buffer, then deleting the
> original *vc-dir* buffer, and trying to type ‘C-c C-c’
> (log-edit-done) in the *vc-log* buffer.

Seems like a slightly different issue, though. Speaking of myself only, 
I can see myself casually killing the vc-diff buffer (especially if I 
just displayed it with C-c C-d), but it seems less likely that I would 
kill the vc-dir buffer when completing the commit.

I suppose 'vc-diff-patch' could use a different buffer name than 
"*vc-diff*" and thus avoid reusing that buffer?

If it brings other problems somehow, oh well. An old bug is something we 
can live with.

But also note that if the patch string was passed as an argument to the 
backend action, this problem might be avoided as well.





  reply	other threads:[~2022-02-13  1:32 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
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 [this message]
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=b8c10195-8e8d-d456-d03a-911e2d5d0054@yandex.ru \
    --to=dgutov@yandex.ru \
    --cc=52349@debbugs.gnu.org \
    --cc=juri@linkov.net \
    /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).