Skip to content

Commit 706d6c3

Browse files
committed
gitk: Add a progress bar to show progress while resetting
Since git reset now gets chatty while resetting, we were getting errors reported when a reset was done using the "reset branch to here" menu item. With this we now read the progress messages from git reset and update a progress bar. Because git reset outputs the progress messages to standard error, and Tcl treats messages to standard error as error messages, we have to invoke git reset via a shell and redirect standard error into standard output. This also fixes a bug in computing descendent heads when head ids are changed via a reset. Signed-off-by: Paul Mackerras <[email protected]>
1 parent 9396cd3 commit 706d6c3

File tree

1 file changed

+45
-7
lines changed

1 file changed

+45
-7
lines changed

gitk

Lines changed: 45 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -5851,19 +5851,54 @@ proc resethead {} {
58515851
bind $w <Visibility> "grab $w; focus $w"
58525852
tkwait window $w
58535853
if {!$confirm_ok} return
5854-
dohidelocalchanges
5855-
if {[catch {exec git reset --$resettype $rowmenuid} err]} {
5854+
if {[catch {set fd [open \
5855+
[list | sh -c "git reset --$resettype $rowmenuid 2>&1"] r]} err]} {
58565856
error_popup $err
58575857
} else {
5858-
set oldhead $mainheadid
5859-
movedhead $rowmenuid $mainhead
5860-
set mainheadid $rowmenuid
5858+
dohidelocalchanges
5859+
set w ".resetprogress"
5860+
filerun $fd [list readresetstat $fd $w]
5861+
toplevel $w
5862+
wm transient $w
5863+
wm title $w "Reset progress"
5864+
message $w.m -text "Reset in progress, please wait..." \
5865+
-justify center -aspect 1000
5866+
pack $w.m -side top -fill x -padx 20 -pady 5
5867+
canvas $w.c -width 150 -height 20 -bg white
5868+
$w.c create rect 0 0 0 20 -fill green -tags rect
5869+
pack $w.c -side top -fill x -padx 20 -pady 5 -expand 1
5870+
nowbusy reset
5871+
}
5872+
}
5873+
5874+
proc readresetstat {fd w} {
5875+
global mainhead mainheadid showlocalchanges
5876+
5877+
if {[gets $fd line] >= 0} {
5878+
if {[regexp {([0-9]+)% \(([0-9]+)/([0-9]+)\)} $line match p m n]} {
5879+
set x [expr {($m * 150) / $n}]
5880+
$w.c coords rect 0 0 $x 20
5881+
}
5882+
return 1
5883+
}
5884+
destroy $w
5885+
notbusy reset
5886+
if {[catch {close $fd} err]} {
5887+
error_popup $err
5888+
}
5889+
set oldhead $mainheadid
5890+
set newhead [exec git rev-parse HEAD]
5891+
if {$newhead ne $oldhead} {
5892+
movehead $newhead $mainhead
5893+
movedhead $newhead $mainhead
5894+
set mainheadid $newhead
58615895
redrawtags $oldhead
5862-
redrawtags $rowmenuid
5896+
redrawtags $newhead
58635897
}
58645898
if {$showlocalchanges} {
58655899
doshowlocalchanges
58665900
}
5901+
return 0
58675902
}
58685903

58695904
# context menu for a head
@@ -6742,7 +6777,10 @@ proc descheads {id} {
67426777
}
67436778
foreach a $arcnos($id) {
67446779
if {$archeads($a) ne {}} {
6745-
set ret [concat $ret $archeads($a)]
6780+
validate_archeads $a
6781+
if {$archeads($a) ne {}} {
6782+
set ret [concat $ret $archeads($a)]
6783+
}
67466784
}
67476785
set d $arcstart($a)
67486786
if {![info exists seen($d)]} {

0 commit comments

Comments
 (0)