aboutsummaryrefslogtreecommitdiffstats
path: root/plumbing/object/patch.go
diff options
context:
space:
mode:
authorMáximo Cuadros <mcuadros@gmail.com>2019-04-18 10:12:52 +0200
committerGitHub <noreply@github.com>2019-04-18 10:12:52 +0200
commitcc5579e8f1d44e7a61b11221ba1b0f6d8afe4e6a (patch)
tree115866a43d3a00f7d17cbb34b2cd923ae6d92e75 /plumbing/object/patch.go
parent829edc9cd7fc87968b98274ad17bd8ed09293861 (diff)
parentf69d20660a0fd331dfa5ec1c77dd3daa6ac00bf4 (diff)
downloadgo-git-cc5579e8f1d44e7a61b11221ba1b0f6d8afe4e6a.tar.gz
Merge pull request #1088 from oleksii-shnyra/fix-1074
plumbing: object, Count stats properly when no new line added at the …
Diffstat (limited to 'plumbing/object/patch.go')
-rw-r--r--plumbing/object/patch.go11
1 files changed, 9 insertions, 2 deletions
diff --git a/plumbing/object/patch.go b/plumbing/object/patch.go
index adeaccb..068589e 100644
--- a/plumbing/object/patch.go
+++ b/plumbing/object/patch.go
@@ -320,11 +320,18 @@ func getFileStatsFromFilePatches(filePatches []fdiff.FilePatch) FileStats {
}
for _, chunk := range fp.Chunks() {
+ s := chunk.Content()
switch chunk.Type() {
case fdiff.Add:
- cs.Addition += strings.Count(chunk.Content(), "\n")
+ cs.Addition += strings.Count(s, "\n")
+ if s[len(s)-1] != '\n' {
+ cs.Addition++
+ }
case fdiff.Delete:
- cs.Deletion += strings.Count(chunk.Content(), "\n")
+ cs.Deletion += strings.Count(s, "\n")
+ if s[len(s)-1] != '\n' {
+ cs.Deletion++
+ }
}
}