summaryrefslogtreecommitdiff
path: root/t/t0004-unwritable.sh
diff options
context:
space:
mode:
Diffstat (limited to 't/t0004-unwritable.sh')
-rwxr-xr-xt/t0004-unwritable.sh68
1 files changed, 68 insertions, 0 deletions
diff --git a/t/t0004-unwritable.sh b/t/t0004-unwritable.sh
new file mode 100755
index 0000000..2342ac5
--- /dev/null
+++ b/t/t0004-unwritable.sh
@@ -0,0 +1,68 @@
+#!/bin/sh
+
+test_description='detect unwritable repository and fail correctly'
+
+. ./test-lib.sh
+
+test_expect_success setup '
+
+ >file &&
+ git add file &&
+ test_tick &&
+ git commit -m initial &&
+ echo >file &&
+ git add file
+
+'
+
+test_expect_success POSIXPERM 'write-tree should notice unwritable repository' '
+
+ (
+ chmod a-w .git/objects .git/objects/?? &&
+ test_must_fail git write-tree
+ )
+ status=$?
+ chmod 775 .git/objects .git/objects/??
+ (exit $status)
+
+'
+
+test_expect_success POSIXPERM 'commit should notice unwritable repository' '
+
+ (
+ chmod a-w .git/objects .git/objects/?? &&
+ test_must_fail git commit -m second
+ )
+ status=$?
+ chmod 775 .git/objects .git/objects/??
+ (exit $status)
+
+'
+
+test_expect_success POSIXPERM 'update-index should notice unwritable repository' '
+
+ (
+ echo 6O >file &&
+ chmod a-w .git/objects .git/objects/?? &&
+ test_must_fail git update-index file
+ )
+ status=$?
+ chmod 775 .git/objects .git/objects/??
+ (exit $status)
+
+'
+
+test_expect_success POSIXPERM 'add should notice unwritable repository' '
+
+ (
+ echo b >file &&
+ chmod a-w .git/objects .git/objects/?? &&
+ test_must_fail git add file
+ )
+ status=$?
+ chmod 775 .git/objects .git/objects/??
+ (exit $status)
+
+'
+
+test_done