Skip to content

Commit 4ccf706

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

File tree

2 files changed

+17
-1
lines changed

2 files changed

+17
-1
lines changed

refs/reftable-backend.c

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1221,8 +1221,12 @@ static int reftable_be_pack_refs(struct ref_store *ref_store,
12211221
stack = refs->main_stack;
12221222

12231223
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));
12251227
goto out;
1228+
}
1229+
12261230
ret = reftable_stack_clean(stack);
12271231
if (ret)
12281232
goto out;

t/t0610-reftable-basics.sh

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -375,6 +375,18 @@ test_expect_success 'pack-refs: compacts tables' '
375375
test_line_count = 1 repo/.git/reftable/tables.list
376376
'
377377

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+
378390
test_expect_success 'pack-refs: prunes stale tables' '
379391
test_when_finished "rm -rf repo" &&
380392
git init repo &&

0 commit comments

Comments
 (0)