diff options
author | Paulo Gomes <pjbgf@linux.com> | 2024-07-13 14:24:30 +0100 |
---|---|---|
committer | Paulo Gomes <pjbgf@linux.com> | 2024-07-13 14:24:30 +0100 |
commit | c736731ac9cbbc002d074de200f417decccc3dca (patch) | |
tree | 4c2b5b72bcb744cfb28b9e2c2e9e6d5ed0bac71f /utils/merkletrie/change.go | |
parent | 94fb0d8e1a77fd962c0dde4bed08ce59bc5cfba2 (diff) | |
download | go-git-c736731ac9cbbc002d074de200f417decccc3dca.tar.gz |
utils: merkletrie, Align error message with upstream
Signed-off-by: Paulo Gomes <pjbgf@linux.com>
Diffstat (limited to 'utils/merkletrie/change.go')
-rw-r--r-- | utils/merkletrie/change.go | 9 |
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 |