Skip to content

Commit c66410e

Browse files
stefanbellergitster
authored andcommitted
submodule init: redirect stdout to stderr
Reroute the output of stdout to stderr as it is just informative messages, not to be consumed by machines. This should not regress any scripts that try to parse the current output, as the output is already internationalized and therefore unstable. We want to init submodules from the helper for `submodule update` in a later patch and the stdout output of said helper is consumed by the parts of `submodule update` which are still written in shell. So we have to be careful which messages are on stdout. Signed-off-by: Stefan Beller <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 08fdbdb commit c66410e

File tree

2 files changed

+20
-7
lines changed

2 files changed

+20
-7
lines changed

builtin/submodule--helper.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -366,7 +366,8 @@ static void init_submodule(const char *path, const char *prefix, int quiet)
366366
die(_("Failed to register url for submodule path '%s'"),
367367
displaypath);
368368
if (!quiet)
369-
printf(_("Submodule '%s' (%s) registered for path '%s'\n"),
369+
fprintf(stderr,
370+
_("Submodule '%s' (%s) registered for path '%s'\n"),
370371
sub->name, url, displaypath);
371372
}
372373

t/t7406-submodule-update.sh

Lines changed: 18 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -108,24 +108,36 @@ pwd=$(pwd)
108108

109109
cat <<EOF >expect
110110
Submodule path '../super': checked out '$supersha1'
111-
Submodule 'merging' ($pwd/merging) registered for path '../super/merging'
112-
Submodule 'none' ($pwd/none) registered for path '../super/none'
113-
Submodule 'rebasing' ($pwd/rebasing) registered for path '../super/rebasing'
114-
Submodule 'submodule' ($pwd/submodule) registered for path '../super/submodule'
115111
Submodule path '../super/merging': checked out '$mergingsha1'
116112
Submodule path '../super/none': checked out '$nonesha1'
117113
Submodule path '../super/rebasing': checked out '$rebasingsha1'
118114
Submodule path '../super/submodule': checked out '$submodulesha1'
119115
EOF
120116

117+
cat <<EOF >expect2
118+
Submodule 'merging' ($pwd/merging) registered for path '../super/merging'
119+
Submodule 'none' ($pwd/none) registered for path '../super/none'
120+
Submodule 'rebasing' ($pwd/rebasing) registered for path '../super/rebasing'
121+
Submodule 'submodule' ($pwd/submodule) registered for path '../super/submodule'
122+
Cloning into '$pwd/recursivesuper/super/merging'...
123+
done.
124+
Cloning into '$pwd/recursivesuper/super/none'...
125+
done.
126+
Cloning into '$pwd/recursivesuper/super/rebasing'...
127+
done.
128+
Cloning into '$pwd/recursivesuper/super/submodule'...
129+
done.
130+
EOF
131+
121132
test_expect_success 'submodule update --init --recursive from subdirectory' '
122133
git -C recursivesuper/super reset --hard HEAD^ &&
123134
(cd recursivesuper &&
124135
mkdir tmp &&
125136
cd tmp &&
126-
git submodule update --init --recursive ../super >../../actual
137+
git submodule update --init --recursive ../super >../../actual 2>../../actual2
127138
) &&
128-
test_cmp expect actual
139+
test_cmp expect actual &&
140+
test_cmp expect2 actual2
129141
'
130142

131143
apos="'";

0 commit comments

Comments
 (0)