From: Finn Arne Gangstad Date: Mon, 6 Apr 2009 13:41:01 +0000 (+0200) Subject: remote: New function remote_is_configured() X-Git-Tag: v1.6.3-rc0~5^2~2 X-Git-Url: https://git.tokkee.org/?a=commitdiff_plain;h=9a23ba3375e2afa8045a433a3debce99c373beb2;p=git.git remote: New function remote_is_configured() Previously, there was no easy way to check for the existence of a configured remote. remote_get for example would always create the remote "on demand". This new function returns 1 if the remote is configured, 0 otherwise. Signed-off-by: Finn Arne Gangstad Signed-off-by: Junio C Hamano --- diff --git a/remote.c b/remote.c index 2b037f11b..b36fd7097 100644 --- a/remote.c +++ b/remote.c @@ -667,6 +667,17 @@ struct remote *remote_get(const char *name) return ret; } +int remote_is_configured(const char *name) +{ + int i; + read_config(); + + for (i = 0; i < remotes_nr; i++) + if (!strcmp(name, remotes[i]->name)) + return 1; + return 0; +} + int for_each_remote(each_remote_fn fn, void *priv) { int i, result = 0; diff --git a/remote.h b/remote.h index de3d21b66..99706a89b 100644 --- a/remote.h +++ b/remote.h @@ -45,6 +45,7 @@ struct remote { }; struct remote *remote_get(const char *name); +int remote_is_configured(const char *name); typedef int each_remote_fn(struct remote *remote, void *priv); int for_each_remote(each_remote_fn fn, void *priv);