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:28 UTC
Message-ID
<7vtxwfw9rp.fsf@alter.siamese.dyndns.org>
In-Reply-To
<1344315709-15897-2-git-send-email-drafnel@gmail.com>
Thanks.

This patch may fix the immediate symptom, but I think the right fix is to correct the way "gc" is invoked by receive-pack, so that nothing "gc" writes to its standard output can leak to the standard output of the receive-pack. After all, receive-pack is the one that knows that its output is a structured protocol communication channel and should not be contaminated by random crufts. Receive-pack is the one that is responsible to avoid this kind of problem in the first place.

Once that fix is done, any future changes to "gc" or its subprograms won't be able to cause the same breakage again. Which automatically makes your patch unnecessary.

Something along this line, perhaps.

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)).

If we instead want to discard the standard output, we would need to either extend run_command_v_opt(), or set up our own child_process and spawn the subprocess using the underlying run_command() API ourselves.

 builtin/receive-pack.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/builtin/receive-pack.c b/builtin/receive-pack.c
index ee7751a..19bdc66 100644
--- a/builtin/receive-pack.c
+++ b/builtin/receive-pack.c
@@ -979,7 +979,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);
 
Previous: Brandon CaseyNext: Junio C Hamano
Message 6 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.