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
path: root/tests
diff options
context:
space:
mode:
authorschu <schu-github@schulog.org>2011-05-29 18:46:24 +0400
committerschu <schu-github@schulog.org>2011-07-06 14:25:27 +0400
commita6e0f315f5f82babd669d93705059c24a6772084 (patch)
tree2e146231d8859d2007ea94533fd76d776124186a /tests
parente1bf24c86221fb412df52340ef2faa65c816c7bf (diff)
Add test case checking renaming of a branch to a new name prefixed with
the old name succeeds, e.g. refs/heads/foo -> refs/heads/foo/bar Reported-by: nulltoken <emeric.fermas@gmail.com> Signed-off-by: schu <schu-github@schulog.org>
Diffstat (limited to 'tests')
-rw-r--r--tests/t10-refs.c32
1 files changed, 32 insertions, 0 deletions
diff --git a/tests/t10-refs.c b/tests/t10-refs.c
index fb252f427..0d1bba3ff 100644
--- a/tests/t10-refs.c
+++ b/tests/t10-refs.c
@@ -686,6 +686,37 @@ BEGIN_TEST(rename6, "can not overwrite name of existing reference")
close_temp_repo(repo);
END_TEST
+static const char *ref_two_name_new = "refs/heads/two/two";
+
+BEGIN_TEST(rename7, "can be renamed to a new name prefixed with the old name")
+ git_reference *ref, *ref_two, *looked_up_ref;
+ git_repository *repo;
+ git_oid id;
+
+ must_pass(open_temp_repo(&repo, REPOSITORY_FOLDER));
+
+ must_pass(git_reference_lookup(&ref, repo, ref_master_name));
+ must_be_true(ref->type & GIT_REF_OID);
+
+ git_oid_cpy(&id, git_reference_oid(ref));
+
+ /* Create loose references */
+ must_pass(git_reference_create_oid(&ref_two, repo, ref_two_name, &id));
+
+ /* An existing reference... */
+ must_pass(git_reference_lookup(&looked_up_ref, repo, ref_two_name));
+
+ /* Can be rename to a new name starting with the old name. */
+ must_pass(git_reference_rename(looked_up_ref, ref_two_name_new));
+
+ /* Check we actually renamed it */
+ must_pass(git_reference_lookup(&looked_up_ref, repo, ref_two_name_new));
+ must_be_true(!strcmp(looked_up_ref->name, ref_two_name_new));
+ must_fail(git_reference_lookup(&looked_up_ref, repo, ref_two_name));
+
+ close_temp_repo(repo);
+END_TEST
+
BEGIN_TEST(delete0, "deleting a ref which is both packed and loose should remove both tracks in the filesystem")
git_reference *looked_up_ref, *another_looked_up_ref;
git_repository *repo;
@@ -968,6 +999,7 @@ BEGIN_SUITE(refs)
ADD_TEST(rename4);
ADD_TEST(rename5);
ADD_TEST(rename6);
+ ADD_TEST(rename7);
ADD_TEST(delete0);
ADD_TEST(list0);