aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJunio C Hamano <gitster@pobox.com>2009-03-21 23:02:55 -0700
committerJunio C Hamano <gitster@pobox.com>2009-03-21 23:02:55 -0700
commit3c954c23d6e951404fada178ee3ac9b747424d85 (patch)
tree688648db5aabb8b91d5acdceee2b211374b1a946
parent0e1aa2f7af6cc11c56a780764ef0ca94c19f0724 (diff)
parent9326d49412c8c154b43cb7eba2a8692e9703b0f4 (diff)
downloadgit-3c954c23d6e951404fada178ee3ac9b747424d85.tar.gz
git-3c954c23d6e951404fada178ee3ac9b747424d85.tar.xz
Merge branch 'db/maint-missing-origin' into maint
* db/maint-missing-origin: Remove total confusion from git-fetch and git-push Give error when no remote is configured
-rw-r--r--builtin-fetch.c6
-rw-r--r--builtin-push.c7
-rw-r--r--remote.c15
3 files changed, 20 insertions, 8 deletions
diff --git a/builtin-fetch.c b/builtin-fetch.c
index 1e4a3d9c5..7fb35fca9 100644
--- a/builtin-fetch.c
+++ b/builtin-fetch.c
@@ -636,6 +636,9 @@ int cmd_fetch(int argc, const char **argv, const char *prefix)
else
remote = remote_get(argv[0]);
+ if (!remote)
+ die("Where do you want to fetch from today?");
+
transport = transport_get(remote, remote->url[0]);
if (verbosity >= 2)
transport->verbose = 1;
@@ -648,9 +651,6 @@ int cmd_fetch(int argc, const char **argv, const char *prefix)
if (depth)
set_option(TRANS_OPT_DEPTH, depth);
- if (!transport->url)
- die("Where do you want to fetch from today?");
-
if (argc > 1) {
int j = 0;
refs = xcalloc(argc + 1, sizeof(const char *));
diff --git a/builtin-push.c b/builtin-push.c
index 122fdcfbd..ca36fb1e5 100644
--- a/builtin-push.c
+++ b/builtin-push.c
@@ -53,8 +53,11 @@ static int do_push(const char *repo, int flags)
int i, errs;
struct remote *remote = remote_get(repo);
- if (!remote)
- die("bad repository '%s'", repo);
+ if (!remote) {
+ if (repo)
+ die("bad repository '%s'", repo);
+ die("No destination configured to push to.");
+ }
if (remote->mirror)
flags |= (TRANSPORT_PUSH_MIRROR|TRANSPORT_PUSH_FORCE);
diff --git a/remote.c b/remote.c
index d7079c6dd..c7a8c2b1f 100644
--- a/remote.c
+++ b/remote.c
@@ -38,6 +38,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;
@@ -330,8 +331,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);
@@ -643,10 +646,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)
@@ -654,7 +663,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;