aboutsummaryrefslogblamecommitdiffstats
path: root/plumbing/object/difftree.go
blob: 3bc29cb09baef7075854a404ec9b66d2588a008f (plain) (tree)
1
2
3
4
5
6
7
8
9
              


               
 

                                                     

 

                                                                    
                                            

                               
 



                                                      
                                                                          
                       
                               

         
                                            
 
package object

import (
	"bytes"

	"srcd.works/go-git.v4/utils/merkletrie"
	"srcd.works/go-git.v4/utils/merkletrie/noder"
)

// DiffTree compares the content and mode of the blobs found via two
// tree objects.
func DiffTree(a, b *Tree) (Changes, error) {
	from := newTreeNoder(a)
	to := newTreeNoder(b)

	hashEqual := func(a, b noder.Hasher) bool {
		return bytes.Equal(a.Hash(), b.Hash())
	}

	merkletrieChanges, err := merkletrie.DiffTree(from, to, hashEqual)
	if err != nil {
		return nil, err
	}

	return newChanges(merkletrieChanges)
}