Skip to content

Commit 2a496ca

Browse files
committed
repo_commit: improve detection of ErrNotExist
1 parent 5dba4f8 commit 2a496ca

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

repo_commit.go

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,7 @@ func (repo *Repository) getCommit(id sha1) (*Commit, error) {
106106

107107
data, err := NewCommand("cat-file", "-p", id.String()).RunInDirBytes(repo.Path)
108108
if err != nil {
109-
if strings.Contains(err.Error(), "fatal: Not a valid object name") {
109+
if strings.Contains(err.Error(), "exit status 128") {
110110
return nil, ErrNotExist{id.String(), ""}
111111
}
112112
return nil, err
@@ -129,6 +129,9 @@ func (repo *Repository) GetCommit(commitID string) (*Commit, error) {
129129
var err error
130130
commitID, err = NewCommand("rev-parse", commitID).RunInDir(repo.Path)
131131
if err != nil {
132+
if strings.Contains(err.Error(), "exit status 128") {
133+
return nil, ErrNotExist{commitID, ""}
134+
}
132135
return nil, err
133136
}
134137
}

0 commit comments

Comments
 (0)