Skip to content

Commit fa1468a

Browse files
trieu1162000gitster
authored andcommitted
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>
1 parent 2f8c3f6 commit fa1468a

File tree

2 files changed

+45
-2
lines changed

2 files changed

+45
-2
lines changed

promisor-remote.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ static int fetch_objects(struct repository *repo,
4646
"fetch", remote_name, "--no-tags",
4747
"--no-write-fetch-head", "--recurse-submodules=no",
4848
"--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)
5050
strvec_push(&child.args, "--quiet");
5151
if (start_command(&child))
5252
die(_("promisor-remote: unable to fork off fetch subprocess"));

t/t0410-partial-clone.sh

Lines changed: 44 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -717,7 +717,29 @@ test_expect_success 'setup for promisor.quiet tests' '
717717
git -C server rm foo.t &&
718718
git -C server commit -m remove &&
719719
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
721743
'
722744

723745
test_expect_success TTY 'promisor.quiet=false shows progress messages' '
@@ -752,6 +774,27 @@ test_expect_success TTY 'promisor.quiet=unconfigured shows progress messages' '
752774
grep "Receiving objects" err
753775
'
754776

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+
755798
. "$TEST_DIRECTORY"/lib-httpd.sh
756799
start_httpd
757800

0 commit comments

Comments
 (0)