Function: magit--git-wash

magit--git-wash is a byte-compiled function defined in magit-git.el.

Signature

(magit--git-wash WASHER KEEP-ERROR &rest ARGS)

Documentation

Execute git with ARGS, inserting washed output at point.

Like magit-git-wash but if KEEP-ERROR is nil and an error occurs, also insert standard error. If KEEP-ERROR is wash-anyway, insert and wash standard output even in case of an error.

Source Code

;; Defined in ~/.emacs.d/elpa/magit-20260411.1452/magit-git.el
(defun magit--git-wash (washer keep-error &rest args)
  "Execute git with ARGS, inserting washed output at point.

Like `magit-git-wash' but if KEEP-ERROR is nil and an error occurs, also
insert standard error.  If KEEP-ERROR is `wash-anyway', insert and wash
standard output even in case of an error."
  (declare (indent 2))
  (setq args (flatten-tree args))
  (let ((beg (point))
        (exit (magit--git-insert (and keep-error 'full) args)))
    (when (stringp exit)
      (goto-char beg)
      (insert (magit--propertize-face exit 'error))
      (insert (if (bolp) "\n" "\n\n")))
    (if (= (point) beg)
        (magit-cancel-section)
      (unless (bolp)
        (insert "\n"))
      (when (or (equal exit 0)
                (eq keep-error 'wash-anyway))
        (save-restriction
          (narrow-to-region beg (point))
          (goto-char beg)
          (funcall washer args))
        (when (or (= (point) beg)
                  (= (point) (1+ beg)))
          (magit-cancel-section))
        (magit-maybe-make-margin-overlay)))
    exit))