git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: "Nguyễn Thái Ngọc Duy" <pclouds@gmail.com>
To: pclouds@gmail.com
Cc: Johannes.Schindelin@gmx.de, git@vger.kernel.org,
	gitster@pobox.com, stolee@gmail.com
Subject: [PATCH v2 7/6] t7814: do not generate same commits in different repos
Date: Fri, 28 Jun 2019 16:35:28 +0700	[thread overview]
Message-ID: <20190628093528.20372-1-pclouds@gmail.com> (raw)
In-Reply-To: <20190627092852.11326-1-pclouds@gmail.com>

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>
---
 > And I can't quite understand how t7814 sometimes passed.

 I do now. This patch makes it fail consistently for me.
 
 This patch technically has nothing to do with this series, but I'll
 try to sneak it in because it was started from there.

 t/t7814-grep-recurse-submodules.sh | 18 +++++++++++++++++-
 1 file changed, 17 insertions(+), 1 deletion(-)

diff --git a/t/t7814-grep-recurse-submodules.sh b/t/t7814-grep-recurse-submodules.sh
index 134a694516..a11366b4ce 100755
--- a/t/t7814-grep-recurse-submodules.sh
+++ b/t/t7814-grep-recurse-submodules.sh
@@ -14,12 +14,14 @@ test_expect_success 'setup directory structure and submodule' '
 	echo "(3|4)" >b/b &&
 	git add a b &&
 	git commit -m "add a and b" &&
+	test_tick &&
 	git init submodule &&
 	echo "(1|2)d(3|4)" >submodule/a &&
 	git -C submodule add a &&
 	git -C submodule commit -m "add a" &&
 	git submodule add ./submodule &&
-	git commit -m "added submodule"
+	git commit -m "added submodule" &&
+	test_tick
 '
 
 test_expect_success 'grep correctly finds patterns in a submodule' '
@@ -65,11 +67,14 @@ test_expect_success 'grep and nested submodules' '
 	echo "(1|2)d(3|4)" >submodule/sub/a &&
 	git -C submodule/sub add a &&
 	git -C submodule/sub commit -m "add a" &&
+	test_tick &&
 	git -C submodule submodule add ./sub &&
 	git -C submodule add sub &&
 	git -C submodule commit -m "added sub" &&
+	test_tick &&
 	git add submodule &&
 	git commit -m "updated submodule" &&
+	test_tick &&
 
 	cat >expect <<-\EOF &&
 	a:(1|2)d(3|4)
@@ -179,15 +184,18 @@ test_expect_success !MINGW 'grep recurse submodule colon in name' '
 	echo "(1|2)d(3|4)" >"parent/fi:le" &&
 	git -C parent add "fi:le" &&
 	git -C parent commit -m "add fi:le" &&
+	test_tick &&
 
 	git init "su:b" &&
 	test_when_finished "rm -rf su:b" &&
 	echo "(1|2)d(3|4)" >"su:b/fi:le" &&
 	git -C "su:b" add "fi:le" &&
 	git -C "su:b" commit -m "add fi:le" &&
+	test_tick &&
 
 	git -C parent submodule add "../su:b" "su:b" &&
 	git -C parent commit -m "add submodule" &&
+	test_tick &&
 
 	cat >expect <<-\EOF &&
 	fi:le:(1|2)d(3|4)
@@ -210,15 +218,18 @@ test_expect_success 'grep history with moved submoules' '
 	echo "(1|2)d(3|4)" >parent/file &&
 	git -C parent add file &&
 	git -C parent commit -m "add file" &&
+	test_tick &&
 
 	git init sub &&
 	test_when_finished "rm -rf sub" &&
 	echo "(1|2)d(3|4)" >sub/file &&
 	git -C sub add file &&
 	git -C sub commit -m "add file" &&
+	test_tick &&
 
 	git -C parent submodule add ../sub dir/sub &&
 	git -C parent commit -m "add submodule" &&
+	test_tick &&
 
 	cat >expect <<-\EOF &&
 	dir/sub/file:(1|2)d(3|4)
@@ -229,6 +240,7 @@ test_expect_success 'grep history with moved submoules' '
 
 	git -C parent mv dir/sub sub-moved &&
 	git -C parent commit -m "moved submodule" &&
+	test_tick &&
 
 	cat >expect <<-\EOF &&
 	file:(1|2)d(3|4)
@@ -251,6 +263,7 @@ test_expect_success 'grep using relative path' '
 	echo "(1|2)d(3|4)" >sub/file &&
 	git -C sub add file &&
 	git -C sub commit -m "add file" &&
+	test_tick &&
 
 	git init parent &&
 	echo "(1|2)d(3|4)" >parent/file &&
@@ -260,6 +273,7 @@ test_expect_success 'grep using relative path' '
 	git -C parent add src/file2 &&
 	git -C parent submodule add ../sub &&
 	git -C parent commit -m "add files and submodule" &&
+	test_tick &&
 
 	# From top works
 	cat >expect <<-\EOF &&
@@ -293,6 +307,7 @@ test_expect_success 'grep from a subdir' '
 	echo "(1|2)d(3|4)" >sub/file &&
 	git -C sub add file &&
 	git -C sub commit -m "add file" &&
+	test_tick &&
 
 	git init parent &&
 	mkdir parent/src &&
@@ -301,6 +316,7 @@ test_expect_success 'grep from a subdir' '
 	git -C parent submodule add ../sub src/sub &&
 	git -C parent submodule add ../sub sub &&
 	git -C parent commit -m "add files and submodules" &&
+	test_tick &&
 
 	# Verify grep from root works
 	cat >expect <<-\EOF &&
-- 
2.22.0.rc0.322.g2b0371e29a


  parent reply	other threads:[~2019-06-28  9:35 UTC|newest]

Thread overview: 31+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-06-24  9:55 [PATCH 0/6] Kill the_repository in tree-walk.c Nguyễn Thái Ngọc Duy
2019-06-24  9:55 ` [PATCH 1/6] sha1-file.c: remove the_repo from read_object_with_reference() Nguyễn Thái Ngọc Duy
2019-06-27 12:54   ` Johannes Schindelin
2019-06-27 13:12     ` Duy Nguyen
2019-06-24  9:55 ` [PATCH 2/6] tree-walk.c: remove the_repo from fill_tree_descriptor() Nguyễn Thái Ngọc Duy
2019-06-24 13:30   ` Derrick Stolee
2019-06-26 16:27     ` Junio C Hamano
2019-06-26 16:47       ` Derrick Stolee
2019-06-24  9:55 ` [PATCH 3/6] tree-walk.c: remove the_repo from get_tree_entry() Nguyễn Thái Ngọc Duy
2019-06-24 14:20   ` Derrick Stolee
2019-06-24 14:55     ` Duy Nguyen
2019-06-24  9:55 ` [PATCH 4/6] tree-walk.c: remove the_repo from get_tree_entry_follow_symlinks() Nguyễn Thái Ngọc Duy
2019-06-24  9:55 ` [PATCH 5/6] match-trees.c: remove the_repo from shift_tree*() Nguyễn Thái Ngọc Duy
2019-06-24  9:55 ` [PATCH 6/6] Use the right 'struct repository' instead of the_repository Nguyễn Thái Ngọc Duy
2019-06-24 14:24   ` Derrick Stolee
2019-06-24 14:45     ` Duy Nguyen
2019-06-27  9:06   ` Johannes Schindelin
2019-06-26 17:20 ` [PATCH 0/6] Kill the_repository in tree-walk.c Junio C Hamano
2019-06-27 13:04   ` Johannes Schindelin
2019-06-27 17:09     ` Derrick Stolee
2019-06-27  9:28 ` [PATCH v2 " Nguyễn Thái Ngọc Duy
2019-06-27  9:28   ` [PATCH v2 1/6] sha1-file.c: remove the_repo from read_object_with_reference() Nguyễn Thái Ngọc Duy
2019-06-28 12:46     ` Johannes Schindelin
2019-06-27  9:28   ` [PATCH v2 2/6] tree-walk.c: remove the_repo from fill_tree_descriptor() Nguyễn Thái Ngọc Duy
2019-06-27  9:28   ` [PATCH v2 3/6] tree-walk.c: remove the_repo from get_tree_entry() Nguyễn Thái Ngọc Duy
2019-06-27  9:28   ` [PATCH v2 4/6] tree-walk.c: remove the_repo from get_tree_entry_follow_symlinks() Nguyễn Thái Ngọc Duy
2019-06-27  9:28   ` [PATCH v2 5/6] match-trees.c: remove the_repo from shift_tree*() Nguyễn Thái Ngọc Duy
2019-06-27  9:28   ` [PATCH v2 6/6] Use the right 'struct repository' instead of the_repository Nguyễn Thái Ngọc Duy
2019-06-27 19:44   ` [PATCH v2 0/6] Kill the_repository in tree-walk.c Junio C Hamano
2019-06-28  9:35   ` Nguyễn Thái Ngọc Duy [this message]
2019-06-28 16:17     ` [PATCH v2 7/6] t7814: do not generate same commits in different repos Junio C Hamano

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20190628093528.20372-1-pclouds@gmail.com \
    --to=pclouds@gmail.com \
    --cc=Johannes.Schindelin@gmx.de \
    --cc=git@vger.kernel.org \
    --cc=gitster@pobox.com \
    --cc=stolee@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).