Skip to content

Commit

Permalink
Flush output in start_async
Browse files Browse the repository at this point in the history
This prevents double output in case stdout is redirected.

Signed-off-by: Anders Melchiorsen <mail@cup.kalibalik.dk>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
  • Loading branch information
Anders Melchiorsen authored and Junio C Hamano committed Aug 4, 2008
1 parent 2253776 commit 2c3766f
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 0 deletions.
3 changes: 3 additions & 0 deletions run-command.c
Original file line number Diff line number Diff line change
Expand Up @@ -304,6 +304,9 @@ int start_async(struct async *async)
async->out = pipe_out[0];

#ifndef __MINGW32__
/* Flush stdio before fork() to avoid cloning buffers */
fflush(NULL);

async->pid = fork();
if (async->pid < 0) {
error("fork (async) failed: %s", strerror(errno));
Expand Down
6 changes: 6 additions & 0 deletions t/t5601-clone.sh
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,12 @@ test_expect_success 'clone with excess parameters (2)' '
'

test_expect_success 'output from clone' '
rm -fr dst &&
git clone -n "file://$(pwd)/src" dst >output &&
test $(grep Initialized output | wc -l) = 1
'

test_expect_success 'clone does not keep pack' '
rm -fr dst &&
Expand Down

0 comments on commit 2c3766f

Please sign in to comment.