summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLibravatar Shawn O. Pearce <spearce@spearce.org>2006-11-07 18:34:09 -0500
committerLibravatar Shawn O. Pearce <spearce@spearce.org>2006-11-07 23:48:20 -0500
commit868c8752451c0b75502a0134068f0cfe055eb7ad (patch)
treeab82641842717825499516e6dc6408b1f47752e9
parentgit-gui: Updated TODO list now that pull is starting to work. (diff)
downloadtgif-868c8752451c0b75502a0134068f0cfe055eb7ad.tar.xz
git-gui: Corrected diff-index/diff-files protocol parsing errors.
When we were receiving a lot of output from diff-index we split records at the wrong locations and started using the file status information (mode and SHA1s) as path names, and then proceeded to try to use part of the path names as status data. This caused all sorts of havoc. So I rewrote the parsing implementation to scan for the pair of null bytes along the buffer and stop scanning (waiting for more data) if both can't be found during this event. This seems to work well under high load (like when processing 6,983 added files). Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
-rwxr-xr-xgit-gui59
1 files changed, 47 insertions, 12 deletions
diff --git a/git-gui b/git-gui
index 4aa035a6c4..48e1c5601f 100755
--- a/git-gui
+++ b/git-gui
@@ -111,6 +111,7 @@ proc read_refresh {fd final} {
global gitdir PARENT commit_type
global ui_index ui_other ui_status_value ui_comm
global status_active file_states
+ global buf_rdi buf_rdf buf_rlo
read $fd
if {![eof $fd]} return
@@ -123,6 +124,10 @@ proc read_refresh {fd final} {
lappend ls_others "--exclude-from=$info_exclude"
}
+ set buf_rdi {}
+ set buf_rdf {}
+ set buf_rlo {}
+
set status_active 3
set ui_status_value {Scanning for modified files ...}
set fd_di [open "| git diff-index --cached -z $PARENT" r]
@@ -158,13 +163,28 @@ proc read_diff_index {fd final} {
global buf_rdi
append buf_rdi [read $fd]
- set pck [split $buf_rdi "\0"]
- set buf_rdi [lindex $pck end]
- foreach {m p} [lrange $pck 0 end-1] {
- if {$m != {} && $p != {}} {
- display_file $p [string index $m end]_
- }
+ set c 0
+ set n [string length $buf_rdi]
+ while {$c < $n} {
+ set z1 [string first "\0" $buf_rdi $c]
+ if {$z1 == -1} break
+ incr z1
+ set z2 [string first "\0" $buf_rdi $z1]
+ if {$z2 == -1} break
+
+ set c $z2
+ incr z2 -1
+ display_file \
+ [string range $buf_rdi $z1 $z2] \
+ [string index $buf_rdi [expr $z1 - 2]]_
+ incr c
+ }
+ if {$c < $n} {
+ set buf_rdi [string range $buf_rdi $c end]
+ } else {
+ set buf_rdi {}
}
+
status_eof $fd buf_rdi $final
}
@@ -172,13 +192,28 @@ proc read_diff_files {fd final} {
global buf_rdf
append buf_rdf [read $fd]
- set pck [split $buf_rdf "\0"]
- set buf_rdf [lindex $pck end]
- foreach {m p} [lrange $pck 0 end-1] {
- if {$m != {} && $p != {}} {
- display_file $p _[string index $m end]
- }
+ set c 0
+ set n [string length $buf_rdf]
+ while {$c < $n} {
+ set z1 [string first "\0" $buf_rdf $c]
+ if {$z1 == -1} break
+ incr z1
+ set z2 [string first "\0" $buf_rdf $z1]
+ if {$z2 == -1} break
+
+ set c $z2
+ incr z2 -1
+ display_file \
+ [string range $buf_rdf $z1 $z2] \
+ _[string index $buf_rdf [expr $z1 - 2]]
+ incr c
+ }
+ if {$c < $n} {
+ set buf_rdf [string range $buf_rdf $c end]
+ } else {
+ set buf_rdf {}
}
+
status_eof $fd buf_rdf $final
}