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

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

From
Eric Sunshine <sunshine@sunshineco.com>
Date
Jun 19, 2015, 20:34 UTC
Message-ID
<CAPig+cTOG7QP25TyJbbm70NBXN6Z0nZPJyjxFp1y147WQmKEDg@mail.gmail.com>
In-Reply-To
<1434738519-28093-1-git-send-email-kuleshovmail@gmail.com>

On Fri, Jun 19, 2015 at 2:28 PM, Alexander Kuleshov <kuleshovmail@gmail.com> wrote:

Show 5 quoted lines
> 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
s/convinience/convenience/
> to not pass everytime -o/--output-directory if an user has pattern
s/everytime/every time/
Show 20 quoted lines
> 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>
> ---
> diff --git a/Documentation/git-format-patch.txt b/Documentation/git-format-patch.txt
> index 0dac4e9..38ddd76 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 seting 'format.outputDirectory' configuration option.
s/seting/setting/ or s/seting//
> +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`.
s/set/set,/
Show 22 quoted lines
>  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 78b3e2c..fc26360 100644
> --- a/builtin/log.c
> +++ b/builtin/log.c
> @@ -688,6 +688,8 @@ enum {
>         COVER_AUTO
>  };
>
> +static const char *config_output_directory = NULL;
> +
>  static int git_format_config(const char *var, const char *value, void *cb)
>  {
>         if (!strcmp(var, "format.headers")) {
> @@ -758,6 +760,9 @@ 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);
> +       }
Style: Unnecessary braces.
Show 22 quoted lines
>         return git_log_config(var, value, cb);
>  }
> @@ -1368,6 +1373,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 890db11..613e2cc 100755
> --- a/t/t4014-format-patch.sh
> +++ b/t/t4014-format-patch.sh
> @@ -40,6 +40,24 @@ test_expect_success setup '
>
>  '
>
> +test_expect_success "format-patch format.outputDirectory option" '
> +       git config format.outputDirectory "patches/" &&

If you're using test_config (which you do below), then drop the above line and replace it with the test_config line.

Show 5 quoted lines
> +       git format-patch master..side &&
> +       cnt=$(ls | wc -l) &&
> +       test $cnt = 3 &&
> +       test_config format.outputDirectory "patches/" &&
> +       git config --unset format.outputDirectory

Move the test_config line to the top of the test and get rid of the 'git config --unset' line since test_config will unset the configuration automatically.

Show 5 quoted lines
> +'
> +
> +test_expect_success "format-patch format.outputDirectory overwritten with -o" '
> +       rm -rf "patches" &&
> +       git config format.outputDirectory "patches/" &&
Ditto: Place test_config line here and get rid of above line.
> +       git format-patch master..side -o "." &&
> +       test_must_fail ls patches/ &&

Don't use test_must_fail for non-git commands. Instead, use '!'. However, in this case, using:

    test_path_is_missing patches &&
would make the intent more clear.
> +       test_config format.outputDirectory "patches/" &&
> +       git config --unset format.outputDirectory
Ditto: Move test_config higher and drop 'git config --unset'.
Show 7 quoted lines
> +'
> +
>  test_expect_success "format-patch --ignore-if-in-upstream" '
>
>         git format-patch --stdout master..side >patch0 &&
> --
> 2.4.4.727.g5c3049e.dirty
Previous: Alexander KuleshovNext: Junio C Hamano
Message 2 of 14 in “format-patch: introduce format.outputDirectory configuration”
  1. format-patch: introduce format.outputDirectory configurationAlexander Kuleshov, Jun 19, 2015
  2. Eric SunshineJun 19, 2015
  3. Junio C HamanoSep 21, 2015
  4. Eric SunshineSep 22, 2015
  5. Junio C HamanoOct 28, 2015
  6. format-patch: introduce format.outputDirectory configurationStephen P. Smith, Jan 10, 2016
  7. Eric SunshineJan 10, 2016
  8. format-patch: introduce format.outputDirectory configurationStephen P. Smith, Jan 11, 2016
  9. Eric SunshineJan 11, 2016
  10. Eric SunshineJan 11, 2016
  11. format-patch: introduce format.outputDirectory configurationStephen P. Smith, Jan 13, 2016
  12. Eric SunshineJan 13, 2016
  13. format-patch: introduce format.outputDirectory configurationStephen P. Smith, Jan 13, 2016
  14. Eric SunshineJan 13, 2016

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.