smithy

commit 5997e10eade2d7461f217ea752c0a136713c84f0

Author: Honza Pokorny <me@honza.ca>

Handle initial commit properly

If there is no parent, compare the current tree against an empty tree.

 pkg/smithy/smithy.go | 16 ++++++++--------


diff --git a/pkg/smithy/smithy.go b/pkg/smithy/smithy.go
index b8116ba942c64e0a2a3e6cc6689dbdcc40496ee6..f869da64eecec7a737db9bb27d0ad609515a2acd 100644
--- a/pkg/smithy/smithy.go
+++ b/pkg/smithy/smithy.go
@@ -514,18 +514,18 @@ }
 
 func GetChanges(commit *object.Commit) (object.Changes, error) {
 	var changes object.Changes
-	parent, err := commit.Parent(0)
-	if err != nil {
-		return changes, err
-	}
+	var parentTree *object.Tree
 
-	currentTree, err := commit.Tree()
+	parent, err := commit.Parent(0)
+	if err == nil {
+		parentTree, err = parent.Tree()
 
-	if err != nil {
-		return changes, err
+		if err != nil {
+			return changes, err
+		}
 	}
 
-	parentTree, err := parent.Tree()
+	currentTree, err := commit.Tree()
 
 	if err != nil {
 		return changes, err