[PATCH 15/15] git-note: Add display of notes to gitk

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

 



Teach gitk to display notes below the commit message similarly to how
notes are displayed when using --decorate with git-{log,show,whatchanged}.

Signed-off-by: Johan Herland <johan@xxxxxxxxxxx>
---
 gitk |   38 +++++++++++++++++++++++++++++++++++---
 1 files changed, 35 insertions(+), 3 deletions(-)

diff --git a/gitk b/gitk
index a57e84c..7bed56b 100755
--- a/gitk
+++ b/gitk
@@ -303,7 +303,7 @@ proc getcommit {id} {
 }
 
 proc readrefs {} {
-    global tagids idtags headids idheads tagcontents
+    global tagids idtags idnotes headids idheads tagcontents
     global otherrefids idotherrefs mainhead
 
     foreach v {tagids idtags headids idheads otherrefids idotherrefs} {
@@ -318,7 +318,7 @@ proc readrefs {} {
 	if {[regexp {^remotes/.*/HEAD$} $path match]} {
 	    continue
 	}
-	if {![regexp {^(tags|heads)/(.*)$} $path match type name]} {
+	if {![regexp {^(tags|notes|heads)/(.*)$} $path match type name]} {
 	    set type others
 	    set name $path
 	}
@@ -341,6 +341,18 @@ proc readrefs {} {
 	    catch {
 	        set tagcontents($name) [exec git cat-file tag $id]
 	    }
+	} elseif { $type == "notes" } {
+	    puts stderr "note name = '$name', id = '$id'"
+	    lappend idnotes($id) $name
+	    set obj {}
+	    set type {}
+	    set tag {}
+	    catch {
+		set commit [exec git rev-parse "$id^0"]
+		if {$commit != $id} {
+		    lappend idnotes($commit) $id
+		}
+	    }
 	} elseif { $type == "heads" } {
 	    set headids($name) $id
 	    lappend idheads($id) $name
@@ -3864,7 +3876,7 @@ proc selectline {l isnew} {
     global displayorder linehtag linentag linedtag
     global canvy0 linespc parentlist childlist
     global currentid sha1entry
-    global commentend idtags linknum
+    global commentend idtags idnotes linknum
     global mergemax numcommits pending_select
     global cmitmode desc_tags anc_tags showneartags allcommits desc_heads
 
@@ -4009,6 +4021,26 @@ proc selectline {l isnew} {
     $ctext insert end "\n"
     appendwithlinks [lindex $info 5] {comment}
 
+    if {[info exists idnotes($id)]} {
+	$ctext insert end "\nNotes:\n"
+	set notes [exec git note -l "$id"]
+	# strip first line.
+	set firstLineEnd [string first "\n" $notes]
+	if {$firstLineEnd < 0} {
+	    # should never happen...
+	    set hdrend 0
+	}
+	set newnotes [string range $notes [expr {$firstLineEnd + 1}] end]
+	# Indent everything by 4 spaces
+	set notes {}
+	foreach line [split $newnotes "\n"] {
+	    append notes "    $line\n"
+	}
+	# Append to $ctext with auto-highlighting of SHA1 IDs.
+	appendwithlinks $notes {comment}
+	$ctext insert end "\n"
+    }
+
     $ctext tag delete Comments
     $ctext tag remove found 1.0 end
     $ctext conf -state disabled
-- 
1.5.2.101.gee49f

-
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html

[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]

  Powered by Linux