git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: [PATCH] format-patch: introduce format.outputDirectory configuration

From
Jeff King <peff@peff.net>
Date
Jun 18, 2015, 19:57 UTC
Message-ID
<20150618195751.GA14550@peff.net>
In-Reply-To
<xmqq616ley7y.fsf@gitster.dls.corp.google.com>
On Thu, Jun 18, 2015 at 10:13:37AM -0700, Junio C Hamano wrote:
Show 16 quoted lines
> > -static const char *set_outdir(const char *prefix, const char *output_directory)
> > +static const char *set_outdir(const char *prefix, const char *output_directory,
> > +			      const char *config_output_directory)
> 
> This change looks ugly and unnecessary.  All the machinery after and
> including the point set_outdir() is called, including reopen_stdout(),
> work on output_directory variable and only that variable.
> 
> Wouldn't it work equally well to have
> 
> 	if (!output_directory)
>         	output_directory = config_output_directory;
> 
> before a call to set_outdir() is made but after the configuration is
> read (namely, soon after parse_options() returns), without making
> any change to this function?

Don't we load the config before parsing options here? In that case, we can use our usual strategy to just set output_directory (which is already a static global) from the config callback, and everything Just Works.

We do have to bump the definition of output_directory up above the config callback, like so (while we are here, we might also want to drop the unnecessary static initializers, which violate our style guide):

diff --git a/builtin/log.c b/builtin/log.c
index e67671e..77c06f7 100644
--- a/builtin/log.c
+++ b/builtin/log.c
@@ -37,6 +37,10 @@ static int use_mailmap_config;
 static const char *fmt_patch_subject_prefix = "PATCH";
 static const char *fmt_pretty;
 
+static FILE *realstdout = NULL;
+static const char *output_directory = NULL;
+static int outdir_offset;
+
 static const char * const builtin_log_usage[] = {
 	N_("git log [<options>] [<revision-range>] [[--] <path>...]"),
 	N_("git show [<options>] <object>..."),
@@ -752,14 +756,12 @@ static int git_format_config(const char *var, const char *value, void *cb)
 		config_cover_letter = git_config_bool(var, value) ? COVER_ON : COVER_OFF;
 		return 0;
 	}
+	if (!strcmp(var, "format.outputdirectory"))
+		return git_config_string(&output_directory, var, value);
 
 	return git_log_config(var, value, cb);
 }
 
-static FILE *realstdout = NULL;
-static const char *output_directory = NULL;
-static int outdir_offset;
-
 static int reopen_stdout(struct commit *commit, const char *subject,
 			 struct rev_info *rev, int quiet)
 {
Previous: Junio C HamanoNext: Junio C Hamano
Message 3 of 18 in “format-patch: introduce format.outputDirectory configuration”
  1. format-patch: introduce format.outputDirectory configurationAlexander Kuleshov, Jun 18, 2015
  2. Junio C HamanoJun 18, 2015
  3. Jeff KingJun 18, 2015
  4. Junio C HamanoJun 18, 2015
  5. Junio C HamanoJun 18, 2015
  6. Jeff KingJun 18, 2015
  7. Jeff KingJun 18, 2015
  8. Junio C HamanoJun 18, 2015
  9. Jeff KingJun 19, 2015
  10. Alexander KuleshovJun 19, 2015
  11. Alexander KuleshovJun 19, 2015
  12. Junio C HamanoJun 19, 2015
  13. Alexander KuleshovJun 19, 2015
  14. Alexander KuleshovJun 19, 2015
  15. Alexander KuleshovJun 19, 2015
  16. Junio C HamanoJun 19, 2015
  17. Remi Galan AlfonsoJun 19, 2015
  18. Alexander KuleshovJun 19, 2015

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.