@matheusbsbs / matheus-bagliano / commits / 0fe055cd24
Fork 0

git-gui: Use progress bar while resetting/aborting files

Resetting a large number of files on a slow filesystem can take considerable time, just as switching branches in such a case can take more than two seconds. We now take advantage of the progress meter output by read-tree and show it in the main window status bar, just like we do during checkout (branch switch). Signed-off-by: Shawn O. Pearce <spearce@spearce.org>

Shawn O. Pearce committed Jul 29, 2007 at 04:06 UTC 0fe055cd2480763393b20676a10fd0bea56b2fc2
1 file changed +12 -4
lib/merge.tcl
+12 -4
@@ -233,10 +233,10 @@ Continue with resetting the current changes?"
233 }
234
235 if {[ask_popup $op_question] eq {yes}} {
236 - set fd [git_read read-tree --reset -u HEAD]
236 + set fd [git_read --stderr read-tree --reset -u -v HEAD]
237 fconfigure $fd -blocking 0 -translation binary
238 fileevent $fd readable [namespace code [list _reset_wait $fd]]
239 - ui_status {Aborting... please wait...}
239 + $::main_status start {Aborting} {files reset}
240 } else {
241 unlock_index
242 }
@@ -245,9 +245,12 @@ Continue with resetting the current changes?"
245 proc _reset_wait {fd} {
246 global ui_comm
247
248 - read $fd
248 + $::main_status update_meter [read $fd]
249 +
250 + fconfigure $fd -blocking 1
251 if {[eof $fd]} {
250 - close $fd
252 + set fail [catch {close $fd} err]
253 + $::main_status stop
254 unlock_index
255
256 $ui_comm delete 0.0 end
@@ -259,7 +262,12 @@ proc _reset_wait {fd} {
262 catch {file delete [gitdir MERGE_MSG]}
263 catch {file delete [gitdir GITGUI_MSG]}
264
265 + if {$fail} {
266 + warn_popup "Abort failed.\n\n$err"
267 + }
268 rescan {ui_status {Abort completed. Ready.}}
269 + } else {
270 + fconfigure $fd -blocking 0
271 }
272 }
273