@matheusbsbs / matheus-bagliano / commits / 0a4da29dd8
Fork 0

Use a function to determine whether a remote is valid

Currently, it only checks url, but it will allow other things in the future. Signed-off-by: Daniel Barkalow <barkalow@iabervon.org> Signed-off-by: Junio C Hamano <gitster@pobox.com>

Daniel Barkalow committed Nov 18, 2009 at 02:42 UTC 0a4da29dd806bca41cc615961d034b5a5fc30ff7
1 file changed +9 -4
remote.c
+9 -4
@@ -52,6 +52,11 @@ static struct rewrites rewrites_push;
52 #define BUF_SIZE (2048)
53 static char buffer[BUF_SIZE];
54
55 +static int valid_remote(const struct remote *remote)
56 +{
57 + return !!remote->url;
58 +}
59 +
60 static const char *alias_url(const char *url, struct rewrites *r)
61 {
62 int i, j;
@@ -688,14 +693,14 @@ struct remote *remote_get(const char *name)
693
694 ret = make_remote(name, 0);
695 if (valid_remote_nick(name)) {
691 - if (!ret->url)
696 + if (!valid_remote(ret))
697 read_remotes_file(ret);
693 - if (!ret->url)
698 + if (!valid_remote(ret))
699 read_branches_file(ret);
700 }
696 - if (name_given && !ret->url)
701 + if (name_given && !valid_remote(ret))
702 add_url_alias(ret, name);
698 - if (!ret->url)
703 + if (!valid_remote(ret))
704 return NULL;
705 ret->fetch = parse_fetch_refspec(ret->fetch_refspec_nr, ret->fetch_refspec);
706 ret->push = parse_push_refspec(ret->push_refspec_nr, ret->push_refspec);