| 1802 | } |
| 1803 | |
| 1804 | static 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 | |
| 1844 | static int set_url(int argc, const char **argv, const char *prefix, |
| 1845 | struct repository *repo UNUSED) |
nothing calls this directly
no test coverage detected