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

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

[nongnu] elpa/git-commit 91ef0822d3 04/18: magit-get-section: Compare co


From: ELPA Syncer
Subject: [nongnu] elpa/git-commit 91ef0822d3 04/18: magit-get-section: Compare constant values
Date: Fri, 25 Mar 2022 13:58:19 -0400 (EDT)

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

    magit-get-section: Compare constant values
    
    Previously only `magit-section-ident' returned a constant value for
    sections that need special handling, but we need to use that value
    in `magit-get-section' as well.
    
    This commit just implements the most straight forward fix.  The next
    commit improves the `magit-section-ident-value', replacing the newly
    added secondary function.
---
 lisp/magit-section.el | 37 ++++++++++++++++++++-----------------
 1 file changed, 20 insertions(+), 17 deletions(-)

diff --git a/lisp/magit-section.el b/lisp/magit-section.el
index 526a4b2ab8..7b2fb4d702 100644
--- a/lisp/magit-section.el
+++ b/lisp/magit-section.el
@@ -401,23 +401,25 @@ never modify it.")
   "Return an unique identifier for SECTION.
 The return value has the form ((TYPE . VALUE)...)."
   (with-slots (type value parent) section
-    (cons (cons type
-                (cond ((eieio-object-p value)
-                       (magit-section-ident-value value))
-                      ((not (memq type '(unpulled unpushed))) value)
-                      ((string-match-p "@{upstream}" value) value)
-                      ;; Unfortunately Git chokes on "@{push}" when
-                      ;; the value of `push.default' does not allow a
-                      ;; 1:1 mapping.  Arbitrary commands may consult
-                      ;; the section value so we cannot use "@{push}".
-                      ;; But `unpushed' and `unpulled' sections should
-                      ;; keep their identity when switching branches
-                      ;; so we have to use another value here.
-                      ((string-match-p "\\`\\.\\." value) "..@{push}")
-                      (t "@{push}..")))
+    (cons (cons type (magit-section-ident-value-1 value type))
           (and parent
                (magit-section-ident parent)))))
 
+(defun magit-section-ident-value-1 (value type)
+  (cond ((eieio-object-p value)
+         (magit-section-ident-value value))
+        ((not (memq type '(unpulled unpushed))) value)
+        ((string-match-p "@{upstream}" value) value)
+        ;; Unfortunately Git chokes on "@{push}" when
+        ;; the value of `push.default' does not allow a
+        ;; 1:1 mapping.  Arbitrary commands may consult
+        ;; the section value so we cannot use "@{push}".
+        ;; But `unpushed' and `unpulled' sections should
+        ;; keep their identity when switching branches
+        ;; so we have to use another value here.
+        ((string-match-p "\\`\\.\\." value) "..@{push}")
+        (t "@{push}..")))
+
 (cl-defgeneric magit-section-ident-value (value)
   "Return a constant representation of VALUE.
 VALUE is the value of a `magit-section' object.  If that is an
@@ -441,12 +443,13 @@ instead of in the one whose root `magit-root-section' is."
               (oref section type))
       (while (and ident
                   (pcase-let* ((`(,type . ,value) (car ident))
-                               (value (magit-section-ident-value value)))
+                               (value (magit-section-ident-value-1 value 
type)))
                     (setq section
                           (cl-find-if (lambda (section)
                                         (and (eq (oref section type) type)
-                                             (equal (magit-section-ident-value
-                                                     (oref section value))
+                                             (equal 
(magit-section-ident-value-1
+                                                     (oref section value)
+                                                     (oref section type))
                                                     value)))
                                       (oref section children)))))
         (pop ident))



reply via email to

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