summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 9a6682b)
raw | patch | inline | side by side (parent: 9a6682b)
author | Daniel Barkalow <barkalow@iabervon.org> | |
Wed, 11 Mar 2009 05:47:20 +0000 (01:47 -0400) | ||
committer | Junio C Hamano <gitster@pobox.com> | |
Wed, 11 Mar 2009 06:14:20 +0000 (23:14 -0700) |
When there's no explicitly-named remote, we use the remote specified
for the current branch, which in turn defaults to "origin". But it
this case should require the remote to actually be configured, and not
fall back to the path "origin".
Possibly, the config file's "remote = something" should require the
something to be a configured remote instead of a bare repository URL,
but we actually test with a bare repository URL.
In fetch, we were giving the sensible error message when coming up
with a URL failed, but this wasn't actually reachable, so move that
error up and use it when appropriate.
In push, we need a new error message, because the old one (formerly
unreachable without a lot of help) used the repo name, which was NULL.
Signed-off-by: Daniel Barkalow <barkalow@iabervon.org>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
for the current branch, which in turn defaults to "origin". But it
this case should require the remote to actually be configured, and not
fall back to the path "origin".
Possibly, the config file's "remote = something" should require the
something to be a configured remote instead of a bare repository URL,
but we actually test with a bare repository URL.
In fetch, we were giving the sensible error message when coming up
with a URL failed, but this wasn't actually reachable, so move that
error up and use it when appropriate.
In push, we need a new error message, because the old one (formerly
unreachable without a lot of help) used the repo name, which was NULL.
Signed-off-by: Daniel Barkalow <barkalow@iabervon.org>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
builtin-fetch.c | patch | blob | history | |
builtin-push.c | patch | blob | history | |
remote.c | patch | blob | history |
diff --git a/builtin-fetch.c b/builtin-fetch.c
index 1e4a3d9c516c88d701819b7f4b73c722412d540f..7fb35fca9d1b57dacaebfd3cb9b2af4d035e750c 100644 (file)
--- a/builtin-fetch.c
+++ b/builtin-fetch.c
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;
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 122fdcfbdc13a11388a091e5ec33d077648fab0a..ca36fb1e5834fc581bc7bf8ed54184bbecdc2389 100644 (file)
--- a/builtin-push.c
+++ b/builtin-push.c
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 d7079c6dd871dc1b482d347d013438fe30cc0908..199830ea93f6f87cd3764afe1880e968209439c7 100644 (file)
--- a/remote.c
+++ b/remote.c
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;
add_url(remote, alias_url(url));
}
+static struct remote *get_remote_by_name(const char *name)
+{
+ int i;
+ for (i = 0; i < remotes_nr; i++) {
+ if (!strcmp(name, remotes[i]->name))
+ return remotes[i];
+ }
+ return NULL;
+}
+
static struct remote *make_remote(const char *name, int len)
{
struct remote *ret;
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);
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;
- ret = make_remote(name, 0);
+ name_given = explicit_default_remote_name;
+ }
+ if (name_given)
+ ret = make_remote(name, 0);
+ else {
+ ret = get_remote_by_name(name);
+ if (!ret)
+ return NULL;
+ }
if (valid_remote_nick(name)) {
if (!ret->url)
read_remotes_file(ret);