Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.kernel.org/pub/scm/git/git.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJeff King <peff@peff.net>2022-09-22 08:33:29 +0300
committerJunio C Hamano <gitster@pobox.com>2022-09-22 22:59:52 +0300
commit5a97b3810946440764a0a9a2292fcfdfa11391d5 (patch)
treeeb5070ccfa30ab222223296a5a2f3cead1ffb51b /t/t5505-remote.sh
parenta0feb8611d4c0b2b5d954efe4e98207f62223436 (diff)
remote: handle rename of remote without fetch refspec
We return an error when trying to rename a remote that has no fetch refspec: $ git config --unset-all remote.origin.fetch $ git remote rename origin foo fatal: could not unset 'remote.foo.fetch' To make things even more confusing, we actually _do_ complete the config modification, via git_config_rename_section(). After that we try to rewrite the fetch refspec (to say refs/remotes/foo instead of origin). But our call to git_config_set_multivar() to remove the existing entries fails, since there aren't any, and it calls die(). We could fix this by using the "gently" form of the config call, and checking the error code. But there is an even simpler fix: if we know that there are no refspecs to rewrite, then we can skip that part entirely. Reported-by: John A. Leuenhagen <john@zlima12.com> Signed-off-by: Jeff King <peff@peff.net> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 't/t5505-remote.sh')
-rwxr-xr-xt/t5505-remote.sh11
1 files changed, 11 insertions, 0 deletions
diff --git a/t/t5505-remote.sh b/t/t5505-remote.sh
index fff14e13ed..4045297179 100755
--- a/t/t5505-remote.sh
+++ b/t/t5505-remote.sh
@@ -836,6 +836,17 @@ test_expect_success 'rename a remote renames repo remote.pushDefault but keeps g
)
'
+test_expect_success 'rename handles remote without fetch refspec' '
+ git clone --bare one no-refspec.git &&
+ # confirm assumption that bare clone does not create refspec
+ test_expect_code 5 \
+ git -C no-refspec.git config --unset-all remote.origin.fetch &&
+ git -C no-refspec.git config remote.origin.url >expect &&
+ git -C no-refspec.git remote rename origin foo &&
+ git -C no-refspec.git config remote.foo.url >actual &&
+ test_cmp expect actual
+'
+
test_expect_success 'rename does not update a non-default fetch refspec' '
git clone one four.one &&
(