@@ -39,6 +39,7 @@ static int branches_nr;
3939
4040static struct branch * current_branch ;
4141static const char * default_remote_name ;
42+ static int explicit_default_remote_name ;
4243
4344static struct rewrite * * rewrite ;
4445static int rewrite_alloc ;
@@ -331,8 +332,10 @@ static int handle_config(const char *key, const char *value, void *cb)
331332 if (!value )
332333 return config_error_nonbool (key );
333334 branch -> remote_name = xstrdup (value );
334- if (branch == current_branch )
335+ if (branch == current_branch ) {
335336 default_remote_name = branch -> remote_name ;
337+ explicit_default_remote_name = 1 ;
338+ }
336339 } else if (!strcmp (subkey , ".merge" )) {
337340 if (!value )
338341 return config_error_nonbool (key );
@@ -644,18 +647,24 @@ static int valid_remote_nick(const char *name)
644647struct remote * remote_get (const char * name )
645648{
646649 struct remote * ret ;
650+ int name_given = 0 ;
647651
648652 read_config ();
649- if (!name )
653+ if (name )
654+ name_given = 1 ;
655+ else {
650656 name = default_remote_name ;
657+ name_given = explicit_default_remote_name ;
658+ }
659+
651660 ret = make_remote (name , 0 );
652661 if (valid_remote_nick (name )) {
653662 if (!ret -> url )
654663 read_remotes_file (ret );
655664 if (!ret -> url )
656665 read_branches_file (ret );
657666 }
658- if (!ret -> url )
667+ if (name_given && !ret -> url )
659668 add_url_alias (ret , name );
660669 if (!ret -> url )
661670 return NULL ;
0 commit comments