remote: write camel-cased *.pushRemote on rename

When a remote is renamed don't change the canonical "*.pushRemote" form to "*.pushremote". Fixes and tests for a minor bug in 923d4a5ca4f (remote rename/remove: handle branch.<name>.pushRemote config values, 2020-01-27). See the preceding commit for why this does & doesn't matter. While we're at it let's also test that we handle the "*.pushDefault" key correctly. The code to handle that was added in b3fd6cbf294 (remote rename/remove: gently handle remote.pushDefault config, 2020-02-01) and does the right thing, but nothing tested that we wrote out the canonical camel-cased form. Signed-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>

Ævar Arnfjörð Bjarmason committed Feb 25, 2021 at 02:21 UTC 0f1da600e6864e8b4fe97aea72a3b68c227a709c
2 files changed +3 -1
builtin/remote.c
+1 -1
@@ -746,7 +746,7 @@ static int mv(int argc, const char **argv)
746 }
747 if (info->push_remote_name && !strcmp(info->push_remote_name, rename.old_name)) {
748 strbuf_reset(&buf);
749 - strbuf_addf(&buf, "branch.%s.pushremote", item->string);
749 + strbuf_addf(&buf, "branch.%s.pushRemote", item->string);
750 git_config_set(buf.buf, rename.new_name);
751 }
752 }
t/t5505-remote.sh
+2
@@ -754,6 +754,7 @@ test_expect_success 'rename a remote' '
754 cd four &&
755 git config branch.main.pushRemote origin &&
756 git remote rename origin upstream &&
757 + grep "pushRemote" .git/config &&
758 test -z "$(git for-each-ref refs/remotes/origin)" &&
759 test "$(git symbolic-ref refs/remotes/upstream/HEAD)" = "refs/remotes/upstream/main" &&
760 test "$(git rev-parse upstream/main)" = "$(git rev-parse main)" &&
@@ -770,6 +771,7 @@ test_expect_success 'rename a remote renames repo remote.pushDefault' '
771 cd four.1 &&
772 git config remote.pushDefault origin &&
773 git remote rename origin upstream &&
774 + grep pushDefault .git/config &&
775 test "$(git config --local remote.pushDefault)" = "upstream"
776 )
777 '