Skip to content

Commit

Permalink
receive-pack: redirect unpack-objects stdout to /dev/null
Browse files Browse the repository at this point in the history
The unpack-objects command should not generally produce any
output on stdout. However, if it's given extra input after
the packfile, it will spew the remainder to stdout. When
called by receive-pack, this means we will break protocol,
since our stdout is connected to the remote send-pack.

Signed-off-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
  • Loading branch information
Jeff King authored and Junio C Hamano committed Sep 21, 2012
1 parent 8ef2794 commit 59bfdfb
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion builtin/receive-pack.c
Original file line number Diff line number Diff line change
Expand Up @@ -821,6 +821,7 @@ static const char *unpack(void)

if (ntohl(hdr.hdr_entries) < unpack_limit) {
int code, i = 0;
struct child_process child;
const char *unpacker[5];
unpacker[i++] = "unpack-objects";
if (quiet)
Expand All @@ -829,7 +830,11 @@ static const char *unpack(void)
unpacker[i++] = "--strict";
unpacker[i++] = hdr_arg;
unpacker[i++] = NULL;
code = run_command_v_opt(unpacker, RUN_GIT_CMD);
memset(&child, 0, sizeof(child));
child.argv = unpacker;
child.no_stdout = 1;
child.git_cmd = 1;
code = run_command(&child);
if (!code)
return NULL;
return "unpack-objects abnormal exit";
Expand Down

0 comments on commit 59bfdfb

Please sign in to comment.