summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLibravatar Shawn O. Pearce <spearce@spearce.org>2007-04-04 12:08:46 -0400
committerLibravatar Shawn O. Pearce <spearce@spearce.org>2007-04-04 12:08:46 -0400
commitf6f2aa39ef97cae03c71ecfecc334f0df60d7920 (patch)
treeb8dfb1c6a158a5bf99aedb58e4acddf61064189b
parentMerge branch 'maint' (diff)
downloadtgif-f6f2aa39ef97cae03c71ecfecc334f0df60d7920.tar.xz
git-gui: Brown paper bag fix division by 0 in blame
If we generate a blame status string before we have obtained any annotation data at all from the input file, or if the input file is empty, our total_lines will be 0. This causes a division by 0 error when we blindly divide by the 0 to compute the total percentage of lines loaded. Instead we should report 0% done. Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
-rwxr-xr-xgit-gui.sh10
1 files changed, 6 insertions, 4 deletions
diff --git a/git-gui.sh b/git-gui.sh
index 60e79ca1b0..7cbc977ea2 100755
--- a/git-gui.sh
+++ b/git-gui.sh
@@ -3604,12 +3604,14 @@ proc read_blame_incremental {fd w w_load w_cmit w_line w_file} {
proc blame_incremental_status {w} {
global blame_status blame_data
+ set have $blame_data($w,blame_lines)
+ set total $blame_data($w,total_lines)
+ set pdone 0
+ if {$total} {set pdone [expr {100 * $have / $total}]}
+
set blame_status($w) [format \
"Loading annotations... %i of %i lines annotated (%2i%%)" \
- $blame_data($w,blame_lines) \
- $blame_data($w,total_lines) \
- [expr {100 * $blame_data($w,blame_lines)
- / $blame_data($w,total_lines)}]]
+ $have $total $pdone]
}
proc blame_click {w w_cmit w_line w_file cur_w pos} {