branch: elpa/magit
commit 70e66c177331e0e60db33457ef5198575bbb584c
Author: Jonas Bernoulli <[email protected]>
Commit: Jonas Bernoulli <[email protected]>

    magit-diff-visit--sides: Absorb magit-diff-visit--range-{from,to}
---
 lisp/magit-diff.el | 25 ++++++++-----------------
 1 file changed, 8 insertions(+), 17 deletions(-)

diff --git a/lisp/magit-diff.el b/lisp/magit-diff.el
index 326636fbfd7..2ad7ac19a87 100644
--- a/lisp/magit-diff.el
+++ b/lisp/magit-diff.el
@@ -1775,8 +1775,14 @@ the Magit-Status buffer for DIRECTORY."
 
 (defun magit-diff-visit--sides ()
   (pcase-let* ((spec (magit-diff--dwim))
-               (old-rev (magit-diff-visit--range-from spec))
-               (new-rev (magit-diff-visit--range-to spec))
+               (`(,old-rev . ,new-rev)
+                (pcase-exhaustive spec
+                  ((pred stringp)
+                   (magit-split-range spec))
+                  (`(,(or 'commit 'stash) . ,rev)
+                   (cons (concat rev "^") rev))
+                  ((pred symbolp)
+                   (cons spec spec))))
                (hunk (magit-diff-visit--hunk))
                ((eieio source value) (oref hunk parent))
                (old-file (or source value))
@@ -1871,21 +1877,6 @@ the Magit-Status buffer for DIRECTORY."
     (max 0 (- (+ (current-column) 2)
               (length (oref section value))))))
 
-(defun magit-diff-visit--range-from (spec)
-  (cond ((consp spec)
-         (concat (cdr spec) "^"))
-        ((stringp spec)
-         (car (magit-split-range spec)))
-        (t
-         spec)))
-
-(defun magit-diff-visit--range-to (spec)
-  (cond ((symbolp spec)
-         spec)
-        ((consp spec)
-         (cdr spec))
-        ((cdr (magit-split-range spec)))))
-
 (defun magit-diff-visit--offset (file rev line)
   (let ((offset 0))
     (with-temp-buffer

Reply via email to