Commit 3e96e3391cdce890e9030615fdb816301534accc

Russell Belfer 2013-05-05T08:01:18

Merge pull request #1549 from nulltoken/fix/from_oids Strict/lax commit API

diff --git a/include/git2/sys/commit.h b/include/git2/sys/commit.h
index 096e028..34a12fb 100644
--- a/include/git2/sys/commit.h
+++ b/include/git2/sys/commit.h
@@ -25,8 +25,9 @@ GIT_BEGIN_DECL
  *
  * See documentation for `git_commit_create()` for information about the
  * parameters, as the meaning is identical excepting that `tree` and
- * `parents` now take `git_oid`.  This is a dangerous API in that the
- * `parents` list of `git_oid`s in not checked for validity.
+ * `parents` now take `git_oid`.  This is a dangerous API in that nor
+ * the `tree`, neither the `parents` list of `git_oid`s are checked for
+ * validity.
  */
 GIT_EXTERN(int) git_commit_create_from_oids(
 	git_oid *oid,
diff --git a/src/commit.c b/src/commit.c
index 46c02c2..3dc647c 100644
--- a/src/commit.c
+++ b/src/commit.c
@@ -96,7 +96,6 @@ int git_commit_create_from_oids(
 	git_odb *odb;
 
 	assert(oid && repo && tree && parent_count >= 0);
-	assert(git_object_owner((const git_object *)tree) == repo);
 
 	git_oid__writebuf(&commit, "tree ", tree);
 
@@ -149,6 +148,7 @@ int git_commit_create(
 	const git_oid **parent_oids;
 
 	assert(parent_count >= 0);
+	assert(git_object_owner((const git_object *)tree) == repo);
 
 	parent_oids = git__malloc(parent_count * sizeof(git_oid *));
 	GITERR_CHECK_ALLOC(parent_oids);