Function: majutsu-diff-wash-file
majutsu-diff-wash-file is a natively compiled function defined in
majutsu-diff.el.
Signature
(majutsu-diff-wash-file)
Documentation
Parse a single file section at point and wrap it in Magit sections.
Source Code
;; Defined in /nix/store/jagqw3nms546pad0gxi5f3wsckk6pji7-emacs-packages-deps/share/emacs/site-lisp/majutsu-diff.el
(defun majutsu-diff-wash-file ()
"Parse a single file section at point and wrap it in Magit sections."
(when (looking-at "^diff --git ")
(let* ((diff-line (buffer-substring-no-properties
(line-beginning-position) (line-end-position)))
(metadata (pop majutsu-diff--file-metadata-queue))
(fallback
(if (string-match "^diff --git a/\\(.*\\) b/\\(.*\\)$" diff-line)
(or (match-string 2 diff-line) (match-string 1 diff-line))
(string-remove-prefix "diff --git " diff-line)))
(file (or (plist-get metadata :target) fallback))
(headers nil)
(diff-header (buffer-substring-no-properties
(line-beginning-position)
(min (point-max) (1+ (line-end-position))))))
;; Drop the diff header line; keep the rest of the text in place.
(majutsu-diff--delete-line)
;; Collect extended headers
(while (and (not (eobp))
(not (looking-at "^diff --git "))
(not (looking-at "^@@ ")))
(push (buffer-substring-no-properties (line-beginning-position)
(min (point-max)
(1+ (line-end-position))))
headers)
(majutsu-diff--delete-line))
(setq headers (nreverse headers))
(magit-insert-section
(jj-file file nil
:header (concat diff-header (string-join headers "")))
(magit-insert-heading
(propertize (majutsu-diff--file-heading file headers)
'font-lock-face 'magit-diff-file-heading))
;; Hunk bodies remain in the buffer; just wrap them.
(while (and (not (eobp)) (looking-at "^@@ "))
(majutsu-diff-wash-hunk file))
(insert "\n"))))
t)