diff options
author | Ben Straub <bs@github.com> | 2014-01-27 14:40:31 -0800 |
---|---|---|
committer | Ben Straub <bs@github.com> | 2014-01-30 15:52:13 -0800 |
commit | 1cc974ab625c2fa0794130eb97ca88c449fc1a06 (patch) | |
tree | 325c27052bbae86612d278ddacab9fc5982e131e /tests/clone | |
parent | b31ebfbc666202fb576f7eb406d7a699134da09d (diff) | |
download | libgit2-1cc974ab625c2fa0794130eb97ca88c449fc1a06.tar.gz |
Augment clone API with reflog parameters
Diffstat (limited to 'tests/clone')
-rw-r--r-- | tests/clone/nonetwork.c | 44 |
1 files changed, 44 insertions, 0 deletions
diff --git a/tests/clone/nonetwork.c b/tests/clone/nonetwork.c index 863412cdb..14d2bbf59 100644 --- a/tests/clone/nonetwork.c +++ b/tests/clone/nonetwork.c @@ -232,3 +232,47 @@ void test_clone_nonetwork__can_detached_head(void) cl_fixture_cleanup("./foo1"); } + +static void assert_correct_reflog(const char *name) +{ + git_reflog *log; + const git_reflog_entry *entry; + char expected_log_message[128] = {0}; + + sprintf(expected_log_message, "clone: from %s", cl_git_fixture_url("testrepo.git")); + + cl_git_pass(git_reflog_read(&log, g_repo, name)); + cl_assert_equal_i(1, git_reflog_entrycount(log)); + entry = git_reflog_entry_byindex(log, 0); + cl_assert_equal_s(expected_log_message, git_reflog_entry_message(entry)); + cl_assert_equal_s("foo@example.com", git_reflog_entry_committer(entry)->email); + + git_reflog_free(log); +} + +void test_clone_nonetwork__clone_updates_reflog_properly(void) +{ + cl_git_pass(git_signature_now(&g_options.signature, "Me", "foo@example.com")); + cl_git_pass(git_clone(&g_repo, cl_git_fixture_url("testrepo.git"), "./foo", &g_options)); + assert_correct_reflog("HEAD"); + assert_correct_reflog("refs/heads/master"); + + git_signature_free(g_options.signature); +} + +void test_clone_nonetwork__clone_into_updates_reflog_properly(void) +{ + git_remote *remote; + git_signature *sig; + cl_git_pass(git_signature_now(&sig, "Me", "foo@example.com")); + + cl_git_pass(git_repository_init(&g_repo, "./foo", false)); + cl_git_pass(git_remote_create(&remote, g_repo, "origin", cl_git_fixture_url("testrepo.git"))); + cl_git_pass(git_clone_into(g_repo, remote, NULL, NULL, sig)); + + assert_correct_reflog("HEAD"); + assert_correct_reflog("refs/heads/master"); + + git_remote_free(remote); + git_signature_free(g_options.signature); +} |