Skip to content

Commit 9a23ba3

Browse files
Finn Arne Gangstadgitster
Finn Arne Gangstad
authored andcommitted
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 <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent bed5d42 commit 9a23ba3

File tree

2 files changed

+12
-0
lines changed

2 files changed

+12
-0
lines changed

remote.c

+11
Original file line numberDiff line numberDiff line change
@@ -667,6 +667,17 @@ struct remote *remote_get(const char *name)
667667
return ret;
668668
}
669669

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+
670681
int for_each_remote(each_remote_fn fn, void *priv)
671682
{
672683
int i, result = 0;

remote.h

+1
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@ struct remote {
4545
};
4646

4747
struct remote *remote_get(const char *name);
48+
int remote_is_configured(const char *name);
4849

4950
typedef int each_remote_fn(struct remote *remote, void *priv);
5051
int for_each_remote(each_remote_fn fn, void *priv);

0 commit comments

Comments
 (0)