diff options
| author | Carlos Martín Nieto <cmn@dwim.me> | 2015-01-07 14:47:02 +0000 |
|---|---|---|
| committer | Carlos Martín Nieto <cmn@dwim.me> | 2015-03-03 14:40:50 +0100 |
| commit | 6bfb990dc74c3749b356f82f7c9744b43fe90ea9 (patch) | |
| tree | 7b9acea4318400e209ce25ffed64df2e5b8ee654 /tests/refs | |
| parent | 23a17803b6e3a8bf21f740726ec0a038968da9a1 (diff) | |
| download | libgit2-6bfb990dc74c3749b356f82f7c9744b43fe90ea9.tar.gz | |
branch: don't accept a reflog message override
This namespace is about behaving like git's branch command, so let's do
exactly that instead of taking a reflog message.
This override is still available via the reference namespace.
Diffstat (limited to 'tests/refs')
| -rw-r--r-- | tests/refs/branches/create.c | 49 | ||||
| -rw-r--r-- | tests/refs/branches/move.c | 53 | ||||
| -rw-r--r-- | tests/refs/branches/upstream.c | 2 | ||||
| -rw-r--r-- | tests/refs/revparse.c | 6 |
4 files changed, 35 insertions, 75 deletions
diff --git a/tests/refs/branches/create.c b/tests/refs/branches/create.c index 4d52c7720..dc805789f 100644 --- a/tests/refs/branches/create.c +++ b/tests/refs/branches/create.c @@ -45,7 +45,7 @@ void test_refs_branches_create__can_create_a_local_branch(void) { retrieve_known_commit(&target, repo); - cl_git_pass(git_branch_create(&branch, repo, NEW_BRANCH_NAME, target, 0, NULL)); + cl_git_pass(git_branch_create(&branch, repo, NEW_BRANCH_NAME, target, 0)); cl_git_pass(git_oid_cmp(git_reference_target(branch), git_commit_id(target))); } @@ -53,14 +53,14 @@ void test_refs_branches_create__can_not_create_a_branch_if_its_name_collide_with { retrieve_known_commit(&target, repo); - cl_assert_equal_i(GIT_EEXISTS, git_branch_create(&branch, repo, "br2", target, 0, NULL)); + cl_assert_equal_i(GIT_EEXISTS, git_branch_create(&branch, repo, "br2", target, 0)); } void test_refs_branches_create__can_force_create_over_an_existing_branch(void) { retrieve_known_commit(&target, repo); - cl_git_pass(git_branch_create(&branch, repo, "br2", target, 1, NULL)); + cl_git_pass(git_branch_create(&branch, repo, "br2", target, 1)); cl_git_pass(git_oid_cmp(git_reference_target(branch), git_commit_id(target))); cl_assert_equal_s("refs/heads/br2", git_reference_name(branch)); } @@ -76,7 +76,7 @@ void test_refs_branches_create__cannot_force_create_over_current_branch(void) cl_assert_equal_i(true, git_branch_is_head(branch2)); oid = git_reference_target(branch2); - cl_git_fail_with(-1, git_branch_create(&branch, repo, "master", target, 1, NULL)); + cl_git_fail_with(-1, git_branch_create(&branch, repo, "master", target, 1)); branch = NULL; cl_git_pass(git_branch_lookup(&branch, repo, "master", GIT_BRANCH_LOCAL)); cl_assert_equal_s("refs/heads/master", git_reference_name(branch)); @@ -89,32 +89,13 @@ void test_refs_branches_create__creating_a_branch_with_an_invalid_name_returns_E retrieve_known_commit(&target, repo); cl_assert_equal_i(GIT_EINVALIDSPEC, - git_branch_create(&branch, repo, "inv@{id", target, 0, NULL)); -} - -void test_refs_branches_create__creation_creates_new_reflog(void) -{ - git_reflog *log; - const git_reflog_entry *entry; - git_signature *sig; - - cl_git_pass(git_signature_now(&sig, "me", "foo@example.com")); - - retrieve_known_commit(&target, repo); - cl_git_pass(git_branch_create(&branch, repo, NEW_BRANCH_NAME, target, false, "create!")); - cl_git_pass(git_reflog_read(&log, repo, "refs/heads/" NEW_BRANCH_NAME)); - - cl_assert_equal_i(1, git_reflog_entrycount(log)); - entry = git_reflog_entry_byindex(log, 0); - cl_assert_equal_s("create!", git_reflog_entry_message(entry)); - - git_reflog_free(log); - git_signature_free(sig); + git_branch_create(&branch, repo, "inv@{id", target, 0)); } void test_refs_branches_create__default_reflog_message(void) { git_reflog *log; + git_buf buf = GIT_BUF_INIT; const git_reflog_entry *entry; git_signature *sig; git_config *cfg; @@ -127,13 +108,15 @@ void test_refs_branches_create__default_reflog_message(void) cl_git_pass(git_signature_default(&sig, repo)); retrieve_known_commit(&target, repo); - cl_git_pass(git_branch_create(&branch, repo, NEW_BRANCH_NAME, target, false, NULL)); + cl_git_pass(git_branch_create(&branch, repo, NEW_BRANCH_NAME, target, false)); cl_git_pass(git_reflog_read(&log, repo, "refs/heads/" NEW_BRANCH_NAME)); entry = git_reflog_entry_byindex(log, 0); - cl_assert_equal_s("Branch: created", git_reflog_entry_message(entry)); + cl_git_pass(git_buf_printf(&buf, "Branch: created from %s", git_oid_tostr_s(git_commit_id(target)))); + cl_assert_equal_s(git_buf_cstr(&buf), git_reflog_entry_message(entry)); cl_assert_equal_s(sig->email, git_reflog_entry_committer(entry)->email); + git_buf_free(&buf); git_reflog_free(log); git_signature_free(sig); } @@ -180,7 +163,7 @@ void test_refs_branches_create__can_create_branch_with_unicode(void) for (i = 0; i < ARRAY_SIZE(names); ++i) { const char *name; cl_git_pass(git_branch_create( - &branch, repo, names[i], target, 0, NULL)); + &branch, repo, names[i], target, 0)); cl_git_pass(git_oid_cmp( git_reference_target(branch), git_commit_id(target))); @@ -238,7 +221,7 @@ void test_refs_branches_create__name_vs_namespace(void) retrieve_known_commit(&target, repo); for (p=item; p->first; p++) { - cl_git_pass(git_branch_create(&branch, repo, p->first, target, 0, NULL)); + cl_git_pass(git_branch_create(&branch, repo, p->first, target, 0)); cl_git_pass(git_oid_cmp(git_reference_target(branch), git_commit_id(target))); cl_git_pass(git_branch_name(&name, branch)); cl_assert_equal_s(name, p->first); @@ -247,7 +230,7 @@ void test_refs_branches_create__name_vs_namespace(void) git_reference_free(branch); branch = NULL; - cl_git_pass(git_branch_create(&branch, repo, p->second, target, 0, NULL)); + cl_git_pass(git_branch_create(&branch, repo, p->second, target, 0)); git_reference_free(branch); branch = NULL; } @@ -276,7 +259,7 @@ void test_refs_branches_create__name_vs_namespace_fail(void) retrieve_known_commit(&target, repo); for (p=item; p->first; p++) { - cl_git_pass(git_branch_create(&branch, repo, p->first, target, 0, NULL)); + cl_git_pass(git_branch_create(&branch, repo, p->first, target, 0)); cl_git_pass(git_oid_cmp(git_reference_target(branch), git_commit_id(target))); cl_git_pass(git_branch_name(&name, branch)); cl_assert_equal_s(name, p->first); @@ -285,7 +268,7 @@ void test_refs_branches_create__name_vs_namespace_fail(void) git_reference_free(branch); branch = NULL; - cl_git_pass(git_branch_create(&branch, repo, p->first_alternate, target, 0, NULL)); + cl_git_pass(git_branch_create(&branch, repo, p->first_alternate, target, 0)); cl_git_pass(git_oid_cmp(git_reference_target(branch), git_commit_id(target))); cl_git_pass(git_branch_name(&name, branch)); cl_assert_equal_s(name, p->first_alternate); @@ -294,7 +277,7 @@ void test_refs_branches_create__name_vs_namespace_fail(void) git_reference_free(branch); branch = NULL; - cl_git_fail(git_branch_create(&branch, repo, p->second, target, 0, NULL)); + cl_git_fail(git_branch_create(&branch, repo, p->second, target, 0)); git_reference_free(branch); branch = NULL; } diff --git a/tests/refs/branches/move.c b/tests/refs/branches/move.c index b78daa2e4..c1d1ae396 100644 --- a/tests/refs/branches/move.c +++ b/tests/refs/branches/move.c @@ -22,7 +22,7 @@ void test_refs_branches_move__can_move_a_local_branch(void) cl_git_pass(git_reference_lookup(&original_ref, repo, "refs/heads/br2")); - cl_git_pass(git_branch_move(&new_ref, original_ref, NEW_BRANCH_NAME, 0, NULL)); + cl_git_pass(git_branch_move(&new_ref, original_ref, NEW_BRANCH_NAME, 0)); cl_assert_equal_s(GIT_REFS_HEADS_DIR NEW_BRANCH_NAME, git_reference_name(new_ref)); git_reference_free(original_ref); @@ -36,11 +36,11 @@ void test_refs_branches_move__can_move_a_local_branch_to_a_different_namespace(v cl_git_pass(git_reference_lookup(&original_ref, repo, "refs/heads/br2")); /* Downward */ - cl_git_pass(git_branch_move(&new_ref, original_ref, "somewhere/" NEW_BRANCH_NAME, 0, NULL)); + cl_git_pass(git_branch_move(&new_ref, original_ref, "somewhere/" NEW_BRANCH_NAME, 0)); git_reference_free(original_ref); /* Upward */ - cl_git_pass(git_branch_move(&newer_ref, new_ref, "br2", 0, NULL)); + cl_git_pass(git_branch_move(&newer_ref, new_ref, "br2", 0)); git_reference_free(new_ref); git_reference_free(newer_ref); @@ -53,11 +53,11 @@ void test_refs_branches_move__can_move_a_local_branch_to_a_partially_colliding_n cl_git_pass(git_reference_lookup(&original_ref, repo, "refs/heads/br2")); /* Downward */ - cl_git_pass(git_branch_move(&new_ref, original_ref, "br2/" NEW_BRANCH_NAME, 0, NULL)); + cl_git_pass(git_branch_move(&new_ref, original_ref, "br2/" NEW_BRANCH_NAME, 0)); git_reference_free(original_ref); /* Upward */ - cl_git_pass(git_branch_move(&newer_ref, new_ref, "br2", 0, NULL)); + cl_git_pass(git_branch_move(&newer_ref, new_ref, "br2", 0)); git_reference_free(new_ref); git_reference_free(newer_ref); @@ -81,7 +81,7 @@ void test_refs_branches_move__can_not_move_a_branch_if_its_destination_name_coll cl_git_pass(git_reference_lookup(&original_ref, repo, "refs/heads/br2")); cl_assert_equal_i(GIT_EEXISTS, - git_branch_move(&new_ref, original_ref, "master", 0, NULL)); + git_branch_move(&new_ref, original_ref, "master", 0)); cl_assert(giterr_last()->message != NULL); cl_git_pass(git_config_get_entry(&ce, config, "branch.master.remote")); @@ -91,7 +91,7 @@ void test_refs_branches_move__can_not_move_a_branch_if_its_destination_name_coll cl_assert_equal_i(GIT_EEXISTS, - git_branch_move(&new_ref, original_ref, "cannot-fetch", 0, NULL)); + git_branch_move(&new_ref, original_ref, "cannot-fetch", 0)); cl_assert(giterr_last()->message != NULL); cl_git_pass(git_config_get_entry(&ce, config, "branch.master.remote")); @@ -103,7 +103,7 @@ void test_refs_branches_move__can_not_move_a_branch_if_its_destination_name_coll cl_git_pass(git_reference_lookup(&original_ref, repo, "refs/heads/track-local")); cl_assert_equal_i(GIT_EEXISTS, - git_branch_move(&new_ref, original_ref, "master", 0, NULL)); + git_branch_move(&new_ref, original_ref, "master", 0)); cl_assert(giterr_last()->message != NULL); cl_git_pass(git_config_get_entry(&ce, config, "branch.master.remote")); @@ -122,7 +122,7 @@ void test_refs_branches_move__moving_a_branch_with_an_invalid_name_returns_EINVA cl_git_pass(git_reference_lookup(&original_ref, repo, "refs/heads/br2")); - cl_assert_equal_i(GIT_EINVALIDSPEC, git_branch_move(&new_ref, original_ref, "Inv@{id", 0, NULL)); + cl_assert_equal_i(GIT_EINVALIDSPEC, git_branch_move(&new_ref, original_ref, "Inv@{id", 0)); git_reference_free(original_ref); } @@ -132,7 +132,7 @@ void test_refs_branches_move__can_not_move_a_non_branch(void) git_reference *tag, *new_ref; cl_git_pass(git_reference_lookup(&tag, repo, "refs/tags/e90810b")); - cl_git_fail(git_branch_move(&new_ref, tag, NEW_BRANCH_NAME, 0, NULL)); + cl_git_fail(git_branch_move(&new_ref, tag, NEW_BRANCH_NAME, 0)); git_reference_free(tag); } @@ -143,7 +143,7 @@ void test_refs_branches_move__can_force_move_over_an_existing_branch(void) cl_git_pass(git_reference_lookup(&original_ref, repo, "refs/heads/br2")); - cl_git_pass(git_branch_move(&new_ref, original_ref, "master", 1, NULL)); + cl_git_pass(git_branch_move(&new_ref, original_ref, "master", 1)); git_reference_free(original_ref); git_reference_free(new_ref); @@ -161,7 +161,7 @@ void test_refs_branches_move__moving_a_branch_moves_related_configuration_data(v assert_config_entry_existence(repo, "branch.moved.remote", false); assert_config_entry_existence(repo, "branch.moved.merge", false); - cl_git_pass(git_branch_move(&new_branch, branch, "moved", 0, NULL)); + cl_git_pass(git_branch_move(&new_branch, branch, "moved", 0)); git_reference_free(branch); assert_config_entry_existence(repo, "branch.track-local.remote", false); @@ -178,7 +178,7 @@ void test_refs_branches_move__moving_the_branch_pointed_at_by_HEAD_updates_HEAD( git_reference *new_branch; cl_git_pass(git_reference_lookup(&branch, repo, "refs/heads/master")); - cl_git_pass(git_branch_move(&new_branch, branch, "master2", 0, NULL)); + cl_git_pass(git_branch_move(&new_branch, branch, "master2", 0)); git_reference_free(branch); git_reference_free(new_branch); @@ -187,29 +187,6 @@ void test_refs_branches_move__moving_the_branch_pointed_at_by_HEAD_updates_HEAD( 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; - git_signature *sig; - - cl_git_pass(git_signature_now(&sig, "me", "foo@example.com")); - - cl_git_pass(git_reference_lookup(&branch, repo, "refs/heads/master")); - cl_git_pass(git_branch_move(&new_branch, branch, "master2", 0, "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); - git_signature_free(sig); -} - void test_refs_branches_move__default_reflog_message(void) { git_reference *branch; @@ -227,7 +204,7 @@ void test_refs_branches_move__default_reflog_message(void) cl_git_pass(git_signature_default(&sig, repo)); cl_git_pass(git_reference_lookup(&branch, repo, "refs/heads/master")); - cl_git_pass(git_branch_move(&new_branch, branch, "master2", 0, NULL)); + cl_git_pass(git_branch_move(&new_branch, branch, "master2", 0)); cl_git_pass(git_reflog_read(&log, repo, git_reference_name(new_branch))); entry = git_reflog_entry_byindex(log, 0); @@ -247,7 +224,7 @@ void test_refs_branches_move__can_move_with_unicode(void) const char *new_branch_name = "\x41\xCC\x8A\x73\x74\x72\x6F\xCC\x88\x6D"; cl_git_pass(git_reference_lookup(&original_ref, repo, "refs/heads/br2")); - cl_git_pass(git_branch_move(&new_ref, original_ref, new_branch_name, 0, NULL)); + cl_git_pass(git_branch_move(&new_ref, original_ref, new_branch_name, 0)); if (cl_repo_get_bool(repo, "core.precomposeunicode")) cl_assert_equal_s(GIT_REFS_HEADS_DIR "\xC3\x85\x73\x74\x72\xC3\xB6\x6D", git_reference_name(new_ref)); diff --git a/tests/refs/branches/upstream.c b/tests/refs/branches/upstream.c index f0aef5578..f44f563a3 100644 --- a/tests/refs/branches/upstream.c +++ b/tests/refs/branches/upstream.c @@ -91,7 +91,7 @@ static void assert_merge_and_or_remote_key_missing(git_repository *repository, c git_reference *branch; cl_assert_equal_i(GIT_OBJ_COMMIT, git_object_type((git_object*)target)); - cl_git_pass(git_branch_create(&branch, repository, entry_name, (git_commit*)target, 0, NULL)); + cl_git_pass(git_branch_create(&branch, repository, entry_name, (git_commit*)target, 0)); cl_assert_equal_i(GIT_ENOTFOUND, git_branch_upstream(&upstream, branch)); diff --git a/tests/refs/revparse.c b/tests/refs/revparse.c index ad468bbbe..3f89b5f77 100644 --- a/tests/refs/revparse.c +++ b/tests/refs/revparse.c @@ -634,7 +634,7 @@ void test_refs_revparse__try_to_retrieve_branch_before_described_tag(void) test_object_inrepo("blah-7-gc47800c", "c47800c7266a2be04c571c04d5a6614691ea99bd", repo); cl_git_pass(git_revparse_single(&target, repo, "HEAD~3")); - cl_git_pass(git_branch_create(&branch, repo, "blah-7-gc47800c", (git_commit *)target, 0, NULL)); + cl_git_pass(git_branch_create(&branch, repo, "blah-7-gc47800c", (git_commit *)target, 0)); git_oid_tostr(sha, GIT_OID_HEXSZ + 1, git_object_id(target)); @@ -672,7 +672,7 @@ void test_refs_revparse__try_to_retrieve_sha_before_branch(void) test_object_inrepo("a65fedf39aefe402d3bb6e24df4d4f5fe4547750", "a65fedf39aefe402d3bb6e24df4d4f5fe4547750", repo); cl_git_pass(git_revparse_single(&target, repo, "HEAD~3")); - cl_git_pass(git_branch_create(&branch, repo, "a65fedf39aefe402d3bb6e24df4d4f5fe4547750", (git_commit *)target, 0, NULL)); + cl_git_pass(git_branch_create(&branch, repo, "a65fedf39aefe402d3bb6e24df4d4f5fe4547750", (git_commit *)target, 0)); git_oid_tostr(sha, GIT_OID_HEXSZ + 1, git_object_id(target)); @@ -708,7 +708,7 @@ void test_refs_revparse__try_to_retrieve_branch_before_abbrev_sha(void) test_object_inrepo("c47800", "c47800c7266a2be04c571c04d5a6614691ea99bd", repo); cl_git_pass(git_revparse_single(&target, repo, "HEAD~3")); - cl_git_pass(git_branch_create(&branch, repo, "c47800", (git_commit *)target, 0, NULL)); + cl_git_pass(git_branch_create(&branch, repo, "c47800", (git_commit *)target, 0)); git_oid_tostr(sha, GIT_OID_HEXSZ + 1, git_object_id(target)); |
