t1301: move modebits() to test-lib-functions.sh
As the modebits() function can be useful outside t1301, let's move it into test-lib-functions.sh, and while at it let's rename it test_modebits(). Signed-off-by: Christian Couder <chriscool@tuxfamily.org> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Christian Couder committed
Jun 25, 2017 at 06:34 UTC
73de1c93adbdac279c10668afbc7ba6e48a7ccac
2 files changed
+12
-11
t/t1301-shared-repo.sh
+7
-11
@@ -19,10 +19,6 @@ test_expect_success 'shared = 0400 (faulty permission u-w)' '
19
)
20
'
21
22
-modebits () {
23
- ls -l "$1" | sed -e 's|^\(..........\).*|\1|'
24
-}
25
-
22
for u in 002 022
23
do
24
test_expect_success POSIXPERM "shared=1 does not clear bits preset by umask $u" '
@@ -88,7 +84,7 @@ do
84
85
rm -f .git/info/refs &&
86
git update-server-info &&
91
- actual="$(modebits .git/info/refs)" &&
87
+ actual="$(test_modebits .git/info/refs)" &&
88
verbose test "x$actual" = "x-$y"
89
90
'
@@ -98,7 +94,7 @@ do
94
95
rm -f .git/info/refs &&
96
git update-server-info &&
101
- actual="$(modebits .git/info/refs)" &&
97
+ actual="$(test_modebits .git/info/refs)" &&
98
verbose test "x$actual" = "x-$x"
99
100
'
@@ -111,7 +107,7 @@ test_expect_success POSIXPERM 'info/refs respects umask in unshared repo' '
107
umask 002 &&
108
git update-server-info &&
109
echo "-rw-rw-r--" >expect &&
114
- modebits .git/info/refs >actual &&
110
+ test_modebits .git/info/refs >actual &&
111
test_cmp expect actual
112
'
113
@@ -177,7 +173,7 @@ test_expect_success POSIXPERM 'remote init does not use config from cwd' '
173
umask 0022 &&
174
git init --bare child.git &&
175
echo "-rw-r--r--" >expect &&
180
- modebits child.git/config >actual &&
176
+ test_modebits child.git/config >actual &&
177
test_cmp expect actual
178
'
179
@@ -187,7 +183,7 @@ test_expect_success POSIXPERM 're-init respects core.sharedrepository (local)' '
183
echo whatever >templates/foo &&
184
git init --template=templates &&
185
echo "-rw-rw-rw-" >expect &&
190
- modebits .git/foo >actual &&
186
+ test_modebits .git/foo >actual &&
187
test_cmp expect actual
188
'
189
@@ -198,7 +194,7 @@ test_expect_success POSIXPERM 're-init respects core.sharedrepository (remote)'
194
test_path_is_missing child.git/foo &&
195
git init --bare --template=../templates child.git &&
196
echo "-rw-rw-rw-" >expect &&
201
- modebits child.git/foo >actual &&
197
+ test_modebits child.git/foo >actual &&
198
test_cmp expect actual
199
'
200
@@ -209,7 +205,7 @@ test_expect_success POSIXPERM 'template can set core.sharedrepository' '
205
cp .git/config templates/config &&
206
git init --bare --template=../templates child.git &&
207
echo "-rw-rw-rw-" >expect &&
212
- modebits child.git/HEAD >actual &&
208
+ test_modebits child.git/HEAD >actual &&
209
test_cmp expect actual
210
'
211
t/test-lib-functions.sh
+5
@@ -216,6 +216,11 @@ test_chmod () {
216
git update-index --add "--chmod=$@"
217
}
218
219
+# Get the modebits from a file.
220
+test_modebits () {
221
+ ls -l "$1" | sed -e 's|^\(..........\).*|\1|'
222
+}
223
+
224
# Unset a configuration variable, but don't fail if it doesn't exist.
225
test_unconfig () {
226
config_dir=