summaryrefslogtreecommitdiff
path: root/tests/refs
diff options
context:
space:
mode:
authorCarlos Martín Nieto <cmn@dwim.me>2014-01-15 13:19:48 +0100
committerCarlos Martín Nieto <cmn@dwim.me>2014-03-17 17:47:47 +0100
commit4b7e1b9e927eec2359f178a260335109d4222e2b (patch)
tree6b9e3a332e6d710f0b17f0f07bc9541a9eab3538 /tests/refs
parentcb562c3fb305b7fa2ddc46983a6107f7b8340293 (diff)
downloadlibgit2-4b7e1b9e927eec2359f178a260335109d4222e2b.tar.gz
refs: append to the HEAD reflog when updating the current branch
When we update the current branch, we must also append to HEAD's reflog to keep them in sync. This is a bit of a hack, but as git.git says, it covers 100% of default cases.
Diffstat (limited to 'tests/refs')
-rw-r--r--tests/refs/reflog/reflog.c23
1 files changed, 23 insertions, 0 deletions
diff --git a/tests/refs/reflog/reflog.c b/tests/refs/reflog/reflog.c
index 3f7d7d777..149e98273 100644
--- a/tests/refs/reflog/reflog.c
+++ b/tests/refs/reflog/reflog.c
@@ -214,3 +214,26 @@ void test_refs_reflog_reflog__write_when_explicitly_active(void)
git_reference_free(ref);
assert_has_reflog(true, "refs/tags/foo");
}
+
+void test_refs_reflog_reflog__append_to_HEAD_when_changing_current_branch(void)
+{
+ size_t nlogs, nlogs_after;
+ git_reference *ref;
+ git_reflog *log;
+ git_oid id;
+
+ cl_git_pass(git_reflog_read(&log, g_repo, "HEAD"));
+ nlogs = git_reflog_entrycount(log);
+ git_reflog_free(log);
+
+ /* Move it back */
+ git_oid_fromstr(&id, "be3563ae3f795b2b4353bcce3a527ad0a4f7f644");
+ cl_git_pass(git_reference_create(&ref, g_repo, "refs/heads/master", &id, 1, NULL, NULL));
+ git_reference_free(ref);
+
+ cl_git_pass(git_reflog_read(&log, g_repo, "HEAD"));
+ nlogs_after = git_reflog_entrycount(log);
+ git_reflog_free(log);
+
+ cl_assert_equal_i(nlogs_after, nlogs + 1);
+}