aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGravatar Runxi Yu2026-02-20 22:37:22 +0800
committerGravatar Runxi Yu2026-02-20 22:37:22 +0800
commitb022f7f8f3515e81d584048b4d953966dd0eb3f2 (patch)
treeda676656b4d6b29c9b0c0ba9c0a51ed2bc6d7add
parentobject: Remove the old opaque errors (diff)
signatureNo signature
object: I guess these checks are unnecessary
-rw-r--r--object/commit_parse.go4
-rw-r--r--object/tag_parse.go4
-rw-r--r--object/tree.go7
-rw-r--r--object/tree_parse.go4
4 files changed, 0 insertions, 19 deletions
diff --git a/object/commit_parse.go b/object/commit_parse.go
index 31def350..9693b4da 100644
--- a/object/commit_parse.go
+++ b/object/commit_parse.go
@@ -10,10 +10,6 @@ import (
// ParseCommit decodes a commit object body.
func ParseCommit(body []byte, algo oid.Algorithm) (*Commit, error) {
- if algo.Size() == 0 {
- return nil, fmt.Errorf("object: commit: invalid hash algorithm %q", algo)
- }
-
c := new(Commit)
i := 0
for i < len(body) {
diff --git a/object/tag_parse.go b/object/tag_parse.go
index 84256166..27dc998d 100644
--- a/object/tag_parse.go
+++ b/object/tag_parse.go
@@ -11,10 +11,6 @@ import (
// ParseTag decodes a tag object body.
func ParseTag(body []byte, algo oid.Algorithm) (*Tag, error) {
- if algo.Size() == 0 {
- return nil, fmt.Errorf("object: tag: invalid hash algorithm %q", algo)
- }
-
t := new(Tag)
i := 0
var haveTarget, haveType bool
diff --git a/object/tree.go b/object/tree.go
index b655be03..a28bfcc9 100644
--- a/object/tree.go
+++ b/object/tree.go
@@ -2,7 +2,6 @@ package object
import (
"bytes"
- "errors"
"fmt"
"sort"
@@ -73,9 +72,6 @@ func (tree *Tree) entry(name []byte, searchIsTree bool) *TreeEntry {
// InsertEntry inserts a tree entry while preserving Git ordering.
func (tree *Tree) InsertEntry(newEntry TreeEntry) error {
- if tree == nil {
- return errors.New("object: tree: insert on nil tree")
- }
if tree.entry(newEntry.Name, true) != nil || tree.entry(newEntry.Name, false) != nil {
return fmt.Errorf("object: tree: entry %q already exists", newEntry.Name)
}
@@ -91,9 +87,6 @@ func (tree *Tree) InsertEntry(newEntry TreeEntry) error {
// RemoveEntry removes a tree entry by name.
func (tree *Tree) RemoveEntry(name []byte) error {
- if tree == nil {
- return errors.New("object: tree: remove on nil tree")
- }
if len(tree.Entries) == 0 {
return fmt.Errorf("object: tree: entry %q not found", name)
}
diff --git a/object/tree_parse.go b/object/tree_parse.go
index ee475803..b9063d75 100644
--- a/object/tree_parse.go
+++ b/object/tree_parse.go
@@ -10,10 +10,6 @@ import (
// ParseTree decodes a tree object body.
func ParseTree(body []byte, algo oid.Algorithm) (*Tree, error) {
- if algo.Size() == 0 {
- return nil, fmt.Errorf("object: tree: invalid hash algorithm %q", algo)
- }
-
var entries []TreeEntry
i := 0
for i < len(body) {