builtin/maintenance: fix loose objects task emitting pack hash
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>
Patrick Steinhardt committed
Aug 19, 2024 at 09:48 UTC
8311e3b5515ea161c74cfd9b032270c0f459f2b8
2 files changed
+22
builtin/gc.c
+6
@@ -1159,6 +1159,12 @@ static int pack_loose(struct maintenance_run_opts *opts)
1159
1160
pack_proc.in = -1;
1161
1162
+ /*
1163
+ * git-pack-objects(1) ends up writing the pack hash to stdout, which
1164
+ * we do not care for.
1165
+ */
1166
+ pack_proc.out = -1;
1167
+
1168
if (start_command(&pack_proc)) {
1169
error(_("failed to start 'git pack-objects' process"));
1170
return 1;
t/t7900-maintenance.sh
+16
@@ -975,4 +975,20 @@ test_expect_success '--detach causes maintenance to run in background' '
975
)
976
'
977
978
+test_expect_success 'repacking loose objects is quiet' '
979
+ test_when_finished "rm -rf repo" &&
980
+ git init repo &&
981
+ (
982
+ cd repo &&
983
+
984
+ test_commit something &&
985
+ git config set maintenance.gc.enabled false &&
986
+ git config set maintenance.loose-objects.enabled true &&
987
+ git config set maintenance.loose-objects.auto 1 &&
988
+
989
+ git maintenance run --quiet >out 2>&1 &&
990
+ test_must_be_empty out
991
+ )
992
+'
993
+
994
test_done