about summary refs log tree commit diff
diff options
context:
space:
mode:
-rw-r--r--modules/workstation/emacs/init.el10
1 files changed, 10 insertions, 0 deletions
diff --git a/modules/workstation/emacs/init.el b/modules/workstation/emacs/init.el
index 09a1a5f4d6b4..1f1d79dd4fe5 100644
--- a/modules/workstation/emacs/init.el
+++ b/modules/workstation/emacs/init.el
@@ -152,6 +152,16 @@
 ;; in the right when this happens).
 (setq magit-commit-show-diff nil)
 
+(defun git-commit-message-pretty-ref (commit)
+  "Generate a reference to git COMMIT in the format used in the
+Linux kernel (`SHORT-HASH (\"SHORT-MESSAGE\")') and insert it at
+point."
+  (interactive
+   (list (or (nreverse (magit-region-values 'commit))
+	     (magit-read-other-branch-or-commit "Reference commit"))))
+  (call-process (magit-git-executable) nil t nil
+		"show" "--no-patch" "--pretty=format:%h (\"%s\")" commit))
+
 (with-eval-after-load "magit"
   (define-key magit-process-mode-map (kbd "k") #'magit-process-kill)