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
path: root/t
diff options
context:
space:
mode:
authorJunio C Hamano <gitster@pobox.com>2020-02-25 22:18:32 +0300
committerJunio C Hamano <gitster@pobox.com>2020-02-25 22:18:32 +0300
commitd0038f4b31d6ab1f0602a4d3c19e35c5004175fa (patch)
tree2b67cde99b211b34335e838515690896794c6d75 /t
parent51ebf55b9309824346a6589c9f3b130c6f371b8f (diff)
parentb3fd6cbf29435f8b49a0a5d9f86236e00b084624 (diff)
Merge branch 'bw/remote-rename-update-config'
"git remote rename X Y" needs to adjust configuration variables (e.g. branch.<name>.remote) whose value used to be X to Y. branch.<name>.pushRemote is now also updated. * bw/remote-rename-update-config: remote rename/remove: gently handle remote.pushDefault config config: provide access to the current line number remote rename/remove: handle branch.<name>.pushRemote config values remote: clean-up config callback remote: clean-up by returning early to avoid one indentation pull --rebase/remote rename: document and honor single-letter abbreviations rebase types
Diffstat (limited to 't')
-rw-r--r--t/helper/test-config.c1
-rwxr-xr-xt/t1308-config-set.sh14
-rwxr-xr-xt/t5505-remote.sh88
3 files changed, 100 insertions, 3 deletions
diff --git a/t/helper/test-config.c b/t/helper/test-config.c
index 1e3bc7c8f4..234c722b48 100644
--- a/t/helper/test-config.c
+++ b/t/helper/test-config.c
@@ -48,6 +48,7 @@ static int iterate_cb(const char *var, const char *value, void *data)
printf("value=%s\n", value ? value : "(null)");
printf("origin=%s\n", current_config_origin_type());
printf("name=%s\n", current_config_name());
+ printf("lno=%d\n", current_config_line());
printf("scope=%s\n", config_scope_name(current_config_scope()));
return 0;
diff --git a/t/t1308-config-set.sh b/t/t1308-config-set.sh
index fba0abe429..3a527e3a84 100755
--- a/t/t1308-config-set.sh
+++ b/t/t1308-config-set.sh
@@ -238,8 +238,8 @@ test_expect_success 'error on modifying repo config without repo' '
cmdline_config="'foo.bar=from-cmdline'"
test_expect_success 'iteration shows correct origins' '
- echo "[foo]bar = from-repo" >.git/config &&
- echo "[foo]bar = from-home" >.gitconfig &&
+ printf "[ignore]\n\tthis = please\n[foo]bar = from-repo\n" >.git/config &&
+ printf "[foo]\n\tbar = from-home\n" >.gitconfig &&
if test_have_prereq MINGW
then
# Use Windows path (i.e. *not* $HOME)
@@ -253,18 +253,28 @@ test_expect_success 'iteration shows correct origins' '
value=from-home
origin=file
name=$HOME_GITCONFIG
+ lno=2
scope=global
+ key=ignore.this
+ value=please
+ origin=file
+ name=.git/config
+ lno=2
+ scope=local
+
key=foo.bar
value=from-repo
origin=file
name=.git/config
+ lno=3
scope=local
key=foo.bar
value=from-cmdline
origin=command line
name=
+ lno=-1
scope=command
EOF
GIT_CONFIG_PARAMETERS=$cmdline_config test-tool config iterate >actual &&
diff --git a/t/t5505-remote.sh b/t/t5505-remote.sh
index 883b32efa0..dda81b7d07 100755
--- a/t/t5505-remote.sh
+++ b/t/t5505-remote.sh
@@ -734,15 +734,53 @@ 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 &&
+ git config branch.master.pushRemote origin &&
git remote rename origin upstream &&
test -z "$(git for-each-ref refs/remotes/origin)" &&
test "$(git symbolic-ref refs/remotes/upstream/HEAD)" = "refs/remotes/upstream/master" &&
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.remote)" = "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"
)
'
@@ -784,6 +822,54 @@ test_expect_success 'rename succeeds with existing remote.<target>.prune' '
git -C four.four remote rename origin upstream
'
+test_expect_success 'remove a remote' '
+ test_config_global remote.pushDefault origin &&
+ git clone one four.five &&
+ (
+ cd four.five &&
+ git config branch.master.pushRemote origin &&
+ 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 "$(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
+ )
+'
+
cat >remotes_origin <<EOF
URL: $(pwd)/one
Push: refs/heads/master:refs/heads/upstream