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

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

[nongnu] elpa/git-commit 4a701c1bdc 3/8: magit-split-range: Handle edge-


From: ELPA Syncer
Subject: [nongnu] elpa/git-commit 4a701c1bdc 3/8: magit-split-range: Handle edge-cases
Date: Tue, 5 Sep 2023 21:59:36 -0400 (EDT)

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

    magit-split-range: Handle edge-cases
    
    Previously we returned non-nil for ".." and "...", but those are
    not valid ranges.
    
    For "a...b" ranges we return ((merge-base "a" "b") . "b").  If "a"
    and/or "b" are invalid, we now return nil, instead of (nil . "b").
---
 lisp/magit-git.el | 20 ++++++++++++++------
 1 file changed, 14 insertions(+), 6 deletions(-)

diff --git a/lisp/magit-git.el b/lisp/magit-git.el
index 37dd31cbc8..edf20a4369 100644
--- a/lisp/magit-git.el
+++ b/lisp/magit-git.el
@@ -2507,13 +2507,21 @@ and this option only controls what face is used.")
           "\\([^.][^ \t]*\\)?\\'"))     ; revB
 
 (defun magit-split-range (range)
+  (pcase-let ((`(,beg ,end ,sep) (magit--split-range-raw range)))
+    (and sep
+         (let ((beg (or beg "HEAD"))
+               (end (or end "HEAD")))
+           (if (string-equal (match-string 2 range) "...")
+               (and-let* ((base (magit-git-string "merge-base" beg end)))
+                 (cons base end))
+             (cons beg end))))))
+
+(defun magit--split-range-raw (range)
   (and (string-match magit-range-re range)
-       (let ((beg (or (match-string 1 range) "HEAD"))
-             (end (or (match-string 3 range) "HEAD")))
-         (cons (if (string-equal (match-string 2 range) "...")
-                   (magit-git-string "merge-base" beg end)
-                 beg)
-               end))))
+       (let ((beg (match-string 1 range))
+             (end (match-string 3 range)))
+         (and (or beg end)
+              (list beg end (match-string 2 range))))))
 
 (defun magit-hash-range (range)
   (if (string-match magit-range-re range)



reply via email to

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