git/list[1] front-page[2] threads[3] people[4] search[5] about
 

git-blame.el: format of date strings

From
Jonathan Nieder <jrnieder@gmail.com>
Date
Feb 11, 2011, 06:42 UTC
Message-ID
<20110211064247.GA26091@elie>
In-Reply-To
<20110211022928.GA24775@elie>
Jonathan Nieder wrote:
>  - The time format (%c) is rather verbose.  I think I prefer %D
>    (so maybe this is a potential tweakable?).

Here's what that might look like. Sadly, format-time-string does not seem to have an equivalent to git log's %ar format.

Signed-off-by: Jonathan Nieder <jrnieder@gmail.com>
---
 contrib/emacs/git-blame.el |   10 ++++++++--
 1 files changed, 8 insertions(+), 2 deletions(-)
diff --git a/contrib/emacs/git-blame.el b/contrib/emacs/git-blame.el
index 9f60a6f..a43981e 100644
--- a/contrib/emacs/git-blame.el
+++ b/contrib/emacs/git-blame.el
@@ -121,6 +121,12 @@ mode. See `git-blame-format' for more information.
 `git-blame' mode. See `git-blame-format' for more information."
   :group 'git-blame)
 
+(defcustom git-blame-date-format
+  "%c"
+  "The format of dates specified with %t or %T passed to `git-blame-format'.
+See `format-time-string' for more information."
+  :group 'git-blame)
+
 (defun git-blame-format (info format)
   "Use format-spec to format the blame info in INFO with the following keys:
 
@@ -146,10 +152,10 @@ mode. See `git-blame-format' for more information.
                    (?H . ,(car info))
                    (?a . ,(git-blame-get-info info 'author))
                    (?A . ,(git-blame-get-info info 'author-mail))
-                   (?t . ,(format-time-string "%c" author-time))
+                   (?t . ,(format-time-string git-blame-date-format author-time))
                    (?c . ,(git-blame-get-info info 'committer))
                    (?C . ,(git-blame-get-info info 'committer-mail))
-                   (?T . ,(format-time-string "%c" committer-time))
+                   (?T . ,(format-time-string git-blame-date-format committer-time))
                    (?s . ,(git-blame-get-info info 'summary))))))
 
 (defun git-blame-color-scale (&rest elements)
-- 
1.7.4
Previous: Jonathan NiederNext: Martin Nordholts
Message 18 of 24 in “git-blame.el: what is format-spec?”
  1. Sergei OrganovDec 4, 2009
  2. Andreas SchwabDec 4, 2009
  3. Sergei OrganovDec 4, 2009
  4. David KågedalDec 4, 2009
  5. Sergei OrganovDec 4, 2009
  6. David KågedalDec 6, 2009
  7. Sergei OrganovDec 7, 2009
  8. David KågedalDec 7, 2009
  9. Alex UnleashedMay 14, 2010
  10. git-blame.el: Add (require 'format-spec)David Kågedal, May 25, 2010
  11. git-blame.el: Add (require 'format-spec)Jonathan Nieder, Oct 29, 2010
  12. git-blame.el: does not show one-line summary in echo areaJonathan Nieder, Feb 4, 2011
  13. David KågedalFeb 4, 2011
  14. Jakub NarebskiFeb 4, 2011
  15. David KågedalFeb 4, 2011
  16. David KågedalFeb 4, 2011
  17. Jonathan NiederFeb 11, 2011
  18. git-blame.el: format of date stringsJonathan Nieder, Feb 11, 2011
  19. Martin NordholtsFeb 11, 2011
  20. git-blame.el: truncate author to avoid jagged left edge of codeJonathan Nieder, Jun 10, 2012
  21. David KågedalJan 29, 2013
  22. Kevin RydeFeb 4, 2011
  23. Andreas SchwabDec 4, 2009
  24. Matthieu MoyDec 4, 2009

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.