@matheusbsbs / matheus-bagliano / commits / 04b393824f
Fork 0

git-gui: Allow update_index to also run a script when it completes.

Like rescan we also have cases where we need to perform a script after we have finished updating a number of files in the index. By changing the parameter structure of update_index we can easily pass through any script we need to run afterwards, such as picking up in the middle of a commit, or finishing what is left of a rescan. Signed-off-by: Shawn O. Pearce <spearce@spearce.org>

Shawn O. Pearce committed Nov 14, 2006 at 01:42 UTC 04b393824ff57b5fcb881a00466e513cd4ad2a7f
1 file changed +20 -11
git-gui
+20 -11
@@ -428,7 +428,10 @@ proc rescan_done {fd buf after} {
428 }
429 }
430 if {$pathList ne {}} {
431 - update_index $pathList
431 + update_index \
432 + "Updating included files" \
433 + $pathList \
434 + [concat {reshow_diff;} $after]
435 return
436 }
437 }
@@ -1197,7 +1200,7 @@ proc display_all_files {} {
1200 $ui_other conf -state disabled
1201 }
1202
1200 -proc update_index {pathList} {
1203 +proc update_index {msg pathList after} {
1204 global update_index_cp update_index_rsd ui_status_value
1205
1206 if {![lock_index update]} return
@@ -1210,7 +1213,7 @@ proc update_index {pathList} {
1213 if {$batch > 25} {set batch 25}
1214
1215 set ui_status_value [format \
1213 - "Including files ... %i/%i files (%.2f%%)" \
1216 + "$msg... %i/%i files (%.2f%%)" \
1217 $update_index_cp \
1218 $totalCnt \
1219 0.0]
@@ -1226,20 +1229,20 @@ proc update_index {pathList} {
1229 $pathList \
1230 $totalCnt \
1231 $batch \
1232 + $msg \
1233 + $after \
1234 ]
1235 }
1236
1232 -proc write_update_index {fd pathList totalCnt batch} {
1237 +proc write_update_index {fd pathList totalCnt batch msg after} {
1238 global update_index_cp update_index_rsd ui_status_value
1239 global file_states ui_fname_value
1240
1241 if {$update_index_cp >= $totalCnt} {
1242 close $fd
1243 unlock_index
1239 - set ui_status_value {Ready.}
1240 - if {$update_index_rsd} {
1241 - reshow_diff
1242 - }
1244 + if {$update_index_rsd} reshow_diff
1245 + uplevel #0 $after
1246 return
1247 }
1248
@@ -1268,7 +1271,7 @@ proc write_update_index {fd pathList totalCnt batch} {
1271 }
1272
1273 set ui_status_value [format \
1271 - "Including files ... %i/%i files (%.2f%%)" \
1274 + "$msg... %i/%i files (%.2f%%)" \
1275 $update_index_cp \
1276 $totalCnt \
1277 [expr {100.0 * $update_index_cp / $totalCnt}]]
@@ -1766,7 +1769,10 @@ proc do_include_all {} {
1769 if {$pathList eq {}} {
1770 unlock_index
1771 } else {
1769 - update_index $pathList
1772 + update_index \
1773 + "Including all modified files" \
1774 + $pathList \
1775 + {set ui_status_value {Ready to commit.}}
1776 }
1777 }
1778
@@ -1985,7 +1991,10 @@ proc toggle_or_diff {w x y} {
1991 $ui_other tag remove in_sel 0.0 end
1992
1993 if {$col == 0} {
1988 - update_index [list $path]
1994 + update_index \
1995 + "Including [short_path $path]" \
1996 + [list $path] \
1997 + {set ui_status_value {Ready.}}
1998 } else {
1999 show_diff $path $w $lno
2000 }