Function: majutsu-diff--attach-file-metadata

majutsu-diff--attach-file-metadata is a natively compiled function defined in majutsu-diff.el.

Signature

(majutsu-diff--attach-file-metadata METADATA)

Documentation

Attach ordered structured METADATA to washed file sections.

Fail closed unless section count, order, paths, and operation statuses all agree with the structured metadata.

Source Code

;; Defined in /nix/store/jagqw3nms546pad0gxi5f3wsckk6pji7-emacs-packages-deps/share/emacs/site-lisp/majutsu-diff.el
(defun majutsu-diff--attach-file-metadata (metadata)
  "Attach ordered structured METADATA to washed file sections.
Fail closed unless section count, order, paths, and operation statuses all
agree with the structured metadata."
  (setq majutsu-diff--file-metadata-by-section (make-hash-table :test #'eq))
  (let ((root (or (bound-and-true-p magit-insert-section--current)
                  magit-root-section))
        real-files stat-files)
    (when root
      (magit-map-sections
       (lambda (section)
         (when (magit-section-match 'jj-file section)
           (if (oref section header)
               (push section real-files)
             (push section stat-files))))
       root))
    (setq real-files (nreverse real-files)
          stat-files (nreverse stat-files))
    (when (and metadata
               (= (length real-files) (length metadata))
               (cl-every #'identity
                         (cl-mapcar #'majutsu-diff--file-metadata-matches-section-p
                                    metadata real-files)))
      (cl-mapc
       (lambda (section entry)
         (majutsu-diff--set-section-path section (plist-get entry :target))
         (puthash section entry majutsu-diff--file-metadata-by-section))
       real-files metadata)
      (when (= (length stat-files) (length metadata))
        (cl-mapc (lambda (section entry)
                   (oset section value (plist-get entry :target)))
                 stat-files metadata)))))