promisor-remote: add promisor.quiet configuration option

Add a configuration option to allow output from the promisor fetching objects to be suppressed. This allows us to stop commands like 'git blame' being swamped with progress messages and gc notifications from the promisor when used in a partial clone. Signed-off-by: Tom Hughes <tom@compton.nu> Signed-off-by: Junio C Hamano <gitster@pobox.com>

Tom Hughes committed May 25, 2024 at 11:09 UTC 7e17d954d8325824c40d0441eb10888d5178755e
4 files changed +51
Documentation/config.txt
+2
@@ -487,6 +487,8 @@ include::config/pager.txt[]
487
488 include::config/pretty.txt[]
489
490 +include::config/promisor.txt[]
491 +
492 include::config/protocol.txt[]
493
494 include::config/pull.txt[]
Documentation/config/promisor.txt new
+3
@@ -0,0 +1,3 @@
1 +promisor.quiet::
2 + If set to "true" assume `--quiet` when fetching additional
3 + objects for a partial clone.
promisor-remote.c
+3
@@ -22,6 +22,7 @@ static int fetch_objects(struct repository *repo,
22 struct child_process child = CHILD_PROCESS_INIT;
23 int i;
24 FILE *child_in;
25 + int quiet;
26
27 child.git_cmd = 1;
28 child.in = -1;
@@ -31,6 +32,8 @@ static int fetch_objects(struct repository *repo,
32 "fetch", remote_name, "--no-tags",
33 "--no-write-fetch-head", "--recurse-submodules=no",
34 "--filter=blob:none", "--stdin", NULL);
35 + if (!git_config_get_bool("promisor.quiet", &quiet) && quiet)
36 + strvec_push(&child.args, "--quiet");
37 if (start_command(&child))
38 die(_("promisor-remote: unable to fork off fetch subprocess"));
39 child_in = xfdopen(child.in, "w");
t/t0410-partial-clone.sh
+43
@@ -3,6 +3,7 @@
3 test_description='partial clone'
4
5 . ./test-lib.sh
6 +. "$TEST_DIRECTORY"/lib-terminal.sh
7
8 # missing promisor objects cause repacks which write bitmaps to fail
9 GIT_TEST_MULTI_PACK_INDEX_WRITE_BITMAP=0
@@ -689,6 +690,48 @@ test_expect_success 'lazy-fetch when accessing object not in the_repository' '
690 ! grep "[?]$FILE_HASH" out
691 '
692
693 +test_expect_success 'setup for promisor.quiet tests' '
694 + rm -rf server &&
695 + test_create_repo server &&
696 + test_commit -C server foo &&
697 + git -C server rm foo.t &&
698 + git -C server commit -m remove &&
699 + git -C server config uploadpack.allowanysha1inwant 1 &&
700 + git -C server config uploadpack.allowfilter 1
701 +'
702 +
703 +test_expect_success TTY 'promisor.quiet=false shows progress messages' '
704 + rm -rf repo &&
705 + git clone --filter=blob:none "file://$(pwd)/server" repo &&
706 + git -C repo config promisor.quiet "false" &&
707 +
708 + test_terminal git -C repo cat-file -p foo:foo.t 2>err &&
709 +
710 + # Ensure that progress messages are written
711 + grep "Receiving objects" err
712 +'
713 +
714 +test_expect_success TTY 'promisor.quiet=true does not show progress messages' '
715 + rm -rf repo &&
716 + git clone --filter=blob:none "file://$(pwd)/server" repo &&
717 + git -C repo config promisor.quiet "true" &&
718 +
719 + test_terminal git -C repo cat-file -p foo:foo.t 2>err &&
720 +
721 + # Ensure that no progress messages are written
722 + ! grep "Receiving objects" err
723 +'
724 +
725 +test_expect_success TTY 'promisor.quiet=unconfigured shows progress messages' '
726 + rm -rf repo &&
727 + git clone --filter=blob:none "file://$(pwd)/server" repo &&
728 +
729 + test_terminal git -C repo cat-file -p foo:foo.t 2>err &&
730 +
731 + # Ensure that progress messages are written
732 + grep "Receiving objects" err
733 +'
734 +
735 . "$TEST_DIRECTORY"/lib-httpd.sh
736 start_httpd
737