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>2015-01-07 15:23:05 +0300
committerCarlos Martín Nieto <cmn@dwim.me>2015-03-03 16:40:50 +0300
commit659cf2029f322ea876d663d85783b48945227e8f (patch)
tree435e9185c38d96656e21db83fc736b5294499b10 /tests/repo
parent99b68a2aecfaa24f252f265d61b230b8e2576dd2 (diff)
Remove the signature from ref-modifying functions
The signature for the reflog is not something which changes dynamically. Almost all uses will be NULL, since we want for the repository's default identity to be used, making it noise. In order to allow for changing the identity, we instead provide git_repository_set_ident() and git_repository_ident() which allow a user to override the choice of signature.
Diffstat (limited to 'tests/repo')
-rw-r--r--tests/repo/head.c66
-rw-r--r--tests/repo/headtree.c2
-rw-r--r--tests/repo/repo_helpers.c2
-rw-r--r--tests/repo/state.c2
4 files changed, 35 insertions, 37 deletions
diff --git a/tests/repo/head.c b/tests/repo/head.c
index d678e150e..b838ff565 100644
--- a/tests/repo/head.c
+++ b/tests/repo/head.c
@@ -3,11 +3,13 @@
#include "repo_helpers.h"
#include "posix.h"
+static const char *g_email = "foo@example.com";
static git_repository *repo;
void test_repo_head__initialize(void)
{
repo = cl_git_sandbox_init("testrepo.git");
+ cl_git_pass(git_repository_set_ident(repo, "Foo Bar", g_email));
}
void test_repo_head__cleanup(void)
@@ -33,24 +35,20 @@ static void check_last_reflog_entry(const char *email, const char *message)
void test_repo_head__head_detached(void)
{
git_reference *ref;
- git_signature *sig;
-
- cl_git_pass(git_signature_now(&sig, "Foo Bar", "foo@example.com"));
cl_assert_equal_i(false, git_repository_head_detached(repo));
- cl_git_pass(git_repository_detach_head(repo, sig, "CABLE DETACHED"));
- check_last_reflog_entry(sig->email, "CABLE DETACHED");
+ cl_git_pass(git_repository_detach_head(repo, "CABLE DETACHED"));
+ check_last_reflog_entry(g_email, "CABLE DETACHED");
cl_assert_equal_i(true, git_repository_head_detached(repo));
/* take the repo back to it's original state */
cl_git_pass(git_reference_symbolic_create(&ref, repo, "HEAD", "refs/heads/master",
- true, sig, "REATTACH"));
+ true, "REATTACH"));
git_reference_free(ref);
- check_last_reflog_entry(sig->email, "REATTACH");
+ check_last_reflog_entry(g_email, "REATTACH");
cl_assert_equal_i(false, git_repository_head_detached(repo));
- git_signature_free(sig);
}
void test_repo_head__unborn_head(void)
@@ -65,7 +63,7 @@ void test_repo_head__unborn_head(void)
/* take the repo back to it's original state */
- cl_git_pass(git_reference_symbolic_create(&ref, repo, "HEAD", "refs/heads/master", 1, NULL, NULL));
+ cl_git_pass(git_reference_symbolic_create(&ref, repo, "HEAD", "refs/heads/master", 1, NULL));
cl_assert(git_repository_head_unborn(repo) == 0);
git_reference_free(ref);
@@ -75,7 +73,7 @@ void test_repo_head__set_head_Attaches_HEAD_to_un_unborn_branch_when_the_branch_
{
git_reference *head;
- cl_git_pass(git_repository_set_head(repo, "refs/heads/doesnt/exist/yet", NULL, NULL));
+ cl_git_pass(git_repository_set_head(repo, "refs/heads/doesnt/exist/yet", NULL));
cl_assert_equal_i(false, git_repository_head_detached(repo));
@@ -84,19 +82,19 @@ void test_repo_head__set_head_Attaches_HEAD_to_un_unborn_branch_when_the_branch_
void test_repo_head__set_head_Returns_ENOTFOUND_when_the_reference_doesnt_exist(void)
{
- cl_assert_equal_i(GIT_ENOTFOUND, git_repository_set_head(repo, "refs/tags/doesnt/exist/yet", NULL, NULL));
+ cl_assert_equal_i(GIT_ENOTFOUND, git_repository_set_head(repo, "refs/tags/doesnt/exist/yet", NULL));
}
void test_repo_head__set_head_Fails_when_the_reference_points_to_a_non_commitish(void)
{
- cl_git_fail(git_repository_set_head(repo, "refs/tags/point_to_blob", NULL, NULL));
+ cl_git_fail(git_repository_set_head(repo, "refs/tags/point_to_blob", NULL));
}
void test_repo_head__set_head_Attaches_HEAD_when_the_reference_points_to_a_branch(void)
{
git_reference *head;
- cl_git_pass(git_repository_set_head(repo, "refs/heads/br2", NULL, NULL));
+ cl_git_pass(git_repository_set_head(repo, "refs/heads/br2", NULL));
cl_assert_equal_i(false, git_repository_head_detached(repo));
@@ -123,7 +121,7 @@ static void assert_head_is_correctly_detached(void)
void test_repo_head__set_head_Detaches_HEAD_when_the_reference_doesnt_point_to_a_branch(void)
{
- cl_git_pass(git_repository_set_head(repo, "refs/tags/test", NULL, NULL));
+ cl_git_pass(git_repository_set_head(repo, "refs/tags/test", NULL));
cl_assert_equal_i(true, git_repository_head_detached(repo));
@@ -136,7 +134,7 @@ void test_repo_head__set_head_detached_Return_ENOTFOUND_when_the_object_doesnt_e
cl_git_pass(git_oid_fromstr(&oid, "deadbeefdeadbeefdeadbeefdeadbeefdeadbeef"));
- cl_assert_equal_i(GIT_ENOTFOUND, git_repository_set_head_detached(repo, &oid, NULL, NULL));
+ cl_assert_equal_i(GIT_ENOTFOUND, git_repository_set_head_detached(repo, &oid, NULL));
}
void test_repo_head__set_head_detached_Fails_when_the_object_isnt_a_commitish(void)
@@ -145,7 +143,7 @@ void test_repo_head__set_head_detached_Fails_when_the_object_isnt_a_commitish(vo
cl_git_pass(git_revparse_single(&blob, repo, "point_to_blob"));
- cl_git_fail(git_repository_set_head_detached(repo, git_object_id(blob), NULL, NULL));
+ cl_git_fail(git_repository_set_head_detached(repo, git_object_id(blob), NULL));
git_object_free(blob);
}
@@ -157,7 +155,7 @@ void test_repo_head__set_head_detached_Detaches_HEAD_and_make_it_point_to_the_pe
cl_git_pass(git_revparse_single(&tag, repo, "tags/test"));
cl_assert_equal_i(GIT_OBJ_TAG, git_object_type(tag));
- cl_git_pass(git_repository_set_head_detached(repo, git_object_id(tag), NULL, NULL));
+ cl_git_pass(git_repository_set_head_detached(repo, git_object_id(tag), NULL));
assert_head_is_correctly_detached();
@@ -168,7 +166,7 @@ void test_repo_head__detach_head_Detaches_HEAD_and_make_it_point_to_the_peeled_c
{
cl_assert_equal_i(false, git_repository_head_detached(repo));
- cl_git_pass(git_repository_detach_head(repo, NULL, NULL));
+ cl_git_pass(git_repository_detach_head(repo, NULL));
assert_head_is_correctly_detached();
}
@@ -177,9 +175,9 @@ void test_repo_head__detach_head_Fails_if_HEAD_and_point_to_a_non_commitish(void
{
git_reference *head;
- cl_git_pass(git_reference_symbolic_create(&head, repo, GIT_HEAD_FILE, "refs/tags/point_to_blob", 1, NULL, NULL));
+ cl_git_pass(git_reference_symbolic_create(&head, repo, GIT_HEAD_FILE, "refs/tags/point_to_blob", 1, NULL));
- cl_git_fail(git_repository_detach_head(repo, NULL, NULL));
+ cl_git_fail(git_repository_detach_head(repo, NULL));
git_reference_free(head);
}
@@ -188,7 +186,7 @@ void test_repo_head__detaching_an_unborn_branch_returns_GIT_EUNBORNBRANCH(void)
{
make_head_unborn(repo, NON_EXISTING_HEAD);
- cl_assert_equal_i(GIT_EUNBORNBRANCH, git_repository_detach_head(repo, NULL, NULL));
+ cl_assert_equal_i(GIT_EUNBORNBRANCH, git_repository_detach_head(repo, NULL));
}
void test_repo_head__retrieving_an_unborn_branch_returns_GIT_EUNBORNBRANCH(void)
@@ -256,11 +254,11 @@ void test_repo_head__setting_head_updates_reflog(void)
cl_git_pass(git_signature_now(&sig, "me", "foo@example.com"));
- cl_git_pass(git_repository_set_head(repo, "refs/heads/haacked", sig, "message1"));
- cl_git_pass(git_repository_set_head(repo, "refs/heads/unborn", sig, "message2"));
+ cl_git_pass(git_repository_set_head(repo, "refs/heads/haacked", "message1"));
+ cl_git_pass(git_repository_set_head(repo, "refs/heads/unborn", "message2"));
cl_git_pass(git_revparse_single(&tag, repo, "tags/test"));
- cl_git_pass(git_repository_set_head_detached(repo, git_object_id(tag), sig, "message3"));
- cl_git_pass(git_repository_set_head(repo, "refs/heads/haacked", sig, "message4"));
+ cl_git_pass(git_repository_set_head_detached(repo, git_object_id(tag),"message3"));
+ cl_git_pass(git_repository_set_head(repo, "refs/heads/haacked", "message4"));
test_reflog(repo, 2, NULL, "refs/heads/haacked", "foo@example.com", "message1");
test_reflog(repo, 1, NULL, "tags/test^{commit}", "foo@example.com", "message3");
@@ -301,12 +299,12 @@ void test_repo_head__detaching_writes_reflog(void)
msg = "message1";
git_oid_fromstr(&id, "e90810b8df3e80c413d903f631643c716887138d");
- cl_git_pass(git_repository_set_head_detached(repo, &id, sig, msg));
+ cl_git_pass(git_repository_set_head_detached(repo, &id, msg));
assert_head_reflog(repo, 0, "a65fedf39aefe402d3bb6e24df4d4f5fe4547750",
"e90810b8df3e80c413d903f631643c716887138d", msg);
msg = "message2";
- cl_git_pass(git_repository_set_head(repo, "refs/heads/haacked", sig, msg));
+ cl_git_pass(git_repository_set_head(repo, "refs/heads/haacked", msg));
assert_head_reflog(repo, 0, "e90810b8df3e80c413d903f631643c716887138d",
"258f0e2a959a364e40ed6603d5d44fbb24765b10", msg);
@@ -324,18 +322,18 @@ void test_repo_head__orphan_branch_does_not_count(void)
/* Have something known */
msg = "message1";
git_oid_fromstr(&id, "e90810b8df3e80c413d903f631643c716887138d");
- cl_git_pass(git_repository_set_head_detached(repo, &id, sig, msg));
+ cl_git_pass(git_repository_set_head_detached(repo, &id, msg));
assert_head_reflog(repo, 0, "a65fedf39aefe402d3bb6e24df4d4f5fe4547750",
"e90810b8df3e80c413d903f631643c716887138d", msg);
/* Switching to an orphan branch does not write tot he reflog */
- cl_git_pass(git_repository_set_head(repo, "refs/heads/orphan", sig, "ignored message"));
+ cl_git_pass(git_repository_set_head(repo, "refs/heads/orphan", "ignored message"));
assert_head_reflog(repo, 0, "a65fedf39aefe402d3bb6e24df4d4f5fe4547750",
"e90810b8df3e80c413d903f631643c716887138d", msg);
/* And coming back, we set the source to zero */
msg = "message2";
- cl_git_pass(git_repository_set_head(repo, "refs/heads/haacked", sig, msg));
+ cl_git_pass(git_repository_set_head(repo, "refs/heads/haacked", msg));
assert_head_reflog(repo, 0, "0000000000000000000000000000000000000000",
"258f0e2a959a364e40ed6603d5d44fbb24765b10", msg);
@@ -356,8 +354,8 @@ void test_repo_head__set_to_current_target(void)
cl_git_pass(git_signature_now(&sig, "me", "foo@example.com"));
msg = "message 1";
- cl_git_pass(git_repository_set_head(repo, "refs/heads/haacked", sig, msg));
- cl_git_pass(git_repository_set_head(repo, "refs/heads/haacked", sig, msg));
+ cl_git_pass(git_repository_set_head(repo, "refs/heads/haacked", msg));
+ cl_git_pass(git_repository_set_head(repo, "refs/heads/haacked", msg));
cl_git_pass(git_reflog_read(&log, repo, GIT_HEAD_FILE));
nentries_after = git_reflog_entrycount(log);
@@ -390,7 +388,7 @@ void test_repo_head__branch_birth(void)
git_reference_free(ref);
msg = "message 1";
- cl_git_pass(git_repository_set_head(repo, "refs/heads/orphan", sig, msg));
+ cl_git_pass(git_repository_set_head(repo, "refs/heads/orphan", msg));
cl_git_pass(git_reflog_read(&log, repo, GIT_HEAD_FILE));
nentries_after = git_reflog_entrycount(log);
@@ -449,7 +447,7 @@ void test_repo_head__symref_chain(void)
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));
+ cl_git_pass(git_reference_symbolic_create(&ref, repo, "refs/heads/master", "refs/heads/foo", 1, msg));
git_reference_free(ref);
cl_assert_equal_i(0, entrycount(repo, "refs/heads/foo"));
diff --git a/tests/repo/headtree.c b/tests/repo/headtree.c
index 79d88c0a7..e8721b7a3 100644
--- a/tests/repo/headtree.c
+++ b/tests/repo/headtree.c
@@ -20,7 +20,7 @@ void test_repo_headtree__cleanup(void)
void test_repo_headtree__can_retrieve_the_root_tree_from_a_detached_head(void)
{
- cl_git_pass(git_repository_detach_head(repo, NULL, NULL));
+ cl_git_pass(git_repository_detach_head(repo, NULL));
cl_git_pass(git_repository_head_tree(&tree, repo));
diff --git a/tests/repo/repo_helpers.c b/tests/repo/repo_helpers.c
index 7c5db4a81..61f696865 100644
--- a/tests/repo/repo_helpers.c
+++ b/tests/repo/repo_helpers.c
@@ -7,7 +7,7 @@ void make_head_unborn(git_repository* repo, const char *target)
{
git_reference *head;
- cl_git_pass(git_reference_symbolic_create(&head, repo, GIT_HEAD_FILE, target, 1, NULL, NULL));
+ cl_git_pass(git_reference_symbolic_create(&head, repo, GIT_HEAD_FILE, target, 1, NULL));
git_reference_free(head);
}
diff --git a/tests/repo/state.c b/tests/repo/state.c
index 13407bffc..8e03f5bc3 100644
--- a/tests/repo/state.c
+++ b/tests/repo/state.c
@@ -37,7 +37,7 @@ void test_repo_state__none_with_HEAD_attached(void)
void test_repo_state__none_with_HEAD_detached(void)
{
- cl_git_pass(git_repository_detach_head(_repo, NULL, NULL));
+ cl_git_pass(git_repository_detach_head(_repo, NULL));
assert_repo_state(GIT_REPOSITORY_STATE_NONE);
}