branch: elpa/git-commit
commit 71630e4db1ff69a8e2c13f112c21b26d8bddf1e6
Author: Jonas Bernoulli <[email protected]>
Commit: Jonas Bernoulli <[email protected]>

    magit-insert-revision-notes: Avoid having to cancel sections
---
 lisp/magit-diff.el | 21 +++++++++------------
 1 file changed, 9 insertions(+), 12 deletions(-)

diff --git a/lisp/magit-diff.el b/lisp/magit-diff.el
index 90cc8ddadb..b0ac153557 100644
--- a/lisp/magit-diff.el
+++ b/lisp/magit-diff.el
@@ -2723,20 +2723,17 @@ or a ref which is not a branch, then it inserts 
nothing."
 
 (defun magit-insert-revision-notes ()
   "Insert commit notes into a revision buffer."
-  (let* ((var "core.notesRef")
-         (def (or (magit-get var) "refs/notes/commits")))
+  (let ((default (or (magit-get "core.notesRef") "refs/notes/commits")))
     (dolist (ref (magit-list-active-notes-refs))
-      (magit-insert-section
-          ( notes ref (not (equal ref def))
+      (when-let ((note (with-temp-buffer
+                         (magit-git-insert "-c" (concat "core.notesRef=" ref)
+                                           "notes" "show" 
magit-buffer-revision)
+                         (magit-revision--wash-message))))
+        (magit-insert-section
+          ( notes ref (not (equal ref default))
             :heading-highlight-face 'magit-diff-hunk-heading-highlight)
-        (let ((beg (point))
-              (rev magit-buffer-revision))
-          (insert (with-temp-buffer
-                    (magit-git-insert "-c" (concat "core.notesRef=" ref)
-                                      "notes" "show" rev)
-                    (magit-revision--wash-message)))
-          (if (= (point) beg)
-              (magit-cancel-section)
+          (let ((beg (point)))
+            (insert note)
             (goto-char beg)
             (end-of-line)
             (insert (format " (%s)"

Reply via email to