diff --git a/builtin/fetch.c b/builtin/fetch.c
index 4b6b1df..2efbd7b 100644
--- a/builtin/fetch.c
+++ b/builtin/fetch.c
@@ -39,6 +39,7 @@ static struct strbuf default_rla = STRBUF_INIT;
static struct transport *transport;
static const char *submodule_prefix = "";
static const char *recurse_submodules_default;
+static int allow_local = 1;
static int option_parse_recurse_submodules(const struct option *opt,
const char *arg, int unset)
@@ -90,6 +91,9 @@ static struct option builtin_fetch_options[] = {
{ OPTION_STRING, 0, "recurse-submodules-default",
&recurse_submodules_default, NULL,
N_("default mode for recursion"), PARSE_OPT_HIDDEN },
+ { OPTION_SET_INT, 0, "allow-local", &allow_local, NULL,
+ N_("allow fetching from local repository"),
+ PARSE_OPT_NOARG | PARSE_OPT_HIDDEN, NULL, 1 },
OPT_END()
};
@@ -1006,7 +1010,7 @@ int cmd_fetch(int argc, const char **argv, const char *prefix)
result = fetch_multiple(&list);
} else if (argc == 0) {
/* No arguments -- use default remote */
- remote = remote_get(NULL);
+ remote = fetchremote_get(NULL, allow_local);
result = fetch_one(remote, argc, argv);
} else if (multiple) {
/* All arguments are assumed to be remotes or groups */diff --git a/remote.c b/remote.c
index 68eb99b..a7e59ab 100644
--- a/remote.c
+++ b/remote.c
@@ -682,7 +682,7 @@ static int valid_remote_nick(const char *name)
return !strchr(name, '/'); /* no slash */
}
-static struct remote *remote_get_1(const char *name, const char *pushremote_name)
+static struct remote *remote_get_1(const char *name, const char *pushremote_name, int allow_local)
{
struct remote *ret;
int name_given = 0;@@ -699,6 +699,11 @@ static struct remote *remote_get_1(const char *name, const char *pushremote_name
}
}
+ if (!allow_local && !strcmp(name, ".")) {
+ name = "origin";
+ name_given = 0;
+ }
+
ret = make_remote(name, 0);
if (valid_remote_nick(name)) {
if (!valid_remote(ret))@@ -718,13 +723,19 @@ static struct remote *remote_get_1(const char *name, const char *pushremote_name
struct remote *remote_get(const char *name)
{
read_config();
- return remote_get_1(name, NULL);
+ return remote_get_1(name, NULL, 1);
}
struct remote *pushremote_get(const char *name)
{
read_config();
- return remote_get_1(name, pushremote_name);
+ return remote_get_1(name, pushremote_name, 1);
+}
+
+struct remote *fetchremote_get(const char *name, int allow_local)
+{
+ read_config();
+ return remote_get_1(name, NULL, allow_local);
}
int remote_is_configured(const char *name)diff --git a/remote.h b/remote.h
index cf56724..f0d6cf3 100644
--- a/remote.h
+++ b/remote.h
@@ -52,6 +52,7 @@ struct remote {
struct remote *remote_get(const char *name);
struct remote *pushremote_get(const char *name);
+struct remote *fetchremote_get(const char *name, int allow_local);
int remote_is_configured(const char *name);
typedef int each_remote_fn(struct remote *remote, void *priv);--
1.8.3.rc1.579.g184e698