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

Re: [PATCH 2/2] prune.c: only print informational message in show_only or verbose mode

From
Junio C Hamano <gitster@pobox.com>
Date
Aug 7, 2012, 05:34 UTC
Message-ID
<7vpq73w9i8.fsf@alter.siamese.dyndns.org>
In-Reply-To
<7vtxwfw9rp.fsf@alter.siamese.dyndns.org>
Junio C Hamano <gitster@pobox.com> writes:
Show 5 quoted lines
> Note that this chooses to expose what comes out of the standard
> output of the subprocess to the standard error to be shown to the
> user sitting on the other end.  This is in line with what we do to
> all of our hooks (Cf. cd83c74 (Redirect update hook stdout to
> stderr., 2006-12-30)).
Ok, now a tested patch, on top of your 1/2
-- >8 --
Subject: [PATCH] receive-pack: do not leak output from auto-gc to standard output

The standard output channel of receive-pack is a structured protocol channel, and subprocesses must never be allowed to leak anything into it by writing to their standard output.

Use RUN_COMMAND_STDOUT_TO_STDERR option to run_command_v_opt() just like we do when running hooks to prevent output from "gc" leaking to the standard output.

Signed-off-by: Junio C Hamano <gitster@pobox.com>
---
 builtin/receive-pack.c | 3 ++-
 t/t5400-send-pack.sh   | 2 +-
 2 files changed, 3 insertions(+), 2 deletions(-)
diff --git a/builtin/receive-pack.c b/builtin/receive-pack.c
index 0afb8b2..3f05d97 100644
--- a/builtin/receive-pack.c
+++ b/builtin/receive-pack.c
@@ -977,7 +977,8 @@ int cmd_receive_pack(int argc, const char **argv, const char *prefix)
 			const char *argv_gc_auto[] = {
 				"gc", "--auto", "--quiet", NULL,
 			};
-			run_command_v_opt(argv_gc_auto, RUN_GIT_CMD);
+			int opt = RUN_GIT_CMD | RUN_COMMAND_STDOUT_TO_STDERR;
+			run_command_v_opt(argv_gc_auto, opt);
 		}
 		if (auto_update_server_info)
 			update_server_info(0);
diff --git a/t/t5400-send-pack.sh b/t/t5400-send-pack.sh
index 04a8791..250c720 100755
--- a/t/t5400-send-pack.sh
+++ b/t/t5400-send-pack.sh
@@ -145,7 +145,7 @@ test_expect_success 'push --all excludes remote-tracking hierarchy' '
 	)
 '
 
-test_expect_failure 'receive-pack runs auto-gc in remote repo' '
+test_expect_success 'receive-pack runs auto-gc in remote repo' '
 	rm -rf parent child &&
 	git init parent &&
 	(
-- 
1.7.12.rc1.93.g8914ab8
Previous: Junio C HamanoNext: Brandon Casey
Message 7 of 15 in “Did we break receive-pack recently?”
  1. Junio C HamanoAug 5, 2012
  2. Brandon CaseyAug 6, 2012
  3. Brandon CaseyAug 6, 2012
  4. 1/2 t/t5400: demonstrate breakage caused by informational message from pruneBrandon Casey, Aug 7, 2012
  5. 2/2 prune.c: only print informational message in show_only or verbose modeBrandon Casey, Aug 7, 2012
  6. Junio C HamanoAug 7, 2012
  7. Junio C HamanoAug 7, 2012
  8. Brandon CaseyAug 7, 2012
  9. Jeff KingAug 7, 2012
  10. Brandon CaseyAug 7, 2012
  11. Junio C HamanoAug 7, 2012
  12. Junio C HamanoAug 7, 2012
  13. Jeff KingAug 7, 2012
  14. Brandon CaseyAug 7, 2012
  15. Jeff KingAug 7, 2012

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.