From 36a7cad6e4ae8a331731666d985a7619a76bb4fb Mon Sep 17 00:00:00 2001 From: Junio C Hamano Date: Fri, 18 Nov 2005 23:54:17 -0800 Subject: readrefs: grab all refs with one call to ls-remote. Instead of reading refs/heads/* and refs/tags/* files ourselves and missing files in subdirectories of heads/ and tags/, use ls-remote on local repository and grab all of them. This lets us also remove the procedure readotherrefs. Signed-off-by: Junio C Hamano diff --git a/gitk b/gitk index 95b05c0..3ea9434 100755 --- a/gitk +++ b/gitk @@ -238,77 +238,43 @@ proc parsecommit {id contents listed olds} { proc readrefs {} { global tagids idtags headids idheads tagcontents - - set tags [glob -nocomplain -types f [gitdir]/refs/tags/*] - foreach f $tags { - catch { - set fd [open $f r] - set line [read $fd] - if {[regexp {^[0-9a-f]{40}} $line id]} { - set direct [file tail $f] - set tagids($direct) $id - lappend idtags($id) $direct - set tagblob [exec git-cat-file tag $id] - set contents [split $tagblob "\n"] - set obj {} - set type {} - set tag {} - foreach l $contents { - if {$l == {}} break - switch -- [lindex $l 0] { - "object" {set obj [lindex $l 1]} - "type" {set type [lindex $l 1]} - "tag" {set tag [string range $l 4 end]} - } - } - if {$obj != {} && $type == "commit" && $tag != {}} { - set tagids($tag) $obj - lappend idtags($obj) $tag - set tagcontents($tag) $tagblob - } - } - close $fd - } - } - set heads [glob -nocomplain -types f [gitdir]/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 - } - } - readotherrefs refs {} {tags heads} -} - -proc readotherrefs {base dname excl} { global otherrefids idotherrefs - set git [gitdir] - set files [glob -nocomplain -types f [file join $git $base *]] - foreach f $files { - catch { - set fd [open $f r] - set line [read $fd 40] - if {[regexp {^[0-9a-f]{40}} $line id]} { - set name "$dname[file tail $f]" - set otherrefids($name) $id - lappend idotherrefs($id) $name + set refd [open [list | git-ls-remote [gitdir]] r] + while {0 <= [set n [gets $refd line]]} { + if {![regexp {^([0-9a-f]{40}) refs/([^^]*)$} $line \ + match id path]} { + continue + } + if {![regexp {^(tags|heads)/(.*)$} $path match type name]} { + set type others + set name $path + } + if {$type == "tags"} { + set tagids($name) $id + lappend idtags($id) $name + set obj {} + set type {} + set tag {} + catch { + set commit [exec git-rev-parse "$id^0"] + if {"$commit" != "$id"} { + set tagids($name) $commit + lappend idtags($commit) $name + } + } + catch { + set tagcontents($name) [exec git-cat-file tag "$id"] } - close $fd + } elseif { $type == "heads" } { + set headids($name) $id + lappend idheads($id) $name + } else { + set otherrefids($name) $id + lappend idotherrefs($id) $name } } - set dirs [glob -nocomplain -types d [file join $git $base *]] - foreach d $dirs { - set dir [file tail $d] - if {[lsearch -exact $excl $dir] >= 0} continue - readotherrefs [file join $base $dir] "$dname$dir/" {} - } + close $refd } proc error_popup msg { -- cgit v0.10.2-6-g49f6 From e246483dc5b56d7deb04a93b0aa08aba4cde0625 Mon Sep 17 00:00:00 2001 From: Frank Sorenson Date: Sun, 30 Oct 2005 02:06:46 -0700 Subject: gitk: Specify line hover font Hovering over a line in gitk displays the commit one-liner in a box, but the text usually overflows the box. The box size is computed with a specified font, so this patch sets the text font as well. Signed-off-by: Frank Sorenson Signed-off-by: Junio C Hamano diff --git a/gitk b/gitk index 3ea9434..5deab53 100755 --- a/gitk +++ b/gitk @@ -3125,7 +3125,7 @@ proc linehover {} { set t [$canv create rectangle $x0 $y0 $x1 $y1 \ -fill \#ffff80 -outline black -width 1 -tags hover] $canv raise $t - set t [$canv create text $x $y -anchor nw -text $text -tags hover] + set t [$canv create text $x $y -anchor nw -text $text -tags hover -font $mainfont] $canv raise $t } -- cgit v0.10.2-6-g49f6 From fd913b39101c6ff185e76e459479621c9b475fa1 Mon Sep 17 00:00:00 2001 From: Pavel Roskin Date: Fri, 11 Nov 2005 10:09:12 -0500 Subject: gitk: use git-diff-tree --no-commit-id gitk switched to use git-diff-tree with one argument in gettreediffs and getblobdiffs. git-diff-tree with one argument outputs commit ID in from of the patch. This causes an empty line after "Comments" in the lower right pane. Also, the diff in the lower left pane has the commit ID, which is useless there. This patch makes git use the newly added -no-commit-id option for git-diff-tree to suppress commit ID. It also removes the p variable in both functions, since it has become useless after switching to the one-argument invocation for git-diff-tree. Signed-off-by: Pavel Roskin Signed-off-by: Junio C Hamano diff --git a/gitk b/gitk index 5deab53..29220b1 100755 --- a/gitk +++ b/gitk @@ -2787,8 +2787,7 @@ proc gettreediffs {ids} { set treepending $ids set treediff {} set id [lindex $ids 0] - set p [lindex $ids 1] - if [catch {set gdtf [open "|git-diff-tree -r $id" r]}] return + if [catch {set gdtf [open "|git-diff-tree --no-commit-id -r $id" r]}] return fconfigure $gdtf -blocking 0 fileevent $gdtf readable [list gettreediffline $gdtf $ids] } @@ -2822,9 +2821,8 @@ proc getblobdiffs {ids} { global difffilestart nextupdate diffinhdr treediffs set id [lindex $ids 0] - set p [lindex $ids 1] set env(GIT_DIFF_OPTS) $diffopts - set cmd [list | git-diff-tree -r -p -C $id] + set cmd [list | git-diff-tree --no-commit-id -r -p -C $id] if {[catch {set bdf [open $cmd r]} err]} { puts "error getting diffs: $err" return -- cgit v0.10.2-6-g49f6 From e3fe532ddce7311cfbbdc98d2e157d33f6275231 Mon Sep 17 00:00:00 2001 From: "Stefan-W. Hahn" Date: Sat, 5 Nov 2005 20:55:29 +0100 Subject: gitk: moving all three panes if clicking on an arrow. Signed-off-by: Stefan-W. Hahn Signed-off-by: Junio C Hamano diff --git a/gitk b/gitk index 29220b1..ab2d9b8 100755 --- a/gitk +++ b/gitk @@ -3158,7 +3158,7 @@ proc clickisonarrow {id y} { } proc arrowjump {id dirn y} { - global mainline sidelines canv + global mainline sidelines canv canv2 canv3 set yt {} if {$dirn eq "down"} { @@ -3196,6 +3196,8 @@ proc arrowjump {id dirn y} { set yfrac 0 } $canv yview moveto $yfrac + $canv2 yview moveto $yfrac + $canv3 yview moveto $yfrac } proc lineclick {x y id isnew} { -- cgit v0.10.2-6-g49f6 From f6e2869f48f7a9b51a2a867ce955c39a9314ef3b Mon Sep 17 00:00:00 2001 From: Paul Mackerras Date: Sun, 20 Nov 2005 23:08:22 +1100 Subject: gitk: Fix some bugs introduced by speedup changes Commits that weren't read from git-rev-list, i.e. the ones displayed with an open circle, were displayed incorrectly: the headline was null if there was only one line, and the commit comment was put all on one line. Also, the terminal commits weren't displayed when -r was used. Signed-off-by: Paul Mackerras diff --git a/gitk b/gitk index ab2d9b8..58b4abc 100755 --- a/gitk +++ b/gitk @@ -218,6 +218,8 @@ proc parsecommit {id contents listed olds} { set i [string first "\n" $comment] if {$i >= 0} { set headline [string trim [string range $comment 0 $i]] + } else { + set headline $comment } if {!$listed} { # git-rev-list indents the comment by 4 spaces; @@ -226,6 +228,7 @@ proc parsecommit {id contents listed olds} { foreach line [split $comment "\n"] { append newcomment " " append newcomment $line + append newcomment "\n" } set comment $newcomment } @@ -1503,17 +1506,15 @@ proc drawrest {} { global numcommits ncmupdate global nextupdate startmsecs revlistorder - if {!$revlistorder} { - set level [decidenext] - if {$level >= 0} { - set phase drawgraph - while 1 { - lappend displayorder [lindex $todo $level] - set hard [updatetodo $level $datemode] - if {$hard} { - set level [decidenext] - if {$level < 0} break - } + set level [decidenext] + if {$level >= 0} { + set phase drawgraph + while 1 { + lappend displayorder [lindex $todo $level] + set hard [updatetodo $level $datemode] + if {$hard} { + set level [decidenext] + if {$level < 0} break } } } -- cgit v0.10.2-6-g49f6