Skip to content

Commit 9326d49

Browse files
committed
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 <[email protected]>
1 parent fa685bd commit 9326d49

File tree

1 file changed

+3
-18
lines changed

1 file changed

+3
-18
lines changed

remote.c

Lines changed: 3 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -105,16 +105,6 @@ static void add_url_alias(struct remote *remote, const char *url)
105105
add_url(remote, alias_url(url));
106106
}
107107

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-
118108
static struct remote *make_remote(const char *name, int len)
119109
{
120110
struct remote *ret;
@@ -665,20 +655,15 @@ struct remote *remote_get(const char *name)
665655
name = default_remote_name;
666656
name_given = explicit_default_remote_name;
667657
}
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);
675660
if (valid_remote_nick(name)) {
676661
if (!ret->url)
677662
read_remotes_file(ret);
678663
if (!ret->url)
679664
read_branches_file(ret);
680665
}
681-
if (!ret->url)
666+
if (name_given && !ret->url)
682667
add_url_alias(ret, name);
683668
if (!ret->url)
684669
return NULL;

0 commit comments

Comments
 (0)