summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLunny Xiao <xiaolunwen@gmail.com>2021-02-19 08:40:17 +0800
committerGitHub <noreply@github.com>2021-02-18 19:40:17 -0500
commit6362b24a59dc8f9cd12a7ee8f044cc15d26e2f79 (patch)
tree90b65c8324a1297f42a74cfcf8d817a8fdfe3f85
parent8f05a2876bda053da43188042fd7dfb60738972a (diff)
downloadgitea-6362b24a59dc8f9cd12a7ee8f044cc15d26e2f79.tar.gz
gitea-6362b24a59dc8f9cd12a7ee8f044cc15d26e2f79.zip
Fix when a commit not found returned 500 (#14732)
Co-authored-by: Lauris BH <lauris@nix.lv>
-rw-r--r--modules/git/repo_commit_nogogit.go6
1 files changed, 6 insertions, 0 deletions
diff --git a/modules/git/repo_commit_nogogit.go b/modules/git/repo_commit_nogogit.go
index a43fe4b334..0a92de1703 100644
--- a/modules/git/repo_commit_nogogit.go
+++ b/modules/git/repo_commit_nogogit.go
@@ -8,6 +8,7 @@ package git
import (
"bufio"
+ "errors"
"fmt"
"io"
"io/ioutil"
@@ -70,10 +71,15 @@ func (repo *Repository) getCommit(id SHA1) (*Commit, error) {
bufReader := bufio.NewReader(stdoutReader)
_, typ, size, err := ReadBatchLine(bufReader)
if err != nil {
+ if errors.Is(err, io.EOF) {
+ return nil, ErrNotExist{ID: id.String()}
+ }
return nil, err
}
switch typ {
+ case "missing":
+ return nil, ErrNotExist{ID: id.String()}
case "tag":
// then we need to parse the tag
// and load the commit