Skip to content

Commit 73de1c9

Browse files
chriscoolgitster
authored andcommitted
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 <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent df801f3 commit 73de1c9

File tree

2 files changed

+12
-11
lines changed

2 files changed

+12
-11
lines changed

t/t1301-shared-repo.sh

Lines changed: 7 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -19,10 +19,6 @@ test_expect_success 'shared = 0400 (faulty permission u-w)' '
1919
)
2020
'
2121

22-
modebits () {
23-
ls -l "$1" | sed -e 's|^\(..........\).*|\1|'
24-
}
25-
2622
for u in 002 022
2723
do
2824
test_expect_success POSIXPERM "shared=1 does not clear bits preset by umask $u" '
@@ -88,7 +84,7 @@ do
8884
8985
rm -f .git/info/refs &&
9086
git update-server-info &&
91-
actual="$(modebits .git/info/refs)" &&
87+
actual="$(test_modebits .git/info/refs)" &&
9288
verbose test "x$actual" = "x-$y"
9389
9490
'
@@ -98,7 +94,7 @@ do
9894
9995
rm -f .git/info/refs &&
10096
git update-server-info &&
101-
actual="$(modebits .git/info/refs)" &&
97+
actual="$(test_modebits .git/info/refs)" &&
10298
verbose test "x$actual" = "x-$x"
10399
104100
'
@@ -111,7 +107,7 @@ test_expect_success POSIXPERM 'info/refs respects umask in unshared repo' '
111107
umask 002 &&
112108
git update-server-info &&
113109
echo "-rw-rw-r--" >expect &&
114-
modebits .git/info/refs >actual &&
110+
test_modebits .git/info/refs >actual &&
115111
test_cmp expect actual
116112
'
117113

@@ -177,7 +173,7 @@ test_expect_success POSIXPERM 'remote init does not use config from cwd' '
177173
umask 0022 &&
178174
git init --bare child.git &&
179175
echo "-rw-r--r--" >expect &&
180-
modebits child.git/config >actual &&
176+
test_modebits child.git/config >actual &&
181177
test_cmp expect actual
182178
'
183179

@@ -187,7 +183,7 @@ test_expect_success POSIXPERM 're-init respects core.sharedrepository (local)' '
187183
echo whatever >templates/foo &&
188184
git init --template=templates &&
189185
echo "-rw-rw-rw-" >expect &&
190-
modebits .git/foo >actual &&
186+
test_modebits .git/foo >actual &&
191187
test_cmp expect actual
192188
'
193189

@@ -198,7 +194,7 @@ test_expect_success POSIXPERM 're-init respects core.sharedrepository (remote)'
198194
test_path_is_missing child.git/foo &&
199195
git init --bare --template=../templates child.git &&
200196
echo "-rw-rw-rw-" >expect &&
201-
modebits child.git/foo >actual &&
197+
test_modebits child.git/foo >actual &&
202198
test_cmp expect actual
203199
'
204200

@@ -209,7 +205,7 @@ test_expect_success POSIXPERM 'template can set core.sharedrepository' '
209205
cp .git/config templates/config &&
210206
git init --bare --template=../templates child.git &&
211207
echo "-rw-rw-rw-" >expect &&
212-
modebits child.git/HEAD >actual &&
208+
test_modebits child.git/HEAD >actual &&
213209
test_cmp expect actual
214210
'
215211

t/test-lib-functions.sh

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -216,6 +216,11 @@ test_chmod () {
216216
git update-index --add "--chmod=$@"
217217
}
218218

219+
# Get the modebits from a file.
220+
test_modebits () {
221+
ls -l "$1" | sed -e 's|^\(..........\).*|\1|'
222+
}
223+
219224
# Unset a configuration variable, but don't fail if it doesn't exist.
220225
test_unconfig () {
221226
config_dir=

0 commit comments

Comments
 (0)