Skip to content

Commit f4d6284

Browse files
ttaylorrgitster
authored andcommitted
commit-graph.c: ensure graph layers respect core.sharedRepository
Non-layered commit-graphs use 'adjust_shared_perm' to make the commit-graph file readable (or not) to a combination of the user, group, and others. Call 'adjust_shared_perm' for split-graph layers to make sure that these also respect 'core.sharedRepository'. The 'commit-graph-chain' file already respects this configuration since it uses 'hold_lock_file_for_update' (which calls 'adjust_shared_perm' eventually in 'create_tempfile_mode'). Suggested-by: Junio C Hamano <[email protected]> Signed-off-by: Taylor Blau <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 1f9beca commit f4d6284

File tree

2 files changed

+28
-0
lines changed

2 files changed

+28
-0
lines changed

commit-graph.c

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1386,6 +1386,12 @@ static int write_commit_graph_file(struct write_commit_graph_context *ctx)
13861386
return -1;
13871387
}
13881388

1389+
if (adjust_shared_perm(ctx->graph_name)) {
1390+
error(_("unable to adjust shared permissions for '%s'"),
1391+
ctx->graph_name);
1392+
return -1;
1393+
}
1394+
13891395
f = hashfd(fd, ctx->graph_name);
13901396
} else {
13911397
hold_lock_file_for_update_mode(&lk, ctx->graph_name,

t/t5324-split-commit-graph.sh

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,10 @@ graph_read_expect() {
3636
test_cmp expect output
3737
}
3838

39+
test_expect_success POSIXPERM 'tweak umask for modebit tests' '
40+
umask 022
41+
'
42+
3943
test_expect_success 'create commits and write commit-graph' '
4044
for i in $(test_seq 3)
4145
do
@@ -351,4 +355,22 @@ test_expect_success 'split across alternate where alternate is not split' '
351355
test_cmp commit-graph .git/objects/info/commit-graph
352356
'
353357

358+
while read mode modebits
359+
do
360+
test_expect_success POSIXPERM "split commit-graph respects core.sharedrepository $mode" '
361+
rm -rf $graphdir $infodir/commit-graph &&
362+
git reset --hard commits/1 &&
363+
test_config core.sharedrepository "$mode" &&
364+
git commit-graph write --split --reachable &&
365+
ls $graphdir/graph-*.graph >graph-files &&
366+
test_line_count = 1 graph-files &&
367+
echo "$modebits" >expect &&
368+
test_modebits $graphdir/graph-*.graph >actual &&
369+
test_cmp expect actual
370+
'
371+
done <<\EOF
372+
0666 -r--r--r--
373+
0600 -r--------
374+
EOF
375+
354376
test_done

0 commit comments

Comments
 (0)