Remove total confusion from git-fetch and git-push
The config file is not the only place remotes are defined, and without consulting .git/remotes and .git/branches, you won't know if "origin" is configured by the user. Don't give up too early and insult the user with a wisecrack "Where do you want to fetch from today?" The only thing the previous patch seems to want to prevent from happening is a lazy "git fetch/push" that does not say where-from/to to produce an error message 'origin not found', and we can do that by not letting add_url_alias() to turn a nickname "origin" literally into a pathname "origin" without changing the rest of the logic. Signed-off-by: Junio C Hamano <gitster@pobox.com>
Junio C Hamano committed
Mar 16, 2009 at 00:35 UTC
9326d49412c8c154b43cb7eba2a8692e9703b0f4
1 file changed
+3
-18
remote.c
+3
-18
@@ -105,16 +105,6 @@ static void add_url_alias(struct remote *remote, const char *url)
105
add_url(remote, alias_url(url));
106
}
107
108
-static struct remote *get_remote_by_name(const char *name)
109
-{
110
- int i;
111
- for (i = 0; i < remotes_nr; i++) {
112
- if (!strcmp(name, remotes[i]->name))
113
- return remotes[i];
114
- }
115
- return NULL;
116
-}
117
-
108
static struct remote *make_remote(const char *name, int len)
109
{
110
struct remote *ret;
@@ -665,20 +655,15 @@ struct remote *remote_get(const char *name)
655
name = default_remote_name;
656
name_given = explicit_default_remote_name;
657
}
668
- if (name_given)
669
- ret = make_remote(name, 0);
670
- else {
671
- ret = get_remote_by_name(name);
672
- if (!ret)
673
- return NULL;
674
- }
658
+
659
+ ret = make_remote(name, 0);
660
if (valid_remote_nick(name)) {
661
if (!ret->url)
662
read_remotes_file(ret);
663
if (!ret->url)
664
read_branches_file(ret);
665
}
681
- if (!ret->url)
666
+ if (name_given && !ret->url)
667
add_url_alias(ret, name);
668
if (!ret->url)
669
return NULL;