提交 9a23ba33 编写于 作者: F Finn Arne Gangstad 提交者: Junio C Hamano

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: NFinn Arne Gangstad <finnag@pvv.org>
Signed-off-by: NJunio C Hamano <gitster@pobox.com>
上级 bed5d421
......@@ -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;
......
......@@ -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);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册