From 042e56e56e644bc9f02780dbf6eeadc40eb57f6a Mon Sep 17 00:00:00 2001 From: Máximo Cuadros Date: Sat, 25 Apr 2020 12:36:40 +0200 Subject: plumbing: object, make renames diff default --- plumbing/object/tree.go | 35 ++++++++++++++++++++--------------- 1 file changed, 20 insertions(+), 15 deletions(-) (limited to 'plumbing/object/tree.go') diff --git a/plumbing/object/tree.go b/plumbing/object/tree.go index d3c8c77..5e6378c 100644 --- a/plumbing/object/tree.go +++ b/plumbing/object/tree.go @@ -304,29 +304,34 @@ func (t *Tree) buildMap() { } // Diff returns a list of changes between this tree and the provided one -func (from *Tree) Diff(to *Tree) (Changes, error) { - return DiffTree(from, to) +func (t *Tree) Diff(to *Tree) (Changes, error) { + return t.DiffContext(context.Background(), to) } -// Diff returns a list of changes between this tree and the provided one -// Error will be returned if context expires -// Provided context must be non nil -func (from *Tree) DiffContext(ctx context.Context, to *Tree) (Changes, error) { - return DiffTreeContext(ctx, from, to) +// DiffContext returns a list of changes between this tree and the provided one +// Error will be returned if context expires. Provided context must be non nil. +// +// NOTE: Since version 5.1.0 the renames are correctly handled, the settings +// used are the recommended options DefaultDiffTreeOptions. +func (t *Tree) DiffContext(ctx context.Context, to *Tree) (Changes, error) { + return DiffTreeWithOptions(ctx, t, to, DefaultDiffTreeOptions) } // Patch returns a slice of Patch objects with all the changes between trees // in chunks. This representation can be used to create several diff outputs. -func (from *Tree) Patch(to *Tree) (*Patch, error) { - return from.PatchContext(context.Background(), to) +func (t *Tree) Patch(to *Tree) (*Patch, error) { + return t.PatchContext(context.Background(), to) } -// Patch returns a slice of Patch objects with all the changes between trees -// in chunks. This representation can be used to create several diff outputs. -// If context expires, an error will be returned -// Provided context must be non-nil -func (from *Tree) PatchContext(ctx context.Context, to *Tree) (*Patch, error) { - changes, err := DiffTreeContext(ctx, from, to) +// PatchContext returns a slice of Patch objects with all the changes between +// trees in chunks. This representation can be used to create several diff +// outputs. If context expires, an error will be returned. Provided context must +// be non-nil. +// +// NOTE: Since version 5.1.0 the renames are correctly handled, the settings +// used are the recommended options DefaultDiffTreeOptions. +func (t *Tree) PatchContext(ctx context.Context, to *Tree) (*Patch, error) { + changes, err := t.DiffContext(ctx, to) if err != nil { return nil, err } -- cgit