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

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

[nongnu] elpa/git-commit 65c4485: magit-current-blame-chunk: Don't try t


From: ELPA Syncer
Subject: [nongnu] elpa/git-commit 65c4485: magit-current-blame-chunk: Don't try to operate in Dired buffers
Date: Wed, 15 Dec 2021 01:57:38 -0500 (EST)

branch: elpa/git-commit
commit 65c4485e19bf570ebcb81fbaa6352c4e94bb05da
Author: Kyle Meyer <kyle@kyleam.com>
Commit: Kyle Meyer <kyle@kyleam.com>

    magit-current-blame-chunk: Don't try to operate in Dired buffers
    
    magit-current-blame-chunk passes the result of
    magit-file-relative-name to git-blame.  For a Dired buffer, this value
    is default-directory, and passing a directory to git-blame will lead
    to an error.  This error can show up when various commands unrelated
    to magit-blame are called from a Dired buffer because
    magit-current-blame-chunk is called by magit-commit-at-point and
    magit-branch-or-commit-at-point.
    
    Don't try to blame the return value of magit-file-relative-name when
    in a Dired buffer, letting the "no file" case be handled according
    NOERROR.
    
    Fixes #4560.
---
 Documentation/RelNotes/3.4.0.org | 5 +++++
 lisp/magit-blame.el              | 4 +++-
 2 files changed, 8 insertions(+), 1 deletion(-)

diff --git a/Documentation/RelNotes/3.4.0.org b/Documentation/RelNotes/3.4.0.org
index 9e2ab7c..ad3d6c4 100644
--- a/Documentation/RelNotes/3.4.0.org
+++ b/Documentation/RelNotes/3.4.0.org
@@ -26,3 +26,8 @@
   current and only selected section until a second section is selected.
 
 - Fixed calculation of gravatar image size.
+
+- The helper function ~magit-current-blame-chunk~ passed the directory
+  visited by a Dired buffer to ~git blame~, leading to some commands
+  (e.g., ~magit-checkout~) erroring when called from a Dired buffer.
+  #4560
diff --git a/lisp/magit-blame.el b/lisp/magit-blame.el
index 9c72fab..24c0713 100644
--- a/lisp/magit-blame.el
+++ b/lisp/magit-blame.el
@@ -232,7 +232,9 @@ Also see option `magit-blame-styles'."
            (magit-blame-chunk-at (point)))
       (and type
            (let ((rev  (or magit-buffer-refname magit-buffer-revision))
-                 (file (magit-file-relative-name nil (not 
magit-buffer-file-name)))
+                 (file (and (not (derived-mode-p 'dired-mode))
+                            (magit-file-relative-name
+                             nil (not magit-buffer-file-name))))
                  (line (format "%i,+1" (line-number-at-pos))))
              (cond (file (with-temp-buffer
                            (magit-with-toplevel



reply via email to

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