promisor-remote: fix promisor.quiet to use the correct repository

fetch_objects() reads the promisor.quiet configuration from the_repository instead of the repo parameter it receives. This means that when git lazy-fetches objects for a non-main repository, eg. a submodule that is itself a partial clone opened via repo_submodule_init(). The submodule's own promisor.quiet setting is ignored and the superproject's setting is used instead. Fix by replacing the_repository with repo in the repo_config_get_bool() call. The practical trigger is git grep --recurse-submodules on a superproject where the submodule is a partial clone. Add a test where promisor.quiet is set only in a partial-clone submodule; a lazy fetch triggered by "git grep --recurse-submodules" must honor that setting. Signed-off-by: Trieu Huynh <vikingtc4@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>

Trieu Huynh committed Apr 7, 2026 at 03:30 UTC fa1468a1f7c7765a6c7dd1faca4c9dc241d0538c
2 files changed +45 -2
promisor-remote.c
+1 -1
@@ -46,7 +46,7 @@ static int fetch_objects(struct repository *repo,
46 "fetch", remote_name, "--no-tags",
47 "--no-write-fetch-head", "--recurse-submodules=no",
48 "--filter=blob:none", "--stdin", NULL);
49 - if (!repo_config_get_bool(the_repository, "promisor.quiet", &quiet) && quiet)
49 + if (!repo_config_get_bool(repo, "promisor.quiet", &quiet) && quiet)
50 strvec_push(&child.args, "--quiet");
51 if (start_command(&child))
52 die(_("promisor-remote: unable to fork off fetch subprocess"));
t/t0410-partial-clone.sh
+44 -1
@@ -717,7 +717,29 @@ test_expect_success 'setup for promisor.quiet tests' '
717 git -C server rm foo.t &&
718 git -C server commit -m remove &&
719 git -C server config uploadpack.allowanysha1inwant 1 &&
720 - git -C server config uploadpack.allowfilter 1
720 + git -C server config uploadpack.allowfilter 1 &&
721 +
722 + # Setup for submodule repo test: superproject whose submodule is a
723 + # partial clone, so that promisor.quiet is read via a non-main repo.
724 + rm -rf sub-pc-src sub-pc-srv.bare super-src super-work &&
725 + git init sub-pc-src &&
726 + test_commit -C sub-pc-src initial file.txt "hello" &&
727 +
728 + git clone --bare sub-pc-src sub-pc-srv.bare &&
729 + git -C sub-pc-srv.bare config uploadpack.allowfilter 1 &&
730 + git -C sub-pc-srv.bare config uploadpack.allowanysha1inwant 1 &&
731 +
732 + git init super-src &&
733 + git -C super-src -c protocol.file.allow=always \
734 + submodule add "file://$(pwd)/sub-pc-srv.bare" sub &&
735 + git -C super-src commit -m "add submodule" &&
736 +
737 + git -c protocol.file.allow=always clone super-src super-work &&
738 + git -C super-work -c protocol.file.allow=always \
739 + submodule update --init --filter=blob:none sub &&
740 +
741 + # Allow file:// in the submodule so that lazy-fetch subprocesses work.
742 + git -C super-work/sub config protocol.file.allow always
743 '
744
745 test_expect_success TTY 'promisor.quiet=false shows progress messages' '
@@ -752,6 +774,27 @@ test_expect_success TTY 'promisor.quiet=unconfigured shows progress messages' '
774 grep "Receiving objects" err
775 '
776
777 +test_expect_success 'promisor.quiet from submodule repo is honored' '
778 + rm -f pc-quiet-trace &&
779 +
780 + # Set promisor.quiet only in the submodule, not the superproject.
781 + git -C super-work/sub config promisor.quiet true &&
782 +
783 + # Push a new commit+blob to the server; the blob stays missing in the
784 + # partial-clone submodule until a lazy fetch is triggered.
785 + test_commit -C sub-pc-src updated new-file.txt "world" &&
786 + git -C sub-pc-src push "$(pwd)/sub-pc-srv.bare" HEAD:master &&
787 + git -C super-work/sub -c protocol.file.allow=always fetch origin &&
788 + git -C super-work/sub reset --mixed origin/master &&
789 +
790 + # grep descends into the submodule and triggers a lazy fetch for the
791 + # missing blob; verify the fetch subprocess carries --quiet.
792 + GIT_TRACE2_EVENT="$(pwd)/pc-quiet-trace" \
793 + git -C super-work grep --cached --recurse-submodules "world" \
794 + 2>/dev/null &&
795 + grep negotiationAlgorithm pc-quiet-trace | grep -e --quiet
796 +'
797 +
798 . "$TEST_DIRECTORY"/lib-httpd.sh
799 start_httpd
800