[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
bug#52349: 29.0.50; vc-git and diff-mode: stage hunks
From: |
Dmitry Gutov |
Subject: |
bug#52349: 29.0.50; vc-git and diff-mode: stage hunks |
Date: |
Mon, 14 Feb 2022 00:51:54 +0200 |
User-agent: |
Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101 Thunderbird/91.5.0 |
On 13.02.2022 21:48, Juri Linkov wrote:
This is fine, so this patch does this:
(if patch-string
(vc-call-backend backend 'checkin files comment rev patch-string)
(vc-call-backend backend 'checkin files comment rev))
Looks good, thanks!
Sorry, I haven't noticed your emails today before I wrote my own. See if
you like the suggestion in there, but this patch is also fine with me.
Though we might try catching the wrong-number-of-arguments error to
report a friendlier explanation to the user.
Also I added the new arg ‘patch-string’ to vc-checkin and vc-start-logentry.
These are not API calls, so they could use a buffer-local variables instead
of args, but I'm not sure about this less important technical detail.
Since the new args are optional, should be fine.
+ (when patch-string
+ (let ((patch-file (make-temp-file "git-patch")))
+ (with-temp-file patch-file
+ (insert patch-string))
+ (unwind-protect
+ (apply #'vc-git-command nil 0 patch-file
+ (list "apply" "--cached"))
+ (delete-file patch-file))))
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.