aboutsummaryrefslogtreecommitdiffstats
path: root/utils/merkletrie/difftree.go
diff options
context:
space:
mode:
authorpaul.t <paul.t@gembaadvantage.com>2021-12-15 06:32:38 +0000
committerpaul.t <paul.t@gembaadvantage.com>2021-12-15 06:32:38 +0000
commit8d923a6fb77d7916da2df33e5a65e038cceef4e1 (patch)
tree5a823fa6e7ffd5e38df105cadcab5a0d6b7475e9 /utils/merkletrie/difftree.go
parentb0f5eb894deb6d6a1051d697f0809082abfad395 (diff)
parent53a714bdc90026135e2f2ada1c4d6c925b2733cd (diff)
downloadgo-git-8d923a6fb77d7916da2df33e5a65e038cceef4e1.tar.gz
Merge branch 'master' into codecommit-ref-delta
Diffstat (limited to 'utils/merkletrie/difftree.go')
-rw-r--r--utils/merkletrie/difftree.go29
1 files changed, 27 insertions, 2 deletions
diff --git a/utils/merkletrie/difftree.go b/utils/merkletrie/difftree.go
index bd084b2..9f5145a 100644
--- a/utils/merkletrie/difftree.go
+++ b/utils/merkletrie/difftree.go
@@ -304,13 +304,38 @@ func DiffTreeContext(ctx context.Context, fromTree, toTree noder.Noder,
return nil, err
}
case onlyToRemains:
- if err = ret.AddRecursiveInsert(to); err != nil {
- return nil, err
+ if to.Skip() {
+ if err = ret.AddRecursiveDelete(to); err != nil {
+ return nil, err
+ }
+ } else {
+ if err = ret.AddRecursiveInsert(to); err != nil {
+ return nil, err
+ }
}
if err = ii.nextTo(); err != nil {
return nil, err
}
case bothHaveNodes:
+ if from.Skip() {
+ if err = ret.AddRecursiveDelete(from); err != nil {
+ return nil, err
+ }
+ if err := ii.nextBoth(); err != nil {
+ return nil, err
+ }
+ break
+ }
+ if to.Skip() {
+ if err = ret.AddRecursiveDelete(to); err != nil {
+ return nil, err
+ }
+ if err := ii.nextBoth(); err != nil {
+ return nil, err
+ }
+ break
+ }
+
if err = diffNodes(&ret, ii); err != nil {
return nil, err
}