]>
Commit | Line | Data |
---|---|---|
edae5f0c JH |
1 | #!/bin/sh |
2 | ||
3 | test_description='detect unwritable repository and fail correctly' | |
4 | ||
956d2e46 | 5 | TEST_PASSES_SANITIZE_LEAK=true |
edae5f0c JH |
6 | . ./test-lib.sh |
7 | ||
8 | test_expect_success setup ' | |
9 | ||
10 | >file && | |
11 | git add file && | |
329636b4 | 12 | test_tick && |
edae5f0c JH |
13 | git commit -m initial && |
14 | echo >file && | |
15 | git add file | |
16 | ||
17 | ' | |
18 | ||
c91cfd19 | 19 | test_expect_success POSIXPERM,SANITY 'write-tree should notice unwritable repository' ' |
dbda9676 JN |
20 | test_when_finished "chmod 775 .git/objects .git/objects/??" && |
21 | chmod a-w .git/objects .git/objects/?? && | |
119b26d6 ÆAB |
22 | test_must_fail git write-tree 2>out.write-tree |
23 | ' | |
24 | ||
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 | |
30 | EOF | |
31 | test_cmp expect out.write-tree | |
edae5f0c JH |
32 | ' |
33 | ||
96ecf699 | 34 | test_expect_success POSIXPERM,SANITY 'commit should notice unwritable repository' ' |
dbda9676 JN |
35 | test_when_finished "chmod 775 .git/objects .git/objects/??" && |
36 | chmod a-w .git/objects .git/objects/?? && | |
119b26d6 ÆAB |
37 | test_must_fail git commit -m second 2>out.commit |
38 | ' | |
39 | ||
40 | test_lazy_prereq COMMIT_OUT 'test -e "$TRASH_DIRECTORY"/out.commit' | |
4ef91a2d | 41 | test_expect_success COMMIT_OUT 'commit output on unwritable repository' ' |
119b26d6 ÆAB |
42 | cat >expect <<-\EOF && |
43 | error: insufficient permission for adding an object to repository database .git/objects | |
44 | error: Error building trees | |
45 | EOF | |
46 | test_cmp expect out.commit | |
edae5f0c JH |
47 | ' |
48 | ||
c91cfd19 | 49 | test_expect_success POSIXPERM,SANITY 'update-index should notice unwritable repository' ' |
dbda9676 JN |
50 | test_when_finished "chmod 775 .git/objects .git/objects/??" && |
51 | echo 6O >file && | |
52 | chmod a-w .git/objects .git/objects/?? && | |
119b26d6 ÆAB |
53 | test_must_fail git update-index file 2>out.update-index |
54 | ' | |
55 | ||
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 | |
62 | EOF | |
63 | test_cmp expect out.update-index | |
edae5f0c JH |
64 | ' |
65 | ||
c91cfd19 | 66 | test_expect_success POSIXPERM,SANITY 'add should notice unwritable repository' ' |
dbda9676 JN |
67 | test_when_finished "chmod 775 .git/objects .git/objects/??" && |
68 | echo b >file && | |
69 | chmod a-w .git/objects .git/objects/?? && | |
119b26d6 ÆAB |
70 | test_must_fail git add file 2>out.add |
71 | ' | |
72 | ||
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 | |
80 | EOF | |
81 | test_cmp expect out.add | |
edae5f0c JH |
82 | ' |
83 | ||
84 | test_done |