0

In git, the following shows patchlog for a directory

git log -p -- hukarz/

How can I do this in Magit?;) I found some patch for it, but has this been included in Magit?

Here's the patch I found

    Modified   magit-key-mode.el
diff --git a/magit-key-mode.el b/magit-key-mode.el
index dd69988..e16e7bc 100644
--- a/magit-key-mode.el
+++ b/magit-key-mode.el
@@ -27,6 +27,7 @@
       ("l" "Short" magit-log)
       ("L" "Long" magit-log-long)
       ("h" "Reflog" magit-reflog)
+      ("p" "Paths" magit-log-for-paths)
       ("rl" "Ranged short" magit-log-ranged)
       ("rL" "Ranged long" magit-log-long-ranged)
       ("rh" "Ranged reflog" magit-reflog-ranged))
    Modified   magit.el
diff --git a/magit.el b/magit.el
index ad5569d..11d9f5d 100644
--- a/magit.el
+++ b/magit.el
@@ -2397,6 +2397,7 @@ magit-topgit and magit-svn"
     ("Log"
      ["Short Log" magit-log t]
      ["Long Log" magit-log-long t]
+     ["Files or directories" magit-log-for-paths t]
      ["Reflog" magit-reflog t]
      ["Extended..." magit-key-mode-popup-logging t])
     "---"
@@ -5229,6 +5230,11 @@ With a non numeric prefix ARG, show all entries"
     (magit-mode-init topdir 'magit-log-mode #'magit-refresh-log-buffer range
                      'long args)))

+(magit-define-command log-for-paths ()
+  (interactive)
+  (let ((paths (read-string "Files or directories: ")))
+    (apply 'magit-log nil "--" (split-string paths))))
+
1
  • I don't think there's been a magit-key-mode.el library in Magit since back in the version 1.x days, but in any case that patch doesn't look like it has anything to do with the -p option to git log.
    – phils
    Apr 18, 2023 at 12:25

1 Answer 1

1

In current versions (and for a long time) these options are in the transient menu by default (-p is referred to by its long option name --patch).

So in the magit log transient menu, just type -p and --.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.