Function: magit-diff-wash-diff
magit-diff-wash-diff is a byte-compiled function defined in
magit-diff.el.
Signature
(magit-diff-wash-diff ARGS)
Source Code
;; Defined in ~/.emacs.d/elpa/magit-20260411.1452/magit-diff.el
(defun magit-diff-wash-diff (args)
(when (magit--any (##string-prefix-p "--color-moved" %) args)
(require 'ansi-color)
(ansi-color-apply-on-region (point-min) (point-max)))
(cond
((looking-at "^Submodule")
(magit-diff-wash-submodule))
((looking-at "^\\* Unmerged path \\(.*\\)")
(let ((file (magit-decode-git-path (match-str 1))))
(magit-delete-line)
(unless (and (derived-mode-p 'magit-status-mode)
(not (member "--cached" args)))
(magit-insert-section (file file)
(insert (propertize
(format "unmerged %s%s" file
(pcase (cddr (car (magit-file-status file)))
('(?D ?D) " (both deleted)")
('(?D ?U) " (deleted by us)")
('(?U ?D) " (deleted by them)")
('(?A ?A) " (both added)")
('(?A ?U) " (added by us)")
('(?U ?A) " (added by them)")
('(?U ?U) "")))
'font-lock-face 'magit-diff-file-heading))
(insert ?\n))))
t)
((looking-at magit-diff-conflict-headline-re)
(let ((long-status (match-str 0))
(status "BUG")
file orig base)
(cond ((equal long-status "merged")
(setq status long-status)
(setq long-status nil))
((setq status
(pcase-exhaustive long-status
("added in remote" "new file")
("added in both" "new file")
("added in local" "new file")
("removed in both" "removed")
("changed in both" "changed")
("removed in local" "removed")
("removed in remote" "removed")))))
(magit-delete-line)
(while (looking-at
"^ \\([^ ]+\\) +[0-9]\\{6\\} \\([a-z0-9]\\{40,\\}\\) \\(.+\\)$")
(magit-bind-match-strings (side _blob name) nil
(pcase side
("result" (setq file name))
("our" (setq orig name))
("their" (setq file name))
("base" (setq base name))))
(magit-delete-line))
(when orig (setq orig (magit-decode-git-path orig)))
(when file (setq file (magit-decode-git-path file)))
(magit-diff-insert-file-section
(or file base) orig status nil nil nil nil long-status)))
;; The files on this line may be ambiguous due to whitespace.
;; That's okay. We can get their names from subsequent headers.
((looking-at "^diff --\
\\(?:\\(?1:git\\) \\(?:\\(?2:.+?\\) \\2\\)?\
\\|\\(?:cc\\|combined\\) \\(?3:.+\\)\\)")
(let ((status (cond ((equal (match-str 1) "git") "modified")
((derived-mode-p 'magit-revision-mode) "resolved")
(t "unmerged")))
(orig nil)
(file (or (match-str 2) (match-str 3)))
(header (list (buffer-substring-no-properties
(line-beginning-position) (1+ (line-end-position)))))
(modes nil)
(rename nil)
(binary nil))
(magit-delete-line)
(while (not (or (eobp)
(looking-at magit-diff-headline-re)
(looking-at magit-log-heading-re)))
(cond
((looking-at "old mode \\(?:[^\n]+\\)\nnew mode \\(?:[^\n]+\\)\n")
(setq modes (match-str 0)))
((looking-at "deleted file .+\n")
(setq status "deleted"))
((looking-at "new file .+\n")
(setq status "new file"))
((looking-at "rename from \\(.+\\)\nrename to \\(.+\\)\n")
(setq rename (match-str 0))
(setq orig (match-str 1))
(setq file (match-str 2))
(setq status "renamed"))
((looking-at "copy from \\(.+\\)\ncopy to \\(.+\\)\n")
(setq orig (match-str 1))
(setq file (match-str 2))
(setq status "new file"))
((looking-at "similarity index .+\n"))
((looking-at "dissimilarity index .+\n"))
((looking-at "index .+\n"))
((looking-at "--- \\(.+?\\)\t?\n")
(unless (equal (match-str 1) "/dev/null")
(setq orig (match-str 1))))
((looking-at "\\+\\+\\+ \\(.+?\\)\t?\n")
(unless (equal (match-str 1) "/dev/null")
(setq file (match-str 1))))
((looking-at "Binary files .+ and .+ differ\n")
(setq binary t))
((looking-at "Binary files differ\n")
(setq binary t))
;; TODO Use all combined diff extended headers.
((looking-at "mode .+\n"))
((error "BUG: Unknown extended header: %S"
(buffer-substring (point) (line-end-position)))))
;; These headers are treated as some sort of special hunk.
(unless (or (string-prefix-p "old mode" (match-str 0))
(string-prefix-p "rename" (match-str 0)))
(push (match-str 0) header))
(magit-delete-match))
(when orig
(setq orig (magit-decode-git-path orig)))
(setq file (magit-decode-git-path file))
(setq header (nreverse header))
;; KLUDGE `git-log' ignores `--no-prefix' when `-L' is used.
(when (and (derived-mode-p 'magit-log-mode)
(seq-some (##string-prefix-p "-L" %)
magit-buffer-log-args))
(when orig
(setq orig (substring orig 2)))
(setq file (substring file 2))
(setq header (list (save-excursion
(string-match "diff [^ ]+" (car header))
(format "%s %s %s\n"
(match-str 0 (car header))
(or orig file)
(or file orig)))
(format "--- %s\n" (or orig "/dev/null"))
(format "+++ %s\n" (or file "/dev/null")))))
(setq header (string-join header))
(magit-diff-insert-file-section
file orig status modes rename header binary nil)))))