{"thread":{"id":"14418","subject":"[PATCH] t0004: fix timing bug","startedAt":"2008-07-12T11:14:52Z","lastAt":"2008-07-12T11:14:52Z","messageCount":1,"participants":["Junio C Hamano"],"isPatch":true,"patchVersion":1,"patchTotal":null},"messages":[{"id":"83071","messageId":"7vej5zwdzn.fsf@gitster.siamese.dyndns.org","threadId":"14418","inReplyTo":null,"subject":"[PATCH] t0004: fix timing bug","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2008-07-12T11:14:52Z","receivedAt":"2008-07-12T11:14:52Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"The test created an initial commit, made .git/objects unwritable and then\nexercised various codepaths to create loose commit, tree and blob objects\nto make sure the commands notice failures from these attempts.\n\nHowever, the initial commit was not preceded with test_tick, which made\nits object name depend on the timestamp.  The names of all the later tree\nand blob objects the test tried to create were static.  If the initial\ncommit's object name happened to begin with the same two hexdigits as the\ntree or blob objects the test later attempted to create, the fan-out\ndirectory in which these tree or blob would be created is already created\nwhen the initial commit was made, and the object creation succeeds, and\ncommands being tested should not notice any failure --- in short, the test\nwas bogus.\n\nThis makes the fan-out directories also unwritable, and adds test_tick\nbefore the commit object creation to make the test repeatable.\n\nThe contents of the file to create a blob from \"a\" to \"60\" is to force the\nname of the blob object to begin with \"1b\", which shares the fan-out\ndirectory with the initial commit that is created with the test.  This was\nuseful when diagnosing the breakage of this test.\n\nSigned-off-by: Junio C Hamano <gitster@pobox.com>\n---\n\n * I initially hoped that I spotted a bug in the Linux filesystem code\n   that lets a quick operation sneak past chmod that is done immediately\n   after it or something racy so that I can tease Linus with it, but no\n   such luck ;-)  Doubly embarrasing is that the test-bug is mine. \n\n t/t0004-unwritable.sh |   19 ++++++++++---------\n 1 files changed, 10 insertions(+), 9 deletions(-)\n\ndiff --git a/t/t0004-unwritable.sh b/t/t0004-unwritable.sh\nindex 9255c63..63e1217 100755\n--- a/t/t0004-unwritable.sh\n+++ b/t/t0004-unwritable.sh\n@@ -8,6 +8,7 @@ test_expect_success setup '\n \n \t>file &&\n \tgit add file &&\n+\ttest_tick &&\n \tgit commit -m initial &&\n \techo >file &&\n \tgit add file\n@@ -17,11 +18,11 @@ test_expect_success setup '\n test_expect_success 'write-tree should notice unwritable repository' '\n \n \t(\n-\t\tchmod a-w .git/objects\n+\t\tchmod a-w .git/objects .git/objects/?? &&\n \t\ttest_must_fail git write-tree\n \t)\n \tstatus=$?\n-\tchmod 775 .git/objects\n+\tchmod 775 .git/objects .git/objects/??\n \t(exit $status)\n \n '\n@@ -29,11 +30,11 @@ test_expect_success 'write-tree should notice unwritable repository' '\n test_expect_success 'commit should notice unwritable repository' '\n \n \t(\n-\t\tchmod a-w .git/objects\n+\t\tchmod a-w .git/objects .git/objects/?? &&\n \t\ttest_must_fail git commit -m second\n \t)\n \tstatus=$?\n-\tchmod 775 .git/objects\n+\tchmod 775 .git/objects .git/objects/??\n \t(exit $status)\n \n '\n@@ -41,12 +42,12 @@ test_expect_success 'commit should notice unwritable repository' '\n test_expect_success 'update-index should notice unwritable repository' '\n \n \t(\n-\t\techo a >file &&\n-\t\tchmod a-w .git/objects\n+\t\techo 6O >file &&\n+\t\tchmod a-w .git/objects .git/objects/?? &&\n \t\ttest_must_fail git update-index file\n \t)\n \tstatus=$?\n-\tchmod 775 .git/objects\n+\tchmod 775 .git/objects .git/objects/??\n \t(exit $status)\n \n '\n@@ -55,11 +56,11 @@ test_expect_success 'add should notice unwritable repository' '\n \n \t(\n \t\techo b >file &&\n-\t\tchmod a-w .git/objects\n+\t\tchmod a-w .git/objects .git/objects/?? &&\n \t\ttest_must_fail git add file\n \t)\n \tstatus=$?\n-\tchmod 775 .git/objects\n+\tchmod 775 .git/objects .git/objects/??\n \t(exit $status)\n \n '\n"}]}