diff options
author | Kristian Høgsberg <krh@redhat.com> | 2007-11-21 21:54:49 -0500 |
---|---|---|
committer | Junio C Hamano <gitster@pobox.com> | 2007-11-22 17:05:05 -0800 |
commit | 99a12694582e2148fcd492f1eedaddcfe2a21621 (patch) | |
tree | c9d7b3648fd3428062fdb316c4ec4036aa250622 /wt-status.c | |
parent | 2888605c649ccd423232161186d72c0e6c458a48 (diff) | |
download | git-99a12694582e2148fcd492f1eedaddcfe2a21621.tar.gz git-99a12694582e2148fcd492f1eedaddcfe2a21621.tar.xz |
builtin-commit: Include the diff in the commit message when verbose.
run_diff_index() and the entire diff machinery is hard coded to output
to stdout, so just redirect that and restore it when done.
Signed-off-by: Kristian Høgsberg <krh@redhat.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'wt-status.c')
-rw-r--r-- | wt-status.c | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/wt-status.c b/wt-status.c index d3c10b8b8..0e0439f2c 100644 --- a/wt-status.c +++ b/wt-status.c @@ -315,12 +315,28 @@ 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; wt_read_cache(s); 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) |