2

I am using gitk to browse my git repo and i would like to print the commit date of commit instead of author date in gitk (on the third column).

Can you tell me how to do it ?

enter image description here

user43968
  • 2,049
  • 20
  • 37

3 Answers3

4

Modify gitk. (It's a big TCL script, so it is easy to modify.)

If you look at a recent version of gitk, you will find:

proc drawcmittext {id row col} { 

near line 6100. About 72 or so lines in you will find:

    set date [lindex $commitinfo($id) 2]
    set date [formatdate $date]

There is no further code to change date, so from here on you are stuck with whatever formatdate did to the initial value from the lindex expression (list index).

The $commitinfo (associative array based on looking up the commit ID) fields are:

    set commitinfo($id) [list $headline $auname $audate \
                             $comname $comdate $comment $hasnote $diff]

(last two lines of parsecommit, around line 1730). So index 2 is $audate, which is the parsed author-date. The committer-date is from index 4 (indices 1 and 3 being author and committer respectively).

The obvious change would be to select index 4 if some command line switch were used. (Making a Tk button that changes the value dynamically would be possible as well, but harder.)

torek
  • 448,244
  • 59
  • 642
  • 775
1

torek's solution as patch for gitk 1.8.1.4-1.1.1 to display committer date instead of author date:

--- /usr/bin/gitk       2013-02-26 15:44:18.000000000 +0100
+++ /usr/local/bin/gitk 2017-09-14 13:52:13.629947026 +0200
@@ -5963,7 +5963,7 @@
     }
     set headline [lindex $commitinfo($id) 0]
     set name [lindex $commitinfo($id) 1]
-    set date [lindex $commitinfo($id) 2]
+    set date [lindex $commitinfo($id) 4]
     set date [formatdate $date]
     set font mainfont
     set nfont mainfont

Save this patch in gitk.patch and apply:

cp /usr/bin/gitk .
patch -p0 gitk gitk.patch
sudo mv gitk /usr/local/bin
lumbric
  • 7,644
  • 7
  • 42
  • 53
  • 1
    Thx for the patch but you need to patch also the name field by replacing 1 by 3 as stated before – user43968 Sep 15 '17 at 16:37
  • @user43968 Well in my case, I really want to replace only the committer date. We switched to Gerrit code review and chose to rebase commits by default. Often I am interested when a commit has been added to the devel or main branch (e.g.: why did the integration tests brake yesterday at 17:23? which changes have been done?), but I am never interested in the comitter (who cares who hit the submit button? the author is the expert behind the commit). – lumbric Sep 16 '17 at 09:43
-1

Use this to display the commit date

git show -s --format=%ci <commit>

Check manual page for other formats of date string

Mojo Allmighty
  • 793
  • 7
  • 18