Skip to content

Commit 45a4365

Browse files
ttaylorrgitster
authored andcommitted
commit-graph.c: make 'commit-graph-chain's read-only
In a previous commit, we made incremental graph layers read-only by using 'git_mkstemp_mode' with permissions '0444'. There is no reason that 'commit-graph-chain's should be modifiable by the user, since they are generated at a temporary location and then atomically renamed into place. To ensure that these files are read-only, too, use 'hold_lock_file_for_update_mode' with the same read-only permission bits, and let the umask and 'adjust_shared_perm' take care of the rest. Signed-off-by: Taylor Blau <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent f4d6284 commit 45a4365

File tree

2 files changed

+4
-1
lines changed

2 files changed

+4
-1
lines changed

commit-graph.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1378,7 +1378,8 @@ static int write_commit_graph_file(struct write_commit_graph_context *ctx)
13781378
if (ctx->split) {
13791379
char *lock_name = get_chain_filename(ctx->odb);
13801380

1381-
hold_lock_file_for_update(&lk, lock_name, LOCK_DIE_ON_ERROR);
1381+
hold_lock_file_for_update_mode(&lk, lock_name,
1382+
LOCK_DIE_ON_ERROR, 0444);
13821383

13831384
fd = git_mkstemp_mode(ctx->graph_name, 0444);
13841385
if (fd < 0) {

t/t5324-split-commit-graph.sh

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -366,6 +366,8 @@ do
366366
test_line_count = 1 graph-files &&
367367
echo "$modebits" >expect &&
368368
test_modebits $graphdir/graph-*.graph >actual &&
369+
test_cmp expect actual &&
370+
test_modebits $graphdir/commit-graph-chain >actual &&
369371
test_cmp expect actual
370372
'
371373
done <<\EOF

0 commit comments

Comments
 (0)