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

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

[nongnu] elpa/git-commit a07b46fbe3: magit-thingatpt--git-revision: Avoi


From: ELPA Syncer
Subject: [nongnu] elpa/git-commit a07b46fbe3: magit-thingatpt--git-revision: Avoid some false-positives
Date: Fri, 3 Jun 2022 08:58:27 -0400 (EDT)

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

    magit-thingatpt--git-revision: Avoid some false-positives
    
    The false-positives vs. false-negatives struggle continues.
    
    In the list of commits being rebases a commit may be prefixed
    with "work", but a branch named "work" may also exist.
---
 lisp/magit-git.el | 20 +++++++++++++++++++-
 1 file changed, 19 insertions(+), 1 deletion(-)

diff --git a/lisp/magit-git.el b/lisp/magit-git.el
index 26636fbd4b..76f4c406c4 100644
--- a/lisp/magit-git.el
+++ b/lisp/magit-git.el
@@ -2369,6 +2369,21 @@ and this option only controls what face is used.")
               (magit-rev-hash (match-string 3 range)))
     (magit-rev-hash range)))
 
+(defvar magit-revision-faces
+  '(magit-hash
+    magit-tag
+    magit-branch-remote
+    magit-branch-remote-head
+    magit-branch-local
+    magit-branch-current
+    magit-branch-upstream
+    magit-branch-warning
+    magit-head
+    magit-refname
+    magit-refname-stash
+    magit-refname-wip
+    magit-refname-pullreq))
+
 (put 'git-revision 'thing-at-point #'magit-thingatpt--git-revision)
 (defun magit-thingatpt--git-revision ()
   (and-let* ((bounds
@@ -2386,7 +2401,10 @@ and this option only controls what face is used.")
     (and (or (and (>= (length string) 7)
                   (string-match-p "[a-z]" string)
                   (magit-commit-p string))
-             (magit-ref-p string))
+             (and (magit-ref-p string)
+                  (let ((face (get-text-property (point) 'face)))
+                    (or (not face)
+                        (member face magit-revision-faces)))))
          string)))
 
 ;;; Completion



reply via email to

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