Skip to content

Commit 2d3cfd7

Browse files
committed
Merge git://repo.or.cz/git-gui
* git://repo.or.cz/git-gui: git-gui: Vertically align textboxes with labels git-gui: Handle workdir detection when CYGWIN=nowinsymlinks git-gui: Add a --trace command line option
2 parents d3d20b8 + 95dcfa3 commit 2d3cfd7

File tree

2 files changed

+48
-30
lines changed

2 files changed

+48
-30
lines changed

git-gui/git-gui.sh

Lines changed: 46 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -122,6 +122,14 @@ set _reponame {}
122122
set _iscygwin {}
123123
set _search_path {}
124124

125+
set _trace [lsearch -exact $argv --trace]
126+
if {$_trace >= 0} {
127+
set argv [lreplace $argv $_trace $_trace]
128+
set _trace 1
129+
} else {
130+
set _trace 0
131+
}
132+
125133
proc appname {} {
126134
global _appname
127135
return $_appname
@@ -245,6 +253,21 @@ proc get_config {name} {
245253
##
246254
## handy utils
247255

256+
proc _trace_exec {cmd} {
257+
if {!$::_trace} return
258+
set d {}
259+
foreach v $cmd {
260+
if {$d ne {}} {
261+
append d { }
262+
}
263+
if {[regexp {[ \t\r\n'"$?*]} $v]} {
264+
set v [sq $v]
265+
}
266+
append d $v
267+
}
268+
puts stderr $d
269+
}
270+
248271
proc _git_cmd {name} {
249272
global _git_cmd_path
250273

@@ -339,7 +362,7 @@ proc _lappend_nice {cmd_var} {
339362
}
340363
341364
proc git {args} {
342-
set opt [list exec]
365+
set opt [list]
343366
344367
while {1} {
345368
switch -- [lindex $args 0] {
@@ -359,12 +382,18 @@ proc git {args} {
359382
set cmdp [_git_cmd [lindex $args 0]]
360383
set args [lrange $args 1 end]
361384
362-
return [eval $opt $cmdp $args]
385+
_trace_exec [concat $opt $cmdp $args]
386+
set result [eval exec $opt $cmdp $args]
387+
if {$::_trace} {
388+
puts stderr "< $result"
389+
}
390+
return $result
363391
}
364392
365393
proc _open_stdout_stderr {cmd} {
394+
_trace_exec $cmd
366395
if {[catch {
367-
set fd [open $cmd r]
396+
set fd [open [concat [list | ] $cmd] r]
368397
} err]} {
369398
if { [lindex $cmd end] eq {2>@1}
370399
&& $err eq {can not find channel named "1"}
@@ -375,6 +404,7 @@ proc _open_stdout_stderr {cmd} {
375404
# to try to start it a second time.
376405
#
377406
set fd [open [concat \
407+
[list | ] \
378408
[lrange $cmd 0 end-1] \
379409
[list |& cat] \
380410
] r]
@@ -387,7 +417,7 @@ proc _open_stdout_stderr {cmd} {
387417
}
388418
389419
proc git_read {args} {
390-
set opt [list |]
420+
set opt [list]
391421
392422
while {1} {
393423
switch -- [lindex $args 0] {
@@ -415,7 +445,7 @@ proc git_read {args} {
415445
}
416446
417447
proc git_write {args} {
418-
set opt [list |]
448+
set opt [list]
419449
420450
while {1} {
421451
switch -- [lindex $args 0] {
@@ -435,7 +465,8 @@ proc git_write {args} {
435465
set cmdp [_git_cmd [lindex $args 0]]
436466
set args [lrange $args 1 end]
437467
438-
return [open [concat $opt $cmdp $args] w]
468+
_trace_exec [concat $opt $cmdp $args]
469+
return [open [concat [list | ] $opt $cmdp $args] w]
439470
}
440471
441472
proc githook_read {hook_name args} {
@@ -455,12 +486,12 @@ proc githook_read {hook_name args} {
455486
}
456487
457488
set scr {if test -x "$1";then exec "$@";fi}
458-
set sh_c [list | $interp -c $scr $interp $pchook]
489+
set sh_c [list $interp -c $scr $interp $pchook]
459490
return [_open_stdout_stderr [concat $sh_c $args]]
460491
}
461492
462493
if {[file executable $pchook]} {
463-
return [_open_stdout_stderr [concat [list | $pchook] $args]]
494+
return [_open_stdout_stderr [concat [list $pchook] $args]]
464495
}
465496
466497
return {}
@@ -1096,27 +1127,18 @@ proc rescan {after {honor_trustmtime 1}} {
10961127
}
10971128
10981129
if {[is_Cygwin]} {
1099-
set is_git_info_link {}
11001130
set is_git_info_exclude {}
11011131
proc have_info_exclude {} {
1102-
global is_git_info_link is_git_info_exclude
1103-
1104-
if {$is_git_info_link eq {}} {
1105-
set is_git_info_link [file isfile [gitdir info.lnk]]
1106-
}
1132+
global is_git_info_exclude
11071133
1108-
if {$is_git_info_link} {
1109-
if {$is_git_info_exclude eq {}} {
1110-
if {[catch {exec test -f [gitdir info exclude]}]} {
1111-
set is_git_info_exclude 0
1112-
} else {
1113-
set is_git_info_exclude 1
1114-
}
1134+
if {$is_git_info_exclude eq {}} {
1135+
if {[catch {exec test -f [gitdir info exclude]}]} {
1136+
set is_git_info_exclude 0
1137+
} else {
1138+
set is_git_info_exclude 1
11151139
}
1116-
return $is_git_info_exclude
1117-
} else {
1118-
return [file readable [gitdir info exclude]]
11191140
}
1141+
return $is_git_info_exclude
11201142
}
11211143
} else {
11221144
proc have_info_exclude {} {

git-gui/lib/choose_repository.tcl

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -388,9 +388,7 @@ method _do_new {} {
388388
-command [cb _new_local_path]
389389
set w_localpath $w_body.where.t
390390

391-
pack $w_body.where.b -side right
392-
pack $w_body.where.l -side left
393-
pack $w_body.where.t -fill x
391+
grid $w_body.where.l $w_body.where.t $w_body.where.b -sticky ew
394392
pack $w_body.where -fill x
395393

396394
trace add variable @local_path write [cb _write_local_path]
@@ -987,9 +985,7 @@ method _do_open {} {
987985
-text [mc "Browse"] \
988986
-command [cb _open_local_path]
989987

990-
pack $w_body.where.b -side right
991-
pack $w_body.where.l -side left
992-
pack $w_body.where.t -fill x
988+
grid $w_body.where.l $w_body.where.t $w_body.where.b -sticky ew
993989
pack $w_body.where -fill x
994990

995991
trace add variable @local_path write [cb _write_local_path]

0 commit comments

Comments
 (0)