emacs-devel
[Top][All Lists]
Advanced

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

Re: VC top of the tree diff and log


From: Dan Nicolaescu
Subject: Re: VC top of the tree diff and log
Date: Thu, 16 Jul 2009 14:38:52 -0700 (PDT)

Miles Bader <address@hidden> writes:

  > Dan Nicolaescu <address@hidden> writes:
  > > A related question: should we have an option (or default?) to show the
  > > short version (--pretty=oneline --graph) ?
  > 
  > Would be useful, though I dunno what you'd bind it too... at some point
  > having too many bindings for essentially-similar-commands becomes kind
  > of annoying/confusing.
  > 
  > I don't really like the default --pretty=oneline format though, as it
  > wastes too much space on the hash, and doesn't show a date (which I find
  > very useful in looking at logs).
  > 
  > Here's what I use (with my own "slog" alias):
  > 
  >    --date=short --pretty=format:"%h  %ad  %s" --abbrev-commit
  > 
  > [note there are _two_ spaces between fields, which makes the result much
  > more readable than one, I think]

Here's what I have now, it defaults to showing short log (and the graph
is shown in both the short and long versions).  It's git specific (no
integration with VC), there's no UI for switching between the long and
short version yet.

Ideas (or even better, code) on how to make all these fit together are
welcome. 


--- vc-git.el.~1.82.~   2009-06-26 18:46:22.000000000 -0700
+++ vc-git.el   2009-07-16 14:22:57.000000000 -0700
@@ -118,6 +118,13 @@ If nil, use the value of `vc-diff-switch
   :version "23.1"
   :group 'vc)
 
+(defcustom vc-git-add-signoff nil
+  "Add a Signoff-by line whn comitting."
+  :type 'boolean
+  :version "23.2"
+  :group 'vc)
+
+
 (defvar git-commits-coding-system 'utf-8
   "Default coding system for git commits.")
 
@@ -417,10 +424,10 @@ If nil, use the value of `vc-diff-switch
 (defun vc-git-unregister (file)
   (vc-git-command nil 0 file "rm" "-f" "--cached" "--"))
 
-
 (defun vc-git-checkin (files rev comment)
   (let ((coding-system-for-write git-commits-coding-system))
-    (vc-git-command nil 0 files "commit" "-m" comment "--only" "--")))
+    (vc-git-command nil 0 files "commit"
+                   (if vc-git-add-signoff "-s" "") "-m" comment "--only" 
"--")))
 
 (defun vc-git-find-revision (file rev buffer)
   (let ((coding-system-for-read 'binary)
@@ -444,6 +451,8 @@ If nil, use the value of `vc-diff-switch
 
 ;;; HISTORY FUNCTIONS
 
+(defvar vc-git-log-type 'short)
+
 (defun vc-git-print-log (files &optional buffer)
   "Get change log associated with FILES."
   (let ((coding-system-for-read git-commits-coding-system)
@@ -458,8 +467,13 @@ If nil, use the value of `vc-diff-switch
     (let ((inhibit-read-only t))
       (with-current-buffer
           buffer
-       (vc-git-command buffer 'async files
-                       "rev-list" "--pretty" "HEAD" "--")))))
+       (if (eq vc-git-log-type 'short)
+           (vc-git-command buffer 'async files
+                           "log" "--graph"
+                           "--date=short" "--pretty=format:%h  %ad  %s" 
"--abbrev-commit"
+                           "--")
+         (vc-git-command buffer 'async files
+                         "rev-list" "--graph" "--pretty" "HEAD" "--"))))))
 
 (defvar log-view-message-re)
 (defvar log-view-file-re)
@@ -472,29 +486,37 @@ If nil, use the value of `vc-diff-switch
   (set (make-local-variable 'log-view-file-re) "\\`a\\`")
   (set (make-local-variable 'log-view-per-file-logs) nil)
   (set (make-local-variable 'log-view-message-re)
-       "^commit *\\([0-9a-z]+\\)")
+       (if (eq vc-git-log-type 'short)
+        "^[*/\\| ]+ \\([0-9a-z]+\\)  \\([-a-z0-9]+\\)  \\(.*\\)"
+        "^[ */\\|]+commit *\\([0-9a-z]+\\)"))
   (set (make-local-variable 'log-view-font-lock-keywords)
-       (append
-        `((,log-view-message-re  (1 'change-log-acknowledgement)))
-        ;; Handle the case:
-        ;; user: address@hidden
-        '(("^Author:[ \t]+\\(address@hidden)"
-           (1 'change-log-email))
-          ;; Handle the case:
-          ;; user: FirstName LastName <address@hidden>
-          ("^Author:[ \t]+\\([^<(]+?\\)[ \t]*[(<]\\(address@hidden)[>)]"
-           (1 'change-log-name)
-           (2 'change-log-email))
-          ("^ +\\(?:\\(?:[Aa]cked\\|[Ss]igned-[Oo]ff\\)-[Bb]y:\\)[ 
\t]+\\(address@hidden)"
-           (1 'change-log-name))
-          ("^ +\\(?:\\(?:[Aa]cked\\|[Ss]igned-[Oo]ff\\)-[Bb]y:\\)[ 
\t]+\\([^<(]+?\\)[ \t]*[(<]\\(address@hidden)[>)]"
-           (1 'change-log-name)
-           (2 'change-log-email))
-          ("^Merge: \\([0-9a-z]+\\) \\([0-9a-z]+\\)"
-           (1 'change-log-acknowledgement)
-           (2 'change-log-acknowledgement))
-          ("^Date:   \\(.+\\)" (1 'change-log-date))
-          ("^summary:[ \t]+\\(.+\\)" (1 'log-view-message))))))
+       (if (eq vc-git-log-type 'short)
+          (append
+           `((,log-view-message-re
+              (1 'change-log-acknowledgement)
+              (2 'change-log-date))))
+        (append
+         `((,log-view-message-re  (1 'change-log-acknowledgement)))
+         ;; Handle the case:
+         ;; user: address@hidden
+         '((" Author:[ \t]+\\(address@hidden)"
+            (1 'change-log-email))
+           ;; Handle the case:
+           ;; user: FirstName LastName <address@hidden>
+           (" Author:[ \t]+\\([^<(]+?\\)[ \t]*[(<]\\(address@hidden)[>)]"
+            (1 'change-log-name)
+            (2 'change-log-email))
+           ("^ +\\(?:\\(?:[Aa]cked\\|[Ss]igned-[Oo]ff\\)-[Bb]y:\\)[ 
\t]+\\(address@hidden)"
+            (1 'change-log-name))
+           ("^ +\\(?:\\(?:[Aa]cked\\|[Ss]igned-[Oo]ff\\)-[Bb]y:\\)[ 
\t]+\\([^<(]+?\\)[ \t]*[(<]\\(address@hidden)[>)]"
+            (1 'change-log-name)
+            (2 'change-log-email))
+           (" Merge: \\([0-9a-z]+\\) \\([0-9a-z]+\\)"
+            (1 'change-log-acknowledgement)
+            (2 'change-log-acknowledgement))
+           (" Date:   \\(.+\\)" (1 'change-log-date))
+           (" summary:[ \t]+\\(.+\\)" (1 'log-view-message)))))))
+
 
 (defun vc-git-show-log-entry (revision)
   "Move to the log entry for REVISION.
@@ -633,12 +655,20 @@ or BRANCH^ (where \"^\" can be repeated)
     (define-key map [git-grep]
       '(menu-item "Git grep..." vc-git-grep
                  :help "Run the `git grep' command"))
+    (define-key map [git-sig]
+      '(menu-item "Add Signoff-by on commit" vc-git-toggle-signoff
+             :help "Add Add Signed-off-by when commiting (i.e. add the -s 
flag)"
+             :button (:toggle . vc-git-add-signoff)))
     map))
 
 (defun vc-git-extra-menu () vc-git-extra-menu-map)
 
 (defun vc-git-extra-status-menu () vc-git-extra-menu-map)
 
+(defun vc-git-toggle-signoff ()
+  (interactive)
+  (setq vc-git-add-signoff (not vc-git-add-signoff)))
+
 ;; Derived from `lgrep'.
 (defun vc-git-grep (regexp &optional files dir)
   "Run git grep, searching for REGEXP in FILES in directory DIR.




reply via email to

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