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

    magit-blob-successor: Return nil for file from worktree
    
    Don't force the caller to deal with this case explicitly.
    Now this function is more like the related `magit-blob-ancestor'.
---
 lisp/magit-files.el | 23 ++++++++++++-----------
 1 file changed, 12 insertions(+), 11 deletions(-)

diff --git a/lisp/magit-files.el b/lisp/magit-files.el
index 22ae6831224..3d32330e25e 100644
--- a/lisp/magit-files.el
+++ b/lisp/magit-files.el
@@ -385,9 +385,8 @@ in a single window."
      [file (magit-buffer-file-name)]]
     ((not file)
      (user-error "Buffer isn't visiting a file or blob"))
-    (magit-buffer-revision
-     (magit-blob-visit
-      (or (magit-blob-successor rev file) file)))
+    ([next (magit-blob-successor rev file)]
+     (magit-blob-visit next))
     ((user-error "You have reached the end of time"))))
 
 (defun magit-blob-previous ()
@@ -429,14 +428,16 @@ the same location in the respective file in the working 
tree."
                       2)))
 
 (defun magit-blob-successor (rev file)
-  (let ((lines (magit-with-toplevel
-                 (magit-git-lines "log" "--format=%H" "--name-only" "--follow"
-                                  "HEAD" "--" file))))
-    (catch 'found
-      (while lines
-        (if (equal (nth 2 lines) rev)
-            (throw 'found (list (nth 0 lines) (nth 1 lines)))
-          (setq lines (nthcdr 2 lines)))))))
+  (pcase rev
+    ("{worktree}" nil)
+    (_ (let ((lines (magit-with-toplevel
+                      (magit-git-lines "log" "--format=%H" "--name-only"
+                                       "--follow" "HEAD" "--" file))))
+         (catch 'found
+           (while lines
+             (if (equal (nth 2 lines) rev)
+                 (throw 'found (list (nth 0 lines) (nth 1 lines)))
+               (setq lines (nthcdr 2 lines)))))))))
 
 ;;; File Commands
 

Reply via email to