git-gui: Always disable the Tcl EOF character when reading
[gitweb.git] / lib / checkout_op.tcl
index 844d8e551c14ba743fbb31746462440b15bb22d0..00a994be120edaa1024733cb94e3f1fe4e494039 100644 (file)
@@ -19,6 +19,7 @@ field create        0; # create the branch if it doesn't exist?
 field reset_ok      0; # did the user agree to reset?
 field fetch_ok      0; # did the fetch succeed?
 
+field readtree_d   {}; # buffered output from read-tree
 field update_old   {}; # was the update-ref call deferred?
 field reflog_msg   {}; # log message for the update-ref call
 
@@ -273,12 +274,12 @@ The rescan will be automatically started now.
                _readtree $this
        } else {
                ui_status {Refreshing file status...}
-               set cmd [list git update-index]
-               lappend cmd -q
-               lappend cmd --unmerged
-               lappend cmd --ignore-missing
-               lappend cmd --refresh
-               set fd [open "| $cmd" r]
+               set fd [git_read update-index \
+                       -q \
+                       --unmerged \
+                       --ignore-missing \
+                       --refresh \
+                       ]
                fconfigure $fd -blocking 0 -translation binary
                fileevent $fd readable [cb _refresh_wait $fd]
        }
@@ -309,51 +310,60 @@ method _name {} {
 method _readtree {} {
        global HEAD
 
-       ui_status "Updating working directory to '[_name $this]'..."
-       set cmd [list git read-tree]
-       lappend cmd -m
-       lappend cmd -u
-       lappend cmd --exclude-per-directory=.gitignore
-       lappend cmd $HEAD
-       lappend cmd $new_hash
-       set fd [open "| $cmd" r]
+       set readtree_d {}
+       $::main_status start \
+               "Updating working directory to '[_name $this]'..." \
+               {files checked out}
+
+       set fd [git_read --stderr read-tree \
+               -m \
+               -u \
+               -v \
+               --exclude-per-directory=.gitignore \
+               $HEAD \
+               $new_hash \
+               ]
        fconfigure $fd -blocking 0 -translation binary
        fileevent $fd readable [cb _readtree_wait $fd]
 }
 
 method _readtree_wait {fd} {
-       global selected_commit_type commit_type HEAD MERGE_HEAD PARENT
-       global current_branch is_detached
-       global ui_comm
+       global current_branch
+
+       set buf [read $fd]
+       $::main_status update_meter $buf
+       append readtree_d $buf
 
-       # -- We never get interesting output on stdout; only stderr.
-       #
-       read $fd
        fconfigure $fd -blocking 1
        if {![eof $fd]} {
                fconfigure $fd -blocking 0
                return
        }
 
-       set name [_name $this]
-
-       # -- The working directory wasn't in sync with the index and
-       #    we'd have to overwrite something to make the switch. A
-       #    merge is required.
-       #
-       if {[catch {close $fd} err]} {
+       if {[catch {close $fd}]} {
+               set err $readtree_d
                regsub {^fatal: } $err {} err
+               $::main_status stop "Aborted checkout of '[_name $this]' (file level merging is required)."
                warn_popup "File level merge required.
 
 $err
 
 Staying on branch '$current_branch'."
-               ui_status "Aborted checkout of '$name' (file level merging is required)."
                unlock_index
                delete_this
                return
        }
 
+       $::main_status stop
+       _after_readtree $this
+}
+
+method _after_readtree {} {
+       global selected_commit_type commit_type HEAD MERGE_HEAD PARENT
+       global current_branch is_detached
+       global ui_comm
+
+       set name [_name $this]
        set log "checkout: moving"
        if {!$is_detached} {
                append log " from $current_branch"
@@ -505,7 +515,7 @@ method _confirm_reset {cur} {
        pack $w.buttons.cancel -side right -padx 5
        pack $w.buttons -side bottom -fill x -pady 10 -padx 10
 
-       set fd [open "| git rev-list --pretty=oneline $cur ^$new_hash" r]
+       set fd [git_read rev-list --pretty=oneline $cur ^$new_hash]
        while {[gets $fd line] > 0} {
                set abbr [string range $line 0 7]
                set subj [string range $line 41 end]