refs/reftable: print errors on compaction failure
When git-pack-refs(1) fails in the reftable backend we end up printing no error message at all, leaving the caller puzzled as to why compaction has failed. Fix this. Signed-off-by: Patrick Steinhardt <ps@pks.im> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Patrick Steinhardt committed
Mar 25, 2024 at 11:02 UTC
4ccf7060d8d0a3c08d1fb03b038a164eb4913d02
2 files changed
+17
-1
refs/reftable-backend.c
+5
-1
@@ -1221,8 +1221,12 @@ static int reftable_be_pack_refs(struct ref_store *ref_store,
1221
stack = refs->main_stack;
1222
1223
ret = reftable_stack_compact_all(stack, NULL);
1224
- if (ret)
1224
+ if (ret < 0) {
1225
+ ret = error(_("unable to compact stack: %s"),
1226
+ reftable_error_str(ret));
1227
goto out;
1228
+ }
1229
+
1230
ret = reftable_stack_clean(stack);
1231
if (ret)
1232
goto out;
t/t0610-reftable-basics.sh
+12
@@ -375,6 +375,18 @@ test_expect_success 'pack-refs: compacts tables' '
375
test_line_count = 1 repo/.git/reftable/tables.list
376
'
377
378
+test_expect_success 'pack-refs: compaction raises locking errors' '
379
+ test_when_finished "rm -rf repo" &&
380
+ git init repo &&
381
+ test_commit -C repo A &&
382
+ touch repo/.git/reftable/tables.list.lock &&
383
+ cat >expect <<-EOF &&
384
+ error: unable to compact stack: data is locked
385
+ EOF
386
+ test_must_fail git -C repo pack-refs 2>err &&
387
+ test_cmp expect err
388
+'
389
+
390
test_expect_success 'pack-refs: prunes stale tables' '
391
test_when_finished "rm -rf repo" &&
392
git init repo &&