2 # Copyright (c) 2010, Jens Lehmann
4 test_description
='Recursive "git fetch" for submodules'
10 add_upstream_commit
() {
13 head1
=$
(git rev-parse
--short HEAD
) &&
14 echo new
>> subfile
&&
17 git commit
-m new subfile
&&
18 head2
=$
(git rev-parse
--short HEAD
) &&
19 echo "From $pwd/submodule" > ..
/expect.err
&&
20 echo " $head1..$head2 master -> origin/master" >> ..
/expect.err
24 head1
=$
(git rev-parse
--short HEAD
) &&
25 echo new
>> deepsubfile
&&
27 git add deepsubfile
&&
28 git commit
-m new deepsubfile
&&
29 head2
=$
(git rev-parse
--short HEAD
) &&
30 echo "From $pwd/deepsubmodule" >> ..
/expect.err
&&
31 echo " $head1..$head2 master -> origin/master" >> ..
/expect.err
35 test_expect_success setup
'
36 mkdir deepsubmodule &&
40 echo deepsubcontent > deepsubfile &&
41 git add deepsubfile &&
42 git commit -m new deepsubfile
48 echo subcontent > subfile &&
50 git submodule add "$pwd/deepsubmodule" deepsubmodule &&
53 git submodule add "$pwd/submodule" submodule &&
54 git commit -am initial &&
55 git clone . downstream &&
58 git submodule update --init --recursive
60 echo "Fetching submodule submodule" > expect.out &&
61 echo "Fetching submodule submodule/deepsubmodule" >> expect.out
64 test_expect_success
"fetch --recurse-submodules recurses into submodules" '
65 add_upstream_commit &&
68 git fetch --recurse-submodules >../actual.out 2>../actual.err
70 test_cmp expect.out actual.out &&
71 test_cmp expect.err actual.err
74 test_expect_success
"fetch alone only fetches superproject" '
75 add_upstream_commit &&
78 git fetch >../actual.out 2>../actual.err
80 ! test -s actual.out &&
84 test_expect_success
"fetch --no-recurse-submodules only fetches superproject" '
87 git fetch --no-recurse-submodules >../actual.out 2>../actual.err
89 ! test -s actual.out &&
93 test_expect_success
"using fetchRecurseSubmodules=true in .gitmodules recurses into submodules" '
96 git config -f .gitmodules submodule.submodule.fetchRecurseSubmodules true &&
97 git fetch >../actual.out 2>../actual.err
99 test_cmp expect.out actual.out &&
100 test_cmp expect.err actual.err
103 test_expect_success
"--no-recurse-submodules overrides .gitmodules config" '
104 add_upstream_commit &&
107 git fetch --no-recurse-submodules >../actual.out 2>../actual.err
109 ! test -s actual.out &&
113 test_expect_success
"using fetchRecurseSubmodules=false in .git/config overrides setting in .gitmodules" '
116 git config submodule.submodule.fetchRecurseSubmodules false &&
117 git fetch >../actual.out 2>../actual.err
119 ! test -s actual.out &&
123 test_expect_success
"--recurse-submodules overrides fetchRecurseSubmodules setting from .git/config" '
126 git fetch --recurse-submodules >../actual.out 2>../actual.err &&
127 git config --unset -f .gitmodules submodule.submodule.fetchRecurseSubmodules &&
128 git config --unset submodule.submodule.fetchRecurseSubmodules
130 test_cmp expect.out actual.out &&
131 test_cmp expect.err actual.err
134 test_expect_success
"--quiet propagates to submodules" '
137 git fetch --recurse-submodules --quiet >../actual.out 2>../actual.err
139 ! test -s actual.out &&
143 test_expect_success
"--dry-run propagates to submodules" '
144 add_upstream_commit &&
147 git fetch --recurse-submodules --dry-run >../actual.out 2>../actual.err
149 test_cmp expect.out actual.out &&
150 test_cmp expect.err actual.err &&
153 git fetch --recurse-submodules >../actual.out 2>../actual.err
155 test_cmp expect.out actual.out &&
156 test_cmp expect.err actual.err
159 test_expect_success
"recurseSubmodules=true propagates into submodules" '
160 add_upstream_commit &&
163 git config fetch.recurseSubmodules true
164 git fetch >../actual.out 2>../actual.err
166 test_cmp expect.out actual.out &&
167 test_cmp expect.err actual.err
170 test_expect_success
"--recurse-submodules overrides config in submodule" '
171 add_upstream_commit &&
176 git config fetch.recurseSubmodules false
178 git fetch --recurse-submodules >../actual.out 2>../actual.err
180 test_cmp expect.out actual.out &&
181 test_cmp expect.err actual.err
184 test_expect_success
"--no-recurse-submodules overrides config setting" '
185 add_upstream_commit &&
188 git config fetch.recurseSubmodules true
189 git fetch --no-recurse-submodules >../actual.out 2>../actual.err
191 ! test -s actual.out &&