Skip to content

Commit 7e17d95

Browse files
tomhughesgitster
authored andcommitted
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 <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 786a3e4 commit 7e17d95

File tree

4 files changed

+51
-0
lines changed

4 files changed

+51
-0
lines changed

Documentation/config.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -487,6 +487,8 @@ include::config/pager.txt[]
487487

488488
include::config/pretty.txt[]
489489

490+
include::config/promisor.txt[]
491+
490492
include::config/protocol.txt[]
491493

492494
include::config/pull.txt[]

Documentation/config/promisor.txt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -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

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ static int fetch_objects(struct repository *repo,
2222
struct child_process child = CHILD_PROCESS_INIT;
2323
int i;
2424
FILE *child_in;
25+
int quiet;
2526

2627
child.git_cmd = 1;
2728
child.in = -1;
@@ -31,6 +32,8 @@ static int fetch_objects(struct repository *repo,
3132
"fetch", remote_name, "--no-tags",
3233
"--no-write-fetch-head", "--recurse-submodules=no",
3334
"--filter=blob:none", "--stdin", NULL);
35+
if (!git_config_get_bool("promisor.quiet", &quiet) && quiet)
36+
strvec_push(&child.args, "--quiet");
3437
if (start_command(&child))
3538
die(_("promisor-remote: unable to fork off fetch subprocess"));
3639
child_in = xfdopen(child.in, "w");

t/t0410-partial-clone.sh

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
test_description='partial clone'
44

55
. ./test-lib.sh
6+
. "$TEST_DIRECTORY"/lib-terminal.sh
67

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

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+
692735
. "$TEST_DIRECTORY"/lib-httpd.sh
693736
start_httpd
694737

0 commit comments

Comments
 (0)