Function: magit-patch-save
magit-patch-save is an autoloaded, interactive and byte-compiled
function defined in magit-patch.el.
Signature
(magit-patch-save FILE &optional ARG)
Documentation
Write current diff into patch FILE.
What arguments are used to create the patch depends on the value
of magit-patch-save-arguments and whether a prefix argument is
used.
If the value is the symbol buffer, then use the same arguments
as the buffer. With a prefix argument use no arguments.
If the value is a list beginning with the symbol exclude, then
use the same arguments as the buffer except for those matched by
entries in the cdr of the list. The comparison is done using
string-prefix-p. With a prefix argument use the same arguments
as the buffer.
If the value is a list of strings (including the empty list), then use those arguments. With a prefix argument use the same arguments as the buffer.
Of course the arguments that are required to actually show the same differences as those shown in the buffer are always used.
Key Bindings
Source Code
;; Defined in ~/.emacs.d/elpa/magit-20260411.1452/magit-patch.el
;;;###autoload
(defun magit-patch-save (file &optional arg)
"Write current diff into patch FILE.
What arguments are used to create the patch depends on the value
of `magit-patch-save-arguments' and whether a prefix argument is
used.
If the value is the symbol `buffer', then use the same arguments
as the buffer. With a prefix argument use no arguments.
If the value is a list beginning with the symbol `exclude', then
use the same arguments as the buffer except for those matched by
entries in the cdr of the list. The comparison is done using
`string-prefix-p'. With a prefix argument use the same arguments
as the buffer.
If the value is a list of strings (including the empty list),
then use those arguments. With a prefix argument use the same
arguments as the buffer.
Of course the arguments that are required to actually show the
same differences as those shown in the buffer are always used."
(interactive (list (read-file-name "Write patch file: " default-directory)
current-prefix-arg))
(unless (derived-mode-p 'magit-diff-mode)
(user-error "Only diff buffers can be saved as patches"))
(let ((rev magit-buffer-diff-range)
(typearg magit-buffer-diff-typearg)
(args magit-buffer-diff-args)
(files magit-buffer-diff-files))
(cond ((eq magit-patch-save-arguments 'buffer)
(when arg
(setq args nil)))
((eq (car-safe magit-patch-save-arguments) 'exclude)
(unless arg
(setq args
(cl-set-difference args (cdr magit-patch-save-arguments)
:test #'equal))))
((not arg)
(setq args magit-patch-save-arguments)))
(with-temp-file file
(magit-git-insert "diff" rev "-p" typearg args "--" files)))
(magit-refresh))