Merge branch 'th/quiet-lazy-fetch-from-promisor'

The promisor.quiet configuration knob can be set to true to make
lazy fetching from promisor remotes silent.

* th/quiet-lazy-fetch-from-promisor:
  promisor-remote: add promisor.quiet configuration option
This commit is contained in:
Junio C Hamano 2024-06-06 12:49:23 -07:00
commit d11b0c75ec
4 changed files with 51 additions and 0 deletions

View file

@ -488,6 +488,8 @@ include::config/pager.txt[]
include::config/pretty.txt[] include::config/pretty.txt[]
include::config/promisor.txt[]
include::config/protocol.txt[] include::config/protocol.txt[]
include::config/pull.txt[] include::config/pull.txt[]

View file

@ -0,0 +1,3 @@
promisor.quiet::
If set to "true" assume `--quiet` when fetching additional
objects for a partial clone.

View file

@ -23,6 +23,7 @@ static int fetch_objects(struct repository *repo,
struct child_process child = CHILD_PROCESS_INIT; struct child_process child = CHILD_PROCESS_INIT;
int i; int i;
FILE *child_in; FILE *child_in;
int quiet;
if (git_env_bool(NO_LAZY_FETCH_ENVIRONMENT, 0)) { if (git_env_bool(NO_LAZY_FETCH_ENVIRONMENT, 0)) {
static int warning_shown; static int warning_shown;
@ -41,6 +42,8 @@ static int fetch_objects(struct repository *repo,
"fetch", remote_name, "--no-tags", "fetch", remote_name, "--no-tags",
"--no-write-fetch-head", "--recurse-submodules=no", "--no-write-fetch-head", "--recurse-submodules=no",
"--filter=blob:none", "--stdin", NULL); "--filter=blob:none", "--stdin", NULL);
if (!git_config_get_bool("promisor.quiet", &quiet) && quiet)
strvec_push(&child.args, "--quiet");
if (start_command(&child)) if (start_command(&child))
die(_("promisor-remote: unable to fork off fetch subprocess")); die(_("promisor-remote: unable to fork off fetch subprocess"));
child_in = xfdopen(child.in, "w"); child_in = xfdopen(child.in, "w");

View file

@ -3,6 +3,7 @@
test_description='partial clone' test_description='partial clone'
. ./test-lib.sh . ./test-lib.sh
. "$TEST_DIRECTORY"/lib-terminal.sh
# missing promisor objects cause repacks which write bitmaps to fail # missing promisor objects cause repacks which write bitmaps to fail
GIT_TEST_MULTI_PACK_INDEX_WRITE_BITMAP=0 GIT_TEST_MULTI_PACK_INDEX_WRITE_BITMAP=0
@ -708,6 +709,48 @@ test_expect_success 'push should not fetch new commit objects' '
grep "^[?]$COMMIT" objects grep "^[?]$COMMIT" objects
' '
test_expect_success 'setup for promisor.quiet tests' '
rm -rf server &&
test_create_repo server &&
test_commit -C server foo &&
git -C server rm foo.t &&
git -C server commit -m remove &&
git -C server config uploadpack.allowanysha1inwant 1 &&
git -C server config uploadpack.allowfilter 1
'
test_expect_success TTY 'promisor.quiet=false shows progress messages' '
rm -rf repo &&
git clone --filter=blob:none "file://$(pwd)/server" repo &&
git -C repo config promisor.quiet "false" &&
test_terminal git -C repo cat-file -p foo:foo.t 2>err &&
# Ensure that progress messages are written
grep "Receiving objects" err
'
test_expect_success TTY 'promisor.quiet=true does not show progress messages' '
rm -rf repo &&
git clone --filter=blob:none "file://$(pwd)/server" repo &&
git -C repo config promisor.quiet "true" &&
test_terminal git -C repo cat-file -p foo:foo.t 2>err &&
# Ensure that no progress messages are written
! grep "Receiving objects" err
'
test_expect_success TTY 'promisor.quiet=unconfigured shows progress messages' '
rm -rf repo &&
git clone --filter=blob:none "file://$(pwd)/server" repo &&
test_terminal git -C repo cat-file -p foo:foo.t 2>err &&
# Ensure that progress messages are written
grep "Receiving objects" err
'
. "$TEST_DIRECTORY"/lib-httpd.sh . "$TEST_DIRECTORY"/lib-httpd.sh
start_httpd start_httpd