summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authornulltoken <emeric.fermas@gmail.com>2013-08-27 19:14:18 +0200
committernulltoken <emeric.fermas@gmail.com>2013-08-27 20:14:10 +0200
commitaec87f712fd1e84038d5d14b83a97d78e2e1b1ad (patch)
treee8ce5ea9b339c2aa67010eb90c725240b3021e87
parent191adce8751e728111a3b1c3e9b2c02fe9f5d775 (diff)
downloadlibgit2-aec87f712fd1e84038d5d14b83a97d78e2e1b1ad.tar.gz
remote: Make git_remote_list() detect pushurl
-rw-r--r--src/remote.c6
-rw-r--r--tests-clar/network/remote/remotes.c10
2 files changed, 12 insertions, 4 deletions
diff --git a/src/remote.c b/src/remote.c
index 7276daa39..10c1b5b81 100644
--- a/src/remote.c
+++ b/src/remote.c
@@ -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;
diff --git a/tests-clar/network/remote/remotes.c b/tests-clar/network/remote/remotes.c
index 55b233eda..6e0eeeb05 100644
--- a/tests-clar/network/remote/remotes.c
+++ b/tests-clar/network/remote/remotes.c
@@ -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);