From: Alexander Kuleshov <kuleshovmail@xxxxxxxxx> We can pass -o/--output-directory to the format-patch command to store patches not in the working directory. This patch introduces format.outputDirectory configuration option for same purpose. The case of usage of this configuration option can be convinience to not pass everytime -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@xxxxxxxxx> Signed-off-by: Stephen P. Smith <ischis2@xxxxxxx> --- Notes: Re-rolled patch by following review comments in: http://article.gmane.org/gmane.comp.version-control.git/272199 http://article.gmane.org/gmane.comp.version-control.git/278354 http://article.gmane.org/gmane.comp.version-control.git/278365 Changes include: * Specifying the patches directory as an argument to ls * Not initialize config_output_directory to NULL * Grammar fixes in documentation * Use test_config rather than git config Documentation/config.txt | 4 ++++ Documentation/git-format-patch.txt | 6 +++++- builtin/log.c | 7 +++++++ t/t4014-format-patch.sh | 13 +++++++++++++ 4 files changed, 29 insertions(+), 1 deletion(-) diff --git a/Documentation/config.txt b/Documentation/config.txt index f617886..e92a0ee 100644 --- a/Documentation/config.txt +++ b/Documentation/config.txt @@ -1243,6 +1243,10 @@ format.coverLetter:: format-patch is invoked, but in addition can be set to "auto", to generate a cover-letter only when there's more than one patch. +format.outputDirectory:: + Set a custom directory to store the resulting files instead of the + current working directory. + filter.<driver>.clean:: The command which is used to convert the content of a worktree file to a blob upon checkin. See linkgit:gitattributes[5] for diff --git a/Documentation/git-format-patch.txt b/Documentation/git-format-patch.txt index e3cdaeb..7a76594 100644 --- a/Documentation/git-format-patch.txt +++ b/Documentation/git-format-patch.txt @@ -57,7 +57,11 @@ The names of the output files are printed to standard output, unless the `--stdout` option is specified. If `-o` is specified, output files are created in <dir>. Otherwise -they are created in the current working directory. +they are created in the current working directory. The default path +can be set with the setting 'format.outputDirectory' configuration option. +If `-o` is specified and 'format.outputDirectory' is set, output files +will be stored in a <dir> that passed to `-o`. When 'format.outputDirectory' +is set, to get default behaviour back is to pass './' to the `-o`. By default, the subject of a single patch is "[PATCH] " followed by the concatenation of lines from the commit message up to the first blank diff --git a/builtin/log.c b/builtin/log.c index e00cea7..679ff76 100644 --- a/builtin/log.c +++ b/builtin/log.c @@ -707,6 +707,8 @@ enum { COVER_AUTO }; +static const char *config_output_directory; + static int git_format_config(const char *var, const char *value, void *cb) { if (!strcmp(var, "format.headers")) { @@ -777,6 +779,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 +1395,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 diff --git a/t/t4014-format-patch.sh b/t/t4014-format-patch.sh index 646c475..5c6f128 100755 --- a/t/t4014-format-patch.sh +++ b/t/t4014-format-patch.sh @@ -40,6 +40,19 @@ test_expect_success setup ' ' +test_expect_success "format-patch format.outputDirectory option" ' + test_config format.outputDirectory "patches/" && + git format-patch master..side && + cnt=$(ls patches | wc -l) && + test $cnt = 3 +' + +test_expect_success "format-patch format.outputDirectory overwritten with -o" ' + test_config format.outputDirectory "patches/" && + git format-patch master..side -o "." && + test_path_is_missing patches/ +' + test_expect_success "format-patch --ignore-if-in-upstream" ' git format-patch --stdout master..side >patch0 && -- 2.7.0-rc2 -- 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