Merge branch 'js/remote-rename-with-half-configured-remote'
With anticipatory tweaking for remotes defined in ~/.gitconfig (e.g. "remote.origin.prune" set to true, even though there may or may not actually be "origin" remote defined in a particular Git repository), "git remote rename" and other commands misinterpreted and behaved as if such a non-existing remote actually existed. * js/remote-rename-with-half-configured-remote: remote rename: more carefully determine whether a remote is configured remote rename: demonstrate a bogus "remote exists" bug
This commit is contained in:
12
remote.c
12
remote.c
@ -255,6 +255,7 @@ static void read_remotes_file(struct remote *remote)
|
||||
|
||||
if (!f)
|
||||
return;
|
||||
remote->configured_in_repo = 1;
|
||||
remote->origin = REMOTE_REMOTES;
|
||||
while (strbuf_getline(&buf, f) != EOF) {
|
||||
const char *v;
|
||||
@ -289,6 +290,7 @@ static void read_branches_file(struct remote *remote)
|
||||
return;
|
||||
}
|
||||
|
||||
remote->configured_in_repo = 1;
|
||||
remote->origin = REMOTE_BRANCHES;
|
||||
|
||||
/*
|
||||
@ -371,6 +373,8 @@ static int handle_config(const char *key, const char *value, void *cb)
|
||||
}
|
||||
remote = make_remote(name, namelen);
|
||||
remote->origin = REMOTE_CONFIG;
|
||||
if (current_config_scope() == CONFIG_SCOPE_REPO)
|
||||
remote->configured_in_repo = 1;
|
||||
if (!strcmp(subkey, "mirror"))
|
||||
remote->mirror = git_config_bool(key, value);
|
||||
else if (!strcmp(subkey, "skipdefaultupdate"))
|
||||
@ -714,9 +718,13 @@ struct remote *pushremote_get(const char *name)
|
||||
return remote_get_1(name, pushremote_for_branch);
|
||||
}
|
||||
|
||||
int remote_is_configured(struct remote *remote)
|
||||
int remote_is_configured(struct remote *remote, int in_repo)
|
||||
{
|
||||
return remote && remote->origin;
|
||||
if (!remote)
|
||||
return 0;
|
||||
if (in_repo)
|
||||
return remote->configured_in_repo;
|
||||
return !!remote->origin;
|
||||
}
|
||||
|
||||
int for_each_remote(each_remote_fn fn, void *priv)
|
||||
|
Reference in New Issue
Block a user