aboutsummaryrefslogtreecommitdiffstats
path: root/utils/merkletrie/change.go
diff options
context:
space:
mode:
authorPaulo Gomes <pjbgf@linux.com>2024-07-13 15:19:59 +0100
committerGitHub <noreply@github.com>2024-07-13 15:19:59 +0100
commit54b70993933f3b708a24132846aa7ed1da285566 (patch)
tree4c2b5b72bcb744cfb28b9e2c2e9e6d5ed0bac71f /utils/merkletrie/change.go
parent94fb0d8e1a77fd962c0dde4bed08ce59bc5cfba2 (diff)
parentc736731ac9cbbc002d074de200f417decccc3dca (diff)
downloadgo-git-54b70993933f3b708a24132846aa7ed1da285566.tar.gz
Merge pull request #1142 from pjbgf/empty
utils: merkletrie, Align error message with upstream
Diffstat (limited to 'utils/merkletrie/change.go')
-rw-r--r--utils/merkletrie/change.go9
1 files changed, 9 insertions, 0 deletions
diff --git a/utils/merkletrie/change.go b/utils/merkletrie/change.go
index cc6dc89..450feb4 100644
--- a/utils/merkletrie/change.go
+++ b/utils/merkletrie/change.go
@@ -1,12 +1,17 @@
package merkletrie
import (
+ "errors"
"fmt"
"io"
"github.com/go-git/go-git/v5/utils/merkletrie/noder"
)
+var (
+ ErrEmptyFileName = errors.New("empty filename in tree entry")
+)
+
// Action values represent the kind of things a Change can represent:
// insertion, deletions or modifications of files.
type Action int
@@ -121,6 +126,10 @@ func (l *Changes) AddRecursiveDelete(root noder.Path) error {
type noderToChangeFn func(noder.Path) Change // NewInsert or NewDelete
func (l *Changes) addRecursive(root noder.Path, ctor noderToChangeFn) error {
+ if root.String() == "" {
+ return ErrEmptyFileName
+ }
+
if !root.IsDir() {
l.Add(ctor(root))
return nil