aboutsummaryrefslogtreecommitdiff
path: root/object/tree/insert.go
diff options
context:
space:
mode:
Diffstat (limited to 'object/tree/insert.go')
-rw-r--r--object/tree/insert.go19
1 files changed, 1 insertions, 18 deletions
diff --git a/object/tree/insert.go b/object/tree/insert.go
index b5227938..5e519069 100644
--- a/object/tree/insert.go
+++ b/object/tree/insert.go
@@ -26,7 +26,7 @@ func (tree *Tree) Insert(entry Entry) error {
return fmt.Errorf("%w: entry %q has invalid mode", ErrInvalidTree, entry.Name)
}
- if _, found := tree.find(entry.Name); found {
+ if _, found := tree.Find(entry.Name); found {
return fmt.Errorf("%w: entry %q already exists", ErrInvalidTree, entry.Name)
}
@@ -41,23 +41,6 @@ func (tree *Tree) Insert(entry Entry) error {
return nil
}
-// find returns the index of the entry with the given name, if present.
-//
-// A name conflicts whether stored as a blob-like or as a subtree entry,
-// so both orderings are searched.
-func (tree *Tree) find(name string) (int, bool) {
- for _, searchIsTree := range [...]bool{true, false} {
- index, ok := slices.BinarySearchFunc(tree.entries, name, func(existing Entry, target string) int {
- return nameCompare(existing.Name, existing.Mode == mode.Directory, target, searchIsTree)
- })
- if ok && tree.entries[index].Name == name {
- return index, true
- }
- }
-
- return 0, false
-}
-
// validateName checks that name is a structurally valid tree entry name.
func validateName(name string) error {
if name == "" {