@matheusbsbs / matheus-bagliano / commits / 1cad232f92
Fork 0

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 <spearce@spearce.org>

Shawn O. Pearce committed Oct 7, 2007 at 18:12 UTC 1cad232f92794834c8e70dfc0a1f35431d2c05cd
1 file changed +12 -42
lib/index.tcl
+12 -42
@@ -12,12 +12,7 @@ proc update_indexinfo {msg pathList after} {
12 set batch [expr {int($totalCnt * .01) + 1}]
13 if {$batch > 25} {set batch 25}
14
15 - ui_status [format \
16 - "%s... %i/%i files (%.2f%%)" \
17 - $msg \
18 - $update_index_cp \
19 - $totalCnt \
20 - 0.0]
15 + $::main_status start $msg [mc "files"]
16 set fd [git_write update-index -z --index-info]
17 fconfigure $fd \
18 -blocking 0 \
@@ -31,18 +26,18 @@ proc update_indexinfo {msg pathList after} {
26 $pathList \
27 $totalCnt \
28 $batch \
34 - $msg \
29 $after \
30 ]
31 }
32
39 -proc write_update_indexinfo {fd pathList totalCnt batch msg after} {
33 +proc write_update_indexinfo {fd pathList totalCnt batch after} {
34 global update_index_cp
35 global file_states current_diff_path
36
37 if {$update_index_cp >= $totalCnt} {
38 close $fd
39 unlock_index
40 + $::main_status stop
41 uplevel #0 $after
42 return
43 }
@@ -68,12 +63,7 @@ proc write_update_indexinfo {fd pathList totalCnt batch msg after} {
63 display_file $path $new
64 }
65
71 - ui_status [format \
72 - "%s... %i/%i files (%.2f%%)" \
73 - $msg \
74 - $update_index_cp \
75 - $totalCnt \
76 - [expr {100.0 * $update_index_cp / $totalCnt}]]
66 + $::main_status update $update_index_cp $totalCnt
67 }
68
69 proc update_index {msg pathList after} {
@@ -87,12 +77,7 @@ proc update_index {msg pathList after} {
77 set batch [expr {int($totalCnt * .01) + 1}]
78 if {$batch > 25} {set batch 25}
79
90 - ui_status [format \
91 - "%s... %i/%i files (%.2f%%)" \
92 - $msg \
93 - $update_index_cp \
94 - $totalCnt \
95 - 0.0]
80 + $::main_status start $msg [mc "files"]
81 set fd [git_write update-index --add --remove -z --stdin]
82 fconfigure $fd \
83 -blocking 0 \
@@ -106,18 +91,18 @@ proc update_index {msg pathList after} {
91 $pathList \
92 $totalCnt \
93 $batch \
109 - $msg \
94 $after \
95 ]
96 }
97
114 -proc write_update_index {fd pathList totalCnt batch msg after} {
98 +proc write_update_index {fd pathList totalCnt batch after} {
99 global update_index_cp
100 global file_states current_diff_path
101
102 if {$update_index_cp >= $totalCnt} {
103 close $fd
104 unlock_index
105 + $::main_status stop
106 uplevel #0 $after
107 return
108 }
@@ -147,12 +132,7 @@ proc write_update_index {fd pathList totalCnt batch msg after} {
132 display_file $path $new
133 }
134
150 - ui_status [format \
151 - "%s... %i/%i files (%.2f%%)" \
152 - $msg \
153 - $update_index_cp \
154 - $totalCnt \
155 - [expr {100.0 * $update_index_cp / $totalCnt}]]
135 + $::main_status update $update_index_cp $totalCnt
136 }
137
138 proc checkout_index {msg pathList after} {
@@ -166,12 +146,7 @@ proc checkout_index {msg pathList after} {
146 set batch [expr {int($totalCnt * .01) + 1}]
147 if {$batch > 25} {set batch 25}
148
169 - ui_status [format \
170 - "%s... %i/%i files (%.2f%%)" \
171 - $msg \
172 - $update_index_cp \
173 - $totalCnt \
174 - 0.0]
149 + $::main_status start $msg [mc "files"]
150 set fd [git_write checkout-index \
151 --index \
152 --quiet \
@@ -191,18 +166,18 @@ proc checkout_index {msg pathList after} {
166 $pathList \
167 $totalCnt \
168 $batch \
194 - $msg \
169 $after \
170 ]
171 }
172
199 -proc write_checkout_index {fd pathList totalCnt batch msg after} {
173 +proc write_checkout_index {fd pathList totalCnt batch after} {
174 global update_index_cp
175 global file_states current_diff_path
176
177 if {$update_index_cp >= $totalCnt} {
178 close $fd
179 unlock_index
180 + $::main_status stop
181 uplevel #0 $after
182 return
183 }
@@ -222,12 +197,7 @@ proc write_checkout_index {fd pathList totalCnt batch msg after} {
197 }
198 }
199
225 - ui_status [format \
226 - "%s... %i/%i files (%.2f%%)" \
227 - $msg \
228 - $update_index_cp \
229 - $totalCnt \
230 - [expr {100.0 * $update_index_cp / $totalCnt}]]
200 + $::main_status update $update_index_cp $totalCnt
201 }
202
203 proc unstage_helper {txt paths} {