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

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

[nongnu] elpa/git-commit 9413847: magit-diff-dwim: Compare unpushed/unpu


From: ELPA Syncer
Subject: [nongnu] elpa/git-commit 9413847: magit-diff-dwim: Compare unpushed/unpulled changes with merged-base
Date: Mon, 15 Nov 2021 12:57:38 -0500 (EST)

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

    magit-diff-dwim: Compare unpushed/unpulled changes with merged-base
    
    The value of the unpushed/unpulled sections are ranges suitable for
    log.  Diff doesn't deal with ranges but endpoints.  In practice that
    means that if a log range uses ".." then "..." should be used in the
    respective diff and vice-versa.
---
 lisp/magit-diff.el | 9 +++++++--
 1 file changed, 7 insertions(+), 2 deletions(-)

diff --git a/lisp/magit-diff.el b/lisp/magit-diff.el
index b4a951c..f251bae 100644
--- a/lisp/magit-diff.el
+++ b/lisp/magit-diff.el
@@ -1100,8 +1100,8 @@ If no DWIM context is found, nil is returned."
       ([* unstaged] 'unstaged)
       ([* staged] 'staged)
       (unmerged 'unmerged)
-      (unpushed (oref it value))
-      (unpulled (oref it value))
+      (unpushed (magit-diff--range-to-endpoints (oref it value)))
+      (unpulled (magit-diff--range-to-endpoints (oref it value)))
       (branch (let ((current (magit-get-current-branch))
                     (atpoint (oref it value)))
                 (if (equal atpoint current)
@@ -1120,6 +1120,11 @@ If no DWIM context is found, nil is returned."
       (stash (cons 'stash (oref it value)))
       (pullreq (forge--pullreq-range (oref it value) t))))))
 
+(defun magit-diff--range-to-endpoints (range)
+  (cond ((string-match "\\.\\.\\." range) (replace-match ".."  nil nil range))
+        ((string-match "\\.\\."    range) (replace-match "..." nil nil range))
+        (t range)))
+
 (defun magit-diff-read-range-or-commit (prompt &optional secondary-default 
mbase)
   "Read range or revision with special diff range treatment.
 If MBASE is non-nil, prompt for which rev to place at the end of



reply via email to

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