diff options
author | Ben Straub <bs@github.com> | 2014-01-28 01:12:31 +0400 |
---|---|---|
committer | Ben Straub <bs@github.com> | 2014-01-31 03:51:00 +0400 |
commit | a2311f92c29e0fee5348d580c3318cf6724cd765 (patch) | |
tree | f4af06ba4ea36749b3f4a76789cd27aa13a457f6 /tests/repo | |
parent | 94f263f59be5be74945367b9793c57f297ed4a44 (diff) |
Ensure updating HEAD updates reflog
Diffstat (limited to 'tests/repo')
-rw-r--r-- | tests/repo/head.c | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/tests/repo/head.c b/tests/repo/head.c index 06e837d70..df7059fd5 100644 --- a/tests/repo/head.c +++ b/tests/repo/head.c @@ -194,3 +194,26 @@ void test_repo_head__can_tell_if_an_unborn_head_is_detached(void) cl_assert_equal_i(false, git_repository_head_detached(repo)); } + +void test_repo_head__setting_head_updates_reflog(void) +{ + git_reflog *log; + const git_reflog_entry *entry1, *entry2, *entry3; + git_object *tag; + + cl_git_pass(git_repository_set_head(repo, "refs/heads/haacked", NULL, "message1")); + cl_git_pass(git_repository_set_head(repo, "refs/heads/unborn", NULL, "message2")); + cl_git_pass(git_revparse_single(&tag, repo, "tags/test")); + cl_git_pass(git_repository_set_head_detached(repo, git_object_id(tag), NULL, "message3")); + + cl_git_pass(git_reflog_read(&log, repo, "HEAD")); + entry1 = git_reflog_entry_byindex(log, 2); + entry2 = git_reflog_entry_byindex(log, 1); + entry3 = git_reflog_entry_byindex(log, 0); + cl_assert_equal_s("message1", git_reflog_entry_message(entry1)); + cl_assert_equal_s("message2", git_reflog_entry_message(entry2)); + cl_assert_equal_s("message3", git_reflog_entry_message(entry3)); + + git_reflog_free(log); + git_object_free(tag); +} |