]> git.ipfire.org Git - thirdparty/git.git/commitdiff
refs/reftable: print errors on compaction failure
authorPatrick Steinhardt <ps@pks.im>
Mon, 25 Mar 2024 10:02:54 +0000 (11:02 +0100)
committerJunio C Hamano <gitster@pobox.com>
Mon, 25 Mar 2024 16:54:07 +0000 (09:54 -0700)
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>
refs/reftable-backend.c
t/t0610-reftable-basics.sh

index 74dab18eda50f8158f3e8c133a8dde70299ce3cb..66cdbbdb24ea5b177af2616536fad1992a8aeb2a 100644 (file)
@@ -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;
index 5f2f9baa9b705bde72fdc334a39bee6ecebcc87e..a53d1dc493adb876caf74491c3937c40ab41385a 100755 (executable)
@@ -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 &&