Commit e871d89b2862ea61a13019705d4074bfcb6b88ae

Ben Straub 2014-01-28T11:32:09

Ensure moving a branch updates the reflog

diff --git a/tests/refs/branches/move.c b/tests/refs/branches/move.c
index bea93b9..0bdb58a 100644
--- a/tests/refs/branches/move.c
+++ b/tests/refs/branches/move.c
@@ -186,3 +186,22 @@ void test_refs_branches_move__moving_the_branch_pointed_at_by_HEAD_updates_HEAD(
 	cl_assert_equal_s("refs/heads/master2", git_reference_name(branch));
 	git_reference_free(branch);
 }
+
+void test_refs_branches_move__updates_the_reflog(void)
+{
+	git_reference *branch;
+	git_reference *new_branch;
+	git_reflog *log;
+	const git_reflog_entry *entry;
+
+	cl_git_pass(git_reference_lookup(&branch, repo, "refs/heads/master"));
+	cl_git_pass(git_branch_move(&new_branch, branch, "master2", 0, NULL, "message"));
+
+	cl_git_pass(git_reflog_read(&log, repo, git_reference_name(new_branch)));
+	entry = git_reflog_entry_byindex(log, 0);
+	cl_assert_equal_s("message", git_reflog_entry_message(entry));
+
+	git_reference_free(branch);
+	git_reference_free(new_branch);
+	git_reflog_free(log);
+}