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:
authorBert Wesarg <bert.wesarg@googlemail.com>2020-02-01 12:34:09 +0300
committerJunio C Hamano <gitster@pobox.com>2020-02-10 21:52:10 +0300
commitb3fd6cbf29435f8b49a0a5d9f86236e00b084624 (patch)
tree552b7f9bb784f8b0991126e93789a82393732c5a /t/t5505-remote.sh
parentf2a2327a4a6a9bccade6df2bed1fdc3a8ab37f4c (diff)
remote rename/remove: gently handle remote.pushDefault config
When renaming a remote with git remote rename X Y git remote remove X Git already renames or removes any branch.<name>.remote and branch.<name>.pushRemote configurations if their value is X. However remote.pushDefault needs a more gentle approach, as this may be set in a non-repo configuration file. In such a case only a warning is printed, such as: warning: The global configuration remote.pushDefault in: $HOME/.gitconfig:35 now names the non-existent remote origin It is changed to remote.pushDefault = Y or removed when set in a repo configuration though. Signed-off-by: Bert Wesarg <bert.wesarg@googlemail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 't/t5505-remote.sh')
-rwxr-xr-xt/t5505-remote.sh76
1 files changed, 74 insertions, 2 deletions
diff --git a/t/t5505-remote.sh b/t/t5505-remote.sh
index 082042b05a..dda81b7d07 100755
--- a/t/t5505-remote.sh
+++ b/t/t5505-remote.sh
@@ -734,6 +734,7 @@ test_expect_success 'reject adding remote with an invalid name' '
# the last two ones check if the config is updated.
test_expect_success 'rename a remote' '
+ test_config_global remote.pushDefault origin &&
git clone one four &&
(
cd four &&
@@ -744,7 +745,42 @@ test_expect_success 'rename a remote' '
test "$(git rev-parse upstream/master)" = "$(git rev-parse master)" &&
test "$(git config remote.upstream.fetch)" = "+refs/heads/*:refs/remotes/upstream/*" &&
test "$(git config branch.master.remote)" = "upstream" &&
- test "$(git config branch.master.pushRemote)" = "upstream"
+ test "$(git config branch.master.pushRemote)" = "upstream" &&
+ test "$(git config --global remote.pushDefault)" = "origin"
+ )
+'
+
+test_expect_success 'rename a remote renames repo remote.pushDefault' '
+ git clone one four.1 &&
+ (
+ cd four.1 &&
+ git config remote.pushDefault origin &&
+ git remote rename origin upstream &&
+ test "$(git config --local remote.pushDefault)" = "upstream"
+ )
+'
+
+test_expect_success 'rename a remote renames repo remote.pushDefault but ignores global' '
+ test_config_global remote.pushDefault other &&
+ git clone one four.2 &&
+ (
+ cd four.2 &&
+ git config remote.pushDefault origin &&
+ git remote rename origin upstream &&
+ test "$(git config --global remote.pushDefault)" = "other" &&
+ test "$(git config --local remote.pushDefault)" = "upstream"
+ )
+'
+
+test_expect_success 'rename a remote renames repo remote.pushDefault but keeps global' '
+ test_config_global remote.pushDefault origin &&
+ git clone one four.3 &&
+ (
+ cd four.3 &&
+ git config remote.pushDefault origin &&
+ git remote rename origin upstream &&
+ test "$(git config --global remote.pushDefault)" = "origin" &&
+ test "$(git config --local remote.pushDefault)" = "upstream"
)
'
@@ -787,6 +823,7 @@ test_expect_success 'rename succeeds with existing remote.<target>.prune' '
'
test_expect_success 'remove a remote' '
+ test_config_global remote.pushDefault origin &&
git clone one four.five &&
(
cd four.five &&
@@ -794,7 +831,42 @@ test_expect_success 'remove a remote' '
git remote remove origin &&
test -z "$(git for-each-ref refs/remotes/origin)" &&
test_must_fail git config branch.master.remote &&
- test_must_fail git config branch.master.pushRemote
+ test_must_fail git config branch.master.pushRemote &&
+ test "$(git config --global remote.pushDefault)" = "origin"
+ )
+'
+
+test_expect_success 'remove a remote removes repo remote.pushDefault' '
+ git clone one four.five.1 &&
+ (
+ cd four.five.1 &&
+ git config remote.pushDefault origin &&
+ git remote remove origin &&
+ test_must_fail git config --local remote.pushDefault
+ )
+'
+
+test_expect_success 'remove a remote removes repo remote.pushDefault but ignores global' '
+ test_config_global remote.pushDefault other &&
+ git clone one four.five.2 &&
+ (
+ cd four.five.2 &&
+ git config remote.pushDefault origin &&
+ git remote remove origin &&
+ test "$(git config --global remote.pushDefault)" = "other" &&
+ test_must_fail git config --local remote.pushDefault
+ )
+'
+
+test_expect_success 'remove a remote removes repo remote.pushDefault but keeps global' '
+ test_config_global remote.pushDefault origin &&
+ git clone one four.five.3 &&
+ (
+ cd four.five.3 &&
+ git config remote.pushDefault origin &&
+ git remote remove origin &&
+ test "$(git config --global remote.pushDefault)" = "origin" &&
+ test_must_fail git config --local remote.pushDefault
)
'