Re: [PATCH] Write diff output to a file in struct diff_options

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Sun, 2008-03-09 at 22:43 -0400, Daniel Barkalow wrote:
> Signed-off-by: Daniel Barkalow <barkalow@xxxxxxxxxxxx>
> ---
> I remember there being some expectation that this would be difficult, but 
> it was a pretty straightforward conversion, so I'm wondering if I've 
> missed something. In any case, this is missing tests and documentation for 
> --output=, but I really want it to use directly for rebase-interactive, 
> and I only did the command line option so I could do informal testing.

I ended up just dup()-ing files around in wt-status.c, but it wasn't
that converting looked difficult, just that I was trying to finish the
builtin-commit work and didn't want to undertake a new rewrite :)  With
your patch, we can now avoid the dup-dance.

cheers,
Kristian


diff --git a/wt-status.c b/wt-status.c
index 32d780a..181821b 100644
--- a/wt-status.c
+++ b/wt-status.c
@@ -314,25 +314,13 @@ 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)


--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html

[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]

  Powered by Linux