Skip to content

Commit 08ba820

Browse files
committed
gitk: Add a progress bar for checking out a head
Now that git checkout reports progress when checking out files, we can use that to provide a progress bar in gitk. We re-use the green progress bar (formerly used when reading stuff in) for that. Signed-off-by: Paul Mackerras <paulus@samba.org>
1 parent 6df7403 commit 08ba820

File tree

1 file changed

+31
-10
lines changed

1 file changed

+31
-10
lines changed

gitk

Lines changed: 31 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -7612,7 +7612,7 @@ proc resethead {} {
76127612
tkwait window $w
76137613
if {!$confirm_ok} return
76147614
if {[catch {set fd [open \
7615-
[list | sh -c "git reset --$resettype $rowmenuid 2>&1"] r]} err]} {
7615+
[list | git reset --$resettype $rowmenuid 2>@1] r]} err]} {
76167616
error_popup $err
76177617
} else {
76187618
dohidelocalchanges
@@ -7674,25 +7674,46 @@ proc cobranch {} {
76747674
global showlocalchanges mainheadid
76757675

76767676
# check the tree is clean first??
7677-
set oldmainhead $mainhead
76787677
nowbusy checkout [mc "Checking out"]
76797678
update
76807679
dohidelocalchanges
76817680
if {[catch {
7682-
exec git checkout -q $headmenuhead
7681+
set fd [open [list | git checkout $headmenuhead 2>@1] r]
76837682
} err]} {
76847683
notbusy checkout
76857684
error_popup $err
7685+
if {$showlocalchanges} {
7686+
dodiffindex
7687+
}
76867688
} else {
7687-
notbusy checkout
7688-
set mainhead $headmenuhead
7689-
set mainheadid $headmenuid
7690-
if {[info exists headids($oldmainhead)]} {
7691-
redrawtags $headids($oldmainhead)
7689+
filerun $fd [list readcheckoutstat $fd $headmenuhead $headmenuid]
7690+
}
7691+
}
7692+
7693+
proc readcheckoutstat {fd newhead newheadid} {
7694+
global mainhead mainheadid headids showlocalchanges progresscoords
7695+
7696+
if {[gets $fd line] >= 0} {
7697+
if {[regexp {([0-9]+)% \(([0-9]+)/([0-9]+)\)} $line match p m n]} {
7698+
set progresscoords [list 0 [expr {1.0 * $m / $n}]]
7699+
adjustprogress
76927700
}
7693-
redrawtags $headmenuid
7694-
selbyid $headmenuid
7701+
return 1
7702+
}
7703+
set progresscoords {0 0}
7704+
adjustprogress
7705+
notbusy checkout
7706+
if {[catch {close $fd} err]} {
7707+
error_popup $err
7708+
}
7709+
set oldmainhead $mainhead
7710+
set mainhead $newhead
7711+
set mainheadid $newheadid
7712+
if {[info exists headids($oldmainhead)]} {
7713+
redrawtags $headids($oldmainhead)
76957714
}
7715+
redrawtags $newheadid
7716+
selbyid $newheadid
76967717
if {$showlocalchanges} {
76977718
dodiffindex
76987719
}

0 commit comments

Comments
 (0)