3 test_description
='detect unwritable repository and fail correctly'
5 TEST_PASSES_SANITIZE_LEAK
=true
8 test_expect_success setup
'
13 git commit -m initial &&
19 test_expect_success POSIXPERM
,SANITY
'write-tree should notice unwritable repository' '
20 test_when_finished "chmod 775 .git/objects .git/objects/??" &&
21 chmod a-w .git/objects .git/objects/?? &&
22 test_must_fail git write-tree 2>out.write-tree
25 test_lazy_prereq WRITE_TREE_OUT
'test -e "$TRASH_DIRECTORY"/out.write-tree'
26 test_expect_success WRITE_TREE_OUT
'write-tree output on unwritable repository' '
27 cat >expect <<-\EOF &&
28 error: insufficient permission for adding an object to repository database .git/objects
29 fatal: git-write-tree: error building trees
31 test_cmp expect out.write-tree
34 test_expect_success POSIXPERM
,SANITY
,!SANITIZE_LEAK
'commit should notice unwritable repository' '
35 test_when_finished "chmod 775 .git/objects .git/objects/??" &&
36 chmod a-w .git/objects .git/objects/?? &&
37 test_must_fail git commit -m second 2>out.commit
40 test_lazy_prereq COMMIT_OUT
'test -e "$TRASH_DIRECTORY"/out.commit'
41 test_expect_success COMMIT_OUT
'commit output on unwritable repository' '
42 cat >expect <<-\EOF &&
43 error: insufficient permission for adding an object to repository database .git/objects
44 error: Error building trees
46 test_cmp expect out.commit
49 test_expect_success POSIXPERM
,SANITY
'update-index should notice unwritable repository' '
50 test_when_finished "chmod 775 .git/objects .git/objects/??" &&
52 chmod a-w .git/objects .git/objects/?? &&
53 test_must_fail git update-index file 2>out.update-index
56 test_lazy_prereq UPDATE_INDEX_OUT
'test -e "$TRASH_DIRECTORY"/out.update-index'
57 test_expect_success UPDATE_INDEX_OUT
'update-index output on unwritable repository' '
58 cat >expect <<-\EOF &&
59 error: insufficient permission for adding an object to repository database .git/objects
60 error: file: failed to insert into database
61 fatal: Unable to process path file
63 test_cmp expect out.update-index
66 test_expect_success POSIXPERM
,SANITY
'add should notice unwritable repository' '
67 test_when_finished "chmod 775 .git/objects .git/objects/??" &&
69 chmod a-w .git/objects .git/objects/?? &&
70 test_must_fail git add file 2>out.add
73 test_lazy_prereq ADD_OUT
'test -e "$TRASH_DIRECTORY"/out.add'
74 test_expect_success ADD_OUT
'add output on unwritable repository' '
75 cat >expect <<-\EOF &&
76 error: insufficient permission for adding an object to repository database .git/objects
77 error: file: failed to insert into database
78 error: unable to index file '\''file'\''
79 fatal: updating files failed
81 test_cmp expect out.add