Skip to content

Commit

Permalink
magit--git-wash: Support commands whose non-zero status isn't an error
Browse files Browse the repository at this point in the history
This fixes a regression introduced by [1: 78a979f], which did not
take into account that "git diff --no-index" exits with 1 if there
are differences (like "diff" does).

Closes #5094.

1: 2023-03-18 78a979f
   Support displaying errors that occur when washing a section
  • Loading branch information
tarsius committed Mar 20, 2024
1 parent 4d378d9 commit 0e8f25a
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 2 deletions.
4 changes: 3 additions & 1 deletion lisp/magit-diff.el
Original file line number Diff line number Diff line change
Expand Up @@ -2170,7 +2170,9 @@ keymap is the parent of their keymaps."
(setq magit-git-global-arguments
(append magit-diff--reset-non-color-moved
magit-git-global-arguments)))
(magit--git-wash #'magit-diff-wash-diffs keep-error cmd args)))
(magit--git-wash #'magit-diff-wash-diffs
(if (member "--no-index" args) 'wash-anyway keep-error)
cmd args)))

(defun magit-diff--maybe-add-stat-arguments (args)
(if (member "--stat" args)
Expand Down
3 changes: 2 additions & 1 deletion lisp/magit-git.el
Original file line number Diff line number Diff line change
Expand Up @@ -597,7 +597,8 @@ call function WASHER with ARGS as its sole argument."
(magit-cancel-section)
(unless (bolp)
(insert "\n"))
(when (equal exit 0)
(when (or (equal exit 0)
(eq keep-error 'wash-anyway))
(save-restriction
(narrow-to-region beg (point))
(goto-char beg)
Expand Down

0 comments on commit 0e8f25a

Please sign in to comment.