aboutsummaryrefslogtreecommitdiffstats
path: root/plumbing/object/commit.go
diff options
context:
space:
mode:
authorMáximo Cuadros <mcuadros@gmail.com>2018-07-10 11:34:51 +0200
committerGitHub <noreply@github.com>2018-07-10 11:34:51 +0200
commit3bd5e82b2512d85becae9677fa06b5a973fd4cfb (patch)
tree7b5aa42ef1b86540f0e30ab6e79aa0772e5986a7 /plumbing/object/commit.go
parent8ad72db0b7e1c03d9fad343890e469d5c3ed757b (diff)
parent9251ea764df3de13518f974635e76315b2b89e3e (diff)
downloadgo-git-3bd5e82b2512d85becae9677fa06b5a973fd4cfb.tar.gz
Merge pull request #874 from smola/patchcontextv4.5.0
plumbing: add context to allow cancel on diff/patch computing
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.