@@ -96,23 +96,54 @@ 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 &&
106- test 1 = "$(git -C repo config core.sharedrepository)"
108+ git init --shared=$shared repo
107109 ) &&
108- test_expect_perms "-rw-rw-r-- " repo/.git/reftable/tables.list &&
110+ test_expect_perms "$expect " repo/.git/reftable/tables.list &&
109111 for table in repo/.git/reftable/*.ref
110112 do
111- test_expect_perms "-rw-rw-r-- " "$table" ||
113+ test_expect_perms "$expect " "$table" ||
112114 return 1
113115 done
114116 '
115- done
117+
118+ test_expect_success POSIXPERM " pack-refs: honors --shared=$shared with umask $umask " '
119+ test_when_finished "rm -rf repo" &&
120+ (
121+ umask $umask &&
122+ git init --shared=$shared repo &&
123+ test_commit -C repo A &&
124+ test_line_count = 3 repo/.git/reftable/tables.list &&
125+ git -C repo pack-refs
126+ ) &&
127+ test_expect_perms "$expect" repo/.git/reftable/tables.list &&
128+ for table in repo/.git/reftable/*.ref
129+ do
130+ test_expect_perms "$expect" "$table" ||
131+ return 1
132+ done
133+ '
134+ }
135+
136+ test_expect_reftable_perms 002 umask " -rw-rw-r--"
137+ test_expect_reftable_perms 022 umask " -rw-r--r--"
138+ test_expect_reftable_perms 027 umask " -rw-r-----"
139+
140+ test_expect_reftable_perms 002 group " -rw-rw-r--"
141+ test_expect_reftable_perms 022 group " -rw-rw-r--"
142+ test_expect_reftable_perms 027 group " -rw-rw----"
143+
144+ test_expect_reftable_perms 002 world " -rw-rw-r--"
145+ test_expect_reftable_perms 022 world " -rw-rw-r--"
146+ test_expect_reftable_perms 027 world " -rw-rw-r--"
116147
117148test_expect_success ' clone: can clone reftable repository' '
118149 test_when_finished "rm -rf repo clone" &&
@@ -450,26 +481,6 @@ test_expect_success 'pack-refs: does not prune non-table files' '
450481 test_path_is_file repo/.git/reftable/garbage
451482'
452483
453- for umask in 002 022
454- do
455- test_expect_success POSIXPERM ' pack-refs: honors core.sharedRepository' '
456- test_when_finished "rm -rf repo" &&
457- (
458- umask $umask &&
459- git init --shared=true repo &&
460- test_commit -C repo A &&
461- test_line_count = 3 repo/.git/reftable/tables.list
462- ) &&
463- git -C repo pack-refs &&
464- test_expect_perms "-rw-rw-r--" repo/.git/reftable/tables.list &&
465- for table in repo/.git/reftable/*.ref
466- do
467- test_expect_perms "-rw-rw-r--" "$table" ||
468- return 1
469- done
470- '
471- done
472-
473484test_expect_success ' packed-refs: writes are synced' '
474485 test_when_finished "rm -rf repo" &&
475486 git init repo &&
0 commit comments