bug-gnu-emacs
[Top][All Lists]
Advanced

[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: Wed, 24 Aug 2022 23:20:59 +0300
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101 Thunderbird/91.9.1

On 24.08.2022 21:20, 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.
This uses the same command `git diff --cached --quiet` as in commit-patch
that you mentioned earlier
https://github.com/caldwell/commit-patch/blob/master/commit-patch#L215-L217
(but with an error message shorter than "Cowardly refusing to do anything
potentially harmful":)

diff --git a/lisp/vc/vc-git.el b/lisp/vc/vc-git.el
index 8458b40714..fa09ecf472 100644
--- a/lisp/vc/vc-git.el
+++ b/lisp/vc/vc-git.el
@@ -944,6 +944,8 @@ vc-git-checkin
                (let ((default-directory (file-name-directory file1)))
                  (make-nearby-temp-file "git-msg")))))
      (when vc-git-patch-string
+      (unless (eq (vc-git-command nil t nil "diff" "--cached" "--quiet") 0)
+        (error "Index not empty"))

user-error, maybe?

        (let ((patch-file (make-temp-file "git-patch")))
          (with-temp-file patch-file
            (insert vc-git-patch-string))

Looking great otherwise. Please install whenever you think it's ready.





reply via email to

[Prev in Thread] Current Thread [Next in Thread]