Subject: Re: bug#59414: 29.0.50; Have vc-git-expanded-log-entry pass --stat

From: Sean Whitton <[email-masked]>
Date: Sun, 04 Dec 2022 15:57:52 -0700

Hello,

Thanks.  Here's a patch.

-- 
Sean Whitton
>From 868141665504d689f8f02bc8c67391b63d8962b2 Mon Sep 17 00:00:00 2001
From: Sean Whitton <[email-masked]>
Date: Sun, 4 Dec 2022 15:56:35 -0700
Subject: [PATCH] Improve passing user switches to Git log commands

* lisp/vc/vc-git.el (vc-git-log-switches): Revise docstring.
(vc-git-shortlog-switches): New defcustom.
(vc-git-print-log): Use vc-git-log-switches or
vc-git-shortlog-switches depending on whether printing a shortlog.
(vc-git-log-outgoing, vc-git-log-incoming): Use
vc-git-shortlog-switches.
(vc-git-log-search, vc-git-expanded-log-entry): Use
vc-git-log-switches.
* etc/NEWS: Document the new defcustom.
---
 etc/NEWS          |  7 ++++++
 lisp/vc/vc-git.el | 57 +++++++++++++++++++++++++++++------------------
 2 files changed, 42 insertions(+), 22 deletions(-)

diff --git a/etc/NEWS b/etc/NEWS
index 9b8edde5155..8f5b17fb4af 100644
--- a/etc/NEWS
+++ b/etc/NEWS
@@ -41,6 +41,13 @@ connection.
 
 * Changes in Specialized Modes and Packages in Emacs 30.1
 
+** VC
+
+---
+*** New user option 'vc-git-shortlog-switches'
+String or list of strings giving Git log switches for shortlogs, such
+as 'C-x v L'.  'vc-git-log-switches' is no longer used for shortlogs.
+
 
 * New Modes and Packages in Emacs 30.1
 
diff --git a/lisp/vc/vc-git.el b/lisp/vc/vc-git.el
index 38e9d5f9c91..59dfb6c1252 100644
--- a/lisp/vc/vc-git.el
+++ b/lisp/vc/vc-git.el
@@ -136,12 +136,19 @@ vc-git-annotate-switches
 ;;;###autoload(put 'vc-git-annotate-switches 'safe-local-variable (lambda (switches) (equal switches "-w")))
 
 (defcustom vc-git-log-switches nil
-  "String or list of strings specifying switches for Git log under VC."
+  "String or list of strings giving Git log switches for non-shortlogs."
   :type '(choice (const :tag "None" nil)
                  (string :tag "Argument String")
                  (repeat :tag "Argument List" :value ("") string))
   :version "28.1")
 
+(defcustom vc-git-shortlog-switches nil
+  "String or list of strings giving Git log switches for shortlogs."
+  :type '(choice (const :tag "None" nil)
+                 (string :tag "Argument String")
+                 (repeat :tag "Argument List" :value ("") string))
+  :version "30.1")
+
 (defcustom vc-git-resolve-conflicts t
   "When non-nil, mark conflicted file as resolved upon saving.
 That is performed after all conflict markers in it have been
@@ -1325,7 +1332,8 @@ vc-git-print-log
                     ,(format "--pretty=tformat:%s"
                              (car vc-git-root-log-format))
                     "--abbrev-commit"))
-                (ensure-list vc-git-log-switches)
+                (ensure-list
+                 (if shortlog vc-git-shortlog-switches vc-git-log-switches))
                 (when (numberp limit)
                   (list "-n" (format "%s" limit)))
 		(when start-revision
@@ -1340,16 +1348,16 @@ vc-git-print-log
 
 (defun vc-git-log-outgoing (buffer remote-location)
   (vc-setup-buffer buffer)
-  (vc-git-command
-   buffer 'async nil
-   "log"
-   "--no-color" "--graph" "--decorate" "--date=short"
-   (format "--pretty=tformat:%s" (car vc-git-root-log-format))
-   "--abbrev-commit"
-   (concat (if (string= remote-location "")
-	       "@{upstream}"
-	     remote-location)
-	   "..HEAD")))
+  (apply #'vc-git-command buffer 'async nil
+         `("log"
+           "--no-color" "--graph" "--decorate" "--date=short"
+           ,(format "--pretty=tformat:%s" (car vc-git-root-log-format))
+           "--abbrev-commit"
+           ,@(ensure-list vc-git-shortlog-switches)
+           ,(concat (if (string= remote-location "")
+	                "@{upstream}"
+	              remote-location)
+	            "..HEAD"))))
 
 (defun vc-git-log-incoming (buffer remote-location)
   (vc-setup-buffer buffer)
@@ -1359,15 +1367,15 @@ vc-git-log-incoming
                     ;; so remove everything except a repository name.
                     (replace-regexp-in-string
                      "/.*" "" remote-location)))
-  (vc-git-command
-   buffer 'async nil
-   "log"
-   "--no-color" "--graph" "--decorate" "--date=short"
-   (format "--pretty=tformat:%s" (car vc-git-root-log-format))
-   "--abbrev-commit"
-   (concat "HEAD.." (if (string= remote-location "")
-			"@{upstream}"
-		      remote-location))))
+  (apply #'vc-git-command buffer 'async nil
+         `("log"
+           "--no-color" "--graph" "--decorate" "--date=short"
+           ,(format "--pretty=tformat:%s" (car vc-git-root-log-format))
+           "--abbrev-commit"
+           ,@(ensure-list vc-git-shortlog-switches)
+           ,(concat "HEAD.." (if (string= remote-location "")
+			         "@{upstream}"
+		               remote-location)))))
 
 (defun vc-git-log-search (buffer pattern)
   "Search the log of changes for PATTERN and output results into BUFFER.
@@ -1378,6 +1386,7 @@ vc-git-log-search
 With a prefix argument, ask for a command to run that will output
 log entries."
   (let ((args `("log" "--no-color" "-i"
+                ,@(ensure-list vc-git-log-switches)
                 ,(format "--grep=%s" (or pattern "")))))
     (when current-prefix-arg
       (setq args (cdr (split-string
@@ -1462,7 +1471,11 @@ vc-git-show-log-entry
 
 (defun vc-git-expanded-log-entry (revision)
   (with-temp-buffer
-    (apply #'vc-git-command t nil nil (list "log" revision "-1"  "--no-color" "--"))
+    (apply #'vc-git-command t nil nil
+           `("log"
+             ,revision
+             "-1"  "--no-color" ,@(ensure-list vc-git-log-switches)
+             "--"))
     (goto-char (point-min))
     (unless (eobp)
       ;; Indent the expanded log entry.
-- 
2.30.2