diff options
author | Ben Straub <bs@github.com> | 2014-01-28 01:39:48 +0400 |
---|---|---|
committer | Ben Straub <bs@github.com> | 2014-01-31 03:51:00 +0400 |
commit | 2952a9d0f474547db88f396dd8cc7c62d61993a2 (patch) | |
tree | ba2f8c6c64ece6cf39c3d3e58a22a599868aae29 /tests | |
parent | 6357388e983be6ad5831d63b84aeb2f9c449411e (diff) |
Ensure creating HEAD creates its reflog
Diffstat (limited to 'tests')
-rw-r--r-- | tests/repo/head.c | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/tests/repo/head.c b/tests/repo/head.c index df7059fd5..d28f254c3 100644 --- a/tests/repo/head.c +++ b/tests/repo/head.c @@ -217,3 +217,24 @@ void test_repo_head__setting_head_updates_reflog(void) git_reflog_free(log); git_object_free(tag); } + +void test_repo_head__setting_creates_head_ref(void) +{ + git_reference *head; + git_reflog *log; + const git_reflog_entry *entry; + + cl_git_pass(git_reference_lookup(&head, repo, "HEAD")); + cl_git_pass(git_reference_delete(head)); + cl_git_pass(git_reflog_delete(repo, "HEAD")); + + cl_git_pass(git_repository_set_head(repo, "refs/heads/haacked", NULL, "create HEAD")); + + cl_git_pass(git_reflog_read(&log, repo, "HEAD")); + cl_assert_equal_i(1, git_reflog_entrycount(log)); + entry = git_reflog_entry_byindex(log, 0); + cl_assert_equal_s("create HEAD", git_reflog_entry_message(entry)); + + git_reflog_free(log); + git_reference_free(head); +} |