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 <finnag@pvv.org> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Finn Arne Gangstad committed
Apr 6, 2009 at 15:41 UTC
9a23ba3375e2afa8045a433a3debce99c373beb2
2 files changed
+12
remote.c
+11
@@ -667,6 +667,17 @@ struct remote *remote_get(const char *name)
667
return ret;
668
}
669
670
+int remote_is_configured(const char *name)
671
+{
672
+ int i;
673
+ read_config();
674
+
675
+ for (i = 0; i < remotes_nr; i++)
676
+ if (!strcmp(name, remotes[i]->name))
677
+ return 1;
678
+ return 0;
679
+}
680
+
681
int for_each_remote(each_remote_fn fn, void *priv)
682
{
683
int i, result = 0;
remote.h
+1
@@ -45,6 +45,7 @@ struct remote {
45
};
46
47
struct remote *remote_get(const char *name);
48
+int remote_is_configured(const char *name);
49
50
typedef int each_remote_fn(struct remote *remote, void *priv);
51
int for_each_remote(each_remote_fn fn, void *priv);