Skip to content

Commit

Permalink
promisor-remote: add promisor.quiet configuration option
Browse files Browse the repository at this point in the history
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 <[email protected]>
Signed-off-by: Junio C Hamano <[email protected]>
  • Loading branch information
tomhughes authored and gitster committed May 26, 2024
1 parent 786a3e4 commit 7e17d95
Show file tree
Hide file tree
Showing 4 changed files with 51 additions and 0 deletions.
2 changes: 2 additions & 0 deletions Documentation/config.txt
Original file line number Diff line number Diff line change
Expand Up @@ -487,6 +487,8 @@ include::config/pager.txt[]

include::config/pretty.txt[]

include::config/promisor.txt[]

include::config/protocol.txt[]

include::config/pull.txt[]
Expand Down
3 changes: 3 additions & 0 deletions Documentation/config/promisor.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
promisor.quiet::
If set to "true" assume `--quiet` when fetching additional
objects for a partial clone.
3 changes: 3 additions & 0 deletions promisor-remote.c
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ static int fetch_objects(struct repository *repo,
struct child_process child = CHILD_PROCESS_INIT;
int i;
FILE *child_in;
int quiet;

child.git_cmd = 1;
child.in = -1;
Expand All @@ -31,6 +32,8 @@ static int fetch_objects(struct repository *repo,
"fetch", remote_name, "--no-tags",
"--no-write-fetch-head", "--recurse-submodules=no",
"--filter=blob:none", "--stdin", NULL);
if (!git_config_get_bool("promisor.quiet", &quiet) && quiet)
strvec_push(&child.args, "--quiet");
if (start_command(&child))
die(_("promisor-remote: unable to fork off fetch subprocess"));
child_in = xfdopen(child.in, "w");
Expand Down
43 changes: 43 additions & 0 deletions t/t0410-partial-clone.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
test_description='partial clone'

. ./test-lib.sh
. "$TEST_DIRECTORY"/lib-terminal.sh

# missing promisor objects cause repacks which write bitmaps to fail
GIT_TEST_MULTI_PACK_INDEX_WRITE_BITMAP=0
Expand Down Expand Up @@ -689,6 +690,48 @@ test_expect_success 'lazy-fetch when accessing object not in the_repository' '
! grep "[?]$FILE_HASH" out
'

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
start_httpd

Expand Down

0 comments on commit 7e17d95

Please sign in to comment.