]> git.ipfire.org Git - thirdparty/git.git/commitdiff
builtin/maintenance: fix loose objects task emitting pack hash
authorPatrick Steinhardt <ps@pks.im>
Mon, 19 Aug 2024 07:48:05 +0000 (09:48 +0200)
committerJunio C Hamano <gitster@pobox.com>
Wed, 21 Aug 2024 18:33:22 +0000 (11:33 -0700)
The "loose-objects" maintenance tasks executes git-pack-objects(1) to
pack all loose objects into a new packfile. This command ends up
printing the hash of the packfile to stdout though, which clutters the
output of `git maintenance run`.

Fix this issue by disabling stdout of the child process.

Signed-off-by: Patrick Steinhardt <ps@pks.im>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
builtin/gc.c
t/t7900-maintenance.sh

index 13bc0572a325d29ae7d112df1ce0be41ef005c69..be75efa17a092270f692e37a23a8f6abb46d69d2 100644 (file)
@@ -1159,6 +1159,12 @@ static int pack_loose(struct maintenance_run_opts *opts)
 
        pack_proc.in = -1;
 
+       /*
+        * git-pack-objects(1) ends up writing the pack hash to stdout, which
+        * we do not care for.
+        */
+       pack_proc.out = -1;
+
        if (start_command(&pack_proc)) {
                error(_("failed to start 'git pack-objects' process"));
                return 1;
index 18e0bb29d7c77692200eb97bd40bc107bc1836e9..abae7a97546f66567cc34f363581fe02dfecf245 100755 (executable)
@@ -975,4 +975,20 @@ test_expect_success '--detach causes maintenance to run in background' '
        )
 '
 
+test_expect_success 'repacking loose objects is quiet' '
+       test_when_finished "rm -rf repo" &&
+       git init repo &&
+       (
+               cd repo &&
+
+               test_commit something &&
+               git config set maintenance.gc.enabled false &&
+               git config set maintenance.loose-objects.enabled true &&
+               git config set maintenance.loose-objects.auto 1 &&
+
+               git maintenance run --quiet >out 2>&1 &&
+               test_must_be_empty out
+       )
+'
+
 test_done