Shawn O. Pearce  committed 982cf98

git-gui: Display a progress bar during blame annotation gathering

Computing the blame records for a large file with a long project
history can take git a while to run; traditionally we have shown
a little meter in the status area of our blame viewer that lets
the user know how many lines have been finished, and how far we
are through the process.

Usually such progress indicators are drawn with a little progress
bar in the window, where the bar shows how much has been completed
and hides itself when the process is complete. I'm using a very
simple hack to do that: draw a canvas with a filled rectangle.

Of course the time remaining has absolutely no relationship to the
progress meter. It could take very little time for git-blame to get
the first 90% of the file, and then it could take many times that to
get the remaining 10%. So the progress meter doesn't really have any
sort of assurances that it relates to the true progress of the work.
But in practice on some ugly history it does seem to hold a reasonable
indicator to the completion status. Besides, its amusing to watch and
that keeps the user from realizing git is being somewhat slow.

Signed-off-by: Shawn O. Pearce <>

  • Participants
  • Parent commits d0b741d

Comments (0)

Files changed (1)

File lib/blame.tcl

 	grid columnconfigure $w.file_pane.out 3 -weight 1
 	grid rowconfigure $w.file_pane.out 0 -weight 1
-	label $w.status \
-		-textvariable @status \
-		-anchor w \
-		-justify left \
-		-borderwidth 1 \
-		-relief sunken
 	set w_cmit $
 	text $w_cmit \
 		-background white -borderwidth 0 \
 	pack $ -side bottom -fill x
 	pack $w_cmit -expand 1 -fill both
+	frame $w.status \
+		-borderwidth 1 \
+		-relief sunken
+	label $w.status.l \
+		-textvariable @status \
+		-anchor w \
+		-justify left
+	canvas $w.status.c \
+		-width 100 \
+		-height [expr {int([winfo reqheight $w.status.l] * 0.6)}] \
+		-borderwidth 1 \
+		-relief groove \
+		-highlightt 0
+	$w.status.c create rectangle 0 0 0 20 -tags bar -fill navy
+	pack $w.status.l -side left
+	pack $w.status.c -side right
 	menu $w.ctxm -tearoff 0
 	$w.ctxm add command \
 		-label "Copy Commit" \
 	bind $w_cmit <Button-1> [list focus $w_cmit]
 	bind $top <Visibility> [list focus $top]
-	bind $top <Destroy> [list delete_this $this]
+	bind $w_file <Destroy> [list delete_this $this]
 	grid configure $w.path -sticky ew
 	grid configure $w.file_pane -sticky nsew
 	if {[eof $fd]} {
 		close $fd
 		set status {Annotation complete.}
+		destroy $w.status.c
 	} else {
 		_status $this
 	set status [format \
 		"Loading annotations... %i of %i lines annotated (%2i%%)" \
 		$have $total $pdone]
+	$w.status.c coords bar 0 0 $pdone 20
 method _click {cur_w pos} {