diff options
author | Thomas Gummerer <t.gummerer@gmail.com> | 2016-02-16 10:47:50 +0100 |
---|---|---|
committer | Junio C Hamano <gitster@pobox.com> | 2016-02-16 13:33:12 -0800 |
commit | 674468b3642abfff7c61d5ff95fffc43b87f70b7 (patch) | |
tree | bf6ab75ebd17f9588b52673007ff1b15f19bf65d /remote.c | |
parent | remote: use parse_config_key (diff) | |
download | tgif-674468b3642abfff7c61d5ff95fffc43b87f70b7.tar.xz |
remote: simplify remote_is_configured()
The remote_is_configured() function allows checking whether a remote
exists or not. The function however only works if remote_get() wasn't
called before calling it. In addition, it only checks the configuration
for remotes, but not remotes or branches files.
Make use of the origin member of struct remote instead, which indicates
where the remote comes from. It will be set to some value if the remote
is configured in any file in the repository, but is initialized to 0 if
the remote is only created in make_remote().
Signed-off-by: Thomas Gummerer <t.gummerer@gmail.com>
Reviewed-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'remote.c')
-rw-r--r-- | remote.c | 13 |
1 files changed, 2 insertions, 11 deletions
@@ -713,18 +713,9 @@ struct remote *pushremote_get(const char *name) return remote_get_1(name, pushremote_for_branch); } -int remote_is_configured(const char *name) +int remote_is_configured(struct remote *remote) { - struct remotes_hash_key lookup; - struct hashmap_entry lookup_entry; - read_config(); - - init_remotes_hash(); - lookup.str = name; - lookup.len = strlen(name); - hashmap_entry_init(&lookup_entry, memhash(name, lookup.len)); - - return hashmap_get(&remotes_hash, &lookup_entry, &lookup) != NULL; + return remote && remote->origin; } int for_each_remote(each_remote_fn fn, void *priv) |