1
0
Fork 0
mirror of https://github.com/git/git.git synced 2024-05-12 23:26:09 +02:00

Merge branch 'ps/reftable-compacted-tables-permission-fix'

Reftable bugfix.

* ps/reftable-compacted-tables-permission-fix:
  reftable/stack: adjust permissions of compacted tables
This commit is contained in:
Junio C Hamano 2024-02-06 14:31:20 -08:00
commit 0f4e178a4f
2 changed files with 29 additions and 2 deletions

View File

@ -849,6 +849,12 @@ static int stack_compact_locked(struct reftable_stack *st, int first, int last,
strbuf_addstr(temp_tab, ".temp.XXXXXX");
tab_fd = mkstemp(temp_tab->buf);
if (st->config.default_permissions &&
chmod(temp_tab->buf, st->config.default_permissions) < 0) {
err = REFTABLE_IO_ERROR;
goto done;
}
wr = reftable_new_writer(reftable_fd_write, reftable_fd_flush, &tab_fd, &st->config);
err = stack_write_compact(st, wr, first, last, config);

View File

@ -443,15 +443,16 @@ static void test_reftable_stack_add(void)
int err = 0;
struct reftable_write_options cfg = {
.exact_log_message = 1,
.default_permissions = 0660,
};
struct reftable_stack *st = NULL;
char *dir = get_tmp_dir(__LINE__);
struct reftable_ref_record refs[2] = { { NULL } };
struct reftable_log_record logs[2] = { { NULL } };
struct strbuf path = STRBUF_INIT;
struct stat stat_result;
int N = ARRAY_SIZE(refs);
err = reftable_new_stack(&st, dir, cfg);
EXPECT_ERR(err);
st->disable_auto_compact = 1;
@ -509,12 +510,32 @@ static void test_reftable_stack_add(void)
reftable_log_record_release(&dest);
}
#ifndef GIT_WINDOWS_NATIVE
strbuf_addstr(&path, dir);
strbuf_addstr(&path, "/tables.list");
err = stat(path.buf, &stat_result);
EXPECT(!err);
EXPECT((stat_result.st_mode & 0777) == cfg.default_permissions);
strbuf_reset(&path);
strbuf_addstr(&path, dir);
strbuf_addstr(&path, "/");
/* do not try at home; not an external API for reftable. */
strbuf_addstr(&path, st->readers[0]->name);
err = stat(path.buf, &stat_result);
EXPECT(!err);
EXPECT((stat_result.st_mode & 0777) == cfg.default_permissions);
#else
(void) stat_result;
#endif
/* cleanup */
reftable_stack_destroy(st);
for (i = 0; i < N; i++) {
reftable_ref_record_release(&refs[i]);
reftable_log_record_release(&logs[i]);
}
strbuf_release(&path);
clear_dir(dir);
}