Function: vc-git-prepare-patch
vc-git-prepare-patch is a byte-compiled function defined in
vc-git.el.gz.
Signature
(vc-git-prepare-patch REV)
Source Code
;; Defined in /usr/src/emacs/lisp/vc/vc-git.el.gz
(defun vc-git-prepare-patch (rev)
(with-current-buffer (generate-new-buffer " *vc-git-prepare-patch*")
(vc-git-command t 0 nil "format-patch"
"--no-numbered" "--stdout" "-n1" rev)
(condition-case _
(let (subject body-start patch-start patch-end)
(goto-char (point-min))
(re-search-forward "^Subject: \\(.*\\)")
(setq subject (match-string 1))
(while (progn (forward-line 1)
(looking-at "[\s\t]\\(.*\\)"))
(setq subject (format "%s %s" subject (match-string 1))))
(goto-char (point-min))
(re-search-forward "\n\n")
(setq body-start (point))
(if ;; If the user has added any of these to
;; `vc-git-diff-switches' then they expect to see the
;; diffstat in *vc-diff* buffers.
(cl-intersection '("--stat"
"--patch-with-stat"
"--compact-summary")
(vc-switches 'git 'diff)
:test #'equal)
(progn (re-search-forward "^---$")
(setq patch-start (pos-bol 2)))
(re-search-forward "^diff --git a/")
(setq patch-start (pos-bol)))
(re-search-forward "^-- $")
(setq patch-end (pos-bol))
(list :subject subject
:body-start body-start
:patch-start patch-start
:patch-end patch-end
:buffer (current-buffer)))
(search-failed (error "git-format-patch output parse failure")))))