diffopt.file-v4
dscho
tagged this
22 Jun 15:01
The idea is to allow callers to redirect log-tree's output to a file without having to freopen() stdout (which would modify global state, a big no-no-no for library functions). I reviewed log-tree.c, graph.c, line-log.c, builtin/shortlog.c and builtin/log.c line by line to ensure that all calls that assumed stdout previously now use the `file` field instead, of course. I would welcome additional eyes to go over the code to confirm that I did not miss anything. This patch series ends up removing the freopen() call in the format-patch command, but that is only a by-product. The ulterior motive behind this series is to allow the sequencer to write a `patch` file as part of my endeavor to move large chunks of rebase -i into a builtin. In contrast to the previous iteration of this patch series, - the use_color = 0 setting was made contingent on use_color != ALWAYS - close_file = 1 was made to work in more circumstances, most notably when calling log_commit_tree() (and in builtin/log.c, where this function is called in a loop) - the changes to builtin/am.c were backed out completely (this is a can of worms I am not prepared to open for now) - I also taught shortlog to respect the --output=<file> option, because it was so easy to do - I added a test case to ensure that `log --output=<file>` works Johannes Schindelin (10): Prepare log/log-tree to reuse the diffopt.close_file attribute log-tree: respect diffopt's configured output file stream line-log: respect diffopt's configured output file stream graph: respect the diffopt.file setting shortlog: support outputting to streams other than stdout format-patch: explicitly switch off color when writing to files format-patch: avoid freopen() format-patch: use stdout directly shortlog: respect the --output=<file> setting Ensure that log respects --output=<file> builtin/log.c | 87 +++++++++++++++++++++++++++++------------------------ builtin/shortlog.c | 15 ++++++--- graph.c | 30 ++++++++++-------- line-log.c | 34 ++++++++++----------- log-tree.c | 69 ++++++++++++++++++++++-------------------- shortlog.h | 1 + t/t4201-shortlog.sh | 6 ++++ t/t4211-line-log.sh | 7 +++++ 8 files changed, 142 insertions(+), 107 deletions(-) Submitted-As: http://mid.gmane.org/cover.1466607667.git.johannes.schindelin@gmx.de In-Reply-To: http://mid.gmane.org/cover.1466420060.git.johannes.schindelin@gmx.de In-Reply-To: http://mid.gmane.org/cover.1466244194.git.johannes.schindelin@gmx.de In-Reply-To: http://mid.gmane.org/cover.1466505222.git.johannes.schindelin@gmx.de