Commit c7bbe3e9 authored by Kyle Meyer's avatar Kyle Meyer

magit-reverse-files: Guard against empty section list

magit-reverse-files removes binary files from `sections', so it may
end up nil.  At the time this code was introduced, passing nil to
magit-reverse-apply wasn't an issue, but it leads to a type error in
magit-apply-patch since ddce6ce4 (sections: Use oref instead of
dedicated slot accessors, 2018-01-17).

Note: magit-discard-files--discard performs a similar removal of
binary files, but it doesn't lead to a type error because it already
guards against the nil case.
parent 3ae75c86
......@@ -648,9 +648,10 @@ so causes the change to be applied to the index as well."
(--separate (member (oref it value) bs)
sections))))
(magit-confirm-files 'reverse (--map (oref it value) sections))
(if (= (length sections) 1)
(magit-reverse-apply (car sections) 'magit-apply-diff args)
(magit-reverse-apply sections 'magit-apply-diffs args))
(cond ((= (length sections) 1)
(magit-reverse-apply (car sections) 'magit-apply-diff args))
(sections
(magit-reverse-apply sections 'magit-apply-diffs args)))
(when binaries
(user-error "Cannot reverse binary files"))))
......
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