aboutsummaryrefslogtreecommitdiffstats
path: root/plumbing/object/commit.go
diff options
context:
space:
mode:
authorAntonio Jesus Navarro Perez <antnavper@gmail.com>2017-05-10 16:47:15 +0200
committerAntonio Jesus Navarro Perez <antnavper@gmail.com>2017-05-23 11:05:14 +0200
commit2f293f4a5214ccba5bdf0b82ff8b62ed39144078 (patch)
tree8942869ff31dbf3aa950c1d3cddb3a0de8ca0aa3 /plumbing/object/commit.go
parent2ff77a8d93529cefdca922dbed89d4b1cd0ee8e5 (diff)
downloadgo-git-2f293f4a5214ccba5bdf0b82ff8b62ed39144078.tar.gz
format/diff: unified diff encoder and public API
- Added Patch interface - Added a Unified Diff encoder from Patches - Added Change method to generate Patches - Added Changes method to generate Patches - Added Tree method to generate Patches - Added Commit method to generate Patches
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,