]> git.ipfire.org Git - thirdparty/git.git/commitdiff
commit-graph.c: make 'commit-graph-chain's read-only
authorTaylor Blau <me@ttaylorr.com>
Wed, 29 Apr 2020 17:36:46 +0000 (11:36 -0600)
committerJunio C Hamano <gitster@pobox.com>
Wed, 29 Apr 2020 19:35:30 +0000 (12:35 -0700)
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 <me@ttaylorr.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
commit-graph.c
t/t5324-split-commit-graph.sh

index d05a55901d886c537d39ca45c994344ffc9bfedf..b2dfd7701f234a157c87901bf5b358cbe19a80b5 100644 (file)
@@ -1378,7 +1378,8 @@ static int write_commit_graph_file(struct write_commit_graph_context *ctx)
        if (ctx->split) {
                char *lock_name = get_chain_filename(ctx->odb);
 
-               hold_lock_file_for_update(&lk, lock_name, LOCK_DIE_ON_ERROR);
+               hold_lock_file_for_update_mode(&lk, lock_name,
+                                              LOCK_DIE_ON_ERROR, 0444);
 
                fd = git_mkstemp_mode(ctx->graph_name, 0444);
                if (fd < 0) {
index 699c23d0771f5e273fdb320233034c6a353b9998..cff5a41f48d01086cdc917dd1e9dc4c1090f1ec0 100755 (executable)
@@ -366,6 +366,8 @@ do
                test_line_count = 1 graph-files &&
                echo "$modebits" >expect &&
                test_modebits $graphdir/graph-*.graph >actual &&
+               test_cmp expect actual &&
+               test_modebits $graphdir/commit-graph-chain >actual &&
                test_cmp expect actual
        '
 done <<\EOF