aboutsummaryrefslogtreecommitdiffstats
path: root/plumbing/object/commit.go
diff options
context:
space:
mode:
authorMáximo Cuadros <mcuadros@gmail.com>2017-05-23 15:38:54 +0200
committerGitHub <noreply@github.com>2017-05-23 15:38:54 +0200
commitf663a9384619965ed8df7a7224e6f15ad18ed4af (patch)
tree337a4615e7a3ef24f46cbe008944a687c6a964ac /plumbing/object/commit.go
parent2ff77a8d93529cefdca922dbed89d4b1cd0ee8e5 (diff)
parent65416cf6c0e8264cc7938fe0611998d52780e089 (diff)
downloadgo-git-f663a9384619965ed8df7a7224e6f15ad18ed4af.tar.gz
Merge pull request #388 from ajnavarro/feature/commit-diff
format/diff: unified diff encoder and public API
Diffstat (limited to 'plumbing/object/commit.go')
-rw-r--r--plumbing/object/commit.go15
1 files changed, 15 insertions, 0 deletions
diff --git a/plumbing/object/commit.go b/plumbing/object/commit.go
index 0a20ae6..c5a1867 100644
--- a/plumbing/object/commit.go
+++ b/plumbing/object/commit.go
@@ -64,6 +64,21 @@ func (c *Commit) Tree() (*Tree, error) {
return GetTree(c.s, c.TreeHash)
}
+// Patch returns the Patch between the actual commit and the provided one.
+func (c *Commit) Patch(to *Commit) (*Patch, error) {
+ fromTree, err := c.Tree()
+ if err != nil {
+ return nil, err
+ }
+
+ toTree, err := to.Tree()
+ if err != nil {
+ return nil, err
+ }
+
+ return fromTree.Patch(toTree)
+}
+
// Parents return a CommitIter to the parent Commits.
func (c *Commit) Parents() CommitIter {
return NewCommitIter(c.s,