Commit aec87f71 by nulltoken

remote: Make git_remote_list() detect pushurl

parent 191adce8
......@@ -1109,10 +1109,10 @@ int git_remote_list(git_strarray *remotes_list, git_repository *repo)
if (git_repository_config__weakptr(&cfg, repo) < 0)
return -1;
if (git_vector_init(&list, 4, NULL) < 0)
if (git_vector_init(&list, 4, git__strcmp_cb) < 0)
return -1;
if (regcomp(&preg, "^remote\\.(.*)\\.url$", REG_EXTENDED) < 0) {
if (regcomp(&preg, "^remote\\.(.*)\\.(push)?url$", REG_EXTENDED) < 0) {
giterr_set(GITERR_OS, "Remote catch regex failed to compile");
return -1;
}
......@@ -1137,6 +1137,8 @@ int git_remote_list(git_strarray *remotes_list, git_repository *repo)
return error;
}
git_vector_uniq(&list, git__free);
remotes_list->strings = (char **)list.contents;
remotes_list->count = list.length;
......
......@@ -243,13 +243,19 @@ void test_network_remote_remotes__list(void)
git_config *cfg;
cl_git_pass(git_remote_list(&list, _repo));
cl_assert(list.count == 4);
cl_assert(list.count == 5);
git_strarray_free(&list);
cl_git_pass(git_repository_config(&cfg, _repo));
/* Create a new remote */
cl_git_pass(git_config_set_string(cfg, "remote.specless.url", "http://example.com"));
/* Update a remote (previously without any url/pushurl entry) */
cl_git_pass(git_config_set_string(cfg, "remote.no-remote-url.pushurl", "http://example.com"));
cl_git_pass(git_remote_list(&list, _repo));
cl_assert(list.count == 5);
cl_assert(list.count == 7);
git_strarray_free(&list);
git_config_free(cfg);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment