aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPatrick Steinhardt <ps@pks.im>2024-03-25 11:02:54 +0100
committerJunio C Hamano <gitster@pobox.com>2024-03-25 09:54:07 -0700
commit4ccf7060d8d0a3c08d1fb03b038a164eb4913d02 (patch)
treedb56ded317fd79acf7434ccbe23ba655f870eeee
parenta2f711ade0c4816a59155d72559cbc4759cd4699 (diff)
downloadgit-4ccf7060d8d0a3c08d1fb03b038a164eb4913d02.tar.gz
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>
-rw-r--r--refs/reftable-backend.c6
-rwxr-xr-xt/t0610-reftable-basics.sh12
2 files changed, 17 insertions, 1 deletions
diff --git a/refs/reftable-backend.c b/refs/reftable-backend.c
index 74dab18eda..66cdbbdb24 100644
--- a/refs/reftable-backend.c
+++ b/refs/reftable-backend.c
@@ -1221,8 +1221,12 @@ static int reftable_be_pack_refs(struct ref_store *ref_store,
stack = refs->main_stack;
ret = reftable_stack_compact_all(stack, NULL);
- if (ret)
+ if (ret < 0) {
+ ret = error(_("unable to compact stack: %s"),
+ reftable_error_str(ret));
goto out;
+ }
+
ret = reftable_stack_clean(stack);
if (ret)
goto out;
diff --git a/t/t0610-reftable-basics.sh b/t/t0610-reftable-basics.sh
index 5f2f9baa9b..a53d1dc493 100755
--- a/t/t0610-reftable-basics.sh
+++ b/t/t0610-reftable-basics.sh
@@ -375,6 +375,18 @@ test_expect_success 'pack-refs: compacts tables' '
test_line_count = 1 repo/.git/reftable/tables.list
'
+test_expect_success 'pack-refs: compaction raises locking errors' '
+ test_when_finished "rm -rf repo" &&
+ git init repo &&
+ test_commit -C repo A &&
+ touch repo/.git/reftable/tables.list.lock &&
+ cat >expect <<-EOF &&
+ error: unable to compact stack: data is locked
+ EOF
+ test_must_fail git -C repo pack-refs 2>err &&
+ test_cmp expect err
+'
+
test_expect_success 'pack-refs: prunes stale tables' '
test_when_finished "rm -rf repo" &&
git init repo &&