Skip to content

Commit 4d35bb2

Browse files
pks-tgitster
authored andcommitted
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 <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 0f3415f commit 4d35bb2

File tree

5 files changed

+74
-89
lines changed

5 files changed

+74
-89
lines changed

reftable/dump.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,9 +27,9 @@ license that can be found in the LICENSE file or at
2727
static int compact_stack(const char *stackdir)
2828
{
2929
struct reftable_stack *stack = NULL;
30-
struct reftable_write_options cfg = { 0 };
30+
struct reftable_write_options opts = { 0 };
3131

32-
int err = reftable_new_stack(&stack, stackdir, cfg);
32+
int err = reftable_new_stack(&stack, stackdir, opts);
3333
if (err < 0)
3434
goto done;
3535

reftable/reftable-stack.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ struct reftable_stack;
2929
* stored in 'dir'. Typically, this should be .git/reftables.
3030
*/
3131
int reftable_new_stack(struct reftable_stack **dest, const char *dir,
32-
struct reftable_write_options config);
32+
struct reftable_write_options opts);
3333

3434
/* returns the update_index at which a next table should be written. */
3535
uint64_t reftable_stack_next_update_index(struct reftable_stack *st);

reftable/stack.c

Lines changed: 20 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -54,15 +54,14 @@ static int reftable_fd_flush(void *arg)
5454
}
5555

5656
int reftable_new_stack(struct reftable_stack **dest, const char *dir,
57-
struct reftable_write_options config)
57+
struct reftable_write_options opts)
5858
{
5959
struct reftable_stack *p = reftable_calloc(1, sizeof(*p));
6060
struct strbuf list_file_name = STRBUF_INIT;
6161
int err = 0;
6262

63-
if (config.hash_id == 0) {
64-
config.hash_id = GIT_SHA1_FORMAT_ID;
65-
}
63+
if (opts.hash_id == 0)
64+
opts.hash_id = GIT_SHA1_FORMAT_ID;
6665

6766
*dest = NULL;
6867

@@ -73,7 +72,7 @@ int reftable_new_stack(struct reftable_stack **dest, const char *dir,
7372
p->list_file = strbuf_detach(&list_file_name, NULL);
7473
p->list_fd = -1;
7574
p->reftable_dir = xstrdup(dir);
76-
p->config = config;
75+
p->opts = opts;
7776

7877
err = reftable_stack_reload_maybe_reuse(p, 1);
7978
if (err < 0) {
@@ -255,7 +254,7 @@ static int reftable_stack_reload_once(struct reftable_stack *st, char **names,
255254

256255
/* success! */
257256
err = reftable_new_merged_table(&new_merged, new_tables,
258-
new_readers_len, st->config.hash_id);
257+
new_readers_len, st->opts.hash_id);
259258
if (err < 0)
260259
goto done;
261260

@@ -578,8 +577,8 @@ static int reftable_stack_init_addition(struct reftable_addition *add,
578577
}
579578
goto done;
580579
}
581-
if (st->config.default_permissions) {
582-
if (chmod(add->lock_file->filename.buf, st->config.default_permissions) < 0) {
580+
if (st->opts.default_permissions) {
581+
if (chmod(add->lock_file->filename.buf, st->opts.default_permissions) < 0) {
583582
err = REFTABLE_IO_ERROR;
584583
goto done;
585584
}
@@ -678,7 +677,7 @@ int reftable_addition_commit(struct reftable_addition *add)
678677
if (err)
679678
goto done;
680679

681-
if (!add->stack->config.disable_auto_compact) {
680+
if (!add->stack->opts.disable_auto_compact) {
682681
/*
683682
* Auto-compact the stack to keep the number of tables in
684683
* control. It is possible that a concurrent writer is already
@@ -756,17 +755,17 @@ int reftable_addition_add(struct reftable_addition *add,
756755
err = REFTABLE_IO_ERROR;
757756
goto done;
758757
}
759-
if (add->stack->config.default_permissions) {
758+
if (add->stack->opts.default_permissions) {
760759
if (chmod(get_tempfile_path(tab_file),
761-
add->stack->config.default_permissions)) {
760+
add->stack->opts.default_permissions)) {
762761
err = REFTABLE_IO_ERROR;
763762
goto done;
764763
}
765764
}
766765
tab_fd = get_tempfile_fd(tab_file);
767766

768767
wr = reftable_new_writer(reftable_fd_write, reftable_fd_flush, &tab_fd,
769-
&add->stack->config);
768+
&add->stack->opts);
770769
err = write_table(wr, arg);
771770
if (err < 0)
772771
goto done;
@@ -849,14 +848,14 @@ static int stack_compact_locked(struct reftable_stack *st,
849848
}
850849
tab_fd = get_tempfile_fd(tab_file);
851850

852-
if (st->config.default_permissions &&
853-
chmod(get_tempfile_path(tab_file), st->config.default_permissions) < 0) {
851+
if (st->opts.default_permissions &&
852+
chmod(get_tempfile_path(tab_file), st->opts.default_permissions) < 0) {
854853
err = REFTABLE_IO_ERROR;
855854
goto done;
856855
}
857856

858857
wr = reftable_new_writer(reftable_fd_write, reftable_fd_flush,
859-
&tab_fd, &st->config);
858+
&tab_fd, &st->opts);
860859
err = stack_write_compact(st, wr, first, last, config);
861860
if (err < 0)
862861
goto done;
@@ -904,7 +903,7 @@ static int stack_write_compact(struct reftable_stack *st,
904903
st->readers[last]->max_update_index);
905904

906905
err = reftable_new_merged_table(&mt, subtabs, subtabs_len,
907-
st->config.hash_id);
906+
st->opts.hash_id);
908907
if (err < 0) {
909908
reftable_free(subtabs);
910909
goto done;
@@ -1094,9 +1093,9 @@ static int stack_compact_range(struct reftable_stack *st,
10941093
goto done;
10951094
}
10961095

1097-
if (st->config.default_permissions) {
1096+
if (st->opts.default_permissions) {
10981097
if (chmod(get_lock_file_path(&tables_list_lock),
1099-
st->config.default_permissions) < 0) {
1098+
st->opts.default_permissions) < 0) {
11001099
err = REFTABLE_IO_ERROR;
11011100
goto done;
11021101
}
@@ -1286,7 +1285,7 @@ static uint64_t *stack_table_sizes_for_compaction(struct reftable_stack *st)
12861285
{
12871286
uint64_t *sizes =
12881287
reftable_calloc(st->merged->stack_len, sizeof(*sizes));
1289-
int version = (st->config.hash_id == GIT_SHA1_FORMAT_ID) ? 1 : 2;
1288+
int version = (st->opts.hash_id == GIT_SHA1_FORMAT_ID) ? 1 : 2;
12901289
int overhead = header_size(version) - 1;
12911290
int i = 0;
12921291
for (i = 0; i < st->merged->stack_len; i++) {
@@ -1435,11 +1434,11 @@ int reftable_stack_clean(struct reftable_stack *st)
14351434
int reftable_stack_print_directory(const char *stackdir, uint32_t hash_id)
14361435
{
14371436
struct reftable_stack *stack = NULL;
1438-
struct reftable_write_options cfg = { .hash_id = hash_id };
1437+
struct reftable_write_options opts = { .hash_id = hash_id };
14391438
struct reftable_merged_table *merged = NULL;
14401439
struct reftable_table table = { NULL };
14411440

1442-
int err = reftable_new_stack(&stack, stackdir, cfg);
1441+
int err = reftable_new_stack(&stack, stackdir, opts);
14431442
if (err < 0)
14441443
goto done;
14451444

reftable/stack.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ struct reftable_stack {
2020

2121
char *reftable_dir;
2222

23-
struct reftable_write_options config;
23+
struct reftable_write_options opts;
2424

2525
struct reftable_reader **readers;
2626
size_t readers_len;

0 commit comments

Comments
 (0)