Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 5a49ff9

Browse files
committed
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.
1 parent 716e20b commit 5a49ff9

File tree

1 file changed

+11
-42
lines changed

1 file changed

+11
-42
lines changed

src/remote.c

Lines changed: 11 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -1442,10 +1442,8 @@ static int rename_fetch_refspecs(
14421442
if (spec->push)
14431443
continue;
14441444

1445-
/* Every refspec is a problem refspec for an anonymous remote, OR */
14461445
/* Does the dst part of the refspec follow the expected format? */
1447-
if (!remote->name ||
1448-
strcmp(git_buf_cstr(&base), spec->string)) {
1446+
if (strcmp(git_buf_cstr(&base), spec->string)) {
14491447

14501448
if ((error = callback(spec->string, payload)) != 0) {
14511449
giterr_set_after_callback(error);
@@ -1497,49 +1495,20 @@ int git_remote_rename(
14971495
if ((error = ensure_remote_name_is_valid(new_name)) < 0)
14981496
return error;
14991497

1500-
if (remote->repo) {
1501-
if ((error = ensure_remote_doesnot_exist(remote->repo, new_name)) < 0)
1502-
return error;
1498+
if ((error = ensure_remote_doesnot_exist(remote->repo, new_name)) < 0)
1499+
return error;
15031500

1504-
if (!remote->name) {
1505-
if ((error = rename_fetch_refspecs(
1506-
remote,
1507-
new_name,
1508-
callback,
1509-
payload)) < 0)
1510-
return error;
1501+
if ((error = rename_remote_config_section(remote->repo, remote->name, new_name)) < 0)
1502+
return error;
15111503

1512-
remote->name = git__strdup(new_name);
1513-
GITERR_CHECK_ALLOC(remote->name);
1504+
if ((error = update_branch_remote_config_entry(remote->repo, remote->name, new_name)) < 0)
1505+
return error;
15141506

1515-
return git_remote_save(remote);
1516-
}
1507+
if ((error = rename_remote_references(remote->repo, remote->name, new_name)) < 0)
1508+
return error;
15171509

1518-
if ((error = rename_remote_config_section(
1519-
remote->repo,
1520-
remote->name,
1521-
new_name)) < 0)
1522-
return error;
1523-
1524-
if ((error = update_branch_remote_config_entry(
1525-
remote->repo,
1526-
remote->name,
1527-
new_name)) < 0)
1528-
return error;
1529-
1530-
if ((error = rename_remote_references(
1531-
remote->repo,
1532-
remote->name,
1533-
new_name)) < 0)
1534-
return error;
1535-
1536-
if ((error = rename_fetch_refspecs(
1537-
remote,
1538-
new_name,
1539-
callback,
1540-
payload)) < 0)
1541-
return error;
1542-
}
1510+
if ((error = rename_fetch_refspecs(remote, new_name, callback, payload)) < 0)
1511+
return error;
15431512

15441513
git__free(remote->name);
15451514

0 commit comments

Comments
 (0)