111
static void write_n_ref_tables(struct reftable_stack *st,
112
size_t n)
113
{
114
- int disable_auto_compact;
115
-
116
- disable_auto_compact = st->opts.disable_auto_compact;
117
- st->opts.disable_auto_compact = 1;
114
+ struct reftable_write_options opts = {
115
+ .disable_auto_compact = 1,
116
+ };
117
118
for (size_t i = 0; i < n; i++) {
119
struct reftable_ref_record ref = {
127
cl_reftable_set_hash(ref.value.val1, i, REFTABLE_HASH_SHA1);
128
129
cl_assert_equal_i(reftable_stack_add(st,
131
- &write_test_ref, &ref, 0), 0);
130
+ &write_test_ref, &ref, &opts, 0), 0);
131
}
133
-
134
- st->opts.disable_auto_compact = disable_auto_compact;
132
}
133
134
struct write_log_arg {
165
struct stat stat_result = { 0 };
166
int err;
167
171
- err = reftable_new_stack(&st, dir, &opts);
168
+ err = reftable_new_stack(&st, dir, NULL);
169
cl_assert(!err);
170
174
- err = reftable_stack_add(st, write_test_ref, &ref, 0);
171
+ err = reftable_stack_add(st, write_test_ref, &ref, &opts, 0);
172
cl_assert(!err);
173
174
err = reftable_stack_read_ref(st, ref.refname, &dest);
207
208
void test_reftable_stack__uptodate(void)
209
{
213
- struct reftable_write_options opts = { 0 };
210
struct reftable_stack *st1 = NULL;
211
struct reftable_stack *st2 = NULL;
212
char *dir = get_tmp_dir(__LINE__);
228
/* simulate multi-process access to the same stack
229
by creating two stacks for the same directory.
230
*/
235
- cl_assert_equal_i(reftable_new_stack(&st1, dir, &opts), 0);
236
- cl_assert_equal_i(reftable_new_stack(&st2, dir, &opts), 0);
231
+ cl_assert_equal_i(reftable_new_stack(&st1, dir, NULL), 0);
232
+ cl_assert_equal_i(reftable_new_stack(&st2, dir, NULL), 0);
233
cl_assert_equal_i(reftable_stack_add(st1, write_test_ref,
238
- &ref1, 0), 0);
234
+ &ref1, NULL, 0), 0);
235
cl_assert_equal_i(reftable_stack_add(st2, write_test_ref,
240
- &ref2, 0), REFTABLE_OUTDATED_ERROR);
236
+ &ref2, NULL, 0), REFTABLE_OUTDATED_ERROR);
237
cl_assert_equal_i(reftable_stack_reload(st2), 0);
238
cl_assert_equal_i(reftable_stack_add(st2, write_test_ref,
243
- &ref2, 0), 0);
239
+ &ref2, NULL, 0), 0);
240
reftable_stack_destroy(st1);
241
reftable_stack_destroy(st2);
242
clear_dir(dir);
245
void test_reftable_stack__transaction_api(void)
246
{
247
char *dir = get_tmp_dir(__LINE__);
252
- struct reftable_write_options opts = { 0 };
248
struct reftable_stack *st = NULL;
249
struct reftable_addition *add = NULL;
250
256
};
257
struct reftable_ref_record dest = { 0 };
258
264
- cl_assert_equal_i(reftable_new_stack(&st, dir, &opts), 0);
259
+ cl_assert_equal_i(reftable_new_stack(&st, dir, NULL), 0);
260
261
reftable_addition_destroy(add);
262
268
- cl_assert_equal_i(reftable_stack_new_addition(&add, st, 0), 0);
263
+ cl_assert_equal_i(reftable_stack_new_addition(&add, st, NULL, 0), 0);
264
cl_assert_equal_i(reftable_addition_add(add, write_test_ref,
265
&ref), 0);
266
cl_assert_equal_i(reftable_addition_commit(add), 0);
301
302
cl_assert_equal_i(reftable_new_stack(&st1, dir, NULL), 0);
303
cl_assert_equal_i(reftable_new_stack(&st2, dir, NULL), 0);
309
- cl_assert_equal_i(reftable_stack_new_addition(&add, st1, 0), 0);
304
+ cl_assert_equal_i(reftable_stack_new_addition(&add, st1, NULL, 0), 0);
305
cl_assert_equal_i(reftable_addition_add(add, write_test_ref,
306
&refs[0]), 0);
307
cl_assert_equal_i(reftable_addition_commit(add), 0);
312
* create the addition and lock the stack by default, but allow the
313
* reload to happen when REFTABLE_STACK_NEW_ADDITION_RELOAD is set.
314
*/
320
- cl_assert_equal_i(reftable_stack_new_addition(&add, st2, 0),
315
+ cl_assert_equal_i(reftable_stack_new_addition(&add, st2, NULL, 0),
316
REFTABLE_OUTDATED_ERROR);
322
- cl_assert_equal_i(reftable_stack_new_addition(&add, st2,
317
+ cl_assert_equal_i(reftable_stack_new_addition(&add, st2, NULL,
318
REFTABLE_STACK_NEW_ADDITION_RELOAD), 0);
319
cl_assert_equal_i(reftable_addition_add(add, write_test_ref,
320
&refs[1]), 0);
337
void test_reftable_stack__transaction_api_performs_auto_compaction(void)
338
{
339
char *dir = get_tmp_dir(__LINE__);
345
- struct reftable_write_options opts = {0};
340
struct reftable_addition *add = NULL;
341
struct reftable_stack *st = NULL;
342
size_t n = 20;
343
350
- cl_assert_equal_i(reftable_new_stack(&st, dir, &opts), 0);
344
+ cl_assert_equal_i(reftable_new_stack(&st, dir, NULL), 0);
345
346
for (size_t i = 0; i <= n; i++) {
347
struct reftable_ref_record ref = {
350
.value.symref = (char *) "master",
351
};
352
char name[100];
353
+ struct reftable_write_options write_opts = {
354
+ .disable_auto_compact = (i != n),
355
+ };
356
357
snprintf(name, sizeof(name), "branch%04"PRIuMAX, (uintmax_t)i);
358
ref.refname = name;
362
* we can ensure that we indeed honor this setting and have
363
* better control over when exactly auto compaction runs.
364
*/
368
- st->opts.disable_auto_compact = i != n;
369
-
365
cl_assert_equal_i(reftable_stack_new_addition(&add,
371
- st, 0), 0);
366
+ st, &write_opts, 0), 0);
367
cl_assert_equal_i(reftable_addition_add(add,
368
write_test_ref, &ref), 0);
369
cl_assert_equal_i(reftable_addition_commit(add), 0);
393
.value_type = REFTABLE_REF_VAL1,
394
.value.val1 = {0x01},
395
};
401
- struct reftable_write_options opts = { 0 };
396
struct reftable_stack *st;
397
struct reftable_buf table_path = REFTABLE_BUF_INIT;
398
char *dir = get_tmp_dir(__LINE__);
399
int err;
400
407
- cl_assert_equal_i(reftable_new_stack(&st, dir, &opts), 0);
401
+ cl_assert_equal_i(reftable_new_stack(&st, dir, NULL), 0);
402
cl_assert_equal_i(reftable_stack_add(st, write_test_ref,
409
- &ref, 0), 0);
403
+ &ref, NULL, 0), 0);
404
cl_assert_equal_i(st->merged->tables_len, 1);
405
cl_assert_equal_i(st->stats.attempts, 0);
406
cl_assert_equal_i(st->stats.failures, 0);
418
write_file_buf(table_path.buf, "", 0);
419
420
ref.update_index = 2;
427
- err = reftable_stack_add(st, write_test_ref, &ref, 0);
421
+ err = reftable_stack_add(st, write_test_ref, &ref, NULL, 0);
422
cl_assert(!err);
423
cl_assert_equal_i(st->merged->tables_len, 2);
424
cl_assert_equal_i(st->stats.attempts, 1);
437
void test_reftable_stack__update_index_check(void)
438
{
439
char *dir = get_tmp_dir(__LINE__);
446
- struct reftable_write_options opts = { 0 };
440
struct reftable_stack *st = NULL;
441
struct reftable_ref_record ref1 = {
442
.refname = (char *) "name1",
451
.value.symref = (char *) "master",
452
};
453
461
- cl_assert_equal_i(reftable_new_stack(&st, dir, &opts), 0);
454
+ cl_assert_equal_i(reftable_new_stack(&st, dir, NULL), 0);
455
cl_assert_equal_i(reftable_stack_add(st, write_test_ref,
463
- &ref1, 0), 0);
456
+ &ref1, NULL, 0), 0);
457
cl_assert_equal_i(reftable_stack_add(st, write_test_ref,
465
- &ref2, 0), REFTABLE_API_ERROR);
458
+ &ref2, NULL, 0), REFTABLE_API_ERROR);
459
reftable_stack_destroy(st);
460
clear_dir(dir);
461
}
463
void test_reftable_stack__lock_failure(void)
464
{
465
char *dir = get_tmp_dir(__LINE__);
473
- struct reftable_write_options opts = { 0 };
466
struct reftable_stack *st = NULL;
467
int i;
468
477
- cl_assert_equal_i(reftable_new_stack(&st, dir, &opts), 0);
469
+ cl_assert_equal_i(reftable_new_stack(&st, dir, NULL), 0);
470
for (i = -1; i != REFTABLE_EMPTY_TABLE_ERROR; i--)
471
cl_assert_equal_i(reftable_stack_add(st, write_error,
480
- &i, 0), i);
472
+ &i, NULL, 0), i);
473
474
reftable_stack_destroy(st);
475
clear_dir(dir);
491
size_t i, N = ARRAY_SIZE(refs);
492
int err = 0;
493
502
- err = reftable_new_stack(&st, dir, &opts);
494
+ err = reftable_new_stack(&st, dir, NULL);
495
cl_assert(!err);
496
497
for (i = 0; i < N; i++) {
513
514
for (i = 0; i < N; i++)
515
cl_assert_equal_i(reftable_stack_add(st, write_test_ref,
524
- &refs[i], 0), 0);
516
+ &refs[i], &opts, 0), 0);
517
518
for (i = 0; i < N; i++) {
519
struct write_log_arg arg = {
521
.update_index = reftable_stack_next_update_index(st),
522
};
523
cl_assert_equal_i(reftable_stack_add(st, write_test_log,
532
- &arg, 0), 0);
524
+ &arg, &opts, 0), 0);
525
}
526
535
- cl_assert_equal_i(reftable_stack_compact_all(st, NULL), 0);
527
+ cl_assert_equal_i(reftable_stack_compact_all(st, &opts, NULL), 0);
528
529
for (i = 0; i < N; i++) {
530
struct reftable_ref_record dest = { 0 };
576
577
void test_reftable_stack__iterator(void)
578
{
587
- struct reftable_write_options opts = { 0 };
579
struct reftable_stack *st = NULL;
580
char *dir = get_tmp_dir(__LINE__);
581
struct reftable_ref_record refs[10] = { 0 };
584
size_t N = ARRAY_SIZE(refs), i;
585
int err;
586
596
- cl_assert_equal_i(reftable_new_stack(&st, dir, &opts), 0);
587
+ cl_assert_equal_i(reftable_new_stack(&st, dir, NULL), 0);
588
589
for (i = 0; i < N; i++) {
590
refs[i].refname = xstrfmt("branch%02"PRIuMAX, (uintmax_t)i);
604
605
for (i = 0; i < N; i++)
606
cl_assert_equal_i(reftable_stack_add(st, write_test_ref,
616
- &refs[i], 0), 0);
607
+ &refs[i], NULL, 0), 0);
608
609
for (i = 0; i < N; i++) {
610
struct write_log_arg arg = {
613
};
614
615
cl_assert_equal_i(reftable_stack_add(st, write_test_log,
625
- &arg, 0), 0);
616
+ &arg, NULL, 0), 0);
617
}
618
619
reftable_stack_init_ref_iterator(st, &it);
660
661
void test_reftable_stack__log_normalize(void)
662
{
672
- struct reftable_write_options opts = {
673
- 0,
674
- };
663
struct reftable_stack *st = NULL;
664
char *dir = get_tmp_dir(__LINE__);
665
struct reftable_log_record input = {
681
.update_index = 1,
682
};
683
696
- cl_assert_equal_i(reftable_new_stack(&st, dir, &opts), 0);
684
+ cl_assert_equal_i(reftable_new_stack(&st, dir, NULL), 0);
685
686
input.value.update.message = (char *) "one\ntwo";
687
cl_assert_equal_i(reftable_stack_add(st, write_test_log,
700
- &arg, 0), REFTABLE_API_ERROR);
688
+ &arg, NULL, 0), REFTABLE_API_ERROR);
689
690
input.value.update.message = (char *) "one";
691
cl_assert_equal_i(reftable_stack_add(st, write_test_log,
704
- &arg, 0), 0);
692
+ &arg, NULL, 0), 0);
693
cl_assert_equal_i(reftable_stack_read_log(st, input.refname,
694
&dest), 0);
695
cl_assert_equal_s(dest.value.update.message, "one\n");
697
input.value.update.message = (char *) "two\n";
698
arg.update_index = 2;
699
cl_assert_equal_i(reftable_stack_add(st, write_test_log,
712
- &arg, 0), 0);
700
+ &arg, NULL, 0), 0);
701
cl_assert_equal_i(reftable_stack_read_log(st, input.refname,
702
&dest), 0);
703
cl_assert_equal_s(dest.value.update.message, "two\n");
711
void test_reftable_stack__tombstone(void)
712
{
713
char *dir = get_tmp_dir(__LINE__);
726
- struct reftable_write_options opts = { 0 };
714
struct reftable_stack *st = NULL;
715
struct reftable_ref_record refs[2] = { 0 };
716
struct reftable_log_record logs[2] = { 0 };
718
struct reftable_ref_record dest = { 0 };
719
struct reftable_log_record log_dest = { 0 };
720
734
- cl_assert_equal_i(reftable_new_stack(&st, dir, &opts), 0);
721
+ cl_assert_equal_i(reftable_new_stack(&st, dir, NULL), 0);
722
723
/* even entries add the refs, odd entries delete them. */
724
for (i = 0; i < N; i++) {
747
}
748
for (i = 0; i < N; i++)
749
cl_assert_equal_i(reftable_stack_add(st, write_test_ref,
763
- &refs[i], 0), 0);
750
+ &refs[i], NULL, 0), 0);
751
752
for (i = 0; i < N; i++) {
753
struct write_log_arg arg = {
755
.update_index = reftable_stack_next_update_index(st),
756
};
757
cl_assert_equal_i(reftable_stack_add(st, write_test_log,
771
- &arg, 0), 0);
758
+ &arg, NULL, 0), 0);
759
}
760
761
cl_assert_equal_i(reftable_stack_read_ref(st, "branch",
766
&log_dest), 1);
767
reftable_log_record_release(&log_dest);
768
782
- cl_assert_equal_i(reftable_stack_compact_all(st, NULL), 0);
769
+ cl_assert_equal_i(reftable_stack_compact_all(st, NULL, NULL), 0);
770
cl_assert_equal_i(reftable_stack_read_ref(st, "branch",
771
&dest), 1);
772
cl_assert_equal_i(reftable_stack_read_log(st, "branch",
786
void test_reftable_stack__hash_id(void)
787
{
788
char *dir = get_tmp_dir(__LINE__);
802
- struct reftable_write_options opts = { 0 };
789
struct reftable_stack *st = NULL;
790
791
struct reftable_ref_record ref = {
794
.value.symref = (char *) "target",
795
.update_index = 1,
796
};
811
- struct reftable_write_options opts32 = { .hash_id = REFTABLE_HASH_SHA256 };
797
+ struct reftable_stack_options opts32 = { .hash_id = REFTABLE_HASH_SHA256 };
798
struct reftable_stack *st32 = NULL;
813
- struct reftable_write_options opts_default = { 0 };
799
struct reftable_stack *st_default = NULL;
800
struct reftable_ref_record dest = { 0 };
801
817
- cl_assert_equal_i(reftable_new_stack(&st, dir, &opts), 0);
802
+ cl_assert_equal_i(reftable_new_stack(&st, dir, NULL), 0);
803
cl_assert_equal_i(reftable_stack_add(st, write_test_ref,
819
- &ref, 0), 0);
804
+ &ref, NULL, 0), 0);
805
806
/* can't read it with the wrong hash ID. */
807
cl_assert_equal_i(reftable_new_stack(&st32, dir,
809
810
/* check that we can read it back with default opts too. */
811
cl_assert_equal_i(reftable_new_stack(&st_default, dir,
827
- &opts_default), 0);
812
+ NULL), 0);
813
cl_assert_equal_i(reftable_stack_read_ref(st_default, "master",
814
&dest), 0);
815
cl_assert(reftable_ref_record_equal(&ref, &dest,
840
void test_reftable_stack__reflog_expire(void)
841
{
842
char *dir = get_tmp_dir(__LINE__);
858
- struct reftable_write_options opts = { 0 };
843
struct reftable_stack *st = NULL;
844
struct reftable_log_record logs[20] = { 0 };
845
size_t i, N = ARRAY_SIZE(logs) - 1;
848
};
849
struct reftable_log_record log = { 0 };
850
867
- cl_assert_equal_i(reftable_new_stack(&st, dir, &opts), 0);
851
+ cl_assert_equal_i(reftable_new_stack(&st, dir, NULL), 0);
852
853
for (i = 1; i <= N; i++) {
854
char buf[256];
869
.update_index = reftable_stack_next_update_index(st),
870
};
871
cl_assert_equal_i(reftable_stack_add(st, write_test_log,
888
- &arg, 0), 0);
872
+ &arg, NULL, 0), 0);
873
}
874
891
- cl_assert_equal_i(reftable_stack_compact_all(st, NULL), 0);
892
- cl_assert_equal_i(reftable_stack_compact_all(st, &expiry), 0);
875
+ cl_assert_equal_i(reftable_stack_compact_all(st, NULL, NULL), 0);
876
+ cl_assert_equal_i(reftable_stack_compact_all(st, NULL, &expiry), 0);
877
cl_assert_equal_i(reftable_stack_read_log(st, logs[9].refname,
878
&log), 1);
879
cl_assert_equal_i(reftable_stack_read_log(st, logs[11].refname,
880
&log), 0);
881
882
expiry.min_update_index = 15;
899
- cl_assert_equal_i(reftable_stack_compact_all(st, &expiry), 0);
883
+ cl_assert_equal_i(reftable_stack_compact_all(st, NULL, &expiry), 0);
884
cl_assert_equal_i(reftable_stack_read_log(st, logs[14].refname,
885
&log), 1);
886
cl_assert_equal_i(reftable_stack_read_log(st, logs[16].refname,
902
903
void test_reftable_stack__empty_add(void)
904
{
921
- struct reftable_write_options opts = { 0 };
905
struct reftable_stack *st = NULL;
906
char *dir = get_tmp_dir(__LINE__);
907
struct reftable_stack *st2 = NULL;
908
926
- cl_assert_equal_i(reftable_new_stack(&st, dir, &opts), 0);
909
+ cl_assert_equal_i(reftable_new_stack(&st, dir, NULL), 0);
910
cl_assert_equal_i(reftable_stack_add(st, write_nothing,
928
- NULL, 0), 0);
929
- cl_assert_equal_i(reftable_new_stack(&st2, dir, &opts), 0);
911
+ NULL, NULL, 0), 0);
912
+ cl_assert_equal_i(reftable_new_stack(&st2, dir, NULL), 0);
913
clear_dir(dir);
914
reftable_stack_destroy(st);
915
reftable_stack_destroy(st2);
935
size_t i, N = 100;
936
int err;
937
955
- cl_assert_equal_i(reftable_new_stack(&st, dir, &opts), 0);
938
+ cl_assert_equal_i(reftable_new_stack(&st, dir, NULL), 0);
939
940
for (i = 0; i < N; i++) {
941
char name[100];
947
};
948
snprintf(name, sizeof(name), "branch%04"PRIuMAX, (uintmax_t)i);
949
967
- err = reftable_stack_add(st, write_test_ref, &ref, 0);
950
+ err = reftable_stack_add(st, write_test_ref, &ref, &opts, 0);
951
cl_assert(!err);
952
970
- err = reftable_stack_auto_compact(st);
953
+ err = reftable_stack_auto_compact(st, &opts);
954
cl_assert(!err);
955
cl_assert(i < 2 || st->merged->tables_len < 2 * fastlogN(i, 2));
956
}
972
size_t N = 100;
973
int err;
974
992
- cl_assert_equal_i(reftable_new_stack(&st, dir, &opts), 0);
975
+ cl_assert_equal_i(reftable_new_stack(&st, dir, NULL), 0);
976
977
for (size_t i = 0; i < N; i++) {
978
char name[20];
983
};
984
xsnprintf(name, sizeof(name), "branch%04"PRIuMAX, (uintmax_t)i);
985
1003
- err = reftable_stack_add(st, &write_test_ref, &ref, 0);
986
+ err = reftable_stack_add(st, &write_test_ref, &ref, &opts, 0);
987
cl_assert(!err);
988
989
cl_assert(i < 5 || st->merged->tables_len < 5 * fastlogN(i, 5));
1003
char *dir = get_tmp_dir(__LINE__);
1004
int err;
1005
1023
- cl_assert_equal_i(reftable_new_stack(&st, dir, &opts), 0);
1006
+ cl_assert_equal_i(reftable_new_stack(&st, dir, NULL), 0);
1007
1008
write_n_ref_tables(st, 5);
1009
cl_assert_equal_i(st->merged->tables_len, 5);
1025
* would in theory compact all tables, due to the preexisting lock we
1026
* only compact the newest two tables.
1027
*/
1045
- err = reftable_stack_auto_compact(st);
1028
+ err = reftable_stack_auto_compact(st, &opts);
1029
cl_assert(!err);
1030
cl_assert_equal_i(st->stats.failures, 0);
1031
cl_assert_equal_i(st->merged->tables_len, 4);
1037
1038
void test_reftable_stack__add_performs_auto_compaction(void)
1039
{
1057
- struct reftable_write_options opts = { 0 };
1040
struct reftable_stack *st = NULL;
1041
char *dir = get_tmp_dir(__LINE__);
1042
size_t i, n = 20;
1043
1062
- cl_assert_equal_i(reftable_new_stack(&st, dir, &opts), 0);
1044
+ cl_assert_equal_i(reftable_new_stack(&st, dir, NULL), 0);
1045
1046
for (i = 0; i <= n; i++) {
1047
struct reftable_ref_record ref = {
1049
.value_type = REFTABLE_REF_SYMREF,
1050
.value.symref = (char *) "master",
1051
};
1052
+ struct reftable_write_options write_opts = {
1053
+ .disable_auto_compact = (i != n),
1054
+ };
1055
bool required = false;
1056
char buf[128];
1057
1060
* we can ensure that we indeed honor this setting and have
1061
* better control over when exactly auto compaction runs.
1062
*/
1078
- st->opts.disable_auto_compact = i != n;
1079
-
1063
snprintf(buf, sizeof(buf), "branch-%04"PRIuMAX, (uintmax_t)i);
1064
ref.refname = buf;
1065
1066
cl_assert_equal_i(reftable_stack_add(st, write_test_ref,
1084
- &ref, 0), 0);
1067
+ &ref, &write_opts, 0), 0);
1068
1069
/*
1070
* The stack length should grow continuously for all runs where
1071
* auto compaction is disabled. When enabled, we should merge
1072
* all tables in the stack.
1073
*/
1091
- cl_assert_equal_i(reftable_stack_compaction_required(st, true, &required), 0);
1074
+ cl_assert_equal_i(reftable_stack_compaction_required(st, NULL, true, &required), 0);
1075
if (i != n) {
1076
cl_assert_equal_i(st->merged->tables_len, i + 1);
1077
if (i < 1)
1098
char *dir = get_tmp_dir(__LINE__);
1099
int err;
1100
1118
- cl_assert_equal_i(reftable_new_stack(&st, dir, &opts), 0);
1101
+ cl_assert_equal_i(reftable_new_stack(&st, dir, NULL), 0);
1102
1103
write_n_ref_tables(st, 3);
1104
cl_assert_equal_i(st->merged->tables_len, 3);
1114
* Compaction is expected to fail given that we were not able to
1115
* compact all tables.
1116
*/
1134
- err = reftable_stack_compact_all(st, NULL);
1117
+ err = reftable_stack_compact_all(st, &opts, NULL);
1118
cl_assert_equal_i(err, REFTABLE_LOCK_ERROR);
1119
cl_assert_equal_i(st->stats.failures, 1);
1120
cl_assert_equal_i(st->merged->tables_len, 3);
1126
1127
void test_reftable_stack__compaction_concurrent(void)
1128
{
1146
- struct reftable_write_options opts = { 0 };
1129
struct reftable_stack *st1 = NULL, *st2 = NULL;
1130
char *dir = get_tmp_dir(__LINE__);
1131
1150
- cl_assert_equal_i(reftable_new_stack(&st1, dir, &opts), 0);
1132
+ cl_assert_equal_i(reftable_new_stack(&st1, dir, NULL), 0);
1133
write_n_ref_tables(st1, 3);
1134
1153
- cl_assert_equal_i(reftable_new_stack(&st2, dir, &opts), 0);
1154
- cl_assert_equal_i(reftable_stack_compact_all(st1, NULL), 0);
1135
+ cl_assert_equal_i(reftable_new_stack(&st2, dir, NULL), 0);
1136
+ cl_assert_equal_i(reftable_stack_compact_all(st1, NULL, NULL), 0);
1137
1138
reftable_stack_destroy(st1);
1139
reftable_stack_destroy(st2);
1153
1154
void test_reftable_stack__compaction_concurrent_clean(void)
1155
{
1174
- struct reftable_write_options opts = { 0 };
1156
struct reftable_stack *st1 = NULL, *st2 = NULL, *st3 = NULL;
1157
char *dir = get_tmp_dir(__LINE__);
1158
1178
- cl_assert_equal_i(reftable_new_stack(&st1, dir, &opts), 0);
1159
+ cl_assert_equal_i(reftable_new_stack(&st1, dir, NULL), 0);
1160
write_n_ref_tables(st1, 3);
1161
1181
- cl_assert_equal_i(reftable_new_stack(&st2, dir, &opts), 0);
1182
- cl_assert_equal_i(reftable_stack_compact_all(st1, NULL), 0);
1162
+ cl_assert_equal_i(reftable_new_stack(&st2, dir, NULL), 0);
1163
+ cl_assert_equal_i(reftable_stack_compact_all(st1, NULL, NULL), 0);
1164
1165
unclean_stack_close(st1);
1166
unclean_stack_close(st2);
1167
1187
- cl_assert_equal_i(reftable_new_stack(&st3, dir, &opts), 0);
1168
+ cl_assert_equal_i(reftable_new_stack(&st3, dir, NULL), 0);
1169
cl_assert_equal_i(reftable_stack_clean(st3), 0);
1170
cl_assert_equal_i(count_dir_entries(dir), 2);
1171
1178
1179
void test_reftable_stack__read_across_reload(void)
1180
{
1200
- struct reftable_write_options opts = { 0 };
1181
struct reftable_stack *st1 = NULL, *st2 = NULL;
1182
struct reftable_ref_record rec = { 0 };
1183
struct reftable_iterator it = { 0 };
1185
int err;
1186
1187
/* Create a first stack and set up an iterator for it. */
1208
- cl_assert_equal_i(reftable_new_stack(&st1, dir, &opts), 0);
1188
+ cl_assert_equal_i(reftable_new_stack(&st1, dir, NULL), 0);
1189
write_n_ref_tables(st1, 2);
1190
cl_assert_equal_i(st1->merged->tables_len, 2);
1191
reftable_stack_init_ref_iterator(st1, &it);
1192
cl_assert_equal_i(reftable_iterator_seek_ref(&it, ""), 0);
1193
1194
/* Set up a second stack for the same directory and compact it. */
1215
- err = reftable_new_stack(&st2, dir, &opts);
1195
+ err = reftable_new_stack(&st2, dir, NULL);
1196
cl_assert(!err);
1197
cl_assert_equal_i(st2->merged->tables_len, 2);
1218
- err = reftable_stack_compact_all(st2, NULL);
1198
+ err = reftable_stack_compact_all(st2, NULL, NULL);
1199
cl_assert(!err);
1200
cl_assert_equal_i(st2->merged->tables_len, 1);
1201
1224
1225
void test_reftable_stack__reload_with_missing_table(void)
1226
{
1247
- struct reftable_write_options opts = { 0 };
1227
struct reftable_stack *st = NULL;
1228
struct reftable_ref_record rec = { 0 };
1229
struct reftable_iterator it = { 0 };
1232
int err;
1233
1234
/* Create a first stack and set up an iterator for it. */
1256
- cl_assert_equal_i(reftable_new_stack(&st, dir, &opts), 0);
1235
+ cl_assert_equal_i(reftable_new_stack(&st, dir, NULL), 0);
1236
write_n_ref_tables(st, 2);
1237
cl_assert_equal_i(st->merged->tables_len, 2);
1238
reftable_stack_init_ref_iterator(st, &it);
1299
char *dir = get_tmp_dir(__LINE__);
1300
struct reftable_stack *st = NULL;
1301
1323
- cl_assert_equal_i(reftable_new_stack(&st, dir, &opts), 0);
1302
+ cl_assert_equal_i(reftable_new_stack(&st, dir, NULL), 0);
1303
1304
reftable_addition_destroy(add);
1305
1327
- cl_assert_equal_i(reftable_stack_new_addition(&add, st, 0), 0);
1306
+ cl_assert_equal_i(reftable_stack_new_addition(&add, st, &opts, 0), 0);
1307
1308
/*
1309
* write_limits_after_ref also updates the update indexes after adding