Skip to content

Commit

Permalink
wt-status.c: no need for dup() dance anymore
Browse files Browse the repository at this point in the history
Now we can generate diff to a file descriptor, we do not have to
dup() the stdout around when writing the status output.

Signed-off-by: Junio C Hamano <gitster@pobox.com>
  • Loading branch information
Kristian Høgsberg authored and Junio C Hamano committed Mar 14, 2008
1 parent c0c7773 commit 4ba0cb2
Showing 1 changed file with 2 additions and 15 deletions.
17 changes: 2 additions & 15 deletions wt-status.c
Original file line number Diff line number Diff line change
Expand Up @@ -269,27 +269,14 @@ static void wt_status_print_untracked(struct wt_status *s)
static void wt_status_print_verbose(struct wt_status *s)
{
struct rev_info rev;
int saved_stdout;

fflush(s->fp);

/* Sigh, the entire diff machinery is hardcoded to output to
* stdout. Do the dup-dance...*/
saved_stdout = dup(STDOUT_FILENO);
if (saved_stdout < 0 ||dup2(fileno(s->fp), STDOUT_FILENO) < 0)
die("couldn't redirect stdout\n");

init_revisions(&rev, NULL);
setup_revisions(0, NULL, &rev, s->reference);
rev.diffopt.output_format |= DIFF_FORMAT_PATCH;
rev.diffopt.detect_rename = 1;
rev.diffopt.file = s->fp;
rev.diffopt.close_file = 0;
run_diff_index(&rev, 1);

fflush(stdout);

if (dup2(saved_stdout, STDOUT_FILENO) < 0)
die("couldn't restore stdout\n");
close(saved_stdout);
}

void wt_status_print(struct wt_status *s)
Expand Down

0 comments on commit 4ba0cb2

Please sign in to comment.