Skip to content

Commit d9c6469

Browse files
logiclrdprati0100
authored andcommitted
git-gui: update status bar to track operations
Update the status bar to track updates as individual "operations" that can overlap. Update all call sites to interact with the new status bar mechanism. Update initialization to explicitly clear status text, since otherwise it may persist across future operations. Signed-off-by: Jonathan Gilbert <[email protected]> Signed-off-by: Pratyush Yadav <[email protected]>
1 parent 29a9366 commit d9c6469

File tree

7 files changed

+354
-108
lines changed

7 files changed

+354
-108
lines changed

git-gui.sh

Lines changed: 15 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1797,10 +1797,10 @@ proc ui_status {msg} {
17971797
}
17981798
}
17991799
1800-
proc ui_ready {{test {}}} {
1800+
proc ui_ready {} {
18011801
global main_status
18021802
if {[info exists main_status]} {
1803-
$main_status show [mc "Ready."] $test
1803+
$main_status show [mc "Ready."]
18041804
}
18051805
}
18061806
@@ -2150,8 +2150,6 @@ proc incr_font_size {font {amt 1}} {
21502150
##
21512151
## ui commands
21522152
2153-
set starting_gitk_msg [mc "Starting gitk... please wait..."]
2154-
21552153
proc do_gitk {revs {is_submodule false}} {
21562154
global current_diff_path file_states current_diff_side ui_index
21572155
global _gitdir _gitworktree
@@ -2206,10 +2204,11 @@ proc do_gitk {revs {is_submodule false}} {
22062204
set env(GIT_WORK_TREE) $_gitworktree
22072205
cd $pwd
22082206
2209-
ui_status $::starting_gitk_msg
2210-
after 10000 {
2211-
ui_ready $starting_gitk_msg
2212-
}
2207+
set status_operation [$::main_status \
2208+
start \
2209+
[mc "Starting %s... please wait..." "gitk"]]
2210+
2211+
after 3500 [list $status_operation stop]
22132212
}
22142213
}
22152214
@@ -2240,10 +2239,11 @@ proc do_git_gui {} {
22402239
set env(GIT_WORK_TREE) $_gitworktree
22412240
cd $pwd
22422241
2243-
ui_status $::starting_gitk_msg
2244-
after 10000 {
2245-
ui_ready $starting_gitk_msg
2246-
}
2242+
set status_operation [$::main_status \
2243+
start \
2244+
[mc "Starting %s... please wait..." "git-gui"]]
2245+
2246+
after 3500 [list $status_operation stop]
22472247
}
22482248
}
22492249
@@ -4159,6 +4159,9 @@ if {$picked && [is_config_true gui.autoexplore]} {
41594159
do_explore
41604160
}
41614161
4162+
# Clear "Initializing..." status
4163+
after 500 {$main_status show ""}
4164+
41624165
# Local variables:
41634166
# mode: tcl
41644167
# indent-tabs-mode: t

lib/blame.tcl

Lines changed: 17 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ field w_cviewer ; # pane showing commit message
2424
field finder ; # find mini-dialog frame
2525
field gotoline ; # line goto mini-dialog frame
2626
field status ; # status mega-widget instance
27+
field status_operation ; # operation displayed by status mega-widget
2728
field old_height ; # last known height of $w.file_pane
2829

2930

@@ -274,6 +275,7 @@ constructor new {i_commit i_path i_jump} {
274275
pack $w_cviewer -expand 1 -fill both
275276

276277
set status [::status_bar::new $w.status]
278+
set status_operation {}
277279

278280
menu $w.ctxm -tearoff 0
279281
$w.ctxm add command \
@@ -602,16 +604,23 @@ method _exec_blame {cur_w cur_d options cur_s} {
602604
} else {
603605
lappend options $commit
604606
}
607+
608+
# We may recurse in from another call to _exec_blame and already have
609+
# a status operation.
610+
if {$status_operation == {}} {
611+
set status_operation [$status start \
612+
$cur_s \
613+
[mc "lines annotated"]]
614+
} else {
615+
$status_operation restart $cur_s
616+
}
617+
605618
lappend options -- $path
606619
set fd [eval git_read --nice blame $options]
607620
fconfigure $fd -blocking 0 -translation lf -encoding utf-8
608621
fileevent $fd readable [cb _read_blame $fd $cur_w $cur_d]
609622
set current_fd $fd
610623
set blame_lines 0
611-
612-
$status start \
613-
$cur_s \
614-
[mc "lines annotated"]
615624
}
616625

617626
method _read_blame {fd cur_w cur_d} {
@@ -806,10 +815,11 @@ method _read_blame {fd cur_w cur_d} {
806815
[mc "Loading original location annotations..."]
807816
} else {
808817
set current_fd {}
809-
$status stop [mc "Annotation complete."]
818+
$status_operation stop [mc "Annotation complete."]
819+
set status_operation {}
810820
}
811821
} else {
812-
$status update $blame_lines $total_lines
822+
$status_operation update $blame_lines $total_lines
813823
}
814824
} ifdeleted { catch {close $fd} }
815825

@@ -1124,7 +1134,7 @@ method _blameparent {} {
11241134
set diffcmd [list diff-tree --unified=0 $cparent $cmit -- $new_path]
11251135
}
11261136
if {[catch {set fd [eval git_read $diffcmd]} err]} {
1127-
$status stop [mc "Unable to display parent"]
1137+
$status_operation stop [mc "Unable to display parent"]
11281138
error_popup [strcat [mc "Error loading diff:"] "\n\n$err"]
11291139
return
11301140
}

lib/checkout_op.tcl

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -341,9 +341,9 @@ method _readtree {} {
341341
global HEAD
342342

343343
set readtree_d {}
344-
$::main_status start \
344+
set status_bar_operation [$::main_status start \
345345
[mc "Updating working directory to '%s'..." [_name $this]] \
346-
[mc "files checked out"]
346+
[mc "files checked out"]]
347347

348348
set fd [git_read --stderr read-tree \
349349
-m \
@@ -354,26 +354,27 @@ method _readtree {} {
354354
$new_hash \
355355
]
356356
fconfigure $fd -blocking 0 -translation binary
357-
fileevent $fd readable [cb _readtree_wait $fd]
357+
fileevent $fd readable [cb _readtree_wait $fd $status_bar_operation]
358358
}
359359

360-
method _readtree_wait {fd} {
360+
method _readtree_wait {fd status_bar_operation} {
361361
global current_branch
362362

363363
set buf [read $fd]
364-
$::main_status update_meter $buf
364+
$status_bar_operation update_meter $buf
365365
append readtree_d $buf
366366

367367
fconfigure $fd -blocking 1
368368
if {![eof $fd]} {
369369
fconfigure $fd -blocking 0
370+
$status_bar_operation stop
370371
return
371372
}
372373

373374
if {[catch {close $fd}]} {
374375
set err $readtree_d
375376
regsub {^fatal: } $err {} err
376-
$::main_status stop [mc "Aborted checkout of '%s' (file level merging is required)." [_name $this]]
377+
$status_bar_operation stop [mc "Aborted checkout of '%s' (file level merging is required)." [_name $this]]
377378
warn_popup [strcat [mc "File level merge required."] "
378379
379380
$err
@@ -384,7 +385,7 @@ $err
384385
return
385386
}
386387

387-
$::main_status stop
388+
$status_bar_operation stop
388389
_after_readtree $this
389390
}
390391

0 commit comments

Comments
 (0)