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 <sbeller@google.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Stefan Beller committed
May 2, 2016 at 15:24 UTC
c66410ed32a807cefca6f679ad5583eda2e9527b
2 files changed
+20
-7
builtin/submodule--helper.c
+2
-1
@@ -366,7 +366,8 @@ static void init_submodule(const char *path, const char *prefix, int quiet)
366
die(_("Failed to register url for submodule path '%s'"),
367
displaypath);
368
if (!quiet)
369
- printf(_("Submodule '%s' (%s) registered for path '%s'\n"),
369
+ fprintf(stderr,
370
+ _("Submodule '%s' (%s) registered for path '%s'\n"),
371
sub->name, url, displaypath);
372
}
373
t/t7406-submodule-update.sh
+18
-6
@@ -108,24 +108,36 @@ pwd=$(pwd)
108
109
cat <<EOF >expect
110
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'
111
Submodule path '../super/merging': checked out '$mergingsha1'
112
Submodule path '../super/none': checked out '$nonesha1'
113
Submodule path '../super/rebasing': checked out '$rebasingsha1'
114
Submodule path '../super/submodule': checked out '$submodulesha1'
115
EOF
116
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
+
132
test_expect_success 'submodule update --init --recursive from subdirectory' '
133
git -C recursivesuper/super reset --hard HEAD^ &&
134
(cd recursivesuper &&
135
mkdir tmp &&
136
cd tmp &&
126
- git submodule update --init --recursive ../super >../../actual
137
+ git submodule update --init --recursive ../super >../../actual 2>../../actual2
138
) &&
128
- test_cmp expect actual
139
+ test_cmp expect actual &&
140
+ test_cmp expect2 actual2
141
'
142
143
apos="'";