Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit eb6aa79

Browse files
committed
remote: failing test for renaming with a symref
1 parent 72bca13 commit eb6aa79

File tree

1 file changed

+48
-0
lines changed

1 file changed

+48
-0
lines changed

tests/network/remote/rename.c

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -218,3 +218,51 @@ void test_network_remote_rename__overwrite_ref_in_target(void)
218218
cl_git_fail_with(GIT_ITEROVER, git_branch_next(&ref, &btype, iter));
219219
git_branch_iterator_free(iter);
220220
}
221+
222+
void test_network_remote_rename__symref_head(void)
223+
{
224+
int error;
225+
git_remote *remote;
226+
git_reference *ref;
227+
git_branch_t btype;
228+
git_branch_iterator *iter;
229+
git_strarray problems = {0};
230+
char idstr[GIT_OID_HEXSZ + 1] = {0};
231+
git_vector refs;
232+
233+
cl_git_pass(git_reference_symbolic_create(&ref, _repo, "refs/remotes/test/HEAD", "refs/remotes/test/master", 0, NULL, NULL));
234+
git_reference_free(ref);
235+
236+
cl_git_pass(git_remote_load(&remote, _repo, "test"));
237+
cl_git_pass(git_remote_rename(&problems, remote, "renamed"));
238+
git_remote_free(remote);
239+
cl_assert_equal_i(0, problems.count);
240+
git_strarray_free(&problems);
241+
242+
cl_git_pass(git_vector_init(&refs, 2, (git_vector_cmp) git_reference_cmp));
243+
cl_git_pass(git_branch_iterator_new(&iter, _repo, GIT_BRANCH_REMOTE));
244+
245+
while ((error = git_branch_next(&ref, &btype, iter)) == 0) {
246+
cl_git_pass(git_vector_insert(&refs, ref));
247+
}
248+
cl_assert_equal_i(GIT_ITEROVER, error);
249+
git_vector_sort(&refs);
250+
251+
cl_assert_equal_i(2, refs.length);
252+
253+
ref = git_vector_get(&refs, 0);
254+
cl_assert_equal_s("refs/remotes/renamed/HEAD", git_reference_name(ref));
255+
cl_assert_equal_s("refs/remotes/renamed/master", git_reference_symbolic_target(ref));
256+
git_reference_free(ref);
257+
258+
ref = git_vector_get(&refs, 1);
259+
cl_assert_equal_s("refs/remotes/renamed/master", git_reference_name(ref));
260+
git_oid_fmt(idstr, git_reference_target(ref));
261+
cl_assert_equal_s("be3563ae3f795b2b4353bcce3a527ad0a4f7f644", idstr);
262+
git_reference_free(ref);
263+
264+
git_vector_free(&refs);
265+
266+
cl_git_fail_with(GIT_ITEROVER, git_branch_next(&ref, &btype, iter));
267+
git_branch_iterator_free(iter);
268+
}

0 commit comments

Comments
 (0)