Commit d4240f5e authored by Kyle Meyer's avatar Kyle Meyer Committed by Jonas Bernoulli

magit-staged-binary-files: Generalize and rename

This function exists so that we can detect when a user is attempting
to perform an invalid operation on a binary file and give an
informative error message.  To make the reverse checks more
comprehensive, we'll need to check diffs other than the one between
HEAD and the index.  In preparation for this, adjust
magit-staged-binary-files to take an arbitrary list of of git-diff
parent fa0e336c
......@@ -586,7 +586,7 @@ without requiring confirmation."
(when new-files
(magit-call-git "add" "--" new-files)
(magit-call-git "reset" "--" new-files))
(let ((binaries (magit-staged-binary-files)))
(let ((binaries (magit-binary-files "--cached")))
(when binaries
(setq sections
(--remove (member (oref it value) binaries)
......@@ -644,7 +644,7 @@ so causes the change to be applied to the index as well."
(defun magit-reverse-files (sections args)
(pcase-let ((`(,binaries ,sections)
(let ((bs (magit-staged-binary-files)))
(let ((bs (magit-binary-files "--cached")))
(--separate (member (oref it value) bs)
(magit-confirm-files 'reverse (--map (oref it value) sections))
......@@ -742,11 +742,12 @@ tracked file."
(and nomodules "--ignore-submodules")
(magit-headish) "--" files))
(defun magit-staged-binary-files ()
(defun magit-binary-files (&rest args)
(--mapcat (and (string-match "^-\t-\t\\(.+\\)" it)
(list (match-string 1 it)))
(magit-git-items "diff" "-z" "--cached"
"--numstat" "--ignore-submodules")))
(apply #'magit-git-items
"diff" "-z" "--numstat" "--ignore-submodules"
(defun magit-unmerged-files ()
(magit-git-items "diff-files" "-z" "--name-only" "--diff-filter=U"))
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment