mirror of
https://github.com/git/git
synced 2024-10-30 13:20:15 +00:00
submodule.c: write "Fetching submodule <foo>" to stderr
The "Pushing submodule <foo>" progress output correctly goes to stderr, but "Fetching submodule <foo>" is going to stdout by mistake. Fix it to write to stderr. Noticed while trying to implement a parallel submodule fetch. When this particular output line went to a different file descriptor, it was buffered separately, resulting in wrongly interleaved output if we copied it to the terminal naively. Signed-off-by: Jonathan Nieder <jrnieder@gmail.com> Signed-off-by: Stefan Beller <sbeller@google.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
This commit is contained in:
parent
4b9ab0ee01
commit
fbf71645d1
2 changed files with 27 additions and 26 deletions
|
@ -689,7 +689,7 @@ int fetch_populated_submodules(const struct argv_array *options,
|
||||||
git_dir = submodule_git_dir.buf;
|
git_dir = submodule_git_dir.buf;
|
||||||
if (is_directory(git_dir)) {
|
if (is_directory(git_dir)) {
|
||||||
if (!quiet)
|
if (!quiet)
|
||||||
printf("Fetching submodule %s%s\n", prefix, ce->name);
|
fprintf(stderr, "Fetching submodule %s%s\n", prefix, ce->name);
|
||||||
cp.dir = submodule_path.buf;
|
cp.dir = submodule_path.buf;
|
||||||
argv_array_push(&argv, default_argv);
|
argv_array_push(&argv, default_argv);
|
||||||
argv_array_push(&argv, "--submodule-prefix");
|
argv_array_push(&argv, "--submodule-prefix");
|
||||||
|
|
|
@ -16,7 +16,8 @@ add_upstream_commit() {
|
||||||
git add subfile &&
|
git add subfile &&
|
||||||
git commit -m new subfile &&
|
git commit -m new subfile &&
|
||||||
head2=$(git rev-parse --short HEAD) &&
|
head2=$(git rev-parse --short HEAD) &&
|
||||||
echo "From $pwd/submodule" > ../expect.err &&
|
echo "Fetching submodule submodule" > ../expect.err &&
|
||||||
|
echo "From $pwd/submodule" >> ../expect.err &&
|
||||||
echo " $head1..$head2 master -> origin/master" >> ../expect.err
|
echo " $head1..$head2 master -> origin/master" >> ../expect.err
|
||||||
) &&
|
) &&
|
||||||
(
|
(
|
||||||
|
@ -27,6 +28,7 @@ add_upstream_commit() {
|
||||||
git add deepsubfile &&
|
git add deepsubfile &&
|
||||||
git commit -m new deepsubfile &&
|
git commit -m new deepsubfile &&
|
||||||
head2=$(git rev-parse --short HEAD) &&
|
head2=$(git rev-parse --short HEAD) &&
|
||||||
|
echo "Fetching submodule submodule/subdir/deepsubmodule" >> ../expect.err
|
||||||
echo "From $pwd/deepsubmodule" >> ../expect.err &&
|
echo "From $pwd/deepsubmodule" >> ../expect.err &&
|
||||||
echo " $head1..$head2 master -> origin/master" >> ../expect.err
|
echo " $head1..$head2 master -> origin/master" >> ../expect.err
|
||||||
)
|
)
|
||||||
|
@ -56,9 +58,7 @@ test_expect_success setup '
|
||||||
(
|
(
|
||||||
cd downstream &&
|
cd downstream &&
|
||||||
git submodule update --init --recursive
|
git submodule update --init --recursive
|
||||||
) &&
|
)
|
||||||
echo "Fetching submodule submodule" > expect.out &&
|
|
||||||
echo "Fetching submodule submodule/subdir/deepsubmodule" >> expect.out
|
|
||||||
'
|
'
|
||||||
|
|
||||||
test_expect_success "fetch --recurse-submodules recurses into submodules" '
|
test_expect_success "fetch --recurse-submodules recurses into submodules" '
|
||||||
|
@ -67,7 +67,7 @@ test_expect_success "fetch --recurse-submodules recurses into submodules" '
|
||||||
cd downstream &&
|
cd downstream &&
|
||||||
git fetch --recurse-submodules >../actual.out 2>../actual.err
|
git fetch --recurse-submodules >../actual.out 2>../actual.err
|
||||||
) &&
|
) &&
|
||||||
test_i18ncmp expect.out actual.out &&
|
test_must_be_empty actual.out &&
|
||||||
test_i18ncmp expect.err actual.err
|
test_i18ncmp expect.err actual.err
|
||||||
'
|
'
|
||||||
|
|
||||||
|
@ -96,7 +96,7 @@ test_expect_success "using fetchRecurseSubmodules=true in .gitmodules recurses i
|
||||||
git config -f .gitmodules submodule.submodule.fetchRecurseSubmodules true &&
|
git config -f .gitmodules submodule.submodule.fetchRecurseSubmodules true &&
|
||||||
git fetch >../actual.out 2>../actual.err
|
git fetch >../actual.out 2>../actual.err
|
||||||
) &&
|
) &&
|
||||||
test_i18ncmp expect.out actual.out &&
|
test_must_be_empty actual.out &&
|
||||||
test_i18ncmp expect.err actual.err
|
test_i18ncmp expect.err actual.err
|
||||||
'
|
'
|
||||||
|
|
||||||
|
@ -127,7 +127,7 @@ test_expect_success "--recurse-submodules overrides fetchRecurseSubmodules setti
|
||||||
git config --unset -f .gitmodules submodule.submodule.fetchRecurseSubmodules &&
|
git config --unset -f .gitmodules submodule.submodule.fetchRecurseSubmodules &&
|
||||||
git config --unset submodule.submodule.fetchRecurseSubmodules
|
git config --unset submodule.submodule.fetchRecurseSubmodules
|
||||||
) &&
|
) &&
|
||||||
test_i18ncmp expect.out actual.out &&
|
test_must_be_empty actual.out &&
|
||||||
test_i18ncmp expect.err actual.err
|
test_i18ncmp expect.err actual.err
|
||||||
'
|
'
|
||||||
|
|
||||||
|
@ -146,7 +146,7 @@ test_expect_success "--dry-run propagates to submodules" '
|
||||||
cd downstream &&
|
cd downstream &&
|
||||||
git fetch --recurse-submodules --dry-run >../actual.out 2>../actual.err
|
git fetch --recurse-submodules --dry-run >../actual.out 2>../actual.err
|
||||||
) &&
|
) &&
|
||||||
test_i18ncmp expect.out actual.out &&
|
test_must_be_empty actual.out &&
|
||||||
test_i18ncmp expect.err actual.err
|
test_i18ncmp expect.err actual.err
|
||||||
'
|
'
|
||||||
|
|
||||||
|
@ -155,7 +155,7 @@ test_expect_success "Without --dry-run propagates to submodules" '
|
||||||
cd downstream &&
|
cd downstream &&
|
||||||
git fetch --recurse-submodules >../actual.out 2>../actual.err
|
git fetch --recurse-submodules >../actual.out 2>../actual.err
|
||||||
) &&
|
) &&
|
||||||
test_i18ncmp expect.out actual.out &&
|
test_must_be_empty actual.out &&
|
||||||
test_i18ncmp expect.err actual.err
|
test_i18ncmp expect.err actual.err
|
||||||
'
|
'
|
||||||
|
|
||||||
|
@ -166,7 +166,7 @@ test_expect_success "recurseSubmodules=true propagates into submodules" '
|
||||||
git config fetch.recurseSubmodules true
|
git config fetch.recurseSubmodules true
|
||||||
git fetch >../actual.out 2>../actual.err
|
git fetch >../actual.out 2>../actual.err
|
||||||
) &&
|
) &&
|
||||||
test_i18ncmp expect.out actual.out &&
|
test_must_be_empty actual.out &&
|
||||||
test_i18ncmp expect.err actual.err
|
test_i18ncmp expect.err actual.err
|
||||||
'
|
'
|
||||||
|
|
||||||
|
@ -180,7 +180,7 @@ test_expect_success "--recurse-submodules overrides config in submodule" '
|
||||||
) &&
|
) &&
|
||||||
git fetch --recurse-submodules >../actual.out 2>../actual.err
|
git fetch --recurse-submodules >../actual.out 2>../actual.err
|
||||||
) &&
|
) &&
|
||||||
test_i18ncmp expect.out actual.out &&
|
test_must_be_empty actual.out &&
|
||||||
test_i18ncmp expect.err actual.err
|
test_i18ncmp expect.err actual.err
|
||||||
'
|
'
|
||||||
|
|
||||||
|
@ -214,16 +214,15 @@ test_expect_success "Recursion stops when no new submodule commits are fetched"
|
||||||
git add submodule &&
|
git add submodule &&
|
||||||
git commit -m "new submodule" &&
|
git commit -m "new submodule" &&
|
||||||
head2=$(git rev-parse --short HEAD) &&
|
head2=$(git rev-parse --short HEAD) &&
|
||||||
echo "Fetching submodule submodule" > expect.out.sub &&
|
|
||||||
echo "From $pwd/." > expect.err.sub &&
|
echo "From $pwd/." > expect.err.sub &&
|
||||||
echo " $head1..$head2 master -> origin/master" >>expect.err.sub &&
|
echo " $head1..$head2 master -> origin/master" >>expect.err.sub &&
|
||||||
head -2 expect.err >> expect.err.sub &&
|
head -3 expect.err >> expect.err.sub &&
|
||||||
(
|
(
|
||||||
cd downstream &&
|
cd downstream &&
|
||||||
git fetch >../actual.out 2>../actual.err
|
git fetch >../actual.out 2>../actual.err
|
||||||
) &&
|
) &&
|
||||||
test_i18ncmp expect.err.sub actual.err &&
|
test_i18ncmp expect.err.sub actual.err &&
|
||||||
test_i18ncmp expect.out.sub actual.out
|
test_must_be_empty actual.out
|
||||||
'
|
'
|
||||||
|
|
||||||
test_expect_success "Recursion doesn't happen when new superproject commits don't change any submodules" '
|
test_expect_success "Recursion doesn't happen when new superproject commits don't change any submodules" '
|
||||||
|
@ -269,7 +268,7 @@ test_expect_success "Recursion picks up config in submodule" '
|
||||||
)
|
)
|
||||||
) &&
|
) &&
|
||||||
test_i18ncmp expect.err.sub actual.err &&
|
test_i18ncmp expect.err.sub actual.err &&
|
||||||
test_i18ncmp expect.out actual.out
|
test_must_be_empty actual.out
|
||||||
'
|
'
|
||||||
|
|
||||||
test_expect_success "Recursion picks up all submodules when necessary" '
|
test_expect_success "Recursion picks up all submodules when necessary" '
|
||||||
|
@ -285,7 +284,8 @@ test_expect_success "Recursion picks up all submodules when necessary" '
|
||||||
git add subdir/deepsubmodule &&
|
git add subdir/deepsubmodule &&
|
||||||
git commit -m "new deepsubmodule"
|
git commit -m "new deepsubmodule"
|
||||||
head2=$(git rev-parse --short HEAD) &&
|
head2=$(git rev-parse --short HEAD) &&
|
||||||
echo "From $pwd/submodule" > ../expect.err.sub &&
|
echo "Fetching submodule submodule" > ../expect.err.sub &&
|
||||||
|
echo "From $pwd/submodule" >> ../expect.err.sub &&
|
||||||
echo " $head1..$head2 master -> origin/master" >> ../expect.err.sub
|
echo " $head1..$head2 master -> origin/master" >> ../expect.err.sub
|
||||||
) &&
|
) &&
|
||||||
head1=$(git rev-parse --short HEAD) &&
|
head1=$(git rev-parse --short HEAD) &&
|
||||||
|
@ -295,13 +295,13 @@ test_expect_success "Recursion picks up all submodules when necessary" '
|
||||||
echo "From $pwd/." > expect.err.2 &&
|
echo "From $pwd/." > expect.err.2 &&
|
||||||
echo " $head1..$head2 master -> origin/master" >> expect.err.2 &&
|
echo " $head1..$head2 master -> origin/master" >> expect.err.2 &&
|
||||||
cat expect.err.sub >> expect.err.2 &&
|
cat expect.err.sub >> expect.err.2 &&
|
||||||
tail -2 expect.err >> expect.err.2 &&
|
tail -3 expect.err >> expect.err.2 &&
|
||||||
(
|
(
|
||||||
cd downstream &&
|
cd downstream &&
|
||||||
git fetch >../actual.out 2>../actual.err
|
git fetch >../actual.out 2>../actual.err
|
||||||
) &&
|
) &&
|
||||||
test_i18ncmp expect.err.2 actual.err &&
|
test_i18ncmp expect.err.2 actual.err &&
|
||||||
test_i18ncmp expect.out actual.out
|
test_must_be_empty actual.out
|
||||||
'
|
'
|
||||||
|
|
||||||
test_expect_success "'--recurse-submodules=on-demand' doesn't recurse when no new commits are fetched in the superproject (and ignores config)" '
|
test_expect_success "'--recurse-submodules=on-demand' doesn't recurse when no new commits are fetched in the superproject (and ignores config)" '
|
||||||
|
@ -317,7 +317,8 @@ test_expect_success "'--recurse-submodules=on-demand' doesn't recurse when no ne
|
||||||
git add subdir/deepsubmodule &&
|
git add subdir/deepsubmodule &&
|
||||||
git commit -m "new deepsubmodule" &&
|
git commit -m "new deepsubmodule" &&
|
||||||
head2=$(git rev-parse --short HEAD) &&
|
head2=$(git rev-parse --short HEAD) &&
|
||||||
echo "From $pwd/submodule" > ../expect.err.sub &&
|
echo Fetching submodule submodule > ../expect.err.sub &&
|
||||||
|
echo "From $pwd/submodule" >> ../expect.err.sub &&
|
||||||
echo " $head1..$head2 master -> origin/master" >> ../expect.err.sub
|
echo " $head1..$head2 master -> origin/master" >> ../expect.err.sub
|
||||||
) &&
|
) &&
|
||||||
(
|
(
|
||||||
|
@ -335,7 +336,7 @@ test_expect_success "'--recurse-submodules=on-demand' recurses as deep as necess
|
||||||
git add submodule &&
|
git add submodule &&
|
||||||
git commit -m "new submodule" &&
|
git commit -m "new submodule" &&
|
||||||
head2=$(git rev-parse --short HEAD) &&
|
head2=$(git rev-parse --short HEAD) &&
|
||||||
tail -2 expect.err > expect.err.deepsub &&
|
tail -3 expect.err > expect.err.deepsub &&
|
||||||
echo "From $pwd/." > expect.err &&
|
echo "From $pwd/." > expect.err &&
|
||||||
echo " $head1..$head2 master -> origin/master" >>expect.err &&
|
echo " $head1..$head2 master -> origin/master" >>expect.err &&
|
||||||
cat expect.err.sub >> expect.err &&
|
cat expect.err.sub >> expect.err &&
|
||||||
|
@ -354,7 +355,7 @@ test_expect_success "'--recurse-submodules=on-demand' recurses as deep as necess
|
||||||
git config --unset -f .gitmodules submodule.subdir/deepsubmodule.fetchRecursive
|
git config --unset -f .gitmodules submodule.subdir/deepsubmodule.fetchRecursive
|
||||||
)
|
)
|
||||||
) &&
|
) &&
|
||||||
test_i18ncmp expect.out actual.out &&
|
test_must_be_empty actual.out &&
|
||||||
test_i18ncmp expect.err actual.err
|
test_i18ncmp expect.err actual.err
|
||||||
'
|
'
|
||||||
|
|
||||||
|
@ -388,7 +389,7 @@ test_expect_success "'fetch.recurseSubmodules=on-demand' overrides global config
|
||||||
head2=$(git rev-parse --short HEAD) &&
|
head2=$(git rev-parse --short HEAD) &&
|
||||||
echo "From $pwd/." > expect.err.2 &&
|
echo "From $pwd/." > expect.err.2 &&
|
||||||
echo " $head1..$head2 master -> origin/master" >>expect.err.2 &&
|
echo " $head1..$head2 master -> origin/master" >>expect.err.2 &&
|
||||||
head -2 expect.err >> expect.err.2 &&
|
head -3 expect.err >> expect.err.2 &&
|
||||||
(
|
(
|
||||||
cd downstream &&
|
cd downstream &&
|
||||||
git config fetch.recurseSubmodules on-demand &&
|
git config fetch.recurseSubmodules on-demand &&
|
||||||
|
@ -399,7 +400,7 @@ test_expect_success "'fetch.recurseSubmodules=on-demand' overrides global config
|
||||||
cd downstream &&
|
cd downstream &&
|
||||||
git config --unset fetch.recurseSubmodules
|
git config --unset fetch.recurseSubmodules
|
||||||
) &&
|
) &&
|
||||||
test_i18ncmp expect.out.sub actual.out &&
|
test_must_be_empty actual.out &&
|
||||||
test_i18ncmp expect.err.2 actual.err
|
test_i18ncmp expect.err.2 actual.err
|
||||||
'
|
'
|
||||||
|
|
||||||
|
@ -416,7 +417,7 @@ test_expect_success "'submodule.<sub>.fetchRecurseSubmodules=on-demand' override
|
||||||
head2=$(git rev-parse --short HEAD) &&
|
head2=$(git rev-parse --short HEAD) &&
|
||||||
echo "From $pwd/." > expect.err.2 &&
|
echo "From $pwd/." > expect.err.2 &&
|
||||||
echo " $head1..$head2 master -> origin/master" >>expect.err.2 &&
|
echo " $head1..$head2 master -> origin/master" >>expect.err.2 &&
|
||||||
head -2 expect.err >> expect.err.2 &&
|
head -3 expect.err >> expect.err.2 &&
|
||||||
(
|
(
|
||||||
cd downstream &&
|
cd downstream &&
|
||||||
git config submodule.submodule.fetchRecurseSubmodules on-demand &&
|
git config submodule.submodule.fetchRecurseSubmodules on-demand &&
|
||||||
|
@ -427,7 +428,7 @@ test_expect_success "'submodule.<sub>.fetchRecurseSubmodules=on-demand' override
|
||||||
cd downstream &&
|
cd downstream &&
|
||||||
git config --unset submodule.submodule.fetchRecurseSubmodules
|
git config --unset submodule.submodule.fetchRecurseSubmodules
|
||||||
) &&
|
) &&
|
||||||
test_i18ncmp expect.out.sub actual.out &&
|
test_must_be_empty actual.out &&
|
||||||
test_i18ncmp expect.err.2 actual.err
|
test_i18ncmp expect.err.2 actual.err
|
||||||
'
|
'
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue