git/list[1] front-page[2] threads[3] people[4] search[5] about
 

[PATCH 03/10] submodule init: redirect stdout to stderr

From
Stefan Beller <sbeller@google.com>
Date
Apr 30, 2016, 00:40 UTC
Message-ID
<1461976845-18228-4-git-send-email-sbeller@google.com>
In-Reply-To
<1461976845-18228-1-git-send-email-sbeller@google.com>

Reroute the output of stdout to stderr as it is just informative messages, not to be consumed by machines.

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>
---
 builtin/submodule--helper.c |  3 ++-
 t/t7406-submodule-update.sh | 24 ++++++++++++++++++------
 2 files changed, 20 insertions(+), 7 deletions(-)
diff --git a/builtin/submodule--helper.c b/builtin/submodule--helper.c
index 5d05393..7f0941d 100644
--- a/builtin/submodule--helper.c
+++ b/builtin/submodule--helper.c
@@ -366,7 +366,8 @@ static void init_submodule(const char *path, const char *prefix, int quiet)
 			die(_("Failed to register url for submodule path '%s'"),
 			    displaypath);
 		if (!quiet)
-			printf(_("Submodule '%s' (%s) registered for path '%s'\n"),
+			fprintf(stderr,
+				_("Submodule '%s' (%s) registered for path '%s'\n"),
 				sub->name, url, displaypath);
 	}
 
diff --git a/t/t7406-submodule-update.sh b/t/t7406-submodule-update.sh
index fd741f5..5f27879 100755
--- a/t/t7406-submodule-update.sh
+++ b/t/t7406-submodule-update.sh
@@ -108,24 +108,36 @@ pwd=$(pwd)
 
 cat <<EOF >expect
 Submodule path '../super': checked out '$supersha1'
-Submodule 'merging' ($pwd/merging) registered for path '../super/merging'
-Submodule 'none' ($pwd/none) registered for path '../super/none'
-Submodule 'rebasing' ($pwd/rebasing) registered for path '../super/rebasing'
-Submodule 'submodule' ($pwd/submodule) registered for path '../super/submodule'
 Submodule path '../super/merging': checked out '$mergingsha1'
 Submodule path '../super/none': checked out '$nonesha1'
 Submodule path '../super/rebasing': checked out '$rebasingsha1'
 Submodule path '../super/submodule': checked out '$submodulesha1'
 EOF
 
+cat <<EOF >expect2
+Submodule 'merging' ($pwd/merging) registered for path '../super/merging'
+Submodule 'none' ($pwd/none) registered for path '../super/none'
+Submodule 'rebasing' ($pwd/rebasing) registered for path '../super/rebasing'
+Submodule 'submodule' ($pwd/submodule) registered for path '../super/submodule'
+Cloning into '$pwd/recursivesuper/super/merging'...
+done.
+Cloning into '$pwd/recursivesuper/super/none'...
+done.
+Cloning into '$pwd/recursivesuper/super/rebasing'...
+done.
+Cloning into '$pwd/recursivesuper/super/submodule'...
+done.
+EOF
+
 test_expect_success 'submodule update --init --recursive from subdirectory' '
 	git -C recursivesuper/super reset --hard HEAD^ &&
 	(cd recursivesuper &&
 	 mkdir tmp &&
 	 cd tmp &&
-	 git submodule update --init --recursive ../super >../../actual
+	 git submodule update --init --recursive ../super >../../actual 2>../../actual2
 	) &&
-	test_cmp expect actual
+	test_cmp expect actual &&
+	test_cmp expect2 actual2
 '
 
 apos="'";
-- 
2.8.0.32.g71f8beb.dirty
Previous: Stefan BellerNext: Stefan Beller
Message 4 of 20 in “submodule output patches”
  1. 00/10 submodule output patchesStefan Beller, Apr 30, 2016
  2. 01/10 submodule deinit test: fix broken && chain in subshellStefan Beller, Apr 30, 2016
  3. 02/10 submodule deinit: lose requirement for giving '.'Stefan Beller, Apr 30, 2016
  4. 03/10 submodule init: redirect stdout to stderrStefan Beller, Apr 30, 2016
  5. 04/10 shell helpers usage: always send help to stderrStefan Beller, Apr 30, 2016
  6. Junio C HamanoMay 2, 2016
  7. Stefan BellerMay 2, 2016
  8. Junio C HamanoMay 3, 2016
  9. Junio C HamanoMay 3, 2016
  10. 05/10 submodule add: send messages to stderrStefan Beller, Apr 30, 2016
  11. Junio C HamanoMay 2, 2016
  12. 06/10 submodule deinit: send messages to stderrStefan Beller, Apr 30, 2016
  13. Junio C HamanoMay 2, 2016
  14. 07/10 submodule foreach: send messages to stderrStefan Beller, Apr 30, 2016
  15. 08/10 submodule update: send messages to stderrStefan Beller, Apr 30, 2016
  16. 09/10 submodule sync: send messages to stderrStefan Beller, Apr 30, 2016
  17. 10/10 submodule deinit: complain when given a file instead of a submoduleStefan Beller, Apr 30, 2016
  18. Per CederqvistMay 2, 2016
  19. Stefan BellerMay 2, 2016
  20. Stefan BellerMay 2, 2016

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.