t4111 fails under valgrind
Hi Jonathan
t4111 never worked under valgrind on my machine, building 9f41a91 and then running it with --valgrind results in:
expecting success:
cp postimage expected &&
reset_subdir preimage other &&
(
cd sub/dir &&
test_must_fail git apply --index "$patch"
) &&
reset_subdir other preimage &&
(
cd sub/dir &&
test_must_fail git apply --index "$patch"
) &&
reset_subdir preimage preimage &&
(
cd sub/dir &&
git apply --index "$patch"
) &&
git show :sub/dir/file >actual &&
test_cmp expected actual &&
test_cmp expected sub/dir/file error: sub/dir/file: does not match index
error: sub/dir/file: does not match index
error: sub/dir/file: does not match index not ok - 5 apply --index from subdir of toplevel #
# cp postimage expected && # reset_subdir preimage other && # ( # cd sub/dir && # test_must_fail git apply --index "$patch" # ) && # reset_subdir other preimage && # ( # cd sub/dir && # test_must_fail git apply --index "$patch" # ) && # reset_subdir preimage preimage && # ( # cd sub/dir && # git apply --index "$patch" # ) && # git show :sub/dir/file >actual && # test_cmp expected actual && # test_cmp expected sub/dir/file
#
Any ideas what might be going wrong?
Signature · 2 lines
Thomas Rast
trast@{inf,student}.ethz.chQuoted 4 lines · Thomas Rast
error: sub/dir/file: does not match index
error: sub/dir/file: does not match index
error: sub/dir/file: does not match index not ok - 5 apply --index from subdir of toplevel
Thanks for reporting. Does this patch work for you?
-- 8< --
Subject: t4111 (apply): refresh index before applying patches to it
"git apply", like most plumbing, does not automatically refresh the index file even if it is only stat-dirty. So unless the two "cp" commands in reset_preimage() for a given file happen to have the same time stamp, there will be a spurious
error: sub/dir/file: does not match index
Refresh the index to eliminate this timing dependency. Noticed by running the test with --valgrind (which slows things down a lot).
---
t/t4111-apply-subdir.sh +2 -1
@@ -36,7 +36,8 @@ test_expect_success 'setup: subdir' ' cp "$2" file && cp "$2" sub/dir/file && cp "$2" sub/dir/b/file && - cp "$2" objects/file + cp "$2" objects/file && + test_might_fail git update-index --refresh -q } '
Quoted 1 line · Jonathan Nieder
Thanks for reporting. Does this patch work for you?
[...]
t/t4111-apply-subdir.sh test_expect_success 'setup: subdir' ' · line 40
Quoted 3 lines
t/t4111-apply-subdir.sh +2
-1- cp "$2" objects/file + cp "$2" objects/file && + test_might_fail git update-index --refresh -q
Yes, that solves it. Thanks!
Signature · 2 lines
Thomas Rast
trast@{inf,student}.ethz.chQuoted 21 lines · Jonathan Nieder
-- 8< --
Subject: t4111 (apply): refresh index before applying patches to it"git apply", like most plumbing, does not automatically refresh the index file even if it is only stat-dirty. So unless the two "cp" commands in
reset_preimage()for a given file happen to have the same time stamp, there will be a spuriouserror: sub/dir/file: does not match index
Refresh the index to eliminate this timing dependency. Noticed by running the test with --valgrind (which slows things down a lot).
Reported-by Thomas Rast <[email protected]>Signed-off-by Jonathan Nieder <[email protected]>---
t/t4111-apply-subdir.sh +0
-0
t/t4111-apply-subdir.sh test_expect_success 'setup: subdir' ' · line 42
Quoted 8 lines
t/t4111-apply-subdir.sh +2
-1@@ -36,7 +36,8 @@ test_expect_success 'setup: subdir' ' cp "$2" file && cp "$2" sub/dir/file && cp "$2" sub/dir/b/file && - cp "$2" objects/file + cp "$2" objects/file && + test_might_fail git update-index --refresh -q } '
Junio, can you pick this up? t4111 consistently fails for me without it.
Signature · 2 lines
Thomas Rast
trast@{inf,student}.ethz.ch