MCPcopy Create free account
hub / github.com/git/git / get_url

Function get_url

builtin/remote.c:1804–1842  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1802}
1803
1804static int get_url(int argc, const char **argv, const char *prefix,
1805 struct repository *repo UNUSED)
1806{
1807 int push_mode = 0, all_mode = 0;
1808 const char *remotename = NULL;
1809 struct remote *remote;
1810 struct strvec *url;
1811 struct option options[] = {
1812 OPT_BOOL('\0', "push", &push_mode,
1813 N_("query push URLs rather than fetch URLs")),
1814 OPT_BOOL('\0', "all", &all_mode,
1815 N_("return all URLs")),
1816 OPT_END()
1817 };
1818 argc = parse_options(argc, argv, prefix, options,
1819 builtin_remote_geturl_usage, 0);
1820
1821 if (argc != 1)
1822 usage_with_options(builtin_remote_geturl_usage, options);
1823
1824 remotename = argv[0];
1825
1826 remote = remote_get(remotename);
1827 if (!remote_is_configured(remote, 1)) {
1828 error(_("No such remote '%s'"), remotename);
1829 exit(2);
1830 }
1831
1832 url = push_mode ? push_url_of_remote(remote) : &remote->url;
1833
1834 if (all_mode) {
1835 for (size_t i = 0; i < url->nr; i++)
1836 printf_ln("%s", url->v[i]);
1837 } else {
1838 printf_ln("%s", url->v[0]);
1839 }
1840
1841 return 0;
1842}
1843
1844static int set_url(int argc, const char **argv, const char *prefix,
1845 struct repository *repo UNUSED)

Callers

nothing calls this directly

Calls 7

parse_optionsFunction · 0.85
usage_with_optionsFunction · 0.85
remote_getFunction · 0.85
remote_is_configuredFunction · 0.85
errorFunction · 0.85
push_url_of_remoteFunction · 0.85
printf_lnFunction · 0.85

Tested by

no test coverage detected