From de3df3bc51e056d179e572fc0fc3bed89b372662 Mon Sep 17 00:00:00 2001 From: Sean Whitton Date: Mon, 2 Jan 2023 23:08:39 -0700 Subject: [PATCH] * 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 7413ecb79b1..06bf927831d 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'. -- 2.39.2