summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorCarlos Martín Nieto <cmn@dwim.me>2014-02-10 23:50:41 +0100
committerCarlos Martín Nieto <cmn@dwim.me>2014-02-10 23:50:41 +0100
commit97645461d8bc74f95080697c1b111894698360c8 (patch)
tree19f8ae3f922c593336e96740436d5416630b62f1 /tests
parentb362fbf363f1793fe9b190f57ecb04afd26b09ce (diff)
downloadlibgit2-cmn/safe-commit.tar.gz
commit: add a function to create a commit on top of a refcmn/safe-commit
Add a way to safely create a commit which builds on top of the current commit in a given reference.
Diffstat (limited to 'tests')
-rw-r--r--tests/commit/write.c27
1 files changed, 27 insertions, 0 deletions
diff --git a/tests/commit/write.c b/tests/commit/write.c
index b1cdf4485..84cc99133 100644
--- a/tests/commit/write.c
+++ b/tests/commit/write.c
@@ -158,3 +158,30 @@ void test_commit_write__root(void)
git_signature_free(committer);
git_reflog_free(log);
}
+
+void test_commit_write__append(void)
+{
+ git_tree *tree;
+ git_oid tree_id, commit_id;
+ git_signature *author, *committer;
+
+ git_oid_fromstr(&tree_id, tree_oid);
+ cl_git_pass(git_tree_lookup(&tree, g_repo, &tree_id));
+
+ cl_git_pass(git_signature_new(&author, committer_name, committer_email, 987654321, 90));
+ cl_git_pass(git_signature_new(&committer, committer_name, committer_email, 123456789, 60));
+
+ cl_git_pass(git_commit_append(
+ &commit_id, /* out id */
+ g_repo,
+ "HEAD",
+ author,
+ committer,
+ NULL,
+ root_commit_message,
+ tree));
+
+ git_tree_free(tree);
+ git_signature_free(committer);
+ git_signature_free(author);
+}