diff options
author | nulltoken <emeric.fermas@gmail.com> | 2012-07-04 16:06:07 +0200 |
---|---|---|
committer | nulltoken <emeric.fermas@gmail.com> | 2012-07-11 20:40:12 +0200 |
commit | 118cf57d426ede29b6695204e707810bbe3888ef (patch) | |
tree | e7eaf8636f19523960b2e1d9ec4643eca736b1a0 /tests-clar | |
parent | 5b071115294e2c7d4b36ac21842ef09c7edd02b6 (diff) | |
download | libgit2-118cf57d426ede29b6695204e707810bbe3888ef.tar.gz |
revwalk: relax the parsing of the commit time
Diffstat (limited to 'tests-clar')
-rw-r--r-- | tests-clar/revwalk/signatureparsing.c | 44 |
1 files changed, 44 insertions, 0 deletions
diff --git a/tests-clar/revwalk/signatureparsing.c b/tests-clar/revwalk/signatureparsing.c new file mode 100644 index 000000000..94de1a343 --- /dev/null +++ b/tests-clar/revwalk/signatureparsing.c @@ -0,0 +1,44 @@ +#include "clar_libgit2.h" + +static git_repository *_repo; +static git_revwalk *_walk; + +void test_revwalk_signatureparsing__initialize(void) +{ + cl_git_pass(git_repository_open(&_repo, cl_fixture("testrepo.git"))); + cl_git_pass(git_revwalk_new(&_walk, _repo)); +} + +void test_revwalk_signatureparsing__cleanup(void) +{ + git_revwalk_free(_walk); + git_repository_free(_repo); +} + +void test_revwalk_signatureparsing__do_not_choke_when_name_contains_angle_brackets(void) +{ + git_reference *ref; + git_oid commit_oid; + git_commit *commit; + const git_signature *signature; + + /* + * The branch below points at a commit with angle brackets in the committer/author name + * committer <Yu V. Bin Haacked> <foo@example.com> 1323847743 +0100 + */ + cl_git_pass(git_reference_lookup(&ref, _repo, "refs/heads/haacked")); + + git_revwalk_push(_walk, git_reference_oid(ref)); + cl_git_pass(git_revwalk_next(&commit_oid, _walk)); + + cl_git_pass(git_commit_lookup(&commit, _repo, git_reference_oid(ref))); + + signature = git_commit_committer(commit); + cl_assert_equal_s("Yu V. Bin Haacked", signature->email); + cl_assert_equal_s("", signature->name); + cl_assert_equal_i(1323847743, (int)signature->when.time); + cl_assert_equal_i(60, signature->when.offset); + + git_commit_free(commit); + git_reference_free(ref); +} |