Function: magit-blame--parse-chunk

magit-blame--parse-chunk is a byte-compiled function defined in magit-blame.el.

Signature

(magit-blame--parse-chunk TYPE)

Source Code

;; Defined in ~/.emacs.d/elpa/magit-20260411.1452/magit-blame.el
(defun magit-blame--parse-chunk (type)
  (let (chunk revinfo)
    (unless (looking-at "^\\(.\\{40,\\}\\) \\([0-9]+\\) \\([0-9]+\\) \\([0-9]+\\)")
      (error "Blaming failed due to unexpected output: %s"
             (buffer-substring-no-properties (point) (line-end-position))))
    (with-slots (orig-rev orig-file prev-rev prev-file)
        (setq chunk (magit-blame-chunk
                     :orig-rev                     (match-str 1)
                     :orig-line  (string-to-number (match-str 2))
                     :final-line (string-to-number (match-str 3))
                     :num-lines  (string-to-number (match-str 4))))
      (forward-line)
      (let (done)
        (while (not done)
          (cond ((looking-at "^filename \\(.+\\)")
                 (setq done t)
                 (setf orig-file (magit-decode-git-path (match-str 1))))
                ((looking-at "^previous \\(.\\{40,\\}\\) \\(.+\\)")
                 (setf prev-rev  (match-str 1))
                 (setf prev-file (magit-decode-git-path (match-str 2))))
                ((looking-at "^\\([^ ]+\\) \\(.+\\)")
                 (push (cons (match-str 1)
                             (match-str 2))
                       revinfo)))
          (forward-line)))
      (when (and (eq type 'removal) prev-rev)
        (cl-rotatef orig-rev  prev-rev)
        (cl-rotatef orig-file prev-file)
        (setq revinfo nil)))
    (list chunk revinfo)))