reftable: consistently refer to reftable_write_options
as opts
Throughout the reftable library the `reftable_write_options` are sometimes referred to as `cfg` and sometimes as `opts`. Unify these to consistently use `opts` to avoid confusion. While at it, touch up the coding style a bit by removing unneeded braces around one-line statements and newlines between variable declarations. Signed-off-by: Patrick Steinhardt <ps@pks.im> Signed-off-by: Junio C Hamano <gitster@pobox.com>
This commit is contained in:

committed by
Junio C Hamano

parent
0f3415f1f8
commit
4d35bb2aba
@ -150,7 +150,7 @@ static void test_reftable_stack_add_one(void)
|
||||
char *dir = get_tmp_dir(__LINE__);
|
||||
struct strbuf scratch = STRBUF_INIT;
|
||||
int mask = umask(002);
|
||||
struct reftable_write_options cfg = {
|
||||
struct reftable_write_options opts = {
|
||||
.default_permissions = 0660,
|
||||
};
|
||||
struct reftable_stack *st = NULL;
|
||||
@ -163,7 +163,7 @@ static void test_reftable_stack_add_one(void)
|
||||
};
|
||||
struct reftable_ref_record dest = { NULL };
|
||||
struct stat stat_result = { 0 };
|
||||
err = reftable_new_stack(&st, dir, cfg);
|
||||
err = reftable_new_stack(&st, dir, opts);
|
||||
EXPECT_ERR(err);
|
||||
|
||||
err = reftable_stack_add(st, &write_test_ref, &ref);
|
||||
@ -186,7 +186,7 @@ static void test_reftable_stack_add_one(void)
|
||||
strbuf_addstr(&scratch, "/tables.list");
|
||||
err = stat(scratch.buf, &stat_result);
|
||||
EXPECT(!err);
|
||||
EXPECT((stat_result.st_mode & 0777) == cfg.default_permissions);
|
||||
EXPECT((stat_result.st_mode & 0777) == opts.default_permissions);
|
||||
|
||||
strbuf_reset(&scratch);
|
||||
strbuf_addstr(&scratch, dir);
|
||||
@ -195,7 +195,7 @@ static void test_reftable_stack_add_one(void)
|
||||
strbuf_addstr(&scratch, st->readers[0]->name);
|
||||
err = stat(scratch.buf, &stat_result);
|
||||
EXPECT(!err);
|
||||
EXPECT((stat_result.st_mode & 0777) == cfg.default_permissions);
|
||||
EXPECT((stat_result.st_mode & 0777) == opts.default_permissions);
|
||||
#else
|
||||
(void) stat_result;
|
||||
#endif
|
||||
@ -209,7 +209,7 @@ static void test_reftable_stack_add_one(void)
|
||||
|
||||
static void test_reftable_stack_uptodate(void)
|
||||
{
|
||||
struct reftable_write_options cfg = { 0 };
|
||||
struct reftable_write_options opts = { 0 };
|
||||
struct reftable_stack *st1 = NULL;
|
||||
struct reftable_stack *st2 = NULL;
|
||||
char *dir = get_tmp_dir(__LINE__);
|
||||
@ -232,10 +232,10 @@ static void test_reftable_stack_uptodate(void)
|
||||
/* simulate multi-process access to the same stack
|
||||
by creating two stacks for the same directory.
|
||||
*/
|
||||
err = reftable_new_stack(&st1, dir, cfg);
|
||||
err = reftable_new_stack(&st1, dir, opts);
|
||||
EXPECT_ERR(err);
|
||||
|
||||
err = reftable_new_stack(&st2, dir, cfg);
|
||||
err = reftable_new_stack(&st2, dir, opts);
|
||||
EXPECT_ERR(err);
|
||||
|
||||
err = reftable_stack_add(st1, &write_test_ref, &ref1);
|
||||
@ -257,8 +257,7 @@ static void test_reftable_stack_uptodate(void)
|
||||
static void test_reftable_stack_transaction_api(void)
|
||||
{
|
||||
char *dir = get_tmp_dir(__LINE__);
|
||||
|
||||
struct reftable_write_options cfg = { 0 };
|
||||
struct reftable_write_options opts = { 0 };
|
||||
struct reftable_stack *st = NULL;
|
||||
int err;
|
||||
struct reftable_addition *add = NULL;
|
||||
@ -271,8 +270,7 @@ static void test_reftable_stack_transaction_api(void)
|
||||
};
|
||||
struct reftable_ref_record dest = { NULL };
|
||||
|
||||
|
||||
err = reftable_new_stack(&st, dir, cfg);
|
||||
err = reftable_new_stack(&st, dir, opts);
|
||||
EXPECT_ERR(err);
|
||||
|
||||
reftable_addition_destroy(add);
|
||||
@ -301,12 +299,12 @@ static void test_reftable_stack_transaction_api(void)
|
||||
static void test_reftable_stack_transaction_api_performs_auto_compaction(void)
|
||||
{
|
||||
char *dir = get_tmp_dir(__LINE__);
|
||||
struct reftable_write_options cfg = {0};
|
||||
struct reftable_write_options opts = {0};
|
||||
struct reftable_addition *add = NULL;
|
||||
struct reftable_stack *st = NULL;
|
||||
int i, n = 20, err;
|
||||
|
||||
err = reftable_new_stack(&st, dir, cfg);
|
||||
err = reftable_new_stack(&st, dir, opts);
|
||||
EXPECT_ERR(err);
|
||||
|
||||
for (i = 0; i <= n; i++) {
|
||||
@ -325,7 +323,7 @@ static void test_reftable_stack_transaction_api_performs_auto_compaction(void)
|
||||
* we can ensure that we indeed honor this setting and have
|
||||
* better control over when exactly auto compaction runs.
|
||||
*/
|
||||
st->config.disable_auto_compact = i != n;
|
||||
st->opts.disable_auto_compact = i != n;
|
||||
|
||||
err = reftable_stack_new_addition(&add, st);
|
||||
EXPECT_ERR(err);
|
||||
@ -361,13 +359,13 @@ static void test_reftable_stack_auto_compaction_fails_gracefully(void)
|
||||
.value_type = REFTABLE_REF_VAL1,
|
||||
.value.val1 = {0x01},
|
||||
};
|
||||
struct reftable_write_options cfg = {0};
|
||||
struct reftable_write_options opts = {0};
|
||||
struct reftable_stack *st;
|
||||
struct strbuf table_path = STRBUF_INIT;
|
||||
char *dir = get_tmp_dir(__LINE__);
|
||||
int err;
|
||||
|
||||
err = reftable_new_stack(&st, dir, cfg);
|
||||
err = reftable_new_stack(&st, dir, opts);
|
||||
EXPECT_ERR(err);
|
||||
|
||||
err = reftable_stack_add(st, write_test_ref, &ref);
|
||||
@ -404,8 +402,7 @@ static int write_error(struct reftable_writer *wr, void *arg)
|
||||
static void test_reftable_stack_update_index_check(void)
|
||||
{
|
||||
char *dir = get_tmp_dir(__LINE__);
|
||||
|
||||
struct reftable_write_options cfg = { 0 };
|
||||
struct reftable_write_options opts = { 0 };
|
||||
struct reftable_stack *st = NULL;
|
||||
int err;
|
||||
struct reftable_ref_record ref1 = {
|
||||
@ -421,7 +418,7 @@ static void test_reftable_stack_update_index_check(void)
|
||||
.value.symref = "master",
|
||||
};
|
||||
|
||||
err = reftable_new_stack(&st, dir, cfg);
|
||||
err = reftable_new_stack(&st, dir, opts);
|
||||
EXPECT_ERR(err);
|
||||
|
||||
err = reftable_stack_add(st, &write_test_ref, &ref1);
|
||||
@ -436,12 +433,11 @@ static void test_reftable_stack_update_index_check(void)
|
||||
static void test_reftable_stack_lock_failure(void)
|
||||
{
|
||||
char *dir = get_tmp_dir(__LINE__);
|
||||
|
||||
struct reftable_write_options cfg = { 0 };
|
||||
struct reftable_write_options opts = { 0 };
|
||||
struct reftable_stack *st = NULL;
|
||||
int err, i;
|
||||
|
||||
err = reftable_new_stack(&st, dir, cfg);
|
||||
err = reftable_new_stack(&st, dir, opts);
|
||||
EXPECT_ERR(err);
|
||||
for (i = -1; i != REFTABLE_EMPTY_TABLE_ERROR; i--) {
|
||||
err = reftable_stack_add(st, &write_error, &i);
|
||||
@ -456,7 +452,7 @@ static void test_reftable_stack_add(void)
|
||||
{
|
||||
int i = 0;
|
||||
int err = 0;
|
||||
struct reftable_write_options cfg = {
|
||||
struct reftable_write_options opts = {
|
||||
.exact_log_message = 1,
|
||||
.default_permissions = 0660,
|
||||
.disable_auto_compact = 1,
|
||||
@ -469,7 +465,7 @@ static void test_reftable_stack_add(void)
|
||||
struct stat stat_result;
|
||||
int N = ARRAY_SIZE(refs);
|
||||
|
||||
err = reftable_new_stack(&st, dir, cfg);
|
||||
err = reftable_new_stack(&st, dir, opts);
|
||||
EXPECT_ERR(err);
|
||||
|
||||
for (i = 0; i < N; i++) {
|
||||
@ -528,7 +524,7 @@ static void test_reftable_stack_add(void)
|
||||
strbuf_addstr(&path, "/tables.list");
|
||||
err = stat(path.buf, &stat_result);
|
||||
EXPECT(!err);
|
||||
EXPECT((stat_result.st_mode & 0777) == cfg.default_permissions);
|
||||
EXPECT((stat_result.st_mode & 0777) == opts.default_permissions);
|
||||
|
||||
strbuf_reset(&path);
|
||||
strbuf_addstr(&path, dir);
|
||||
@ -537,7 +533,7 @@ static void test_reftable_stack_add(void)
|
||||
strbuf_addstr(&path, st->readers[0]->name);
|
||||
err = stat(path.buf, &stat_result);
|
||||
EXPECT(!err);
|
||||
EXPECT((stat_result.st_mode & 0777) == cfg.default_permissions);
|
||||
EXPECT((stat_result.st_mode & 0777) == opts.default_permissions);
|
||||
#else
|
||||
(void) stat_result;
|
||||
#endif
|
||||
@ -555,7 +551,7 @@ static void test_reftable_stack_add(void)
|
||||
static void test_reftable_stack_log_normalize(void)
|
||||
{
|
||||
int err = 0;
|
||||
struct reftable_write_options cfg = {
|
||||
struct reftable_write_options opts = {
|
||||
0,
|
||||
};
|
||||
struct reftable_stack *st = NULL;
|
||||
@ -579,7 +575,7 @@ static void test_reftable_stack_log_normalize(void)
|
||||
.update_index = 1,
|
||||
};
|
||||
|
||||
err = reftable_new_stack(&st, dir, cfg);
|
||||
err = reftable_new_stack(&st, dir, opts);
|
||||
EXPECT_ERR(err);
|
||||
|
||||
input.value.update.message = "one\ntwo";
|
||||
@ -612,8 +608,7 @@ static void test_reftable_stack_tombstone(void)
|
||||
{
|
||||
int i = 0;
|
||||
char *dir = get_tmp_dir(__LINE__);
|
||||
|
||||
struct reftable_write_options cfg = { 0 };
|
||||
struct reftable_write_options opts = { 0 };
|
||||
struct reftable_stack *st = NULL;
|
||||
int err;
|
||||
struct reftable_ref_record refs[2] = { { NULL } };
|
||||
@ -622,8 +617,7 @@ static void test_reftable_stack_tombstone(void)
|
||||
struct reftable_ref_record dest = { NULL };
|
||||
struct reftable_log_record log_dest = { NULL };
|
||||
|
||||
|
||||
err = reftable_new_stack(&st, dir, cfg);
|
||||
err = reftable_new_stack(&st, dir, opts);
|
||||
EXPECT_ERR(err);
|
||||
|
||||
/* even entries add the refs, odd entries delete them. */
|
||||
@ -691,8 +685,7 @@ static void test_reftable_stack_tombstone(void)
|
||||
static void test_reftable_stack_hash_id(void)
|
||||
{
|
||||
char *dir = get_tmp_dir(__LINE__);
|
||||
|
||||
struct reftable_write_options cfg = { 0 };
|
||||
struct reftable_write_options opts = { 0 };
|
||||
struct reftable_stack *st = NULL;
|
||||
int err;
|
||||
|
||||
@ -702,24 +695,24 @@ static void test_reftable_stack_hash_id(void)
|
||||
.value.symref = "target",
|
||||
.update_index = 1,
|
||||
};
|
||||
struct reftable_write_options cfg32 = { .hash_id = GIT_SHA256_FORMAT_ID };
|
||||
struct reftable_write_options opts32 = { .hash_id = GIT_SHA256_FORMAT_ID };
|
||||
struct reftable_stack *st32 = NULL;
|
||||
struct reftable_write_options cfg_default = { 0 };
|
||||
struct reftable_write_options opts_default = { 0 };
|
||||
struct reftable_stack *st_default = NULL;
|
||||
struct reftable_ref_record dest = { NULL };
|
||||
|
||||
err = reftable_new_stack(&st, dir, cfg);
|
||||
err = reftable_new_stack(&st, dir, opts);
|
||||
EXPECT_ERR(err);
|
||||
|
||||
err = reftable_stack_add(st, &write_test_ref, &ref);
|
||||
EXPECT_ERR(err);
|
||||
|
||||
/* can't read it with the wrong hash ID. */
|
||||
err = reftable_new_stack(&st32, dir, cfg32);
|
||||
err = reftable_new_stack(&st32, dir, opts32);
|
||||
EXPECT(err == REFTABLE_FORMAT_ERROR);
|
||||
|
||||
/* check that we can read it back with default config too. */
|
||||
err = reftable_new_stack(&st_default, dir, cfg_default);
|
||||
/* check that we can read it back with default opts too. */
|
||||
err = reftable_new_stack(&st_default, dir, opts_default);
|
||||
EXPECT_ERR(err);
|
||||
|
||||
err = reftable_stack_read_ref(st_default, "master", &dest);
|
||||
@ -752,8 +745,7 @@ static void test_suggest_compaction_segment_nothing(void)
|
||||
static void test_reflog_expire(void)
|
||||
{
|
||||
char *dir = get_tmp_dir(__LINE__);
|
||||
|
||||
struct reftable_write_options cfg = { 0 };
|
||||
struct reftable_write_options opts = { 0 };
|
||||
struct reftable_stack *st = NULL;
|
||||
struct reftable_log_record logs[20] = { { NULL } };
|
||||
int N = ARRAY_SIZE(logs) - 1;
|
||||
@ -764,8 +756,7 @@ static void test_reflog_expire(void)
|
||||
};
|
||||
struct reftable_log_record log = { NULL };
|
||||
|
||||
|
||||
err = reftable_new_stack(&st, dir, cfg);
|
||||
err = reftable_new_stack(&st, dir, opts);
|
||||
EXPECT_ERR(err);
|
||||
|
||||
for (i = 1; i <= N; i++) {
|
||||
@ -828,21 +819,19 @@ static int write_nothing(struct reftable_writer *wr, void *arg)
|
||||
|
||||
static void test_empty_add(void)
|
||||
{
|
||||
struct reftable_write_options cfg = { 0 };
|
||||
struct reftable_write_options opts = { 0 };
|
||||
struct reftable_stack *st = NULL;
|
||||
int err;
|
||||
char *dir = get_tmp_dir(__LINE__);
|
||||
|
||||
struct reftable_stack *st2 = NULL;
|
||||
|
||||
|
||||
err = reftable_new_stack(&st, dir, cfg);
|
||||
err = reftable_new_stack(&st, dir, opts);
|
||||
EXPECT_ERR(err);
|
||||
|
||||
err = reftable_stack_add(st, &write_nothing, NULL);
|
||||
EXPECT_ERR(err);
|
||||
|
||||
err = reftable_new_stack(&st2, dir, cfg);
|
||||
err = reftable_new_stack(&st2, dir, opts);
|
||||
EXPECT_ERR(err);
|
||||
clear_dir(dir);
|
||||
reftable_stack_destroy(st);
|
||||
@ -861,16 +850,15 @@ static int fastlog2(uint64_t sz)
|
||||
|
||||
static void test_reftable_stack_auto_compaction(void)
|
||||
{
|
||||
struct reftable_write_options cfg = {
|
||||
struct reftable_write_options opts = {
|
||||
.disable_auto_compact = 1,
|
||||
};
|
||||
struct reftable_stack *st = NULL;
|
||||
char *dir = get_tmp_dir(__LINE__);
|
||||
|
||||
int err, i;
|
||||
int N = 100;
|
||||
|
||||
err = reftable_new_stack(&st, dir, cfg);
|
||||
err = reftable_new_stack(&st, dir, opts);
|
||||
EXPECT_ERR(err);
|
||||
|
||||
for (i = 0; i < N; i++) {
|
||||
@ -900,13 +888,13 @@ static void test_reftable_stack_auto_compaction(void)
|
||||
|
||||
static void test_reftable_stack_add_performs_auto_compaction(void)
|
||||
{
|
||||
struct reftable_write_options cfg = { 0 };
|
||||
struct reftable_write_options opts = { 0 };
|
||||
struct reftable_stack *st = NULL;
|
||||
struct strbuf refname = STRBUF_INIT;
|
||||
char *dir = get_tmp_dir(__LINE__);
|
||||
int err, i, n = 20;
|
||||
|
||||
err = reftable_new_stack(&st, dir, cfg);
|
||||
err = reftable_new_stack(&st, dir, opts);
|
||||
EXPECT_ERR(err);
|
||||
|
||||
for (i = 0; i <= n; i++) {
|
||||
@ -921,7 +909,7 @@ static void test_reftable_stack_add_performs_auto_compaction(void)
|
||||
* we can ensure that we indeed honor this setting and have
|
||||
* better control over when exactly auto compaction runs.
|
||||
*/
|
||||
st->config.disable_auto_compact = i != n;
|
||||
st->opts.disable_auto_compact = i != n;
|
||||
|
||||
strbuf_reset(&refname);
|
||||
strbuf_addf(&refname, "branch-%04d", i);
|
||||
@ -948,14 +936,13 @@ static void test_reftable_stack_add_performs_auto_compaction(void)
|
||||
|
||||
static void test_reftable_stack_compaction_concurrent(void)
|
||||
{
|
||||
struct reftable_write_options cfg = { 0 };
|
||||
struct reftable_write_options opts = { 0 };
|
||||
struct reftable_stack *st1 = NULL, *st2 = NULL;
|
||||
char *dir = get_tmp_dir(__LINE__);
|
||||
|
||||
int err, i;
|
||||
int N = 3;
|
||||
|
||||
err = reftable_new_stack(&st1, dir, cfg);
|
||||
err = reftable_new_stack(&st1, dir, opts);
|
||||
EXPECT_ERR(err);
|
||||
|
||||
for (i = 0; i < N; i++) {
|
||||
@ -972,7 +959,7 @@ static void test_reftable_stack_compaction_concurrent(void)
|
||||
EXPECT_ERR(err);
|
||||
}
|
||||
|
||||
err = reftable_new_stack(&st2, dir, cfg);
|
||||
err = reftable_new_stack(&st2, dir, opts);
|
||||
EXPECT_ERR(err);
|
||||
|
||||
err = reftable_stack_compact_all(st1, NULL);
|
||||
@ -998,14 +985,13 @@ static void unclean_stack_close(struct reftable_stack *st)
|
||||
|
||||
static void test_reftable_stack_compaction_concurrent_clean(void)
|
||||
{
|
||||
struct reftable_write_options cfg = { 0 };
|
||||
struct reftable_write_options opts = { 0 };
|
||||
struct reftable_stack *st1 = NULL, *st2 = NULL, *st3 = NULL;
|
||||
char *dir = get_tmp_dir(__LINE__);
|
||||
|
||||
int err, i;
|
||||
int N = 3;
|
||||
|
||||
err = reftable_new_stack(&st1, dir, cfg);
|
||||
err = reftable_new_stack(&st1, dir, opts);
|
||||
EXPECT_ERR(err);
|
||||
|
||||
for (i = 0; i < N; i++) {
|
||||
@ -1022,7 +1008,7 @@ static void test_reftable_stack_compaction_concurrent_clean(void)
|
||||
EXPECT_ERR(err);
|
||||
}
|
||||
|
||||
err = reftable_new_stack(&st2, dir, cfg);
|
||||
err = reftable_new_stack(&st2, dir, opts);
|
||||
EXPECT_ERR(err);
|
||||
|
||||
err = reftable_stack_compact_all(st1, NULL);
|
||||
@ -1031,7 +1017,7 @@ static void test_reftable_stack_compaction_concurrent_clean(void)
|
||||
unclean_stack_close(st1);
|
||||
unclean_stack_close(st2);
|
||||
|
||||
err = reftable_new_stack(&st3, dir, cfg);
|
||||
err = reftable_new_stack(&st3, dir, opts);
|
||||
EXPECT_ERR(err);
|
||||
|
||||
err = reftable_stack_clean(st3);
|
||||
|
Reference in New Issue
Block a user