Merge branch 'cs/http-use-basic-after-failed-negotiate'
[alt-git.git] / t / t5506-remote-groups.sh
blob8f150c0793e4be0ee2a2fe6e07512da4e0717f7b
1 #!/bin/sh
3 test_description='git remote group handling'
4 GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME=main
5 export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME
7 . ./test-lib.sh
9 mark() {
10 echo "$1" >mark
13 update_repo() {
14 (cd $1 &&
15 echo content >>file &&
16 git add file &&
17 git commit -F ../mark)
20 update_repos() {
21 update_repo one $1 &&
22 update_repo two $1
25 repo_fetched() {
26 if test "$(git log -1 --pretty=format:%s $1 --)" = "$(cat mark)"; then
27 echo >&2 "repo was fetched: $1"
28 return 0
30 echo >&2 "repo was not fetched: $1"
31 return 1
34 test_expect_success 'setup' '
35 mkdir one && (cd one && git init) &&
36 mkdir two && (cd two && git init) &&
37 git remote add -m main one one &&
38 git remote add -m main two two
41 test_expect_success 'no group updates all' '
42 mark update-all &&
43 update_repos &&
44 git remote update &&
45 repo_fetched one &&
46 repo_fetched two
49 test_expect_success 'nonexistent group produces error' '
50 mark nonexistent &&
51 update_repos &&
52 test_must_fail git remote update nonexistent &&
53 ! repo_fetched one &&
54 ! repo_fetched two
57 test_expect_success 'updating group updates all members (remote update)' '
58 mark group-all &&
59 update_repos &&
60 git config --add remotes.all one &&
61 git config --add remotes.all two &&
62 git remote update all &&
63 repo_fetched one &&
64 repo_fetched two
67 test_expect_success 'updating group updates all members (fetch)' '
68 mark fetch-group-all &&
69 update_repos &&
70 git fetch all &&
71 repo_fetched one &&
72 repo_fetched two
75 test_expect_success 'updating group does not update non-members (remote update)' '
76 mark group-some &&
77 update_repos &&
78 git config --add remotes.some one &&
79 git remote update some &&
80 repo_fetched one &&
81 ! repo_fetched two
84 test_expect_success 'updating group does not update non-members (fetch)' '
85 mark fetch-group-some &&
86 update_repos &&
87 git config --add remotes.some one &&
88 git remote update some &&
89 repo_fetched one &&
90 ! repo_fetched two
93 test_expect_success 'updating remote name updates that remote' '
94 mark remote-name &&
95 update_repos &&
96 git remote update one &&
97 repo_fetched one &&
98 ! repo_fetched two
101 test_done