Function: magit-apply-hunk

magit-apply-hunk is a byte-compiled function defined in magit-apply.el.

Signature

(magit-apply-hunk HUNK &rest ARGS)

Source Code

;; Defined in ~/.emacs.d/elpa/magit-20260411.1452/magit-apply.el
(defun magit-apply-hunk (hunk &rest args)
  (let ((file (oref hunk parent)))
    (when (magit-diff--combined-p file)
      (user-error "Cannot un-/stage resolution hunks.  Stage the whole file"))
    (let* ((header (car (oref hunk value)))
           (header (and (symbolp header) header))
           (content (magit-apply--section-content hunk)))
      (magit-apply-patch
       file args
       (concat (magit-diff-file-header hunk (not (eq header 'rename)))
               (if header
                   content
                 (magit-apply--adjust-hunk-new-start content)))))))