]> source.dussan.org Git - gitea.git/commitdiff
Fix when a commit not found returned 500 (#14732)
authorLunny Xiao <xiaolunwen@gmail.com>
Fri, 19 Feb 2021 00:40:17 +0000 (08:40 +0800)
committerGitHub <noreply@github.com>
Fri, 19 Feb 2021 00:40:17 +0000 (19:40 -0500)
Co-authored-by: Lauris BH <lauris@nix.lv>
modules/git/repo_commit_nogogit.go

index a43fe4b3349f9233b3dee74fc1edf05aae4da4fc..0a92de17037ef643362cbafa8de91bd0331292b4 100644 (file)
@@ -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