Skip to content

Commit

Permalink
remote: New function remote_is_configured()
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
Finn Arne Gangstad authored and Junio C Hamano committed Apr 8, 2009
1 parent bed5d42 commit 9a23ba3
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 0 deletions.
11 changes: 11 additions & 0 deletions remote.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
1 change: 1 addition & 0 deletions remote.h
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down

0 comments on commit 9a23ba3

Please sign in to comment.