aboutsummaryrefslogtreecommitdiff
path: root/diff/trees/diff.go
blob: 7736d08fe7c44af6805e91aa16ee84bbdd6e69e5 (about) (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
// Package trees provides recursive diffs between Git tree objects.
package trees

import (
	"codeberg.org/lindenii/furgit/object"
	"codeberg.org/lindenii/furgit/objectid"
)

// Diff compares two trees and returns recursive differences.
//
// readTree is used to lazily load child trees by object ID when recursion
// reaches directory entries.
func Diff(a, b *object.Tree, readTree func(objectid.ObjectID) (*object.Tree, error)) ([]Entry, error) {
	var out []Entry

	err := diffRecursive(a, b, nil, readTree, &out)
	if err != nil {
		return nil, err
	}

	return out, nil
}