From: Finn Arne Gangstad <finnag@pvv.org>
To: git@vger.kernel.org
Cc: gitster@pobox.com, Finn Arne Gangstad <finnag@pvv.org>
Subject: [PATCH 2/3] remote: New function remote_is_configured()
Date: Mon, 6 Apr 2009 15:41:01 +0200 [thread overview]
Message-ID: <1239025262-16960-3-git-send-email-finnag@pvv.org> (raw)
In-Reply-To: <1239025262-16960-1-git-send-email-finnag@pvv.org>
Previously, there was no beautiful 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>
---
remote.c | 11 +++++++++++
remote.h | 1 +
2 files changed, 12 insertions(+), 0 deletions(-)
diff --git a/remote.c b/remote.c
index d12140e..a06761a 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 de3d21b..99706a8 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);
--
1.6.2.1.471.gdfdaa
next prev parent reply other threads:[~2009-04-06 13:43 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-04-06 13:40 [PATCH 0/3] git remote update: Check args and fallback to remotes Finn Arne Gangstad
2009-04-06 13:41 ` [PATCH 1/3] git remote update: Report error for non-existing groups Finn Arne Gangstad
2009-04-08 2:16 ` Junio C Hamano
2009-04-08 8:07 ` Finn Arne Gangstad
2009-04-08 8:20 ` Junio C Hamano
2009-04-08 17:08 ` Jeff King
2009-04-08 18:48 ` Junio C Hamano
2009-04-06 13:41 ` Finn Arne Gangstad [this message]
2009-04-06 13:41 ` [PATCH 3/3] git remote update: Fallback to remote if group does not exist Finn Arne Gangstad
2009-04-06 20:18 ` [PATCH 0/3] git remote update: Check args and fallback to remotes Jeff King
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1239025262-16960-3-git-send-email-finnag@pvv.org \
--to=finnag@pvv.org \
--cc=git@vger.kernel.org \
--cc=gitster@pobox.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).