提交 1cad232f 编写于 作者: S Shawn O. Pearce

git-gui: Use progress meter in the status bar during index updates

If we are updating the index to stage or unstage changes or reverting
files in the working directory we can use the progress handling parts
of our status bar to perform this display work, reducing the amount of
code duplication we have in the index handling module.

Unfortunately the status bar is still a strict approximation as it is
unable to know when git-update-index has processed the data we fed to
it.  The progress bar is actually a progress of the pipe buffer filling
up in the OS, not of the actual work done.  Still, it tells the user we
are working and that has some value.
Signed-off-by: NShawn O. Pearce <spearce@spearce.org>
上级 51e1eadb
......@@ -12,12 +12,7 @@ proc update_indexinfo {msg pathList after} {
set batch [expr {int($totalCnt * .01) + 1}]
if {$batch > 25} {set batch 25}
ui_status [format \
"%s... %i/%i files (%.2f%%)" \
$msg \
$update_index_cp \
$totalCnt \
0.0]
$::main_status start $msg [mc "files"]
set fd [git_write update-index -z --index-info]
fconfigure $fd \
-blocking 0 \
......@@ -31,18 +26,18 @@ proc update_indexinfo {msg pathList after} {
$pathList \
$totalCnt \
$batch \
$msg \
$after \
]
}
proc write_update_indexinfo {fd pathList totalCnt batch msg after} {
proc write_update_indexinfo {fd pathList totalCnt batch after} {
global update_index_cp
global file_states current_diff_path
if {$update_index_cp >= $totalCnt} {
close $fd
unlock_index
$::main_status stop
uplevel #0 $after
return
}
......@@ -68,12 +63,7 @@ proc write_update_indexinfo {fd pathList totalCnt batch msg after} {
display_file $path $new
}
ui_status [format \
"%s... %i/%i files (%.2f%%)" \
$msg \
$update_index_cp \
$totalCnt \
[expr {100.0 * $update_index_cp / $totalCnt}]]
$::main_status update $update_index_cp $totalCnt
}
proc update_index {msg pathList after} {
......@@ -87,12 +77,7 @@ proc update_index {msg pathList after} {
set batch [expr {int($totalCnt * .01) + 1}]
if {$batch > 25} {set batch 25}
ui_status [format \
"%s... %i/%i files (%.2f%%)" \
$msg \
$update_index_cp \
$totalCnt \
0.0]
$::main_status start $msg [mc "files"]
set fd [git_write update-index --add --remove -z --stdin]
fconfigure $fd \
-blocking 0 \
......@@ -106,18 +91,18 @@ proc update_index {msg pathList after} {
$pathList \
$totalCnt \
$batch \
$msg \
$after \
]
}
proc write_update_index {fd pathList totalCnt batch msg after} {
proc write_update_index {fd pathList totalCnt batch after} {
global update_index_cp
global file_states current_diff_path
if {$update_index_cp >= $totalCnt} {
close $fd
unlock_index
$::main_status stop
uplevel #0 $after
return
}
......@@ -147,12 +132,7 @@ proc write_update_index {fd pathList totalCnt batch msg after} {
display_file $path $new
}
ui_status [format \
"%s... %i/%i files (%.2f%%)" \
$msg \
$update_index_cp \
$totalCnt \
[expr {100.0 * $update_index_cp / $totalCnt}]]
$::main_status update $update_index_cp $totalCnt
}
proc checkout_index {msg pathList after} {
......@@ -166,12 +146,7 @@ proc checkout_index {msg pathList after} {
set batch [expr {int($totalCnt * .01) + 1}]
if {$batch > 25} {set batch 25}
ui_status [format \
"%s... %i/%i files (%.2f%%)" \
$msg \
$update_index_cp \
$totalCnt \
0.0]
$::main_status start $msg [mc "files"]
set fd [git_write checkout-index \
--index \
--quiet \
......@@ -191,18 +166,18 @@ proc checkout_index {msg pathList after} {
$pathList \
$totalCnt \
$batch \
$msg \
$after \
]
}
proc write_checkout_index {fd pathList totalCnt batch msg after} {
proc write_checkout_index {fd pathList totalCnt batch after} {
global update_index_cp
global file_states current_diff_path
if {$update_index_cp >= $totalCnt} {
close $fd
unlock_index
$::main_status stop
uplevel #0 $after
return
}
......@@ -222,12 +197,7 @@ proc write_checkout_index {fd pathList totalCnt batch msg after} {
}
}
ui_status [format \
"%s... %i/%i files (%.2f%%)" \
$msg \
$update_index_cp \
$totalCnt \
[expr {100.0 * $update_index_cp / $totalCnt}]]
$::main_status update $update_index_cp $totalCnt
}
proc unstage_helper {txt paths} {
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册