# Copyright (C) 2006, 2007 Shawn Pearce
 
 proc update_indexinfo {msg pathList after} {
-       global update_index_cp ui_status_value
+       global update_index_cp
 
        if {![lock_index update]} return
 
        set batch [expr {int($totalCnt * .01) + 1}]
        if {$batch > 25} {set batch 25}
 
-       set ui_status_value [format \
-               "$msg... %i/%i files (%.2f%%)" \
+       ui_status [format \
+               "%s... %i/%i files (%.2f%%)" \
+               $msg \
                $update_index_cp \
                $totalCnt \
                0.0]
-       set fd [open "| git update-index -z --index-info" w]
+       set fd [git_write update-index -z --index-info]
        fconfigure $fd \
                -blocking 0 \
                -buffering full \
 }
 
 proc write_update_indexinfo {fd pathList totalCnt batch msg after} {
-       global update_index_cp ui_status_value
+       global update_index_cp
        global file_states current_diff_path
 
        if {$update_index_cp >= $totalCnt} {
                display_file $path $new
        }
 
-       set ui_status_value [format \
-               "$msg... %i/%i files (%.2f%%)" \
+       ui_status [format \
+               "%s... %i/%i files (%.2f%%)" \
+               $msg \
                $update_index_cp \
                $totalCnt \
                [expr {100.0 * $update_index_cp / $totalCnt}]]
 }
 
 proc update_index {msg pathList after} {
-       global update_index_cp ui_status_value
+       global update_index_cp
 
        if {![lock_index update]} return
 
        set batch [expr {int($totalCnt * .01) + 1}]
        if {$batch > 25} {set batch 25}
 
-       set ui_status_value [format \
-               "$msg... %i/%i files (%.2f%%)" \
+       ui_status [format \
+               "%s... %i/%i files (%.2f%%)" \
+               $msg \
                $update_index_cp \
                $totalCnt \
                0.0]
-       set fd [open "| git update-index --add --remove -z --stdin" w]
+       set fd [git_write update-index --add --remove -z --stdin]
        fconfigure $fd \
                -blocking 0 \
                -buffering full \
 }
 
 proc write_update_index {fd pathList totalCnt batch msg after} {
-       global update_index_cp ui_status_value
+       global update_index_cp
        global file_states current_diff_path
 
        if {$update_index_cp >= $totalCnt} {
                display_file $path $new
        }
 
-       set ui_status_value [format \
-               "$msg... %i/%i files (%.2f%%)" \
+       ui_status [format \
+               "%s... %i/%i files (%.2f%%)" \
+               $msg \
                $update_index_cp \
                $totalCnt \
                [expr {100.0 * $update_index_cp / $totalCnt}]]
 }
 
 proc checkout_index {msg pathList after} {
-       global update_index_cp ui_status_value
+       global update_index_cp
 
        if {![lock_index update]} return
 
        set batch [expr {int($totalCnt * .01) + 1}]
        if {$batch > 25} {set batch 25}
 
-       set ui_status_value [format \
-               "$msg... %i/%i files (%.2f%%)" \
+       ui_status [format \
+               "%s... %i/%i files (%.2f%%)" \
+               $msg \
                $update_index_cp \
                $totalCnt \
                0.0]
-       set cmd [list git checkout-index]
-       lappend cmd --index
-       lappend cmd --quiet
-       lappend cmd --force
-       lappend cmd -z
-       lappend cmd --stdin
-       set fd [open "| $cmd " w]
+       set fd [git_write checkout-index \
+               --index \
+               --quiet \
+               --force \
+               -z \
+               --stdin \
+               ]
        fconfigure $fd \
                -blocking 0 \
                -buffering full \
 }
 
 proc write_checkout_index {fd pathList totalCnt batch msg after} {
-       global update_index_cp ui_status_value
+       global update_index_cp
        global file_states current_diff_path
 
        if {$update_index_cp >= $totalCnt} {
                }
        }
 
-       set ui_status_value [format \
-               "$msg... %i/%i files (%.2f%%)" \
+       ui_status [format \
+               "%s... %i/%i files (%.2f%%)" \
+               $msg \
                $update_index_cp \
                $totalCnt \
                [expr {100.0 * $update_index_cp / $totalCnt}]]
                update_indexinfo \
                        $txt \
                        $pathList \
-                       [concat $after {set ui_status_value {Ready.}}]
+                       [concat $after [list ui_ready]]
        }
 }
 
                update_index \
                        $txt \
                        $pathList \
-                       [concat $after {set ui_status_value {Ready to commit.}}]
+                       [concat $after {ui_status {Ready to commit.}}]
        }
 }
 
                "[appname] ([reponame])" \
                "Revert changes in $s?
 
-Any unadded changes will be permanently lost by the revert." \
+Any unstaged changes will be permanently lost by the revert." \
                question \
                1 \
                {Do Nothing} \
                checkout_index \
                        $txt \
                        $pathList \
-                       [concat $after {set ui_status_value {Ready.}}]
+                       [concat $after [list ui_ready]]
        } else {
                unlock_index
        }