Skip to content

Commit 2f960dd

Browse files
pks-tgitster
authored andcommitted
t0610: make --shared= tests reusable
We have two kinds of `--shared=` tests, one for git-init(1) and one for git-pack-refs(1). Merge them into a reusable function such that we can easily add additional testcases with different umasks and flags for the `--shared=` switch. Signed-off-by: Patrick Steinhardt <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 8a0bebd commit 2f960dd

File tree

1 file changed

+30
-27
lines changed

1 file changed

+30
-27
lines changed

t/t0610-reftable-basics.sh

Lines changed: 30 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -96,23 +96,46 @@ test_expect_perms () {
9696
esac
9797
}
9898

99-
for umask in 002 022
100-
do
101-
test_expect_success POSIXPERM 'init: honors core.sharedRepository' '
99+
test_expect_reftable_perms () {
100+
local umask="$1"
101+
local shared="$2"
102+
local expect="$3"
103+
104+
test_expect_success POSIXPERM "init: honors --shared=$shared with umask $umask" '
102105
test_when_finished "rm -rf repo" &&
103106
(
104107
umask $umask &&
105-
git init --shared=true repo &&
108+
git init --shared=$shared repo &&
106109
test 1 = "$(git -C repo config core.sharedrepository)"
107110
) &&
108-
test_expect_perms "-rw-rw-r--" repo/.git/reftable/tables.list &&
111+
test_expect_perms "$expect" repo/.git/reftable/tables.list &&
109112
for table in repo/.git/reftable/*.ref
110113
do
111-
test_expect_perms "-rw-rw-r--" "$table" ||
114+
test_expect_perms "$expect" "$table" ||
112115
return 1
113116
done
114117
'
115-
done
118+
119+
test_expect_success POSIXPERM "pack-refs: honors --shared=$shared with umask $umask" '
120+
test_when_finished "rm -rf repo" &&
121+
(
122+
umask $umask &&
123+
git init --shared=$shared repo &&
124+
test_commit -C repo A &&
125+
test_line_count = 3 repo/.git/reftable/tables.list
126+
) &&
127+
git -C repo pack-refs &&
128+
test_expect_perms "$expect" repo/.git/reftable/tables.list &&
129+
for table in repo/.git/reftable/*.ref
130+
do
131+
test_expect_perms "$expect" "$table" ||
132+
return 1
133+
done
134+
'
135+
}
136+
137+
test_expect_reftable_perms 002 true "-rw-rw-r--"
138+
test_expect_reftable_perms 022 true "-rw-rw-r--"
116139

117140
test_expect_success 'clone: can clone reftable repository' '
118141
test_when_finished "rm -rf repo clone" &&
@@ -359,26 +382,6 @@ test_expect_success 'pack-refs: does not prune non-table files' '
359382
test_path_is_file repo/.git/reftable/garbage
360383
'
361384

362-
for umask in 002 022
363-
do
364-
test_expect_success POSIXPERM 'pack-refs: honors core.sharedRepository' '
365-
test_when_finished "rm -rf repo" &&
366-
(
367-
umask $umask &&
368-
git init --shared=true repo &&
369-
test_commit -C repo A &&
370-
test_line_count = 3 repo/.git/reftable/tables.list
371-
) &&
372-
git -C repo pack-refs &&
373-
test_expect_perms "-rw-rw-r--" repo/.git/reftable/tables.list &&
374-
for table in repo/.git/reftable/*.ref
375-
do
376-
test_expect_perms "-rw-rw-r--" "$table" ||
377-
return 1
378-
done
379-
'
380-
done
381-
382385
test_expect_success 'packed-refs: writes are synced' '
383386
test_when_finished "rm -rf repo" &&
384387
git init repo &&

0 commit comments

Comments
 (0)