summaryrefslogtreecommitdiff
path: root/tests/t04-commit.c
diff options
context:
space:
mode:
authorVicent Marti <tanoku@gmail.com>2011-06-28 19:15:48 +0200
committerVicent Marti <tanoku@gmail.com>2011-06-28 19:36:27 +0200
commitd5afc0390c3ef919fcde23300d7aefdaeafa5daa (patch)
tree0b661ef8536266c5bf5de645025c8072bc35dc85 /tests/t04-commit.c
parent0b10c9ea6ef5d85d862edd044d96561c4fd16e9b (diff)
downloadlibgit2-d5afc0390c3ef919fcde23300d7aefdaeafa5daa.tar.gz
Remove redundant methods from the API
A bunch of redundant methods have been removed from the external API. - All the reference/tag creation methods with `_f` are gone. The force flag is now passed as an argument to the normal create methods. - All the different commit creation methods are gone; commit creation now always requires a `git_commit` pointer for parents and a `git_tree` pointer for tree, to ensure that corrupted commits cannot be generated. - All the different tag creation methods are gone; tag creation now always requires a `git_object` pointer to ensure that tags are not created to inexisting objects.
Diffstat (limited to 'tests/t04-commit.c')
-rw-r--r--tests/t04-commit.c20
1 files changed, 14 insertions, 6 deletions
diff --git a/tests/t04-commit.c b/tests/t04-commit.c
index 0ae0cdfb2..b7e0afe1e 100644
--- a/tests/t04-commit.c
+++ b/tests/t04-commit.c
@@ -415,19 +415,21 @@ This is a commit created in memory and it will be written back to disk\n"
static const char *tree_oid = "1810dff58d8a660512d4832e740f692884338ccd";
-
BEGIN_TEST(write0, "write a new commit object from memory to disk")
git_repository *repo;
git_commit *commit;
git_oid tree_id, parent_id, commit_id;
const git_signature *author, *committer;
- /* char hex_oid[41]; */
+ git_commit *parent;
+ git_tree *tree;
must_pass(git_repository_open(&repo, REPOSITORY_FOLDER));
-
git_oid_fromstr(&tree_id, tree_oid);
+ must_pass(git_tree_lookup(&tree, repo, &tree_id));
+
git_oid_fromstr(&parent_id, commit_ids[4]);
+ must_pass(git_commit_lookup(&parent, repo, &parent_id));
/* create signatures */
committer = git_signature_new(COMMITTER_NAME, COMMITTER_EMAIL, 123456789, 60);
@@ -443,8 +445,11 @@ BEGIN_TEST(write0, "write a new commit object from memory to disk")
author,
committer,
COMMIT_MESSAGE,
- &tree_id,
- 1, &parent_id));
+ tree,
+ 1, parent));
+
+ git_object_close((git_object *)parent);
+ git_object_close((git_object *)tree);
git_signature_free((git_signature *)committer);
git_signature_free((git_signature *)author);
@@ -486,10 +491,12 @@ BEGIN_TEST(root0, "create a root commit")
const char *branch_name = "refs/heads/root-commit-branch";
git_reference *head, *branch;
char *head_old;
+ git_tree *tree;
must_pass(git_repository_open(&repo, REPOSITORY_FOLDER));
git_oid_fromstr(&tree_id, tree_oid);
+ must_pass(git_tree_lookup(&tree, repo, &tree_id));
/* create signatures */
committer = git_signature_new(COMMITTER_NAME, COMMITTER_EMAIL, 123456789, 60);
@@ -513,9 +520,10 @@ BEGIN_TEST(root0, "create a root commit")
author,
committer,
ROOT_COMMIT_MESSAGE,
- &tree_id,
+ tree,
0));
+ git_object_close((git_object *)tree);
git_signature_free((git_signature *)committer);
git_signature_free((git_signature *)author);