emacs-diffs
[Top][All Lists]
Advanced

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

master 5be502a697c: Improve passing user switches to Git log commands (b


From: Sean Whitton
Subject: master 5be502a697c: Improve passing user switches to Git log commands (bug#59414)
Date: Mon, 5 Dec 2022 00:08:35 -0500 (EST)

branch: master
commit 5be502a697c4253270c9c3aa7536db239adc1572
Author: Sean Whitton <spwhitton@spwhitton.name>
Commit: Sean Whitton <spwhitton@spwhitton.name>

    Improve passing user switches to Git log commands (bug#59414)
    
    * 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 @@ If nil, use the value of `vc-annotate-switches'.  If t, 
use no 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 @@ If LIMIT is a revision string, use it as an end-revision."
                     ,(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 @@ If LIMIT is a revision string, use it as an 
end-revision."
 
 (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 @@ If LIMIT is a revision string, use it as an 
end-revision."
                     ;; 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 @@ Display all entries that match log messages in long 
format.
 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 @@ or BRANCH^ (where \"^\" can be repeated)."
 
 (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.



reply via email to

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