emacs-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

emacs-29 de3df3bc51: * lisp/vc/vc-git.el (vc-git-checkin): Pass vc-git-d


From: Sean Whitton
Subject: emacs-29 de3df3bc51: * lisp/vc/vc-git.el (vc-git-checkin): Pass vc-git-diff-switches.
Date: Tue, 3 Jan 2023 01:26:38 -0500 (EST)

branch: emacs-29
commit de3df3bc51e056d179e572fc0fc3bed89b372662
Author: Sean Whitton <spwhitton@spwhitton.name>
Commit: Sean Whitton <spwhitton@spwhitton.name>

    * lisp/vc/vc-git.el (vc-git-checkin): Pass vc-git-diff-switches.
---
 lisp/vc/vc-git.el | 13 ++++++++++---
 1 file changed, 10 insertions(+), 3 deletions(-)

diff --git a/lisp/vc/vc-git.el b/lisp/vc/vc-git.el
index 7413ecb79b..06bf927831 100644
--- a/lisp/vc/vc-git.el
+++ b/lisp/vc/vc-git.el
@@ -992,6 +992,8 @@ It is based on `log-edit-mode', and has Git-specific 
extensions."
   (let ((vc-git-patch-string patch-string))
     (vc-git-checkin nil comment)))
 
+(autoload 'vc-switches "vc")
+
 (defun vc-git-checkin (files comment &optional _rev)
   (let* ((file1 (or (car files) default-directory))
          (root (vc-git-root file1))
@@ -1021,7 +1023,14 @@ It is based on `log-edit-mode', and has Git-specific 
extensions."
         ;; currently staged to the index.  So remove the whole file diff
         ;; from the patch because commit will take it from the index.
         (with-temp-buffer
-          (vc-git-command (current-buffer) t nil "diff" "--cached")
+          ;; If the user has switches like -D, -M etc. in their
+          ;; `vc-git-diff-switches', we must pass them here too, or
+          ;; our string matches will fail.
+          (if vc-git-diff-switches
+              (apply #'vc-git-command (current-buffer) t nil
+                     "diff" "--cached" (vc-switches 'git 'diff))
+            ;; Following code doesn't understand plain diff(1) output.
+            (user-error "Cannot commit patch with nil `vc-git-diff-switches'"))
           (goto-char (point-min))
           (let ((pos (point)) file-diff file-beg)
             (while (not (eobp))
@@ -1291,8 +1300,6 @@ This prompts for a branch to merge from."
   :type 'boolean
   :version "26.1")
 
-(autoload 'vc-switches "vc")
-
 (defun vc-git-print-log (files buffer &optional shortlog start-revision limit)
   "Print commit log associated with FILES into specified BUFFER.
 If SHORTLOG is non-nil, use a short format based on `vc-git-root-log-format'.



reply via email to

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