Skip to content

Commit 4b7f2fa

Browse files
committed
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 <[email protected]>
1 parent 2c3fd4b commit 4b7f2fa

File tree

2 files changed

+3
-2
lines changed

2 files changed

+3
-2
lines changed

builtin/receive-pack.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -977,7 +977,8 @@ int cmd_receive_pack(int argc, const char **argv, const char *prefix)
977977
const char *argv_gc_auto[] = {
978978
"gc", "--auto", "--quiet", NULL,
979979
};
980-
run_command_v_opt(argv_gc_auto, RUN_GIT_CMD);
980+
int opt = RUN_GIT_CMD | RUN_COMMAND_STDOUT_TO_STDERR;
981+
run_command_v_opt(argv_gc_auto, opt);
981982
}
982983
if (auto_update_server_info)
983984
update_server_info(0);

t/t5400-send-pack.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -145,7 +145,7 @@ test_expect_success 'push --all excludes remote-tracking hierarchy' '
145145
)
146146
'
147147

148-
test_expect_failure 'receive-pack runs auto-gc in remote repo' '
148+
test_expect_success 'receive-pack runs auto-gc in remote repo' '
149149
rm -rf parent child &&
150150
git init parent &&
151151
(

0 commit comments

Comments
 (0)