Code

git-gui: Allow users to browse any branch, not just the current one
[git.git] / lib / diff.tcl
index 05bf75179bdc04cc31e887f9d0817524db8a1cf4..e09e1257e1be299caceb0c6f0074c1b43b566974 100644 (file)
@@ -86,6 +86,7 @@ proc show_diff {path w {lno {}}} {
                set max_sz [expr {128 * 1024}]
                if {[catch {
                                set fd [open $path r]
+                               fconfigure $fd -eofchar {}
                                set content [read $fd $max_sz]
                                close $fd
                                set sz [file size $path]
@@ -131,7 +132,7 @@ proc show_diff {path w {lno {}}} {
                return
        }
 
-       set cmd [list | git]
+       set cmd [list]
        if {$w eq $ui_index} {
                lappend cmd diff-index
                lappend cmd --cached
@@ -154,7 +155,7 @@ proc show_diff {path w {lno {}}} {
        lappend cmd --
        lappend cmd $path
 
-       if {[catch {set fd [open $cmd r]} err]} {
+       if {[catch {set fd [eval git_read --nice $cmd]} err]} {
                set diff_active 0
                unlock_index
                ui_status "Unable to display [escape_path $path]"
@@ -271,7 +272,7 @@ proc apply_hunk {x y} {
        if {$current_diff_path eq {} || $current_diff_header eq {}} return
        if {![lock_index apply_hunk]} return
 
-       set apply_cmd {git apply --cached --whitespace=nowarn}
+       set apply_cmd {apply --cached --whitespace=nowarn}
        set mi [lindex $file_states($current_diff_path) 0]
        if {$current_diff_side eq $ui_index} {
                set mode unstage
@@ -301,7 +302,7 @@ proc apply_hunk {x y} {
        }
 
        if {[catch {
-               set p [open "| $apply_cmd" w]
+               set p [eval git_write $apply_cmd]
                fconfigure $p -translation binary -encoding binary
                puts -nonewline $p $current_diff_header
                puts -nonewline $p [$ui_diff get $s_lno $e_lno]