emacs-elpa-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[nongnu] elpa/git-commit 0f64ac4abd 4/6: magit-apply-{hunks, hunk, regio


From: ELPA Syncer
Subject: [nongnu] elpa/git-commit 0f64ac4abd 4/6: magit-apply-{hunks, hunk, region}: Cosmetics
Date: Tue, 12 Sep 2023 18:59:31 -0400 (EDT)

branch: elpa/git-commit
commit 0f64ac4abd791b20a8e371a611f8869036561c0c
Author: Jonas Bernoulli <jonas@bernoul.li>
Commit: Jonas Bernoulli <jonas@bernoul.li>

    magit-apply-{hunks,hunk,region}: Cosmetics
---
 lisp/magit-apply.el | 53 ++++++++++++++++++++++++++++-------------------------
 1 file changed, 28 insertions(+), 25 deletions(-)

diff --git a/lisp/magit-apply.el b/lisp/magit-apply.el
index 27a9cf734f..ece5838587 100644
--- a/lisp/magit-apply.el
+++ b/lisp/magit-apply.el
@@ -185,38 +185,41 @@ adjusted as \"@@ -10,6 +10,7 @@\" and \"@@ -18,6 +19,7 
@@\"."
 (defun magit-apply--adjust-hunk-new-start (hunk)
   (car (magit-apply--adjust-hunk-new-starts (list hunk))))
 
-(defun magit-apply-hunks (sections &rest args)
-  (let ((section (oref (car sections) parent)))
-    (when (magit-diff--combined-p section)
+(defun magit-apply-hunks (hunks &rest args)
+  (let ((file (oref (car hunks) parent)))
+    (when (magit-diff--combined-p file)
       (user-error "Cannot un-/stage resolution hunks.  Stage the whole file"))
     (magit-apply-patch
-     section args
-     (concat (oref section header)
+     file args
+     (concat (oref file header)
              (mapconcat #'identity
                         (magit-apply--adjust-hunk-new-starts
-                         (mapcar #'magit-apply--section-content sections))
+                         (mapcar #'magit-apply--section-content hunks))
                         "")))))
 
-(defun magit-apply-hunk (section &rest args)
-  (when (magit-diff--combined-p (magit-section-parent section))
-    (user-error "Cannot un-/stage resolution hunks.  Stage the whole file"))
-  (let* ((header (car (oref section value)))
-         (header (and (symbolp header) header))
-         (content (magit-apply--section-content section)))
+(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)))))))
+
+(defun magit-apply-region (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"))
     (magit-apply-patch
-     (oref section parent) args
-     (concat (magit-diff-file-header section (not (eq header 'rename)))
-             (if header
-                 content
-               (magit-apply--adjust-hunk-new-start content))))))
-
-(defun magit-apply-region (section &rest args)
-  (when (magit-diff--combined-p (magit-section-parent section))
-    (user-error "Cannot un-/stage resolution hunks.  Stage the whole file"))
-  (magit-apply-patch (oref section parent) args
-                     (concat (magit-diff-file-header section)
-                             (magit-apply--adjust-hunk-new-start
-                              (magit-diff-hunk-region-patch section args)))))
+     file args
+     (concat (magit-diff-file-header hunk)
+             (magit-apply--adjust-hunk-new-start
+              (magit-diff-hunk-region-patch hunk args))))))
 
 (defun magit-apply-patch (section:s args patch)
   (let* ((files (if (atom section:s)



reply via email to

[Prev in Thread] Current Thread [Next in Thread]