path: root/t/
diff options
authorJunio C Hamano <>2018-06-15 18:13:39 (GMT)
committerJunio C Hamano <>2018-06-15 18:20:08 (GMT)
commit037714252f74ae77e816018e43b2504a1b057246 (patch)
treeb50cad99709711c60d673be889481447226930e3 /t/
parentfc54c1af3ec09bab8b8ea09768c2da4069b7f53e (diff)
tests: clean after SANITY tests
Some of our tests try to make sure Git behaves sensibly in a read-only directory, by dropping 'w' permission bit before doing a test and then restoring it after it is done. The latter is needed for the test framework to clean after itself without leaving a leftover directory that cannot be removed. Ancient parts of tests however arrange the above with chmod a-w . && ... do the test ... status=$? chmod 775 . (exit $status) which obviously would not work if the test somehow dies before it has the chance to do "chmod 775". Rewrite them by following a more robust pattern recently written tests use, which is test_when_finished "chmod 775 ." && chmod a-w . && ... do the test ... Signed-off-by: Junio C Hamano <>
Diffstat (limited to 't/')
1 files changed, 1 insertions, 3 deletions
diff --git a/t/ b/t/
index 50052e2..10b084d 100755
--- a/t/
+++ b/t/
@@ -1099,6 +1099,7 @@ EOF
test_expect_success POSIXPERM,SANITY 'status succeeds in a read-only repository' '
+ test_when_finished "chmod 775 .git" &&
chmod a-w .git &&
# make dir1/tracked stat-dirty
@@ -1108,9 +1109,6 @@ test_expect_success POSIXPERM,SANITY 'status succeeds in a read-only repository'
# make sure "status" succeeded without writing index out
git diff-files | grep dir1/tracked
- status=$?
- chmod 775 .git
- (exit $status)
(cd sm && echo > bar && git add bar && git commit -q -m 'Add bar') && git add sm