Skip to content

Commit 663d250

Browse files
pcloudsgitster
authored andcommitted
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 <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 34e7771 commit 663d250

File tree

1 file changed

+17
-1
lines changed

1 file changed

+17
-1
lines changed

t/t7814-grep-recurse-submodules.sh

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,12 +14,14 @@ test_expect_success 'setup directory structure and submodule' '
1414
echo "(3|4)" >b/b &&
1515
git add a b &&
1616
git commit -m "add a and b" &&
17+
test_tick &&
1718
git init submodule &&
1819
echo "(1|2)d(3|4)" >submodule/a &&
1920
git -C submodule add a &&
2021
git -C submodule commit -m "add a" &&
2122
git submodule add ./submodule &&
22-
git commit -m "added submodule"
23+
git commit -m "added submodule" &&
24+
test_tick
2325
'
2426

2527
test_expect_success 'grep correctly finds patterns in a submodule' '
@@ -65,11 +67,14 @@ test_expect_success 'grep and nested submodules' '
6567
echo "(1|2)d(3|4)" >submodule/sub/a &&
6668
git -C submodule/sub add a &&
6769
git -C submodule/sub commit -m "add a" &&
70+
test_tick &&
6871
git -C submodule submodule add ./sub &&
6972
git -C submodule add sub &&
7073
git -C submodule commit -m "added sub" &&
74+
test_tick &&
7175
git add submodule &&
7276
git commit -m "updated submodule" &&
77+
test_tick &&
7378
7479
cat >expect <<-\EOF &&
7580
a:(1|2)d(3|4)
@@ -179,15 +184,18 @@ test_expect_success !MINGW 'grep recurse submodule colon in name' '
179184
echo "(1|2)d(3|4)" >"parent/fi:le" &&
180185
git -C parent add "fi:le" &&
181186
git -C parent commit -m "add fi:le" &&
187+
test_tick &&
182188
183189
git init "su:b" &&
184190
test_when_finished "rm -rf su:b" &&
185191
echo "(1|2)d(3|4)" >"su:b/fi:le" &&
186192
git -C "su:b" add "fi:le" &&
187193
git -C "su:b" commit -m "add fi:le" &&
194+
test_tick &&
188195
189196
git -C parent submodule add "../su:b" "su:b" &&
190197
git -C parent commit -m "add submodule" &&
198+
test_tick &&
191199
192200
cat >expect <<-\EOF &&
193201
fi:le:(1|2)d(3|4)
@@ -210,15 +218,18 @@ test_expect_success 'grep history with moved submoules' '
210218
echo "(1|2)d(3|4)" >parent/file &&
211219
git -C parent add file &&
212220
git -C parent commit -m "add file" &&
221+
test_tick &&
213222
214223
git init sub &&
215224
test_when_finished "rm -rf sub" &&
216225
echo "(1|2)d(3|4)" >sub/file &&
217226
git -C sub add file &&
218227
git -C sub commit -m "add file" &&
228+
test_tick &&
219229
220230
git -C parent submodule add ../sub dir/sub &&
221231
git -C parent commit -m "add submodule" &&
232+
test_tick &&
222233
223234
cat >expect <<-\EOF &&
224235
dir/sub/file:(1|2)d(3|4)
@@ -229,6 +240,7 @@ test_expect_success 'grep history with moved submoules' '
229240
230241
git -C parent mv dir/sub sub-moved &&
231242
git -C parent commit -m "moved submodule" &&
243+
test_tick &&
232244
233245
cat >expect <<-\EOF &&
234246
file:(1|2)d(3|4)
@@ -251,6 +263,7 @@ test_expect_success 'grep using relative path' '
251263
echo "(1|2)d(3|4)" >sub/file &&
252264
git -C sub add file &&
253265
git -C sub commit -m "add file" &&
266+
test_tick &&
254267
255268
git init parent &&
256269
echo "(1|2)d(3|4)" >parent/file &&
@@ -260,6 +273,7 @@ test_expect_success 'grep using relative path' '
260273
git -C parent add src/file2 &&
261274
git -C parent submodule add ../sub &&
262275
git -C parent commit -m "add files and submodule" &&
276+
test_tick &&
263277
264278
# From top works
265279
cat >expect <<-\EOF &&
@@ -293,6 +307,7 @@ test_expect_success 'grep from a subdir' '
293307
echo "(1|2)d(3|4)" >sub/file &&
294308
git -C sub add file &&
295309
git -C sub commit -m "add file" &&
310+
test_tick &&
296311
297312
git init parent &&
298313
mkdir parent/src &&
@@ -301,6 +316,7 @@ test_expect_success 'grep from a subdir' '
301316
git -C parent submodule add ../sub src/sub &&
302317
git -C parent submodule add ../sub sub &&
303318
git -C parent commit -m "add files and submodules" &&
319+
test_tick &&
304320
305321
# Verify grep from root works
306322
cat >expect <<-\EOF &&

0 commit comments

Comments
 (0)