summaryrefslogtreecommitdiff
path: root/builtin/remote.c
diff options
context:
space:
mode:
authorThomas Gummerer <t.gummerer@gmail.com>2016-02-16 09:47:50 (GMT)
committerJunio C Hamano <gitster@pobox.com>2016-02-16 21:33:12 (GMT)
commit674468b3642abfff7c61d5ff95fffc43b87f70b7 (patch)
treebf6ab75ebd17f9588b52673007ff1b15f19bf65d /builtin/remote.c
parentbc60f8a77c6e676225810f33117abcf9117b1c1e (diff)
downloadgit-674468b3642abfff7c61d5ff95fffc43b87f70b7.zip
git-674468b3642abfff7c61d5ff95fffc43b87f70b7.tar.gz
git-674468b3642abfff7c61d5ff95fffc43b87f70b7.tar.bz2
remote: simplify remote_is_configured()
The remote_is_configured() function allows checking whether a remote exists or not. The function however only works if remote_get() wasn't called before calling it. In addition, it only checks the configuration for remotes, but not remotes or branches files. Make use of the origin member of struct remote instead, which indicates where the remote comes from. It will be set to some value if the remote is configured in any file in the repository, but is initialized to 0 if the remote is only created in make_remote(). Signed-off-by: Thomas Gummerer <t.gummerer@gmail.com> Reviewed-by: Jeff King <peff@peff.net> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'builtin/remote.c')
-rw-r--r--builtin/remote.c12
1 files changed, 6 insertions, 6 deletions
diff --git a/builtin/remote.c b/builtin/remote.c
index 2b2ff9b..d966262 100644
--- a/builtin/remote.c
+++ b/builtin/remote.c
@@ -1441,9 +1441,9 @@ static int set_remote_branches(const char *remotename, const char **branches,
strbuf_addf(&key, "remote.%s.fetch", remotename);
- if (!remote_is_configured(remotename))
- die(_("No such remote '%s'"), remotename);
remote = remote_get(remotename);
+ if (!remote_is_configured(remote))
+ die(_("No such remote '%s'"), remotename);
if (!add_mode && remove_all_fetch_refspecs(remotename, key.buf)) {
strbuf_release(&key);
@@ -1498,9 +1498,9 @@ static int get_url(int argc, const char **argv)
remotename = argv[0];
- if (!remote_is_configured(remotename))
- die(_("No such remote '%s'"), remotename);
remote = remote_get(remotename);
+ if (!remote_is_configured(remote))
+ die(_("No such remote '%s'"), remotename);
url_nr = 0;
if (push_mode) {
@@ -1566,9 +1566,9 @@ static int set_url(int argc, const char **argv)
if (delete_mode)
oldurl = newurl;
- if (!remote_is_configured(remotename))
- die(_("No such remote '%s'"), remotename);
remote = remote_get(remotename);
+ if (!remote_is_configured(remote))
+ die(_("No such remote '%s'"), remotename);
if (push_mode) {
strbuf_addf(&name_buf, "remote.%s.pushurl", remotename);