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

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

[nongnu] elpa/git-commit b32521d543: magit-ediff-read-files: Handle rena


From: ELPA Syncer
Subject: [nongnu] elpa/git-commit b32521d543: magit-ediff-read-files: Handle renames in one-file logs
Date: Mon, 21 Mar 2022 09:58:24 -0400 (EDT)

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

    magit-ediff-read-files: Handle renames in one-file logs
    
    When a log uses "--follow" to show the history for a single file,
    including history from before it was renamed, then the user might
    invoke Ediff on a range where the name of the modified file does
    not match the name stored in `magit-buffer-log-files'.
    
    Try to determine which of the files that are being modified in that
    range is an early incarnation of the file for which the log is shown.
    
    This fails if the differences are too large for `git-diff' to still
    consider the files to be renamed.  In that case fall back to having
    users select the file themselves.
    
    Closes #4377.
---
 lisp/magit-ediff.el | 24 +++++++++++++++++-------
 1 file changed, 17 insertions(+), 7 deletions(-)

diff --git a/lisp/magit-ediff.el b/lisp/magit-ediff.el
index 114793efa2..4c5c084580 100644
--- a/lisp/magit-ediff.el
+++ b/lisp/magit-ediff.el
@@ -271,13 +271,23 @@ range)."
   "Read file in REVB, return it and the corresponding file in REVA.
 When FILEB is non-nil, use this as REVB's file instead of
 prompting for it."
-  (unless fileB
-    (setq fileB (magit-read-file-choice
-                 (format "File to compare between %s and %s"
-                         revA (or revB "the working tree"))
-                 (magit-changed-files revA revB)
-                 (format "No changed files between %s and %s"
-                         revA (or revB "the working tree")))))
+  (unless (and fileB (member fileB (magit-revision-files revB)))
+    (setq fileB
+          (or (and fileB
+                   magit-buffer-log-files
+                   (derived-mode-p 'magit-log-mode)
+                   (member "--follow" magit-buffer-log-args)
+                   (cdr (assoc fileB
+                               (magit-renamed-files
+                                revB
+                                (oref (car (oref magit-root-section children))
+                                      value)))))
+              (magit-read-file-choice
+               (format "File to compare between %s and %s"
+                       revA (or revB "the working tree"))
+               (magit-changed-files revA revB)
+               (format "No changed files between %s and %s"
+                       revA (or revB "the working tree"))))))
   (list (or (car (member fileB (magit-revision-files revA)))
             (cdr (assoc fileB (magit-renamed-files revB revA)))
             (magit-read-file-choice



reply via email to

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