Skip to content

Commit

Permalink
plumbing: object/patch, printStat strings.Repeat cause panic (#310)
Browse files Browse the repository at this point in the history
  • Loading branch information
cookeem committed May 12, 2021
1 parent 320db9a commit e6e2339
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions plumbing/object/patch.go
Expand Up @@ -287,8 +287,16 @@ func printStat(fileStats []FileStat) string {
for _, fs := range fileStats {
addn := float64(fs.Addition)
deln := float64(fs.Deletion)
adds := strings.Repeat("+", int(math.Floor(addn/scaleFactor)))
dels := strings.Repeat("-", int(math.Floor(deln/scaleFactor)))
addc := int(math.Floor(addn/scaleFactor))
delc := int(math.Floor(deln/scaleFactor))
if addc < 0 {
addc = 0
}
if delc < 0 {
delc = 0
}
adds := strings.Repeat("+", addc)
dels := strings.Repeat("-", delc)
finalOutput += fmt.Sprintf(" %s | %d %s%s\n", fs.Name, (fs.Addition + fs.Deletion), adds, dels)
}

Expand Down

0 comments on commit e6e2339

Please sign in to comment.