Skip to content

Commit 8311e3b

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

File tree

2 files changed

+22
-0
lines changed

2 files changed

+22
-0
lines changed

builtin/gc.c

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1159,6 +1159,12 @@ static int pack_loose(struct maintenance_run_opts *opts)
11591159

11601160
pack_proc.in = -1;
11611161

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+
11621168
if (start_command(&pack_proc)) {
11631169
error(_("failed to start 'git pack-objects' process"));
11641170
return 1;

t/t7900-maintenance.sh

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -975,4 +975,20 @@ test_expect_success '--detach causes maintenance to run in background' '
975975
)
976976
'
977977

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+
978994
test_done

0 commit comments

Comments
 (0)