diff options
author | Junio C Hamano <gitster@pobox.com> | 2009-03-17 18:58:41 -0700 |
---|---|---|
committer | Junio C Hamano <gitster@pobox.com> | 2009-03-17 18:58:41 -0700 |
commit | 9d5b05c6d56a0fb12d43d50d7853178feaf59daa (patch) | |
tree | 9b8179288ca004c2a5bf7d8bc74d1ed8ce8f13fe /remote.c | |
parent | 6e5660a7ab20275d80262d0a21bc6c52eead9cd7 (diff) | |
parent | 9326d49412c8c154b43cb7eba2a8692e9703b0f4 (diff) | |
download | git-9d5b05c6d56a0fb12d43d50d7853178feaf59daa.tar.gz |
Merge branch 'db/maint-missing-origin'
* db/maint-missing-origin:
Remove total confusion from git-fetch and git-push
Give error when no remote is configured
Diffstat (limited to 'remote.c')
-rw-r--r-- | remote.c | 15 |
1 files changed, 12 insertions, 3 deletions
@@ -39,6 +39,7 @@ static int branches_nr; static struct branch *current_branch; static const char *default_remote_name; +static int explicit_default_remote_name; static struct rewrite **rewrite; static int rewrite_alloc; @@ -331,8 +332,10 @@ static int handle_config(const char *key, const char *value, void *cb) if (!value) return config_error_nonbool(key); branch->remote_name = xstrdup(value); - if (branch == current_branch) + if (branch == current_branch) { default_remote_name = branch->remote_name; + explicit_default_remote_name = 1; + } } else if (!strcmp(subkey, ".merge")) { if (!value) return config_error_nonbool(key); @@ -644,10 +647,16 @@ static int valid_remote_nick(const char *name) struct remote *remote_get(const char *name) { struct remote *ret; + int name_given = 0; read_config(); - if (!name) + if (name) + name_given = 1; + else { name = default_remote_name; + name_given = explicit_default_remote_name; + } + ret = make_remote(name, 0); if (valid_remote_nick(name)) { if (!ret->url) @@ -655,7 +664,7 @@ struct remote *remote_get(const char *name) if (!ret->url) read_branches_file(ret); } - if (!ret->url) + if (name_given && !ret->url) add_url_alias(ret, name); if (!ret->url) return NULL; |