receive-pack: do not leak output from auto-gc to standard output
authorJunio C Hamano <gitster@pobox.com>
Tue, 7 Aug 2012 05:31:10 +0000 (22:31 -0700)
committerJunio C Hamano <gitster@pobox.com>
Tue, 7 Aug 2012 05:31:10 +0000 (22:31 -0700)
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
t/t5400-send-pack.sh

index 0afb8b289621c419bd7472097335e4235da37d61..3f05d971ec2f8b047b2ef3a32c91f039d686d91a 100644 (file)
@@ -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);
index 04a87913ed85e331b08b084df03972ff1630f7b6..250c720c14602bdf21e6a7200437b13fe6feaca3 100755 (executable)
@@ -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 &&
        (