summaryrefslogtreecommitdiffstats
path: root/modules/git
diff options
context:
space:
mode:
authorzeripath <art27@cantab.net>2021-06-16 23:16:47 +0100
committerGitHub <noreply@github.com>2021-06-16 18:16:47 -0400
commit5f4522cd1fc4207138c54c706b65f62083fb4299 (patch)
treea6b670053bf2c0ab7a2ed2da2daa1568bd25fa7a /modules/git
parent6d69df28047bf7fd3e307391b484a93432615b90 (diff)
downloadgitea-5f4522cd1fc4207138c54c706b65f62083fb4299.tar.gz
gitea-5f4522cd1fc4207138c54c706b65f62083fb4299.zip
Fix missing discard in repo_language_stats (#16030)
Set the missing discard(1) in repo_language_stats. Signed-off-by: Andrew Thornton <art27@cantab.net> Co-authored-by: 6543 <6543@obermui.de>
Diffstat (limited to 'modules/git')
-rw-r--r--modules/git/repo_language_stats_nogogit.go10
1 files changed, 3 insertions, 7 deletions
diff --git a/modules/git/repo_language_stats_nogogit.go b/modules/git/repo_language_stats_nogogit.go
index 0130d0a300..abbf5e943b 100644
--- a/modules/git/repo_language_stats_nogogit.go
+++ b/modules/git/repo_language_stats_nogogit.go
@@ -25,11 +25,7 @@ func (repo *Repository) GetLanguageStats(commitID string) (map[string]int64, err
defer cancel()
writeID := func(id string) error {
- _, err := batchStdinWriter.Write([]byte(id))
- if err != nil {
- return err
- }
- _, err = batchStdinWriter.Write([]byte{'\n'})
+ _, err := batchStdinWriter.Write([]byte(id + "\n"))
return err
}
@@ -85,10 +81,10 @@ func (repo *Repository) GetLanguageStats(commitID string) (map[string]int64, err
}
sizeToRead := size
- discard := int64(0)
+ discard := int64(1)
if size > fileSizeLimit {
sizeToRead = fileSizeLimit
- discard = size - fileSizeLimit
+ discard = size - fileSizeLimit + 1
}
_, err = contentBuf.ReadFrom(io.LimitReader(batchReader, sizeToRead))