Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/mono/libgit2.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCarlos Martín Nieto <cmn@dwim.me>2014-03-19 21:14:35 +0400
committerCarlos Martín Nieto <cmn@dwim.me>2014-03-19 21:14:35 +0400
commit99797c96cd57a616ada009a2359390c605d33929 (patch)
treeeaa862563a6a681d07fc664648a41fa1768297a5 /tests/repo
parent6aaae94a7060834a68f3fd24d8006dbfe769e04a (diff)
reflog: handle symref chains
Given HEAD -> master -> foo, when updating foo's reflog we should also update HEAD's, as it's considered the current branch.
Diffstat (limited to 'tests/repo')
-rw-r--r--tests/repo/head.c51
1 files changed, 51 insertions, 0 deletions
diff --git a/tests/repo/head.c b/tests/repo/head.c
index d68a5a61e..79892a3ea 100644
--- a/tests/repo/head.c
+++ b/tests/repo/head.c
@@ -416,3 +416,54 @@ void test_repo_head__branch_birth(void)
git_signature_free(sig);
}
+
+static size_t entrycount(git_repository *repo, const char *name)
+{
+ git_reflog *log;
+ size_t ret;
+
+ cl_git_pass(git_reflog_read(&log, repo, name));
+ ret = git_reflog_entrycount(log);
+ git_reflog_free(log);
+
+ return ret;
+}
+
+void test_repo_head__symref_chain(void)
+{
+ git_signature *sig;
+ git_oid id;
+ git_tree *tree;
+ git_reference *ref;
+ const char *msg;
+ size_t nentries, nentries_master;
+
+ nentries = entrycount(repo, GIT_HEAD_FILE);
+
+ cl_git_pass(git_signature_now(&sig, "me", "foo@example.com"));
+
+ cl_git_pass(git_repository_head(&ref, repo));
+ cl_git_pass(git_reference_peel((git_object **) &tree, ref, GIT_OBJ_TREE));
+ git_reference_free(ref);
+
+ nentries_master = entrycount(repo, "refs/heads/master");
+
+ msg = "message 1";
+ cl_git_pass(git_reference_symbolic_create(&ref, repo, "refs/heads/master", "refs/heads/foo", 1, sig, msg));
+ git_reference_free(ref);
+
+ cl_assert_equal_i(0, entrycount(repo, "refs/heads/foo"));
+ cl_assert_equal_i(nentries, entrycount(repo, GIT_HEAD_FILE));
+ cl_assert_equal_i(nentries_master, entrycount(repo, "refs/heads/master"));
+
+ msg = "message 2";
+ cl_git_pass(git_commit_create(&id, repo, "HEAD", sig, sig, NULL, msg, tree, 0, NULL));
+ git_tree_free(tree);
+
+ cl_assert_equal_i(1, entrycount(repo, "refs/heads/foo"));
+ cl_assert_equal_i(nentries +1, entrycount(repo, GIT_HEAD_FILE));
+ cl_assert_equal_i(nentries_master, entrycount(repo, "refs/heads/master"));
+
+ git_signature_free(sig);
+
+}