t7814: do not generate same commits in different repos

t7814 has repo tree like this initial-repo submodule sub In each repo 'submodule' and 'sub', a commit is made to add the same initial file 'a' with the same message 'add a'. If tests run fast enough, the two commits are made in the same second, resulting identical commits. There is nothing wrong with that per-se. But it could make the test flaky. Currently all submodule odbs are merged back in the main one (because we can't, or couldn't, access separate submodule repos otherwise). But eventually we need to access objects from the right repo. Because the same commit could sometimes be present in both 'submodule' and 'sub', if there is a bug looking up objects in the wrong repo, sometimes it will go unnoticed because it finds the needed object in the wrong repo anyway. Fix this by changing commit time after every commit. This makes all commits unique. Of course there are still identical blobs in different repos, but because we often lookup commit first, then tree and blob, unique commits are already quite safe. Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>

Nguyễn Thái Ngọc Duy committed Jun 28, 2019 at 16:35 UTC 663d25018f11418ed888128e8b07b1cbe576712a
1 file changed +17 -1
t/t7814-grep-recurse-submodules.sh
+17 -1
@@ -14,12 +14,14 @@ test_expect_success 'setup directory structure and submodule' '
14 echo "(3|4)" >b/b &&
15 git add a b &&
16 git commit -m "add a and b" &&
17 + test_tick &&
18 git init submodule &&
19 echo "(1|2)d(3|4)" >submodule/a &&
20 git -C submodule add a &&
21 git -C submodule commit -m "add a" &&
22 git submodule add ./submodule &&
22 - git commit -m "added submodule"
23 + git commit -m "added submodule" &&
24 + test_tick
25 '
26
27 test_expect_success 'grep correctly finds patterns in a submodule' '
@@ -65,11 +67,14 @@ test_expect_success 'grep and nested submodules' '
67 echo "(1|2)d(3|4)" >submodule/sub/a &&
68 git -C submodule/sub add a &&
69 git -C submodule/sub commit -m "add a" &&
70 + test_tick &&
71 git -C submodule submodule add ./sub &&
72 git -C submodule add sub &&
73 git -C submodule commit -m "added sub" &&
74 + test_tick &&
75 git add submodule &&
76 git commit -m "updated submodule" &&
77 + test_tick &&
78
79 cat >expect <<-\EOF &&
80 a:(1|2)d(3|4)
@@ -179,15 +184,18 @@ test_expect_success !MINGW 'grep recurse submodule colon in name' '
184 echo "(1|2)d(3|4)" >"parent/fi:le" &&
185 git -C parent add "fi:le" &&
186 git -C parent commit -m "add fi:le" &&
187 + test_tick &&
188
189 git init "su:b" &&
190 test_when_finished "rm -rf su:b" &&
191 echo "(1|2)d(3|4)" >"su:b/fi:le" &&
192 git -C "su:b" add "fi:le" &&
193 git -C "su:b" commit -m "add fi:le" &&
194 + test_tick &&
195
196 git -C parent submodule add "../su:b" "su:b" &&
197 git -C parent commit -m "add submodule" &&
198 + test_tick &&
199
200 cat >expect <<-\EOF &&
201 fi:le:(1|2)d(3|4)
@@ -210,15 +218,18 @@ test_expect_success 'grep history with moved submoules' '
218 echo "(1|2)d(3|4)" >parent/file &&
219 git -C parent add file &&
220 git -C parent commit -m "add file" &&
221 + test_tick &&
222
223 git init sub &&
224 test_when_finished "rm -rf sub" &&
225 echo "(1|2)d(3|4)" >sub/file &&
226 git -C sub add file &&
227 git -C sub commit -m "add file" &&
228 + test_tick &&
229
230 git -C parent submodule add ../sub dir/sub &&
231 git -C parent commit -m "add submodule" &&
232 + test_tick &&
233
234 cat >expect <<-\EOF &&
235 dir/sub/file:(1|2)d(3|4)
@@ -229,6 +240,7 @@ test_expect_success 'grep history with moved submoules' '
240
241 git -C parent mv dir/sub sub-moved &&
242 git -C parent commit -m "moved submodule" &&
243 + test_tick &&
244
245 cat >expect <<-\EOF &&
246 file:(1|2)d(3|4)
@@ -251,6 +263,7 @@ test_expect_success 'grep using relative path' '
263 echo "(1|2)d(3|4)" >sub/file &&
264 git -C sub add file &&
265 git -C sub commit -m "add file" &&
266 + test_tick &&
267
268 git init parent &&
269 echo "(1|2)d(3|4)" >parent/file &&
@@ -260,6 +273,7 @@ test_expect_success 'grep using relative path' '
273 git -C parent add src/file2 &&
274 git -C parent submodule add ../sub &&
275 git -C parent commit -m "add files and submodule" &&
276 + test_tick &&
277
278 # From top works
279 cat >expect <<-\EOF &&
@@ -293,6 +307,7 @@ test_expect_success 'grep from a subdir' '
307 echo "(1|2)d(3|4)" >sub/file &&
308 git -C sub add file &&
309 git -C sub commit -m "add file" &&
310 + test_tick &&
311
312 git init parent &&
313 mkdir parent/src &&
@@ -301,6 +316,7 @@ test_expect_success 'grep from a subdir' '
316 git -C parent submodule add ../sub src/sub &&
317 git -C parent submodule add ../sub sub &&
318 git -C parent commit -m "add files and submodules" &&
319 + test_tick &&
320
321 # Verify grep from root works
322 cat >expect <<-\EOF &&