user43968
user43968

Reputation: 2129

Display commiter date in gitk instead of author date

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

Upvotes: 3

Views: 1613

Answers (3)

lumbric
lumbric

Reputation: 9093

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

Upvotes: 3

torek
torek

Reputation: 489313

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.)

Upvotes: 5

Mojo Allmighty
Mojo Allmighty

Reputation: 793

Use this to display the commit date

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

Check manual page for other formats of date string

Upvotes: -1

Related Questions