]>
git.proxmox.com Git - libgit2.git/blob - tests/t0402-details.c
2 #include "test_helpers.h"
6 #include <git/commit.h>
7 #include <git/revwalk.h>
9 static const char *odb_dir
= "../t0501-objects";
10 static const char *commit_ids
[] = {
11 "a4a7dce85cf63874e984719f4fdd239f5145052f", /* 0 */
12 "9fd738e8f7967c078dceed8190330fc8648ee56a", /* 1 */
13 "4a202b346bb0fb0db7eff3cffeb3c70babbd2045", /* 2 */
14 "c47800c7266a2be04c571c04d5a6614691ea99bd", /* 3 */
15 "8496071c1b46c854b31185ea97743be6a8774479", /* 4 */
16 "5b5b025afb0b4c913b4c338a42934a3863bf3644", /* 5 */
19 BEGIN_TEST(query_details_test
)
20 const size_t commit_count
= sizeof(commit_ids
) / sizeof(const char *);
26 must_pass(git_odb_open(&db
, odb_dir
));
28 repo
= git_repository_alloc(db
);
29 must_be_true(repo
!= NULL
);
31 for (i
= 0; i
< commit_count
; ++i
) {
35 const git_person
*author
, *committer
;
36 const char *message
, *message_short
;
39 git_oid_mkstr(&id
, commit_ids
[i
]);
41 commit
= git_commit_lookup(repo
, &id
);
42 must_be_true(commit
!= NULL
);
44 message
= git_commit_message(commit
);
45 message_short
= git_commit_message_short(commit
);
46 author
= git_commit_author(commit
);
47 committer
= git_commit_committer(commit
);
48 commit_time
= git_commit_time(commit
);
50 must_be_true(strcmp(author
->name
, "Scott Chacon") == 0);
51 must_be_true(strcmp(author
->email
, "schacon@gmail.com") == 0);
52 must_be_true(strcmp(committer
->name
, "Scott Chacon") == 0);
53 must_be_true(strcmp(committer
->email
, "schacon@gmail.com") == 0);
54 must_be_true(strchr(message
, '\n') != NULL
);
55 must_be_true(strchr(message_short
, '\n') == NULL
);
56 must_be_true(commit_time
> 0);
59 git_repository_free(repo
);