Skip to content

Commit b9dcf84

Browse files
committed
Merge commit 'git-gui/master'
* commit 'git-gui/master': (36 commits) git-gui: Change prior tree SHA-1 verification to use git_read git-gui: Include a space in Cygwin shortcut command lines git-gui: Use sh.exe in Cygwin shortcuts git-gui: Paper bag fix for Cygwin shortcut creation git-gui: Improve the Windows and Mac OS X shortcut creators git-gui: Teach console widget to use git_read git-gui: Perform our own magic shbang detection on Windows git-gui: Treat `git version` as `git --version` git-gui: Assume unfound commands are known by git wrapper git-gui: Correct gitk installation location git-gui: Always use absolute path to all git executables git-gui: Show a progress meter for checking out files git-gui: Change the main window progress bar to use status_bar git-gui: Extract blame viewer status bar into mega-widget git-gui: Allow double-click in checkout dialog to start checkout git-gui: Default selection to first matching ref git-gui: Unabbreviate commit SHA-1s prior to display git-gui: Refactor branch switch to support detached head git-gui: Refactor our ui_status_value update technique git-gui: Better handling of detached HEAD ...
2 parents 237ce83 + b215883 commit b9dcf84

23 files changed

Lines changed: 2210 additions & 888 deletions

git-gui/git-gui.sh

Lines changed: 375 additions & 86 deletions
Large diffs are not rendered by default.

git-gui/lib/blame.tcl

Lines changed: 33 additions & 57 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ field w_amov ; # text column: annotations + move tracking
2121
field w_asim ; # text column: annotations (simple computation)
2222
field w_file ; # text column: actual file data
2323
field w_cviewer ; # pane showing commit message
24-
field status ; # text variable bound to status bar
24+
field status ; # status mega-widget instance
2525
field old_height ; # last known height of $w.file_pane
2626

2727
# Tk UI colors
@@ -33,6 +33,13 @@ variable group_colors {
3333
#ececec
3434
}
3535

36+
# Switches for original location detection
37+
#
38+
variable original_options [list -C -C]
39+
if {[git-version >= 1.5.3]} {
40+
lappend original_options -w ; # ignore indentation changes
41+
}
42+
3643
# Current blame data; cleared/reset on each load
3744
#
3845
field commit ; # input commit to blame
@@ -235,14 +242,7 @@ constructor new {i_commit i_path} {
235242
pack $w.file_pane.cm.sbx -side bottom -fill x
236243
pack $w_cviewer -expand 1 -fill both
237244

238-
frame $w.status \
239-
-borderwidth 1 \
240-
-relief sunken
241-
label $w.status.l \
242-
-textvariable @status \
243-
-anchor w \
244-
-justify left
245-
pack $w.status.l -side left
245+
set status [::status_bar::new $w.status]
246246

247247
menu $w.ctxm -tearoff 0
248248
$w.ctxm add command \
@@ -304,8 +304,9 @@ constructor new {i_commit i_path} {
304304

305305
set req_w [winfo reqwidth $top]
306306
set req_h [winfo reqheight $top]
307+
set scr_h [expr {[winfo screenheight $top] - 100}]
307308
if {$req_w < 600} {set req_w 600}
308-
if {$req_h < 400} {set req_h 400}
309+
if {$req_h < $scr_h} {set req_h $scr_h}
309310
set g "${req_w}x${req_h}"
310311
wm geometry $top $g
311312
update
@@ -352,19 +353,6 @@ method _load {jump} {
352353
set total_lines 0
353354
}
354355

355-
if {[winfo exists $w.status.c]} {
356-
$w.status.c coords bar 0 0 0 20
357-
} else {
358-
canvas $w.status.c \
359-
-width 100 \
360-
-height [expr {int([winfo reqheight $w.status.l] * 0.6)}] \
361-
-borderwidth 1 \
362-
-relief groove \
363-
-highlightt 0
364-
$w.status.c create rectangle 0 0 0 20 -tags bar -fill navy
365-
pack $w.status.c -side right
366-
}
367-
368356
if {$history eq {}} {
369357
$w_back conf -state disabled
370358
} else {
@@ -378,13 +366,12 @@ method _load {jump} {
378366
set amov_data [list [list]]
379367
set asim_data [list [list]]
380368

381-
set status "Loading $commit:[escape_path $path]..."
369+
$status show "Reading $commit:[escape_path $path]..."
382370
$w_path conf -text [escape_path $path]
383371
if {$commit eq {}} {
384372
set fd [open $path r]
385373
} else {
386-
set cmd [list git cat-file blob "$commit:$path"]
387-
set fd [open "| $cmd" r]
374+
set fd [git_read cat-file blob "$commit:$path"]
388375
}
389376
fconfigure $fd -blocking 0 -translation lf -encoding binary
390377
fileevent $fd readable [cb _read_file $fd $jump]
@@ -487,30 +474,28 @@ method _read_file {fd jump} {
487474
} ifdeleted { catch {close $fd} }
488475

489476
method _exec_blame {cur_w cur_d options cur_s} {
490-
set cmd [list]
491-
if {![is_Windows] || [is_Cygwin]} {
492-
lappend cmd nice
493-
}
494-
lappend cmd git blame
495-
set cmd [concat $cmd $options]
496-
lappend cmd --incremental
477+
lappend options --incremental
497478
if {$commit eq {}} {
498-
lappend cmd --contents $path
479+
lappend options --contents $path
499480
} else {
500-
lappend cmd $commit
481+
lappend options $commit
501482
}
502-
lappend cmd -- $path
503-
set fd [open "| $cmd" r]
483+
lappend options -- $path
484+
set fd [eval git_read --nice blame $options]
504485
fconfigure $fd -blocking 0 -translation lf -encoding binary
505-
fileevent $fd readable [cb _read_blame $fd $cur_w $cur_d $cur_s]
486+
fileevent $fd readable [cb _read_blame $fd $cur_w $cur_d]
506487
set current_fd $fd
507488
set blame_lines 0
508-
_status $this $cur_s
489+
490+
$status start \
491+
"Loading$cur_s annotations..." \
492+
{lines annotated}
509493
}
510494

511-
method _read_blame {fd cur_w cur_d cur_s} {
495+
method _read_blame {fd cur_w cur_d} {
512496
upvar #0 $cur_d line_data
513497
variable group_colors
498+
variable original_options
514499

515500
if {$fd ne $current_fd} {
516501
catch {close $fd}
@@ -547,6 +532,10 @@ method _read_blame {fd cur_w cur_d cur_s} {
547532
set a_name {}
548533
catch {set a_name $header($cmit,author)}
549534
while {$a_name ne {}} {
535+
if {$author_abbr ne {}
536+
&& [string index $a_name 0] eq {'}} {
537+
regsub {^'[^']+'\s+} $a_name {} a_name
538+
}
550539
if {![regexp {^([[:upper:]])} $a_name _a]} break
551540
append author_abbr $_a
552541
unset _a
@@ -680,30 +669,17 @@ method _read_blame {fd cur_w cur_d cur_s} {
680669
close $fd
681670
if {$cur_w eq $w_asim} {
682671
_exec_blame $this $w_amov @amov_data \
683-
[list -M -C -C] \
672+
$original_options \
684673
{ original location}
685674
} else {
686675
set current_fd {}
687-
set status {Annotation complete.}
688-
destroy $w.status.c
676+
$status stop {Annotation complete.}
689677
}
690678
} else {
691-
_status $this $cur_s
679+
$status update $blame_lines $total_lines
692680
}
693681
} ifdeleted { catch {close $fd} }
694682

695-
method _status {cur_s} {
696-
set have $blame_lines
697-
set total $total_lines
698-
set pdone 0
699-
if {$total} {set pdone [expr {100 * $have / $total}]}
700-
701-
set status [format \
702-
"Loading%s annotations... %i of %i lines annotated (%2i%%)" \
703-
$cur_s $have $total $pdone]
704-
$w.status.c coords bar 0 0 $pdone 20
705-
}
706-
707683
method _click {cur_w pos} {
708684
set lno [lindex [split [$cur_w index $pos] .] 0]
709685
_showcommit $this $cur_w $lno
@@ -784,7 +760,7 @@ method _showcommit {cur_w lno} {
784760
if {[catch {set msg $header($cmit,message)}]} {
785761
set msg {}
786762
catch {
787-
set fd [open "| git cat-file commit $cmit" r]
763+
set fd [git_read cat-file commit $cmit]
788764
fconfigure $fd -encoding binary -translation lf
789765
if {[catch {set enc $repo_config(i18n.commitencoding)}]} {
790766
set enc utf-8

0 commit comments

Comments
 (0)