threads / discuss / 791

gitk-1.1 out

Subject: gitk-1.1 out

## tl;dr

9 messages between Jun 1, 2005 and Jun 10, 2005.

replies: 8people: 4as markdown or json

Paul Mackerras· Jun 1, 2005, 10:09 UTC · lore
The latest version of gitk is at:
	http://ozlabs.org/~paulus/gitk/gitk-1.1.tar.gz
(yes, a real tarball this time, with a README even. :)
New features in this version include:
* Commits that are pointed to by a tag in .git/refs/tags are now
  marked with a little yellow "luggage label" shape attached to the
  circle representing the commit.  The tag name is written on the
  label.
* Gitk now uses git-rev-list instead of git-rev-tree.  This means it
  should be faster when looking at just a small range of commits.
  Instead of using "gitk HEAD ^ORIG_HEAD" though, you need to use
  "gitk HEAD ORIG_HEAD"; the arguments are passed to git-rev-list,
  which takes slightly different arguments from git-rev-tree.
  Unfortunately gitk still needs to see the whole git-rev-list output
  before it can start to draw the graph; I plan to address this.
* You can now type a tag name or a SHA1 id in the SHA1 field, and
  press return or the "Goto" button to jump to that commit.
Paul.
Ingo Molnar· Jun 1, 2005, 11:19 UTC · re: Paul Mackerras · lore

Re: gitk-1.1 out

* Paul Mackerras <paulus@samba.org> wrote:
> The latest version of gitk is at:
> 
> 	http://ozlabs.org/~paulus/gitk/gitk-1.1.tar.gz

works very well for me, and all the bugs of the previous version that i could trigger are fixed now.

	Ingo
Sean· Jun 2, 2005, 13:32 UTC · re: Paul Mackerras · lore

Re: gitk-1.1 out

On Wed, June 1, 2005 6:09 am, Paul Mackerras said:
Show 6 quoted lines
> The latest version of gitk is at:
>
> 	http://ozlabs.org/~paulus/gitk/gitk-1.1.tar.gz
>
> (yes, a real tarball this time, with a README even. :)
>
Hi Paul,

Looks really good! Thought i'd share some homespun rpms that upgrade Fedora TCL/Tk to use anti-aliased fonts for gitk. They make the text displayed in gitk a little nicer to read. Only tested on Fedora FC3 and there's no warranty, but they should work for others too.

The rpms and a couple of screenshots are available from: http://git.homelinux.com

Cheers, Sean

Linus Torvalds· Jun 8, 2005, 14:49 UTC · re: Paul Mackerras · lore

Re: gitk-1.1 out

On Wed, 1 Jun 2005, Paul Mackerras wrote:
Show 5 quoted lines
> 
> * Commits that are pointed to by a tag in .git/refs/tags are now
>   marked with a little yellow "luggage label" shape attached to the
>   circle representing the commit.  The tag name is written on the
>   label.

Can you do the same for things in .git/refs/heads? Possibly using another color?

I realize that that may sound silly, but a tree that has many branches can validly be used with gitk with something like this:

	gitk $(ls .git/refs/heads)

and it results in gitk correctly showing all the different heads, but because they aren't marked in the output, it's almost impossible to understand what's up.

You can try it out with something like Jeff's tree at 
	rsync://rsync.kernel.org/pub/scm/linux/kernel/git/jgarzik/netdev-2.6.git/

if you want to, but the reason I noticed was that I was trying it out with the result of "git cvsimport" in a tree that had branches. If it had had flags for the branches, it would have been an _extremely_ nice visualization tool, as it was it was just "cool, but I can't tell what those different tips are" ;)

		Linus
Paul Mackerras· Jun 9, 2005, 04:46 UTC · re: Linus Torvalds · lore

Re: gitk-1.1 out

Linus Torvalds writes:
> Can you do the same for things in .git/refs/heads? Possibly using another 
> color?

Sure - the hardest part is going to be deciding on the shape and color to use. :) Perhaps I'll try just using a green rectangle with black on white text inside and see if that stands out enough.

> I realize that that may sound silly, but a tree that has many branches can 
> validly be used with gitk with something like this:
> 
> 	gitk $(ls .git/refs/heads)

Um, did I break that when I changed to using git-rev-list instead of git-rev-tree?

Paul.
Linus Torvalds· Jun 9, 2005, 14:22 UTC · re: Paul Mackerras · lore

Re: gitk-1.1 out

On Thu, 9 Jun 2005, Paul Mackerras wrote:
Show 8 quoted lines
> 
> > I realize that that may sound silly, but a tree that has many branches can 
> > validly be used with gitk with something like this:
> > 
> > 	gitk $(ls .git/refs/heads)
> 
> Um, did I break that when I changed to using git-rev-list instead of
> git-rev-tree?
No, I fixed git-rev-list to do multiple heads.
		Linus
Paul Mackerras· Jun 9, 2005, 12:50 UTC · re: Linus Torvalds · lore

Re: gitk-1.1 out

Linus Torvalds writes:
> Can you do the same for things in .git/refs/heads? Possibly using another 
> color?

Try this patch against gitk-1.1 and let me know what you think. I draw the heads as a green rectangle with a black border.

I also added a -t option to gitk which makes it use gitk-rev-tree instead of git-rev-list, so that you can do

	gitk -t $(ls .git/refs/heads)

Paul. ---

diff -urN gitk-1.1/gitk current/gitk --- gitk-1.1/gitk 2005-06-01 18:14:51.000000000 +1000 +++ current/gitk 2005-06-09 22:41:56.000000000 +1000

@@ -10,13 +10,18 @@
 # CVS $Revision: 1.20 $
 
 proc getcommits {rargs} {
-    global commits commfd phase canv mainfont
+    global commits commfd phase canv mainfont treemode
     if {$rargs == {}} {
 	set rargs HEAD
     }
     set commits {}
     set phase getcommits
-    if [catch {set commfd [open "|git-rev-list $rargs" r]} err] {
+    if {$treemode} {
+	set cmd "git-rev-tree"
+    } else {
+	set cmd "git-rev-list"
+    }
+    if [catch {set commfd [open "|$cmd $rargs" r]} err] {
 	puts stderr "Error executing git-rev-list: $err"
 	exit 1
     }
@@ -28,7 +33,7 @@
 }
 
 proc getcommitline {commfd}  {
-    global commits parents cdate nparents children nchildren
+    global commits parents cdate nparents children nchildren treemode
     set n [gets $commfd line]
     if {$n < 0} {
 	if {![eof $commfd]} return
@@ -39,8 +44,9 @@
 	    return
 	}
 	if {[string range $err 0 4] == "usage"} {
+	    set cmd [expr {$treemode? "tree": "list"}]
 	    set err "\
-Gitk: error reading commits: bad arguments to git-rev-list.\n\
+Gitk: error reading commits: bad arguments to git-rev-$cmd.\n\
 (Note: arguments to gitk are passed to git-rev-list\
 to allow selection of commits to be displayed.)"
 	} else {
@@ -49,11 +55,19 @@
 	error_popup $err
 	exit 1
     }
-    if {![regexp {^[0-9a-f]{40}$} $line]} {
-	error_popup "Can't parse git-rev-tree output: {$line}"
-	exit 1
+    if {$treemode} {
+	if {![regexp {^[0-9]* ([0-9a-f]{40}):} $line match id]} {
+	    error_popup "Can't parse git-rev-tree output: {$line}"
+	    exit 1
+	}
+	lappend commits $id
+    } else {
+	if {![regexp {^[0-9a-f]{40}$} $line]} {
+	    error_popup "Can't parse git-rev-list output: {$line}"
+	    exit 1
+	}
+	lappend commits $line
     }
-    lappend commits $line
 }
 
 proc readallcommits {} {
@@ -130,7 +144,7 @@
 }
 
 proc readrefs {} {
-    global tagids idtags
+    global tagids idtags headids idheads
     set tags [glob -nocomplain -types f .git/refs/tags/*]
     foreach f $tags {
 	catch {
@@ -154,6 +168,20 @@
 		    lappend idtags($obj) $tag
 		}
 	    }
+	    close $fd
+	}
+    }
+    set heads [glob -nocomplain -types f .git/refs/heads/*]
+    foreach f $heads {
+	catch {
+	    set fd [open $f r]
+	    set line [read $fd 40]
+	    if {[regexp {^[0-9a-f]{40}} $line id]} {
+		set head [file tail $f]
+		set headids($head) $line
+		lappend idheads($line) $head
+	    }
+	    close $fd
 	}
     }
 }
@@ -537,6 +565,7 @@
     global lineid linehtag linentag linedtag commitinfo
     global nextcolor colormap numcommits
     global stopped phase redisplaying selectedline idtags idline
+    global idheads
 
     allcanvs delete all
     set start {}
@@ -616,13 +645,22 @@
 	if {$nparents($id) > 2} {
 	    set xt [expr {$xt + ($nparents($id) - 2) * $linespc}]
 	}
-	if {[info exists idtags($id)] && $idtags($id) != {}} {
+	set marks {}
+	set ntags 0
+	if {[info exists idtags($id)]} {
+	    set marks $idtags($id)
+	    set ntags [llength $marks]
+	}
+	if {[info exists idheads($id)]} {
+	    set marks [concat $marks $idheads($id)]
+	}
+	if {$marks != {}} {
 	    set delta [expr {int(0.5 * ($linespc - $lthickness))}]
 	    set yt [expr $canvy - 0.5 * $linespc]
 	    set yb [expr $yt + $linespc - 1]
 	    set xvals {}
 	    set wvals {}
-	    foreach tag $idtags($id) {
+	    foreach tag $marks {
 		set wid [font measure $mainfont $tag]
 		lappend xvals $xt
 		lappend wvals $wid
@@ -631,12 +669,20 @@
 	    set t [$canv create line $x $canvy [lindex $xvals end] $canvy \
 		       -width $lthickness -fill black]
 	    $canv lower $t
-	    foreach tag $idtags($id) x $xvals wid $wvals {
+	    foreach tag $marks x $xvals wid $wvals {
 		set xl [expr $x + $delta]
 		set xr [expr $x + $delta + $wid + $lthickness]
-		$canv create polygon $x [expr $yt + $delta] $xl $yt\
-		    $xr $yt $xr $yb $xl $yb $x [expr $yb - $delta] \
-		    -width 1 -outline black -fill yellow
+		if {[incr ntags -1] >= 0} {
+		    # draw a tag
+		    $canv create polygon $x [expr $yt + $delta] $xl $yt\
+			$xr $yt $xr $yb $xl $yb $x [expr $yb - $delta] \
+			-width 1 -outline black -fill yellow
+		} else {
+		    # draw a head
+		    set xl [expr $xl - $delta/2]
+		    $canv create polygon $x $yt $xr $yt $xr $yb $x $yb \
+			-width 1 -outline black -fill green
+		}
 		$canv create text $xl $canvy -anchor w -text $tag \
 		    -font $mainfont
 	    }
@@ -1334,7 +1380,8 @@
 set textfont {Courier 9}
 
 set colors {green red blue magenta darkgrey brown orange}
-set colorbycommitter false
+set colorbycommitter 0
+set treemode 0
 
 catch {source ~/.gitk}
 
@@ -1350,6 +1397,7 @@
 	"^-b" { set boldnames 1 }
 	"^-c" { set colorbycommitter 1 }
 	"^-d" { set datemode 1 }
+	"^-t" { set treemode 1 }
 	default {
 	    lappend revtreeargs $arg
 	}
Linus Torvalds· Jun 9, 2005, 14:58 UTC · re: Paul Mackerras · lore

Re: gitk-1.1 out

On Thu, 9 Jun 2005, Paul Mackerras wrote:
> 
> Try this patch against gitk-1.1 and let me know what you think.  I
> draw the heads as a green rectangle with a black border.

Works for me. My cvs-import testing "syslinux" tree now has the heads of the different branches nicely named.

However, I also changed it to allow the "direct" kinds of tags which the cvs2git thing creates, where the tag file contains just a direct pointer to the commit, rather than a pointer to a tag object.

I'm not a TCL weenie, so this is just a very quick hack, and you may want to re-do things properly, but something like the appended works for me..

> I also added a -t option to gitk which makes it use gitk-rev-tree
> instead of git-rev-list, so that you can do
> 
> 	gitk -t $(ls .git/refs/heads)
No need, I think yoy may have an old version of git.
		Linus

--- hacky hack hack --- --- gitk 2005-06-09 07:26:50.000000000 -0700 +++ gitk 2005-06-09 07:55:00.000000000 -0700

@@ -151,6 +151,11 @@
 	    set fd [open $f r]
 	    set line [read $fd]
 	    if {[regexp {^[0-9a-f]{40}} $line id]} {
+		if {[regexp {[^/]*$} $f direct]} {
+		    set tagids($direct) $id
+		    lappend idtags($id) $direct
+		}
+
 		set contents [split [exec git-cat-file tag $id] "\n"]
 		set obj {}
 		set type {}
Paul Mackerras· Jun 10, 2005, 09:56 UTC · re: Linus Torvalds · lore

Re: gitk-1.1 out

Linus Torvalds writes:
Show 6 quoted lines
> However, I also changed it to allow the "direct" kinds of tags which the 
> cvs2git thing creates, where the tag file contains just a direct pointer 
> to the commit, rather than a pointer to a tag object.
> 
> I'm not a TCL weenie, so this is just a very quick hack, and you may want 
> to re-do things properly, but something like the appended works for me..

I'll use file tail instead of regexp, but apart from that it looks fine.

Show 6 quoted lines
> > I also added a -t option to gitk which makes it use gitk-rev-tree
> > instead of git-rev-list, so that you can do
> > 
> > 	gitk -t $(ls .git/refs/heads)
> 
> No need, I think yoy may have an old version of git.
Ah yes, I did.  I'll take the -t option out then.
Paul.

← back to recent threads