diff options
Diffstat (limited to 'lib')
-rw-r--r-- | lib/blame.tcl | 21 | ||||
-rw-r--r-- | lib/branch.tcl | 7 | ||||
-rw-r--r-- | lib/browser.tcl | 3 | ||||
-rw-r--r-- | lib/checkout_op.tcl | 39 | ||||
-rw-r--r-- | lib/commit.tcl | 4 | ||||
-rw-r--r-- | lib/database.tcl | 2 | ||||
-rw-r--r-- | lib/diff.tcl | 8 | ||||
-rw-r--r-- | lib/index.tcl | 18 | ||||
-rw-r--r-- | lib/merge.tcl | 18 | ||||
-rw-r--r-- | lib/option.tcl | 1 | ||||
-rw-r--r-- | lib/remote.tcl | 2 | ||||
-rw-r--r-- | lib/remote_branch_delete.tcl | 2 |
12 files changed, 57 insertions, 68 deletions
diff --git a/lib/blame.tcl b/lib/blame.tcl index 13bfab3352..4bdb9a27a3 100644 --- a/lib/blame.tcl +++ b/lib/blame.tcl @@ -371,8 +371,7 @@ method _load {jump} { if {$commit eq {}} { set fd [open $path r] } else { - set cmd [list git cat-file blob "$commit:$path"] - set fd [open "| $cmd" r] + set fd [git_read cat-file blob "$commit:$path"] } fconfigure $fd -blocking 0 -translation lf -encoding binary fileevent $fd readable [cb _read_file $fd $jump] @@ -475,20 +474,14 @@ method _read_file {fd jump} { } ifdeleted { catch {close $fd} } method _exec_blame {cur_w cur_d options cur_s} { - set cmd [list] - if {![is_Windows] || [is_Cygwin]} { - lappend cmd nice - } - lappend cmd git blame - set cmd [concat $cmd $options] - lappend cmd --incremental + lappend options --incremental if {$commit eq {}} { - lappend cmd --contents $path + lappend options --contents $path } else { - lappend cmd $commit + lappend options $commit } - lappend cmd -- $path - set fd [open "| $cmd" r] + lappend options -- $path + set fd [eval git_read --nice blame $options] fconfigure $fd -blocking 0 -translation lf -encoding binary fileevent $fd readable [cb _read_blame $fd $cur_w $cur_d] set current_fd $fd @@ -767,7 +760,7 @@ method _showcommit {cur_w lno} { if {[catch {set msg $header($cmit,message)}]} { set msg {} catch { - set fd [open "| git cat-file commit $cmit" r] + set fd [git_read cat-file commit $cmit] fconfigure $fd -encoding binary -translation lf if {[catch {set enc $repo_config(i18n.commitencoding)}]} { set enc utf-8 diff --git a/lib/branch.tcl b/lib/branch.tcl index b948d926ae..777eeb79c1 100644 --- a/lib/branch.tcl +++ b/lib/branch.tcl @@ -7,7 +7,7 @@ proc load_all_heads {} { set rh refs/heads set rh_len [expr {[string length $rh] + 1}] set all_heads [list] - set fd [open "| git for-each-ref --format=%(refname) $rh" r] + set fd [git_read for-each-ref --format=%(refname) $rh] while {[gets $fd line] > 0} { if {!$some_heads_tracking || ![is_tracking_branch $line]} { lappend all_heads [string range $line $rh_len end] @@ -20,7 +20,10 @@ proc load_all_heads {} { proc load_all_tags {} { set all_tags [list] - set fd [open "| git for-each-ref --sort=-taggerdate --format=%(refname) refs/tags" r] + set fd [git_read for-each-ref \ + --sort=-taggerdate \ + --format=%(refname) \ + refs/tags] while {[gets $fd line] > 0} { if {![regsub ^refs/tags/ $line {} name]} continue lappend all_tags $name diff --git a/lib/browser.tcl b/lib/browser.tcl index 3d6341bcc5..4d33052ab5 100644 --- a/lib/browser.tcl +++ b/lib/browser.tcl @@ -178,8 +178,7 @@ method _ls {tree_id {name {}}} { lappend browser_stack [list $tree_id $name] $w conf -state disabled - set cmd [list git ls-tree -z $tree_id] - set fd [open "| $cmd" r] + set fd [git_read ls-tree -z $tree_id] fconfigure $fd -blocking 0 -translation binary -encoding binary fileevent $fd readable [cb _read $fd] } diff --git a/lib/checkout_op.tcl b/lib/checkout_op.tcl index 5d02daac6f..00a994be12 100644 --- a/lib/checkout_op.tcl +++ b/lib/checkout_op.tcl @@ -274,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] } @@ -315,23 +315,14 @@ method _readtree {} { "Updating working directory to '[_name $this]'..." \ {files checked out} - set cmd [list git read-tree] - lappend cmd -m - lappend cmd -u - lappend cmd -v - lappend cmd --exclude-per-directory=.gitignore - lappend cmd $HEAD - lappend cmd $new_hash - - if {[catch { - set fd [open "| $cmd 2>@1" r] - } err]} { - # Older versions of Tcl 8.4 don't have this 2>@1 IO - # redirect operator. Fallback to |& cat for those. - # - set fd [open "| $cmd |& cat" r] - } - + 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] } @@ -524,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] diff --git a/lib/commit.tcl b/lib/commit.tcl index d0e4996bae..dc7c88c601 100644 --- a/lib/commit.tcl +++ b/lib/commit.tcl @@ -25,7 +25,7 @@ You are currently in the middle of a merge that has not been fully completed. Y set msg {} set parents [list] if {[catch { - set fd [open "| git cat-file commit $curHEAD" r] + set fd [git_read cat-file commit $curHEAD] fconfigure $fd -encoding binary -translation lf if {[catch {set enc $repo_config(i18n.commitencoding)}]} { set enc utf-8 @@ -235,7 +235,7 @@ proc commit_prehook_wait {fd_ph curHEAD msg} { proc commit_writetree {curHEAD msg} { ui_status {Committing changes...} - set fd_wt [open "| git write-tree" r] + set fd_wt [git_read write-tree] fileevent $fd_wt readable \ [list commit_committree $fd_wt $curHEAD $msg] } diff --git a/lib/database.tcl b/lib/database.tcl index 43e4a289bb..87c815d7ac 100644 --- a/lib/database.tcl +++ b/lib/database.tcl @@ -2,7 +2,7 @@ # Copyright (C) 2006, 2007 Shawn Pearce proc do_stats {} { - set fd [open "| git count-objects -v" r] + set fd [git_read count-objects -v] while {[gets $fd line] > 0} { if {[regexp {^([^:]+): (\d+)$} $line _ name value]} { set stats($name) $value diff --git a/lib/diff.tcl b/lib/diff.tcl index 05bf75179b..9cb9d0604a 100644 --- a/lib/diff.tcl +++ b/lib/diff.tcl @@ -131,7 +131,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 +154,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 +271,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 +301,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] diff --git a/lib/index.tcl b/lib/index.tcl index 7c175a96a6..3ea72e1ec9 100644 --- a/lib/index.tcl +++ b/lib/index.tcl @@ -17,7 +17,7 @@ proc update_indexinfo {msg pathList after} { $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 \ @@ -90,7 +90,7 @@ proc update_index {msg pathList after} { $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 \ @@ -167,13 +167,13 @@ proc checkout_index {msg pathList after} { $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 \ diff --git a/lib/merge.tcl b/lib/merge.tcl index f0a02ea228..288d7ac889 100644 --- a/lib/merge.tcl +++ b/lib/merge.tcl @@ -146,7 +146,7 @@ The working directory will now be reset. You can attempt this merge again by merging only one branch at a time." $w - set fd [open "| git read-tree --reset -u HEAD" r] + set fd [git_read read-tree --reset -u HEAD] fconfigure $fd -blocking 0 -translation binary fileevent $fd readable \ [namespace code [list _reset_wait $fd]] @@ -167,11 +167,13 @@ proc dialog {} { if {![_can_merge]} return set fmt {list %(objectname) %(*objectname) %(refname) %(subject)} - set cmd [list git for-each-ref --tcl --format=$fmt] - lappend cmd refs/heads - lappend cmd refs/remotes - lappend cmd refs/tags - set fr_fd [open "| $cmd" r] + set fr_fd [git_read for-each-ref \ + --tcl \ + --format=$fmt \ + refs/heads \ + refs/remotes \ + refs/tags \ + ] fconfigure $fr_fd -translation binary while {[gets $fr_fd line] > 0} { set line [eval $line] @@ -186,7 +188,7 @@ proc dialog {} { close $fr_fd set to_show {} - set fr_fd [open "| git rev-list --all --not HEAD"] + set fr_fd [git_read rev-list --all --not HEAD] while {[gets $fr_fd line] > 0} { if {[catch {set ref $sha1($line)}]} continue foreach n $ref { @@ -282,7 +284,7 @@ You must finish amending this commit. Aborting the current $op will cause *ALL* uncommitted changes to be lost. Continue with aborting the current $op?"] eq {yes}} { - set fd [open "| git read-tree --reset -u HEAD" r] + set fd [git_read read-tree --reset -u HEAD] fconfigure $fd -blocking 0 -translation binary fileevent $fd readable [namespace code [list _reset_wait $fd]] ui_status {Aborting... please wait...} diff --git a/lib/option.tcl b/lib/option.tcl index 743304269b..aa9f783afd 100644 --- a/lib/option.tcl +++ b/lib/option.tcl @@ -95,6 +95,7 @@ $copyright" \ } set d {} + append d "git wrapper: $::_git\n" append d "git exec dir: [gitexec]\n" append d "git-gui lib: $oguilib" diff --git a/lib/remote.tcl b/lib/remote.tcl index fabec05fff..e235ca8876 100644 --- a/lib/remote.tcl +++ b/lib/remote.tcl @@ -32,7 +32,7 @@ proc all_tracking_branches {} { } if {$pat ne {}} { - set fd [open "| git for-each-ref --format=%(refname) $cmd" r] + set fd [eval git_read for-each-ref --format=%(refname) $cmd] while {[gets $fd n] > 0} { foreach spec $pat { set dst [string range [lindex $spec 0] 0 end-2] diff --git a/lib/remote_branch_delete.tcl b/lib/remote_branch_delete.tcl index d7e2b8db45..c88a360db5 100644 --- a/lib/remote_branch_delete.tcl +++ b/lib/remote_branch_delete.tcl @@ -296,7 +296,7 @@ method _load {cache uri} { set full_list [list] set head_cache($cache) [list] set full_cache($cache) [list] - set active_ls [open "| [list git ls-remote $uri]" r] + set active_ls [git_read ls-remote $uri] fconfigure $active_ls \ -blocking 0 \ -translation lf \ |