1
0
Fork 0
mirror of https://github.com/git/git.git synced 2024-10-29 21:37:53 +01:00

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>
This commit is contained in:
Shawn O. Pearce 2006-11-07 18:34:09 -05:00
parent c5437df168
commit 868c875245

59
git-gui
View file

@ -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
}