aboutsummaryrefslogtreecommitdiff
path: root/reftable/stack_test.c
diff options
context:
space:
mode:
authorPatrick Steinhardt <ps@pks.im>2024-05-13 10:17:59 +0200
committerJunio C Hamano <gitster@pobox.com>2024-05-13 17:02:38 -0700
commit799237852bd265feb1e1a8d4a19780e20991b4fd (patch)
treef566c5630b6305a64aad7d23850bb019228264e0 /reftable/stack_test.c
parent4d35bb2abaeff3965024b0f1599641641bcb17a6 (diff)
downloadgit-799237852bd265feb1e1a8d4a19780e20991b4fd.tar.xz
reftable: pass opts as constant pointer
We sometimes pass the refatble write options as value and sometimes as a pointer. This is quite confusing and makes the reader wonder whether the options get modified sometimes. In fact, `reftable_new_writer()` does cause the caller-provided options to get updated when some values aren't set up. This is quite unexpected, but didn't cause any harm until now. Adapt the code so that we do not modify the caller-provided values anymore. While at it, refactor the code to code to consistently pass the options as a constant pointer to clarify that the caller-provided opts will not ever get modified. Signed-off-by: Patrick Steinhardt <ps@pks.im> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'reftable/stack_test.c')
-rw-r--r--reftable/stack_test.c48
1 files changed, 24 insertions, 24 deletions
diff --git a/reftable/stack_test.c b/reftable/stack_test.c
index e17ad4dc62..d15f11d712 100644
--- a/reftable/stack_test.c
+++ b/reftable/stack_test.c
@@ -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, opts);
+ err = reftable_new_stack(&st, dir, &opts);
EXPECT_ERR(err);
err = reftable_stack_add(st, &write_test_ref, &ref);
@@ -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, opts);
+ err = reftable_new_stack(&st1, dir, &opts);
EXPECT_ERR(err);
- err = reftable_new_stack(&st2, dir, opts);
+ err = reftable_new_stack(&st2, dir, &opts);
EXPECT_ERR(err);
err = reftable_stack_add(st1, &write_test_ref, &ref1);
@@ -270,7 +270,7 @@ static void test_reftable_stack_transaction_api(void)
};
struct reftable_ref_record dest = { NULL };
- err = reftable_new_stack(&st, dir, opts);
+ err = reftable_new_stack(&st, dir, &opts);
EXPECT_ERR(err);
reftable_addition_destroy(add);
@@ -304,7 +304,7 @@ static void test_reftable_stack_transaction_api_performs_auto_compaction(void)
struct reftable_stack *st = NULL;
int i, n = 20, err;
- err = reftable_new_stack(&st, dir, opts);
+ err = reftable_new_stack(&st, dir, &opts);
EXPECT_ERR(err);
for (i = 0; i <= n; i++) {
@@ -365,7 +365,7 @@ static void test_reftable_stack_auto_compaction_fails_gracefully(void)
char *dir = get_tmp_dir(__LINE__);
int err;
- err = reftable_new_stack(&st, dir, opts);
+ err = reftable_new_stack(&st, dir, &opts);
EXPECT_ERR(err);
err = reftable_stack_add(st, write_test_ref, &ref);
@@ -418,7 +418,7 @@ static void test_reftable_stack_update_index_check(void)
.value.symref = "master",
};
- err = reftable_new_stack(&st, dir, opts);
+ err = reftable_new_stack(&st, dir, &opts);
EXPECT_ERR(err);
err = reftable_stack_add(st, &write_test_ref, &ref1);
@@ -437,7 +437,7 @@ static void test_reftable_stack_lock_failure(void)
struct reftable_stack *st = NULL;
int err, i;
- err = reftable_new_stack(&st, dir, opts);
+ 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);
@@ -465,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, opts);
+ err = reftable_new_stack(&st, dir, &opts);
EXPECT_ERR(err);
for (i = 0; i < N; i++) {
@@ -575,7 +575,7 @@ static void test_reftable_stack_log_normalize(void)
.update_index = 1,
};
- err = reftable_new_stack(&st, dir, opts);
+ err = reftable_new_stack(&st, dir, &opts);
EXPECT_ERR(err);
input.value.update.message = "one\ntwo";
@@ -617,7 +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, opts);
+ err = reftable_new_stack(&st, dir, &opts);
EXPECT_ERR(err);
/* even entries add the refs, odd entries delete them. */
@@ -701,18 +701,18 @@ static void test_reftable_stack_hash_id(void)
struct reftable_stack *st_default = NULL;
struct reftable_ref_record dest = { NULL };
- err = reftable_new_stack(&st, dir, opts);
+ 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, opts32);
+ err = reftable_new_stack(&st32, dir, &opts32);
EXPECT(err == REFTABLE_FORMAT_ERROR);
/* check that we can read it back with default opts too. */
- err = reftable_new_stack(&st_default, dir, opts_default);
+ err = reftable_new_stack(&st_default, dir, &opts_default);
EXPECT_ERR(err);
err = reftable_stack_read_ref(st_default, "master", &dest);
@@ -756,7 +756,7 @@ static void test_reflog_expire(void)
};
struct reftable_log_record log = { NULL };
- err = reftable_new_stack(&st, dir, opts);
+ err = reftable_new_stack(&st, dir, &opts);
EXPECT_ERR(err);
for (i = 1; i <= N; i++) {
@@ -825,13 +825,13 @@ static void test_empty_add(void)
char *dir = get_tmp_dir(__LINE__);
struct reftable_stack *st2 = NULL;
- err = reftable_new_stack(&st, dir, opts);
+ 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, opts);
+ err = reftable_new_stack(&st2, dir, &opts);
EXPECT_ERR(err);
clear_dir(dir);
reftable_stack_destroy(st);
@@ -858,7 +858,7 @@ static void test_reftable_stack_auto_compaction(void)
int err, i;
int N = 100;
- err = reftable_new_stack(&st, dir, opts);
+ err = reftable_new_stack(&st, dir, &opts);
EXPECT_ERR(err);
for (i = 0; i < N; i++) {
@@ -894,7 +894,7 @@ static void test_reftable_stack_add_performs_auto_compaction(void)
char *dir = get_tmp_dir(__LINE__);
int err, i, n = 20;
- err = reftable_new_stack(&st, dir, opts);
+ err = reftable_new_stack(&st, dir, &opts);
EXPECT_ERR(err);
for (i = 0; i <= n; i++) {
@@ -942,7 +942,7 @@ static void test_reftable_stack_compaction_concurrent(void)
int err, i;
int N = 3;
- err = reftable_new_stack(&st1, dir, opts);
+ err = reftable_new_stack(&st1, dir, &opts);
EXPECT_ERR(err);
for (i = 0; i < N; i++) {
@@ -959,7 +959,7 @@ static void test_reftable_stack_compaction_concurrent(void)
EXPECT_ERR(err);
}
- err = reftable_new_stack(&st2, dir, opts);
+ err = reftable_new_stack(&st2, dir, &opts);
EXPECT_ERR(err);
err = reftable_stack_compact_all(st1, NULL);
@@ -991,7 +991,7 @@ static void test_reftable_stack_compaction_concurrent_clean(void)
int err, i;
int N = 3;
- err = reftable_new_stack(&st1, dir, opts);
+ err = reftable_new_stack(&st1, dir, &opts);
EXPECT_ERR(err);
for (i = 0; i < N; i++) {
@@ -1008,7 +1008,7 @@ static void test_reftable_stack_compaction_concurrent_clean(void)
EXPECT_ERR(err);
}
- err = reftable_new_stack(&st2, dir, opts);
+ err = reftable_new_stack(&st2, dir, &opts);
EXPECT_ERR(err);
err = reftable_stack_compact_all(st1, NULL);
@@ -1017,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, opts);
+ err = reftable_new_stack(&st3, dir, &opts);
EXPECT_ERR(err);
err = reftable_stack_clean(st3);