aboutsummaryrefslogtreecommitdiffstats
path: root/plumbing/object/commit.go
diff options
context:
space:
mode:
authorMarc Barussaud <marc.barussaud@orange.com>2018-06-26 15:23:19 +0200
committerSantiago M. Mola <santi@mola.io>2018-07-02 15:11:59 +0200
commit9251ea764df3de13518f974635e76315b2b89e3e (patch)
tree9db44a52be37dd58e21b97861a9b3e1683449b24 /plumbing/object/commit.go
parent662e2c226e9b8352a90cd1951233fab30a4e5042 (diff)
downloadgo-git-9251ea764df3de13518f974635e76315b2b89e3e.tar.gz
plumbing: add context to allow cancel on diff/patch computing
Signed-off-by: Marc Barussaud <marc.barussaud@orange.com>
Diffstat (limited to 'plumbing/object/commit.go')
-rw-r--r--plumbing/object/commit.go11
1 files changed, 9 insertions, 2 deletions
diff --git a/plumbing/object/commit.go b/plumbing/object/commit.go
index c9a4c0e..3ed85ba 100644
--- a/plumbing/object/commit.go
+++ b/plumbing/object/commit.go
@@ -3,6 +3,7 @@ package object
import (
"bufio"
"bytes"
+ "context"
"errors"
"fmt"
"io"
@@ -75,7 +76,8 @@ func (c *Commit) Tree() (*Tree, error) {
}
// Patch returns the Patch between the actual commit and the provided one.
-func (c *Commit) Patch(to *Commit) (*Patch, error) {
+// Error will be return if context expires. Provided context must be non-nil
+func (c *Commit) PatchContext(ctx context.Context, to *Commit) (*Patch, error) {
fromTree, err := c.Tree()
if err != nil {
return nil, err
@@ -86,7 +88,12 @@ func (c *Commit) Patch(to *Commit) (*Patch, error) {
return nil, err
}
- return fromTree.Patch(toTree)
+ return fromTree.PatchContext(ctx, toTree)
+}
+
+// Patch returns the Patch between the actual commit and the provided one.
+func (c *Commit) Patch(to *Commit) (*Patch, error) {
+ return c.PatchContext(context.Background(), to)
}
// Parents return a CommitIter to the parent Commits.