mirror of
https://git.proxmox.com/git/libgit2
synced 2025-05-05 22:55:47 +00:00
remote: Make git_remote_list() detect pushurl
This commit is contained in:
parent
191adce875
commit
aec87f712f
@ -1109,10 +1109,10 @@ int git_remote_list(git_strarray *remotes_list, git_repository *repo)
|
|||||||
if (git_repository_config__weakptr(&cfg, repo) < 0)
|
if (git_repository_config__weakptr(&cfg, repo) < 0)
|
||||||
return -1;
|
return -1;
|
||||||
|
|
||||||
if (git_vector_init(&list, 4, NULL) < 0)
|
if (git_vector_init(&list, 4, git__strcmp_cb) < 0)
|
||||||
return -1;
|
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");
|
giterr_set(GITERR_OS, "Remote catch regex failed to compile");
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
@ -1137,6 +1137,8 @@ int git_remote_list(git_strarray *remotes_list, git_repository *repo)
|
|||||||
return error;
|
return error;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
git_vector_uniq(&list, git__free);
|
||||||
|
|
||||||
remotes_list->strings = (char **)list.contents;
|
remotes_list->strings = (char **)list.contents;
|
||||||
remotes_list->count = list.length;
|
remotes_list->count = list.length;
|
||||||
|
|
||||||
|
@ -243,13 +243,19 @@ void test_network_remote_remotes__list(void)
|
|||||||
git_config *cfg;
|
git_config *cfg;
|
||||||
|
|
||||||
cl_git_pass(git_remote_list(&list, _repo));
|
cl_git_pass(git_remote_list(&list, _repo));
|
||||||
cl_assert(list.count == 4);
|
cl_assert(list.count == 5);
|
||||||
git_strarray_free(&list);
|
git_strarray_free(&list);
|
||||||
|
|
||||||
cl_git_pass(git_repository_config(&cfg, _repo));
|
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"));
|
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_git_pass(git_remote_list(&list, _repo));
|
||||||
cl_assert(list.count == 5);
|
cl_assert(list.count == 7);
|
||||||
git_strarray_free(&list);
|
git_strarray_free(&list);
|
||||||
|
|
||||||
git_config_free(cfg);
|
git_config_free(cfg);
|
||||||
|
Loading…
Reference in New Issue
Block a user