提交 0fe055cd 编写于 作者: S Shawn O. Pearce

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: NShawn O. Pearce <spearce@spearce.org>
上级 94a4dd9b
...@@ -233,10 +233,10 @@ Continue with resetting the current changes?" ...@@ -233,10 +233,10 @@ Continue with resetting the current changes?"
} }
if {[ask_popup $op_question] eq {yes}} { if {[ask_popup $op_question] eq {yes}} {
set fd [git_read read-tree --reset -u HEAD] set fd [git_read --stderr read-tree --reset -u -v HEAD]
fconfigure $fd -blocking 0 -translation binary fconfigure $fd -blocking 0 -translation binary
fileevent $fd readable [namespace code [list _reset_wait $fd]] fileevent $fd readable [namespace code [list _reset_wait $fd]]
ui_status {Aborting... please wait...} $::main_status start {Aborting} {files reset}
} else { } else {
unlock_index unlock_index
} }
...@@ -245,9 +245,12 @@ Continue with resetting the current changes?" ...@@ -245,9 +245,12 @@ Continue with resetting the current changes?"
proc _reset_wait {fd} { proc _reset_wait {fd} {
global ui_comm global ui_comm
read $fd $::main_status update_meter [read $fd]
fconfigure $fd -blocking 1
if {[eof $fd]} { if {[eof $fd]} {
close $fd set fail [catch {close $fd} err]
$::main_status stop
unlock_index unlock_index
$ui_comm delete 0.0 end $ui_comm delete 0.0 end
...@@ -259,7 +262,12 @@ proc _reset_wait {fd} { ...@@ -259,7 +262,12 @@ proc _reset_wait {fd} {
catch {file delete [gitdir MERGE_MSG]} catch {file delete [gitdir MERGE_MSG]}
catch {file delete [gitdir GITGUI_MSG]} catch {file delete [gitdir GITGUI_MSG]}
if {$fail} {
warn_popup "Abort failed.\n\n$err"
}
rescan {ui_status {Abort completed. Ready.}} rescan {ui_status {Abort completed. Ready.}}
} else {
fconfigure $fd -blocking 0
} }
} }
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册