format-patch: introduce format.outputDirectory configuration
We can pass -o/--output-directory to the format-patch command to store patches in some place other than the working directory. This patch introduces format.outputDirectory configuration option for same purpose. The case of usage of this configuration option can be convenience to not pass every time -o/--output-directory if an user has pattern to store all patches in the /patches directory for example. The format.outputDirectory has lower priority than command line option, so if user will set format.outputDirectory and pass the command line option, a result will be stored in a directory that passed to command line option. Signed-off-by: Alexander Kuleshov <kuleshovmail@gmail.com> Signed-off-by: Stephen P. Smith <ischis2@cox.net> Reviewed-by: Eric Sunshine <sunshine@sunshineco.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
This commit is contained in:
committed by
Junio C Hamano
parent
754884255b
commit
bc6bf2d764
@ -699,6 +699,7 @@ static int do_signoff;
|
||||
static const char *signature = git_version_string;
|
||||
static const char *signature_file;
|
||||
static int config_cover_letter;
|
||||
static const char *config_output_directory;
|
||||
|
||||
enum {
|
||||
COVER_UNSET,
|
||||
@ -777,6 +778,8 @@ 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(&config_output_directory, var, value);
|
||||
|
||||
return git_log_config(var, value, cb);
|
||||
}
|
||||
@ -1391,6 +1394,9 @@ int cmd_format_patch(int argc, const char **argv, const char *prefix)
|
||||
if (rev.show_notes)
|
||||
init_display_notes(&rev.notes_opt);
|
||||
|
||||
if (!output_directory && !use_stdout)
|
||||
output_directory = config_output_directory;
|
||||
|
||||
if (!use_stdout)
|
||||
output_directory = set_outdir(prefix, output_directory);
|
||||
else
|
||||
|
||||
Reference in New Issue
Block a user