[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)
- [nongnu] elpa/git-commit updated (a3b9b00702 -> 27099441a0), ELPA Syncer, 2023/09/05
- [nongnu] elpa/git-commit 4a701c1bdc 3/8: magit-split-range: Handle edge-cases,
ELPA Syncer <=
- [nongnu] elpa/git-commit 363e5acffe 5/8: magit-thingatpt--git-revision: Trim parentheses and punctuation, ELPA Syncer, 2023/09/05
- [nongnu] elpa/git-commit 728685f7be 2/8: magit-read-range-or-commit: Cosmetics, ELPA Syncer, 2023/09/05
- [nongnu] elpa/git-commit 88f4b93b10 1/8: magit-patch-create: Improve a prompt, ELPA Syncer, 2023/09/05
- [nongnu] elpa/git-commit 8220f94b82 4/8: magit-hash-range: Properly validate, ELPA Syncer, 2023/09/05
- [nongnu] elpa/git-commit ec95f00b1b 6/8: magit-thingatpt--git-revision: Filter out some mismatches, ELPA Syncer, 2023/09/05
- [nongnu] elpa/git-commit a3b7cdc486 7/8: git-revision-range: New thing-at-point type, ELPA Syncer, 2023/09/05
- [nongnu] elpa/git-commit 27099441a0 8/8: Offer textual range at point as next history element, ELPA Syncer, 2023/09/05