Commit 5a49ff9f by Carlos Martín Nieto

remote: remove rename code for anonymous remotes

We don't allow renames of anonymous remotes, so there's no need to
handle them.

A remote is always associated with a repository, so there's no need to
check for that.
parent 716e20b4
...@@ -1442,10 +1442,8 @@ static int rename_fetch_refspecs( ...@@ -1442,10 +1442,8 @@ static int rename_fetch_refspecs(
if (spec->push) if (spec->push)
continue; continue;
/* Every refspec is a problem refspec for an anonymous remote, OR */
/* Does the dst part of the refspec follow the expected format? */ /* Does the dst part of the refspec follow the expected format? */
if (!remote->name || if (strcmp(git_buf_cstr(&base), spec->string)) {
strcmp(git_buf_cstr(&base), spec->string)) {
if ((error = callback(spec->string, payload)) != 0) { if ((error = callback(spec->string, payload)) != 0) {
giterr_set_after_callback(error); giterr_set_after_callback(error);
...@@ -1497,49 +1495,20 @@ int git_remote_rename( ...@@ -1497,49 +1495,20 @@ int git_remote_rename(
if ((error = ensure_remote_name_is_valid(new_name)) < 0) if ((error = ensure_remote_name_is_valid(new_name)) < 0)
return error; return error;
if (remote->repo) { if ((error = ensure_remote_doesnot_exist(remote->repo, new_name)) < 0)
if ((error = ensure_remote_doesnot_exist(remote->repo, new_name)) < 0) return error;
return error;
if (!remote->name) { if ((error = rename_remote_config_section(remote->repo, remote->name, new_name)) < 0)
if ((error = rename_fetch_refspecs( return error;
remote,
new_name,
callback,
payload)) < 0)
return error;
remote->name = git__strdup(new_name); if ((error = update_branch_remote_config_entry(remote->repo, remote->name, new_name)) < 0)
GITERR_CHECK_ALLOC(remote->name); return error;
return git_remote_save(remote); if ((error = rename_remote_references(remote->repo, remote->name, new_name)) < 0)
} return error;
if ((error = rename_remote_config_section( if ((error = rename_fetch_refspecs(remote, new_name, callback, payload)) < 0)
remote->repo, return error;
remote->name,
new_name)) < 0)
return error;
if ((error = update_branch_remote_config_entry(
remote->repo,
remote->name,
new_name)) < 0)
return error;
if ((error = rename_remote_references(
remote->repo,
remote->name,
new_name)) < 0)
return error;
if ((error = rename_fetch_refspecs(
remote,
new_name,
callback,
payload)) < 0)
return error;
}
git__free(remote->name); git__free(remote->name);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment