1
Fork 0
mirror of git://git.sv.gnu.org/emacs.git synced 2026-01-09 05:01:02 -08:00

* lisp/vc/vc-git.el (vc-git-checkin): Pass vc-git-diff-switches.

This commit is contained in:
Sean Whitton 2023-01-02 23:08:39 -07:00
parent 6dd3e352f4
commit de3df3bc51

View file

@ -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'.