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

gitk "parent information" in commit window

From
Linus Torvalds <torvalds@osdl.org>
Date
Aug 7, 2005, 20:58 UTC
Message-ID
<Pine.LNX.4.58.0508071351150.3258@g5.osdl.org>
This adds a useful "Parent:" line to the git commit information window.
It looks something like this (from the infamous octopus merge):
	Author: Junio C Hamano <junkio@cox.net>  2005-05-05 16:16:54
	Committer: Junio C Hamano <junkio@cox.net>  2005-05-05 16:16:54
	Parent: fc54a9c30ccad3fde5890d2c0ca2e2acc0848fbc  (Update git-apply-patch-script ...)
	Parent: 9e30dd7c0ecc9f10372f31539d0122db97418353  (Make git-prune-script executa ...)
	Parent: c4b83e618f1df7d8ecc9392fa40e5bebccbe6b5a  (Do not write out new index if ...)
	Parent: 660265909fc178581ef327076716dfd3550e6e7b  (diff-cache shows differences  ...)
	Parent: b28858bf65d4fd6d8bb070865518ec43817fe7f3  (Update diff engine for symlin ...)
	
	    Octopus merge of the following five patches.
	    
	      Update git-apply-patch-script for symbolic links.
	      Make git-prune-script executable again.
	      Do not write out new index if nothing has changed.
	      diff-cache shows differences for unmerged paths without --cache.
	      Update diff engine for symlinks stored in the cache.
	    
	    Signed-off-by: Junio C Hamano <junkio@cox.net>

where all the parent commit ID's are clickable, because the new lines are added as part of the "comment" string, and thus the regular clickability thing will match them automatically.

I think this is good. And my random-tcl-monkey-skills are clearly getting better (although it's perfectly possible that somebody who actually knows what he is doing would have done things differently).

Signed-off-by: Linus Torvalds <torvalds@osdl.org>
---
[ Btw, the patch was generated against a tree that had Paul's hovering 
  patches merged. Junio, I don't think you've merged that yet, so this may 
  apply better to Paul's tree than to standard git. But I _think_ it will 
  apply cleanly to either one ]
diff --git a/gitk b/gitk
--- a/gitk
+++ b/gitk
@@ -1799,9 +1799,21 @@ proc selectline {l isnew} {
 	}
 	$ctext insert end "\n"
     }
-    $ctext insert end "\n"
+ 
     set commentstart [$ctext index "end - 1c"]
-    set comment [lindex $info 5]
+    set comment {}
+    foreach p $parents($id) {
+	set l "..."
+	if {[info exists commitinfo($p)]} {
+	    set l [lindex $commitinfo($p) 0]
+	    if {[string length $l] > 32} {
+		set l "[string range $l 0 28] ..."
+	    }
+	}
+	append comment "Parent: $p  ($l)\n"
+    }
+    append comment "\n"
+    append comment [lindex $info 5]
     $ctext insert end $comment
     $ctext insert end "\n"
 
Next: Junio C Hamano
Message 1 of 6 in “gitk "parent information" in commit window”
  1. Linus TorvaldsAug 7, 2005
  2. Junio C HamanoAug 7, 2005
  3. Paul MackerrasAug 7, 2005
  4. A Large Angry SCMAug 8, 2005
  5. Junio C HamanoAug 8, 2005
  6. A Large Angry SCMAug 8, 2005

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.