From 1cad232f92794834c8e70dfc0a1f35431d2c05cd Mon Sep 17 00:00:00 2001 From: "Shawn O. Pearce" Date: Sun, 7 Oct 2007 18:12:31 -0700 Subject: [PATCH] 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: Shawn O. Pearce --- lib/index.tcl | 54 ++++++++++++--------------------------------------- 1 file changed, 12 insertions(+), 42 deletions(-) diff --git a/lib/index.tcl b/lib/index.tcl index 47255261d..9e04f2b68 100644 --- a/lib/index.tcl +++ b/lib/index.tcl @@ -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} { -- 2.26.2