X-Git-Url: https://git.tokkee.org/?a=blobdiff_plain;f=remote.c;h=c7a8c2b1fbdea9aa03d8a5ccd8cbfb39eed742df;hb=ee27ca4a781844ddbf556ec64daae24d748a7c5a;hp=d7079c6dd871dc1b482d347d013438fe30cc0908;hpb=32f2f11f39bf8fe0cfebdfbc36cc2476507d5f1c;p=git.git 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;