@matheusbsbs / matheus-bagliano / commits / 4ba0cb27c1
Fork 0

wt-status.c: no need for dup() dance anymore

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>

Kristian Høgsberg committed Mar 10, 2008 at 13:58 UTC 4ba0cb27c1c0c3aa65d28e1891c1f3dca3db5f93
1 file changed +2 -15
wt-status.c
+2 -15
@@ -269,27 +269,14 @@ static void wt_status_print_untracked(struct wt_status *s)
269 static void wt_status_print_verbose(struct wt_status *s)
270 {
271 struct rev_info rev;
272 - int saved_stdout;
273 -
274 - fflush(s->fp);
275 -
276 - /* Sigh, the entire diff machinery is hardcoded to output to
277 - * stdout. Do the dup-dance...*/
278 - saved_stdout = dup(STDOUT_FILENO);
279 - if (saved_stdout < 0 ||dup2(fileno(s->fp), STDOUT_FILENO) < 0)
280 - die("couldn't redirect stdout\n");
272
273 init_revisions(&rev, NULL);
274 setup_revisions(0, NULL, &rev, s->reference);
275 rev.diffopt.output_format |= DIFF_FORMAT_PATCH;
276 rev.diffopt.detect_rename = 1;
277 + rev.diffopt.file = s->fp;
278 + rev.diffopt.close_file = 0;
279 run_diff_index(&rev, 1);
287 -
288 - fflush(stdout);
289 -
290 - if (dup2(saved_stdout, STDOUT_FILENO) < 0)
291 - die("couldn't restore stdout\n");
292 - close(saved_stdout);
280 }
281
282 void wt_status_print(struct wt_status *s)