commit,status: describe --porcelain just like push
[git/gitweb.git] / t / t5526-fetch-submodules.sh
bloba5f458533fd071c13550a72bf251e2e10c109637
1 #!/bin/sh
2 # Copyright (c) 2010, Jens Lehmann
4 test_description='Recursive "git fetch" for submodules'
6 . ./test-lib.sh
8 pwd=$(pwd)
10 add_upstream_commit() {
12 cd submodule &&
13 head1=$(git rev-parse --short HEAD) &&
14 echo new >> subfile &&
15 test_tick &&
16 git add 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
21 ) &&
23 cd deepsubmodule &&
24 head1=$(git rev-parse --short HEAD) &&
25 echo new >> deepsubfile &&
26 test_tick &&
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 &&
38 cd deepsubmodule &&
39 git init &&
40 echo deepsubcontent > deepsubfile &&
41 git add deepsubfile &&
42 git commit -m new deepsubfile
43 ) &&
44 mkdir submodule &&
46 cd submodule &&
47 git init &&
48 echo subcontent > subfile &&
49 git add subfile &&
50 git submodule add "$pwd/deepsubmodule" deepsubmodule &&
51 git commit -a -m new
52 ) &&
53 git submodule add "$pwd/submodule" submodule &&
54 git commit -am initial &&
55 git clone . downstream &&
57 cd downstream &&
58 git submodule update --init --recursive
59 ) &&
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 &&
67 cd downstream &&
68 git fetch --recurse-submodules >../actual.out 2>../actual.err
69 ) &&
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 &&
77 cd downstream &&
78 git fetch >../actual.out 2>../actual.err
79 ) &&
80 ! test -s actual.out &&
81 ! test -s actual.err
84 test_expect_success "fetch --no-recurse-submodules only fetches superproject" '
86 cd downstream &&
87 git fetch --no-recurse-submodules >../actual.out 2>../actual.err
88 ) &&
89 ! test -s actual.out &&
90 ! test -s actual.err
93 test_expect_success "using fetchRecurseSubmodules=true in .gitmodules recurses into submodules" '
95 cd downstream &&
96 git config -f .gitmodules submodule.submodule.fetchRecurseSubmodules true &&
97 git fetch >../actual.out 2>../actual.err
98 ) &&
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 &&
106 cd downstream &&
107 git fetch --no-recurse-submodules >../actual.out 2>../actual.err
108 ) &&
109 ! test -s actual.out &&
110 ! test -s actual.err
113 test_expect_success "using fetchRecurseSubmodules=false in .git/config overrides setting in .gitmodules" '
115 cd downstream &&
116 git config submodule.submodule.fetchRecurseSubmodules false &&
117 git fetch >../actual.out 2>../actual.err
118 ) &&
119 ! test -s actual.out &&
120 ! test -s actual.err
123 test_expect_success "--recurse-submodules overrides fetchRecurseSubmodules setting from .git/config" '
125 cd downstream &&
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
129 ) &&
130 test_cmp expect.out actual.out &&
131 test_cmp expect.err actual.err
134 test_expect_success "--quiet propagates to submodules" '
136 cd downstream &&
137 git fetch --recurse-submodules --quiet >../actual.out 2>../actual.err
138 ) &&
139 ! test -s actual.out &&
140 ! test -s actual.err
143 test_expect_success "--dry-run propagates to submodules" '
144 add_upstream_commit &&
146 cd downstream &&
147 git fetch --recurse-submodules --dry-run >../actual.out 2>../actual.err
148 ) &&
149 test_cmp expect.out actual.out &&
150 test_cmp expect.err actual.err &&
152 cd downstream &&
153 git fetch --recurse-submodules >../actual.out 2>../actual.err
154 ) &&
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 &&
162 cd downstream &&
163 git config fetch.recurseSubmodules true
164 git fetch >../actual.out 2>../actual.err
165 ) &&
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 &&
173 cd downstream &&
175 cd submodule &&
176 git config fetch.recurseSubmodules false
177 ) &&
178 git fetch --recurse-submodules >../actual.out 2>../actual.err
179 ) &&
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 &&
187 cd downstream &&
188 git config fetch.recurseSubmodules true
189 git fetch --no-recurse-submodules >../actual.out 2>../actual.err
190 ) &&
191 ! test -s actual.out &&
192 ! test -s actual.err
195 test_done