[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[nongnu] elpa/git-commit 557ab2c062 4/4: magit-diff-wash-diff: Fix heade
From: |
ELPA Syncer |
Subject: |
[nongnu] elpa/git-commit 557ab2c062 4/4: magit-diff-wash-diff: Fix headers for "git log -L --no-prefix" |
Date: |
Fri, 14 Oct 2022 13:58:42 -0400 (EDT) |
branch: elpa/git-commit
commit 557ab2c0620930afc0b1da3453c42fa2b5d86145
Author: Jonas Bernoulli <jonas@bernoul.li>
Commit: Jonas Bernoulli <jonas@bernoul.li>
magit-diff-wash-diff: Fix headers for "git log -L --no-prefix"
It was already possible to apply commits shown by "git log -L
--no-prefix", but to allow applying files and hunks, we also
have to fix the file headers.
---
lisp/magit-diff.el | 13 +++++++++++--
1 file changed, 11 insertions(+), 2 deletions(-)
diff --git a/lisp/magit-diff.el b/lisp/magit-diff.el
index 3ba2eed4bf..d169a015e4 100644
--- a/lisp/magit-diff.el
+++ b/lisp/magit-diff.el
@@ -2312,14 +2312,23 @@ section or a child thereof."
(when orig
(setq orig (magit-decode-git-path orig)))
(setq file (magit-decode-git-path file))
- (setq header (mapconcat #'identity (nreverse header) ""))
+ (setq header (nreverse header))
;; KLUDGE `git-log' ignores `--no-prefix' when `-L' is used.
(when (and (derived-mode-p 'magit-log-mode)
(seq-some (lambda (arg) (string-prefix-p "-L" arg))
magit-buffer-log-args))
(when orig
(setq orig (substring orig 2)))
- (setq file (substring file 2)))
+ (setq file (substring file 2))
+ (setq header (list (save-excursion
+ (string-match "diff [^ ]+" (car header))
+ (format "%s %s %s\n"
+ (match-string 0 (car header))
+ (or orig file)
+ (or file orig)))
+ (format "--- %s\n" (or orig "/dev/null"))
+ (format "+++ %s\n" (or file "/dev/null")))))
+ (setq header (mapconcat #'identity header ""))
(magit-diff-insert-file-section
file orig status modes rename header binary nil)))))