diff options
author | Máximo Cuadros <mcuadros@gmail.com> | 2021-12-10 06:51:49 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-12-10 06:51:49 +0100 |
commit | fe158cd6e176682e087efea9625ec5409f2956bf (patch) | |
tree | 63afb89d42b388316d045820b44972f54e0b8f01 /utils/merkletrie/difftree.go | |
parent | 589a41ceedfa89e1ff334a969d1beb28cb731de9 (diff) | |
parent | 39f97ab86a776dd8acd58a79a660d0cfdb7068c0 (diff) | |
download | go-git-fe158cd6e176682e087efea9625ec5409f2956bf.tar.gz |
Merge branch 'master' into jc-push-atomic
Diffstat (limited to 'utils/merkletrie/difftree.go')
-rw-r--r-- | utils/merkletrie/difftree.go | 29 |
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 } |