From 56e29f597c8f85b0dfee9ba7408f8d09fd5adb5a Mon Sep 17 00:00:00 2001 From: "Shawn O. Pearce" Date: Mon, 9 Jul 2007 11:55:45 -0400 Subject: [PATCH 1/2] git-gui: Correct ls-tree buffering problem in browser Our file browser was showing bad output as it did not properly buffer a partial record when read from `ls-tree -z`. This did not show up on my Mac OS X system as most trees are small, the pipe buffers generally big and `ls-tree -z` was generally fast enough that all data was ready before Tcl started to read. However on my Cygwin system one of my production repositories had a large enough tree and packfile that it took a couple of pipe buffers for `ls-tree -z` to complete its dump. Signed-off-by: Shawn O. Pearce --- lib/browser.tcl | 22 +++++++++++++--------- 1 file changed, 13 insertions(+), 9 deletions(-) diff --git a/lib/browser.tcl b/lib/browser.tcl index 3d6341bcc5..e612247c9e 100644 --- a/lib/browser.tcl +++ b/lib/browser.tcl @@ -11,6 +11,8 @@ field browser_status {Starting...} field browser_stack {} field browser_busy 1 +field ls_buf {}; # Buffered record output from ls-tree + constructor new {commit} { global cursor_ptr M1B make_toplevel top w @@ -160,7 +162,7 @@ method _click {was_double_click pos} { } method _ls {tree_id {name {}}} { - set browser_buffer {} + set ls_buf {} set browser_files {} set browser_busy 1 @@ -185,17 +187,19 @@ method _ls {tree_id {name {}}} { } method _read {fd} { - append browser_buffer [read $fd] - set pck [split $browser_buffer "\0"] - set browser_buffer [lindex $pck end] + append ls_buf [read $fd] + set pck [split $ls_buf "\0"] + set ls_buf [lindex $pck end] set n [llength $browser_files] $w conf -state normal foreach p [lrange $pck 0 end-1] { - set info [split $p "\t"] - set path [lindex $info 1] - set info [split [lindex $info 0] { }] - set type [lindex $info 1] + set tab [string first "\t" $p] + if {$tab == -1} continue + + set info [split [string range $p 0 [expr {$tab - 1}]] { }] + set path [string range $p [expr {$tab + 1}] end] + set type [lindex $info 1] set object [lindex $info 2] switch -- $type { @@ -225,7 +229,7 @@ method _read {fd} { close $fd set browser_status Ready. set browser_busy 0 - unset browser_buffer + set ls_buf {} if {$n > 0} { $w tag add in_sel 1.0 2.0 focus -force $w From e87fb0f1b4a4b458394a65d664145a9a8001e821 Mon Sep 17 00:00:00 2001 From: "Shawn O. Pearce" Date: Mon, 9 Jul 2007 11:14:00 -0400 Subject: [PATCH 2/2] git-gui: Don't linewrap within console windows If we get more than 80 characters of text in a single line odds are it is output from git-fetch or git-push and its showing a lot of detail off to the right edge that is not so important to the average user. We still want to make sure we show everything we need, but we can get away with that information being off to the side with a horizontal scrollbar. Signed-off-by: Shawn O. Pearce --- lib/console.tcl | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/lib/console.tcl b/lib/console.tcl index ce25d92cac..34de5d4859 100644 --- a/lib/console.tcl +++ b/lib/console.tcl @@ -31,16 +31,20 @@ method _init {} { -background white -borderwidth 1 \ -relief sunken \ -width 80 -height 10 \ + -wrap none \ -font font_diff \ -state disabled \ + -xscrollcommand [list $w.m.sbx set] \ -yscrollcommand [list $w.m.sby set] label $w.m.s -text {Working... please wait...} \ -anchor w \ -justify left \ -font font_uibold + scrollbar $w.m.sbx -command [list $w.m.t xview] -orient h scrollbar $w.m.sby -command [list $w.m.t yview] pack $w.m.l1 -side top -fill x pack $w.m.s -side bottom -fill x + pack $w.m.sbx -side bottom -fill x pack $w.m.sby -side right -fill y pack $w.m.t -side left -fill both -expand 1 pack $w.m -side top -fill both -expand 1 -padx 5 -pady 10