{"thread":{"id":"51002","subject":"[PATCH 0/2] format-patch: teach format.notes config option","startedAt":"2019-04-27T19:25:25Z","lastAt":"2019-05-14T17:01:13Z","messageCount":15,"participants":["Denton Liu","Junio C Hamano","Beat Bolli"],"isPatch":true,"patchVersion":1,"patchTotal":2},"messages":[{"id":"374603","messageId":"cover.1556388260.git.liu.denton@gmail.com","threadId":"51002","inReplyTo":null,"subject":"[PATCH 0/2] format-patch: teach format.notes config option","fromName":"Denton Liu","fromEmail":"liu.denton@gmail.com","sentAt":"2019-04-27T19:25:12Z","receivedAt":"2019-04-27T19:25:25Z","isPatch":true,"sender":{"key":"liu.denton@gmail.com","avatar":"https://avatars.githubusercontent.com/u/9620836?v=4"},"body":"If a user sends patches with git-format-patch, they might want to take\nadvantage of notes to add additional commentary. However, if they are\nforgetful (like me) they may forget to include the `--notes` option in\ntheir invocation of git-format-patch.\n\nTeach git-format-patch the `format.notes` config option where if its\nvalue is true, notes will automatically be appended.\n\nDenton Liu (2):\n  git-format-patch.txt: document --no-notes option\n  format-patch: teach format.notes config option\n\n Documentation/config/format.txt    |  4 ++++\n Documentation/git-format-patch.txt |  7 ++++++-\n builtin/log.c                      |  6 ++++++\n t/t4014-format-patch.sh            | 28 ++++++++++++++++++++++++++++\n 4 files changed, 44 insertions(+), 1 deletion(-)\n\n-- \n2.21.0.1033.g0e8cc1100c\n\n"},{"id":"374604","messageId":"48b6331d75c0e7cd2e435ae912f2b19f7f2f6b43.1556388260.git.liu.denton@gmail.com","threadId":"51002","inReplyTo":"cover.1556388260.git.liu.denton@gmail.com","subject":"[PATCH 1/2] git-format-patch.txt: document --no-notes option","fromName":"Denton Liu","fromEmail":"liu.denton@gmail.com","sentAt":"2019-04-27T19:25:22Z","receivedAt":"2019-04-27T19:25:27Z","isPatch":true,"sender":{"key":"liu.denton@gmail.com","avatar":"https://avatars.githubusercontent.com/u/9620836?v=4"},"body":"Internally, git-format-patch uses the `handle_revision_opt` parser. The\nparser handles the `--no-notes` option to negate an earlier `--notes`\noption, but it isn't documented. Document this option so that users are\naware of it.\n\nSigned-off-by: Denton Liu <liu.denton@gmail.com>\n---\n Documentation/git-format-patch.txt | 4 +++-\n 1 file changed, 3 insertions(+), 1 deletion(-)\n\ndiff --git a/Documentation/git-format-patch.txt b/Documentation/git-format-patch.txt\nindex 1af85d404f..2c3971390e 100644\n--- a/Documentation/git-format-patch.txt\n+++ b/Documentation/git-format-patch.txt\n@@ -22,7 +22,8 @@ SYNOPSIS\n \t\t   [--rfc] [--subject-prefix=Subject-Prefix]\n \t\t   [(--reroll-count|-v) <n>]\n \t\t   [--to=<email>] [--cc=<email>]\n-\t\t   [--[no-]cover-letter] [--quiet] [--notes[=<ref>]]\n+\t\t   [--[no-]cover-letter] [--quiet]\n+\t\t   [--no-notes | --notes[=<ref>]]\n \t\t   [--interdiff=<previous>]\n \t\t   [--range-diff=<previous> [--creation-factor=<percent>]]\n \t\t   [--progress]\n@@ -263,6 +264,7 @@ material (this may change in the future).\n \tfor details.\n \n --notes[=<ref>]::\n+--no-notes::\n \tAppend the notes (see linkgit:git-notes[1]) for the commit\n \tafter the three-dash line.\n +\n-- \n2.21.0.1033.g0e8cc1100c\n\n"},{"id":"374605","messageId":"1338045be4a185cddc3ebf8adbe4b744551acf15.1556388260.git.liu.denton@gmail.com","threadId":"51002","inReplyTo":"cover.1556388260.git.liu.denton@gmail.com","subject":"[PATCH 2/2] format-patch: teach format.notes config option","fromName":"Denton Liu","fromEmail":"liu.denton@gmail.com","sentAt":"2019-04-27T19:25:25Z","receivedAt":"2019-04-27T19:25:30Z","isPatch":true,"sender":{"key":"liu.denton@gmail.com","avatar":"https://avatars.githubusercontent.com/u/9620836?v=4"},"body":"In git-format-patch, notes can be appended with the `--notes` option.\nHowever, this must be specified by the user on an\ninvocation-by-invocation basis. If a user is not careful, it's possible\nthat they may forget to include it and generate a patch series without\nnotes.\n\nTeach git-format-patch the `format.notes` config option where if its\nvalue is true, notes will automatically be appended. This option is\noverridable with the `--no-notes` option in case a user wishes not to\nappend notes.\n\nSigned-off-by: Denton Liu <liu.denton@gmail.com>\n---\n Documentation/config/format.txt    |  4 ++++\n Documentation/git-format-patch.txt |  3 +++\n builtin/log.c                      |  6 ++++++\n t/t4014-format-patch.sh            | 28 ++++++++++++++++++++++++++++\n 4 files changed, 41 insertions(+)\n\ndiff --git a/Documentation/config/format.txt b/Documentation/config/format.txt\nindex dc77941c48..55327b6511 100644\n--- a/Documentation/config/format.txt\n+++ b/Documentation/config/format.txt\n@@ -85,3 +85,7 @@ format.outputDirectory::\n format.useAutoBase::\n \tA boolean value which lets you enable the `--base=auto` option of\n \tformat-patch by default.\n+\n+format.notes::\n+\tA boolean value which lets you enable the `--notes` option of\n+\tformat-patch by default.\ndiff --git a/Documentation/git-format-patch.txt b/Documentation/git-format-patch.txt\nindex 2c3971390e..9ce5b8aaee 100644\n--- a/Documentation/git-format-patch.txt\n+++ b/Documentation/git-format-patch.txt\n@@ -275,6 +275,9 @@ these explanations after `format-patch` has run but before sending,\n keeping them as Git notes allows them to be maintained between versions\n of the patch series (but see the discussion of the `notes.rewrite`\n configuration options in linkgit:git-notes[1] to use this workflow).\n++\n+The default is `--no-notes`, unless the `format.notes` configuration is\n+set.\n \n --[no-]signature=<signature>::\n \tAdd a signature to each message produced. Per RFC 3676 the signature\ndiff --git a/builtin/log.c b/builtin/log.c\nindex e43ee12fb1..3c6fd9b117 100644\n--- a/builtin/log.c\n+++ b/builtin/log.c\n@@ -769,6 +769,7 @@ static const char *signature = git_version_string;\n static const char *signature_file;\n static int config_cover_letter;\n static const char *config_output_directory;\n+static int show_notes;\n \n enum {\n \tCOVER_UNSET,\n@@ -864,6 +865,10 @@ static int git_format_config(const char *var, const char *value, void *cb)\n \t\t\tfrom = NULL;\n \t\treturn 0;\n \t}\n+\tif (!strcmp(var, \"format.notes\")) {\n+\t\tshow_notes = git_config_bool(var, value);\n+\t\treturn 0;\n+\t}\n \n \treturn git_log_config(var, value, cb);\n }\n@@ -1626,6 +1631,7 @@ int cmd_format_patch(int argc, const char **argv, const char *prefix)\n \trev.max_parents = 1;\n \trev.diffopt.flags.recursive = 1;\n \trev.subject_prefix = fmt_patch_subject_prefix;\n+\trev.show_notes = show_notes;\n \tmemset(&s_r_opt, 0, sizeof(s_r_opt));\n \ts_r_opt.def = \"HEAD\";\n \ts_r_opt.revarg_opt = REVARG_COMMITTISH;\ndiff --git a/t/t4014-format-patch.sh b/t/t4014-format-patch.sh\nindex b6e2fdbc44..fe9522121a 100755\n--- a/t/t4014-format-patch.sh\n+++ b/t/t4014-format-patch.sh\n@@ -738,6 +738,34 @@ test_expect_success 'format-patch --notes --signoff' '\n \tsed \"1,/^---$/d\" out | grep \"test message\"\n '\n \n+test_expect_success 'format-patch notes output control' '\n+\tgit notes add -m \"notes config message\" HEAD &&\n+\ttest_when_finished git notes remove HEAD &&\n+\n+\tgit format-patch -1 --stdout >out &&\n+\t! grep \"notes config message\" out &&\n+\tgit format-patch -1 --stdout --notes >out &&\n+\tgrep \"notes config message\" out &&\n+\tgit format-patch -1 --stdout --no-notes >out &&\n+\t! grep \"notes config message\" out &&\n+\tgit format-patch -1 --stdout --notes --no-notes >out &&\n+\t! grep \"notes config message\" out &&\n+\tgit format-patch -1 --stdout --no-notes --notes >out &&\n+\tgrep \"notes config message\" out &&\n+\n+\ttest_config format.notes true &&\n+\tgit format-patch -1 --stdout >out &&\n+\tgrep \"notes config message\" out &&\n+\tgit format-patch -1 --stdout --notes >out &&\n+\tgrep \"notes config message\" out &&\n+\tgit format-patch -1 --stdout --no-notes >out &&\n+\t! grep \"notes config message\" out &&\n+\tgit format-patch -1 --stdout --notes --no-notes >out &&\n+\t! grep \"notes config message\" out &&\n+\tgit format-patch -1 --stdout --no-notes --notes >out &&\n+\tgrep \"notes config message\" out\n+'\n+\n echo \"fatal: --name-only does not make sense\" > expect.name-only\n echo \"fatal: --name-status does not make sense\" > expect.name-status\n echo \"fatal: --check does not make sense\" > expect.check\n-- \n2.21.0.1033.g0e8cc1100c\n\n"},{"id":"374985","messageId":"xmqqlfzinab4.fsf@gitster-ct.c.googlers.com","threadId":"51002","inReplyTo":"1338045be4a185cddc3ebf8adbe4b744551acf15.1556388260.git.liu.denton@gmail.com","subject":"Re: [PATCH 2/2] format-patch: teach format.notes config option","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2019-05-07T04:43:59Z","receivedAt":"2019-05-07T04:44:09Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Denton Liu <liu.denton@gmail.com> writes:\n\n> In git-format-patch, notes can be appended with the `--notes` option.\n> However, this must be specified by the user on an\n> invocation-by-invocation basis. If a user is not careful, it's possible\n> that they may forget to include it and generate a patch series without\n> notes.\n>\n> Teach git-format-patch the `format.notes` config option where if its\n> value is true, notes will automatically be appended. This option is\n> overridable with the `--no-notes` option in case a user wishes not to\n> append notes.\n>\n> Signed-off-by: Denton Liu <liu.denton@gmail.com>\n> ---\n>  Documentation/config/format.txt    |  4 ++++\n>  Documentation/git-format-patch.txt |  3 +++\n>  builtin/log.c                      |  6 ++++++\n>  t/t4014-format-patch.sh            | 28 ++++++++++++++++++++++++++++\n>  4 files changed, 41 insertions(+)\n>\n> diff --git a/Documentation/config/format.txt b/Documentation/config/format.txt\n> index dc77941c48..55327b6511 100644\n> --- a/Documentation/config/format.txt\n> +++ b/Documentation/config/format.txt\n> @@ -85,3 +85,7 @@ format.outputDirectory::\n>  format.useAutoBase::\n>  \tA boolean value which lets you enable the `--base=auto` option of\n>  \tformat-patch by default.\n> +\n> +format.notes::\n> +\tA boolean value which lets you enable the `--notes` option of\n> +\tformat-patch by default.\n\nWhoa.  Why should this be a boolean?\n\nI think I can do\n\n\tgit format-patch --notes=amlog master..\n\nand was hoping that this can be used to configure the option out of\nmy command line typing.\n\n> diff --git a/t/t4014-format-patch.sh b/t/t4014-format-patch.sh\n> index b6e2fdbc44..fe9522121a 100755\n> --- a/t/t4014-format-patch.sh\n> +++ b/t/t4014-format-patch.sh\n> @@ -738,6 +738,34 @@ test_expect_success 'format-patch --notes --signoff' '\n>  \tsed \"1,/^---$/d\" out | grep \"test message\"\n>  '\n\nAnd if you look at the existing test above this, you'd notice that\nthe command is tested is in \"format-patch --notes=test\" form.  We\nshould make sure that the same is done with the config in the new\ntest, too.\n\n> +test_expect_success 'format-patch notes output control' '\n> +\tgit notes add -m \"notes config message\" HEAD &&\n> +\ttest_when_finished git notes remove HEAD &&\n> +\n> +\tgit format-patch -1 --stdout >out &&\n> +\t! grep \"notes config message\" out &&\n> +\tgit format-patch -1 --stdout --notes >out &&\n> +\tgrep \"notes config message\" out &&\n> +\tgit format-patch -1 --stdout --no-notes >out &&\n> +\t! grep \"notes config message\" out &&\n> +\tgit format-patch -1 --stdout --notes --no-notes >out &&\n> +\t! grep \"notes config message\" out &&\n> +\tgit format-patch -1 --stdout --no-notes --notes >out &&\n> +\tgrep \"notes config message\" out &&\n> +\n> +\ttest_config format.notes true &&\n> +\tgit format-patch -1 --stdout >out &&\n> +\tgrep \"notes config message\" out &&\n> +\tgit format-patch -1 --stdout --notes >out &&\n> +\tgrep \"notes config message\" out &&\n> +\tgit format-patch -1 --stdout --no-notes >out &&\n> +\t! grep \"notes config message\" out &&\n> +\tgit format-patch -1 --stdout --notes --no-notes >out &&\n> +\t! grep \"notes config message\" out &&\n> +\tgit format-patch -1 --stdout --no-notes --notes >out &&\n> +\tgrep \"notes config message\" out\n> +'\n> +\n>  echo \"fatal: --name-only does not make sense\" > expect.name-only\n>  echo \"fatal: --name-status does not make sense\" > expect.name-status\n>  echo \"fatal: --check does not make sense\" > expect.check\n"},{"id":"375144","messageId":"cover.1557327652.git.liu.denton@gmail.com","threadId":"51002","inReplyTo":"cover.1556388260.git.liu.denton@gmail.com","subject":"[PATCH v2 0/2] format-patch: teach format.notes config option","fromName":"Denton Liu","fromEmail":"liu.denton@gmail.com","sentAt":"2019-05-08T15:02:08Z","receivedAt":"2019-05-08T15:02:14Z","isPatch":true,"sender":{"key":"liu.denton@gmail.com","avatar":"https://avatars.githubusercontent.com/u/9620836?v=4"},"body":"Hi Junio,\n\nThanks for the review. I made format.notes accept one (or more) refs\nnow.\n\nChanges since v1:\n\n* Made format.notes accept a notes ref instead of a boolean\n\n\nDenton Liu (2):\n  git-format-patch.txt: document --no-notes option\n  format-patch: teach format.notes config option\n\n Documentation/config/format.txt    | 13 ++++++\n Documentation/git-format-patch.txt |  7 ++-\n builtin/log.c                      | 18 +++++++-\n t/t4014-format-patch.sh            | 70 ++++++++++++++++++++++++++++++\n 4 files changed, 106 insertions(+), 2 deletions(-)\n\nRange-diff against v1:\n1:  48b6331d75 = 1:  4c3535f25b git-format-patch.txt: document --no-notes option\n2:  1338045be4 ! 2:  fe674bf63e format-patch: teach format.notes config option\n    @@ -8,8 +8,9 @@\n         that they may forget to include it and generate a patch series without\n         notes.\n     \n    -    Teach git-format-patch the `format.notes` config option where if its\n    -    value is true, notes will automatically be appended. This option is\n    +    Teach git-format-patch the `format.notes` config option its value is a\n    +    notes ref that will be automatically be appended. The special value of\n    +    \"standard\" can be used to specify the standard notes. This option is\n         overridable with the `--no-notes` option in case a user wishes not to\n         append notes.\n     \n    @@ -24,8 +25,17 @@\n      \tformat-patch by default.\n     +\n     +format.notes::\n    -+\tA boolean value which lets you enable the `--notes` option of\n    -+\tformat-patch by default.\n    ++\tA ref which specifies where to get the notes (see\n    ++\tlinkgit:git-notes[1]) that are appended for the commit after the\n    ++\tthree-dash line.\n    +++\n    ++If the special value of \"standard\" is specified, then the standard notes\n    ++ref is used (i.e. the notes ref used by `git notes` when no `--ref`\n    ++argument is specified). If one wishes to use the ref\n    ++`ref/notes/standard`, please use that literal instead.\n    +++\n    ++This configuration can be specified multiple times in order to allow\n    ++multiple notes refs to be included.\n     \n      diff --git a/Documentation/git-format-patch.txt b/Documentation/git-format-patch.txt\n      --- a/Documentation/git-format-patch.txt\n    @@ -45,32 +55,45 @@\n      --- a/builtin/log.c\n      +++ b/builtin/log.c\n     @@\n    - static const char *signature_file;\n    - static int config_cover_letter;\n    - static const char *config_output_directory;\n    -+static int show_notes;\n      \n    - enum {\n    - \tCOVER_UNSET,\n    + static int git_format_config(const char *var, const char *value, void *cb)\n    + {\n    ++\tstruct rev_info *rev = cb;\n    ++\n    + \tif (!strcmp(var, \"format.headers\")) {\n    + \t\tif (!value)\n    + \t\t\tdie(_(\"format.headers without value\"));\n     @@\n      \t\t\tfrom = NULL;\n      \t\treturn 0;\n      \t}\n     +\tif (!strcmp(var, \"format.notes\")) {\n    -+\t\tshow_notes = git_config_bool(var, value);\n    ++\t\tstruct strbuf buf = STRBUF_INIT;\n    ++\n    ++\t\trev->show_notes = 1;\n    ++\t\tif (!strcmp(value, \"standard\"))\n    ++\t\t\trev->notes_opt.use_default_notes = 1;\n    ++\t\telse {\n    ++\t\t\tstrbuf_addstr(&buf, value);\n    ++\t\t\texpand_notes_ref(&buf);\n    ++\t\t\tstring_list_append(&rev->notes_opt.extra_notes_refs,\n    ++\t\t\t\t\tstrbuf_detach(&buf, NULL));\n    ++\t\t}\n     +\t\treturn 0;\n     +\t}\n      \n      \treturn git_log_config(var, value, cb);\n      }\n     @@\n    - \trev.max_parents = 1;\n    - \trev.diffopt.flags.recursive = 1;\n    - \trev.subject_prefix = fmt_patch_subject_prefix;\n    -+\trev.show_notes = show_notes;\n    - \tmemset(&s_r_opt, 0, sizeof(s_r_opt));\n    - \ts_r_opt.def = \"HEAD\";\n    - \ts_r_opt.revarg_opt = REVARG_COMMITTISH;\n    + \textra_to.strdup_strings = 1;\n    + \textra_cc.strdup_strings = 1;\n    + \tinit_log_defaults();\n    +-\tgit_config(git_format_config, NULL);\n    + \trepo_init_revisions(the_repository, &rev, prefix);\n    ++\tgit_config(git_format_config, &rev);\n    + \trev.commit_format = CMIT_FMT_EMAIL;\n    + \trev.expand_tabs_in_log_default = 0;\n    + \trev.verbose_header = 1;\n     \n      diff --git a/t/t4014-format-patch.sh b/t/t4014-format-patch.sh\n      --- a/t/t4014-format-patch.sh\n    @@ -94,7 +117,7 @@\n     +\tgit format-patch -1 --stdout --no-notes --notes >out &&\n     +\tgrep \"notes config message\" out &&\n     +\n    -+\ttest_config format.notes true &&\n    ++\ttest_config format.notes standard &&\n     +\tgit format-patch -1 --stdout >out &&\n     +\tgrep \"notes config message\" out &&\n     +\tgit format-patch -1 --stdout --notes >out &&\n    @@ -106,6 +129,48 @@\n     +\tgit format-patch -1 --stdout --no-notes --notes >out &&\n     +\tgrep \"notes config message\" out\n     +'\n    ++\n    ++test_expect_success 'format-patch with multiple notes refs' '\n    ++\tgit notes --ref note1 add -m \"this is note 1\" HEAD &&\n    ++\ttest_when_finished git notes --ref note1 remove HEAD &&\n    ++\tgit notes --ref note2 add -m \"this is note 2\" HEAD &&\n    ++\ttest_when_finished git notes --ref note2 remove HEAD &&\n    ++\n    ++\tgit format-patch -1 --stdout >out &&\n    ++\t! grep \"this is note 1\" out &&\n    ++\t! grep \"this is note 2\" out &&\n    ++\tgit format-patch -1 --stdout --notes=note1 >out &&\n    ++\tgrep \"this is note 1\" out &&\n    ++\t! grep \"this is note 2\" out &&\n    ++\tgit format-patch -1 --stdout --notes=note2 >out &&\n    ++\t! grep \"this is note 1\" out &&\n    ++\tgrep \"this is note 2\" out &&\n    ++\tgit format-patch -1 --stdout --notes=note1 --notes=note2 >out &&\n    ++\tgrep \"this is note 1\" out &&\n    ++\tgrep \"this is note 2\" out &&\n    ++\n    ++\ttest_config format.notes note1 &&\n    ++\tgit format-patch -1 --stdout >out &&\n    ++\tgrep \"this is note 1\" out &&\n    ++\t! grep \"this is note 2\" out &&\n    ++\tgit format-patch -1 --stdout --no-notes >out &&\n    ++\t! grep \"this is note 1\" out &&\n    ++\t! grep \"this is note 2\" out &&\n    ++\tgit format-patch -1 --stdout --notes=note2 >out &&\n    ++\tgrep \"this is note 1\" out &&\n    ++\tgrep \"this is note 2\" out &&\n    ++\tgit format-patch -1 --stdout --no-notes --notes=note2 >out &&\n    ++\t! grep \"this is note 1\" out &&\n    ++\tgrep \"this is note 2\" out &&\n    ++\n    ++\tgit config --add format.notes note2 &&\n    ++\tgit format-patch -1 --stdout >out &&\n    ++\tgrep \"this is note 1\" out &&\n    ++\tgrep \"this is note 2\" out &&\n    ++\tgit format-patch -1 --stdout --no-notes >out &&\n    ++\t! grep \"this is note 1\" out &&\n    ++\t! grep \"this is note 2\" out\n    ++'\n     +\n      echo \"fatal: --name-only does not make sense\" > expect.name-only\n      echo \"fatal: --name-status does not make sense\" > expect.name-status\n-- \n2.21.0.1049.geb646f7864\n\n"},{"id":"375145","messageId":"4c3535f25bdffc8d94617c74f7c078cce59a044f.1557327652.git.liu.denton@gmail.com","threadId":"51002","inReplyTo":"cover.1557327652.git.liu.denton@gmail.com","subject":"[PATCH v2 1/2] git-format-patch.txt: document --no-notes option","fromName":"Denton Liu","fromEmail":"liu.denton@gmail.com","sentAt":"2019-05-08T15:02:11Z","receivedAt":"2019-05-08T15:02:17Z","isPatch":true,"sender":{"key":"liu.denton@gmail.com","avatar":"https://avatars.githubusercontent.com/u/9620836?v=4"},"body":"Internally, git-format-patch uses the `handle_revision_opt` parser. The\nparser handles the `--no-notes` option to negate an earlier `--notes`\noption, but it isn't documented. Document this option so that users are\naware of it.\n\nSigned-off-by: Denton Liu <liu.denton@gmail.com>\n---\n Documentation/git-format-patch.txt | 4 +++-\n 1 file changed, 3 insertions(+), 1 deletion(-)\n\ndiff --git a/Documentation/git-format-patch.txt b/Documentation/git-format-patch.txt\nindex 1af85d404f..2c3971390e 100644\n--- a/Documentation/git-format-patch.txt\n+++ b/Documentation/git-format-patch.txt\n@@ -22,7 +22,8 @@ SYNOPSIS\n \t\t   [--rfc] [--subject-prefix=Subject-Prefix]\n \t\t   [(--reroll-count|-v) <n>]\n \t\t   [--to=<email>] [--cc=<email>]\n-\t\t   [--[no-]cover-letter] [--quiet] [--notes[=<ref>]]\n+\t\t   [--[no-]cover-letter] [--quiet]\n+\t\t   [--no-notes | --notes[=<ref>]]\n \t\t   [--interdiff=<previous>]\n \t\t   [--range-diff=<previous> [--creation-factor=<percent>]]\n \t\t   [--progress]\n@@ -263,6 +264,7 @@ material (this may change in the future).\n \tfor details.\n \n --notes[=<ref>]::\n+--no-notes::\n \tAppend the notes (see linkgit:git-notes[1]) for the commit\n \tafter the three-dash line.\n +\n-- \n2.21.0.1049.geb646f7864\n\n"},{"id":"375146","messageId":"fe674bf63e8d5b8a06a3f880db4dc4bcfd2183f6.1557327652.git.liu.denton@gmail.com","threadId":"51002","inReplyTo":"cover.1557327652.git.liu.denton@gmail.com","subject":"[PATCH v2 2/2] format-patch: teach format.notes config option","fromName":"Denton Liu","fromEmail":"liu.denton@gmail.com","sentAt":"2019-05-08T15:02:14Z","receivedAt":"2019-05-08T15:02:19Z","isPatch":true,"sender":{"key":"liu.denton@gmail.com","avatar":"https://avatars.githubusercontent.com/u/9620836?v=4"},"body":"In git-format-patch, notes can be appended with the `--notes` option.\nHowever, this must be specified by the user on an\ninvocation-by-invocation basis. If a user is not careful, it's possible\nthat they may forget to include it and generate a patch series without\nnotes.\n\nTeach git-format-patch the `format.notes` config option its value is a\nnotes ref that will be automatically be appended. The special value of\n\"standard\" can be used to specify the standard notes. This option is\noverridable with the `--no-notes` option in case a user wishes not to\nappend notes.\n\nSigned-off-by: Denton Liu <liu.denton@gmail.com>\n---\nOne thing I'm worried about is that I'm not really sure using \"standard\"\nas the special value is a good idea. Would \"auto\" be a better special\nvalue?\n\n Documentation/config/format.txt    | 13 ++++++\n Documentation/git-format-patch.txt |  3 ++\n builtin/log.c                      | 18 +++++++-\n t/t4014-format-patch.sh            | 70 ++++++++++++++++++++++++++++++\n 4 files changed, 103 insertions(+), 1 deletion(-)\n\ndiff --git a/Documentation/config/format.txt b/Documentation/config/format.txt\nindex dc77941c48..e25f9cfc61 100644\n--- a/Documentation/config/format.txt\n+++ b/Documentation/config/format.txt\n@@ -85,3 +85,16 @@ format.outputDirectory::\n format.useAutoBase::\n \tA boolean value which lets you enable the `--base=auto` option of\n \tformat-patch by default.\n+\n+format.notes::\n+\tA ref which specifies where to get the notes (see\n+\tlinkgit:git-notes[1]) that are appended for the commit after the\n+\tthree-dash line.\n++\n+If the special value of \"standard\" is specified, then the standard notes\n+ref is used (i.e. the notes ref used by `git notes` when no `--ref`\n+argument is specified). If one wishes to use the ref\n+`ref/notes/standard`, please use that literal instead.\n++\n+This configuration can be specified multiple times in order to allow\n+multiple notes refs to be included.\ndiff --git a/Documentation/git-format-patch.txt b/Documentation/git-format-patch.txt\nindex 2c3971390e..9ce5b8aaee 100644\n--- a/Documentation/git-format-patch.txt\n+++ b/Documentation/git-format-patch.txt\n@@ -275,6 +275,9 @@ these explanations after `format-patch` has run but before sending,\n keeping them as Git notes allows them to be maintained between versions\n of the patch series (but see the discussion of the `notes.rewrite`\n configuration options in linkgit:git-notes[1] to use this workflow).\n++\n+The default is `--no-notes`, unless the `format.notes` configuration is\n+set.\n \n --[no-]signature=<signature>::\n \tAdd a signature to each message produced. Per RFC 3676 the signature\ndiff --git a/builtin/log.c b/builtin/log.c\nindex e43ee12fb1..24954e42b0 100644\n--- a/builtin/log.c\n+++ b/builtin/log.c\n@@ -779,6 +779,8 @@ enum {\n \n static int git_format_config(const char *var, const char *value, void *cb)\n {\n+\tstruct rev_info *rev = cb;\n+\n \tif (!strcmp(var, \"format.headers\")) {\n \t\tif (!value)\n \t\t\tdie(_(\"format.headers without value\"));\n@@ -864,6 +866,20 @@ static int git_format_config(const char *var, const char *value, void *cb)\n \t\t\tfrom = NULL;\n \t\treturn 0;\n \t}\n+\tif (!strcmp(var, \"format.notes\")) {\n+\t\tstruct strbuf buf = STRBUF_INIT;\n+\n+\t\trev->show_notes = 1;\n+\t\tif (!strcmp(value, \"standard\"))\n+\t\t\trev->notes_opt.use_default_notes = 1;\n+\t\telse {\n+\t\t\tstrbuf_addstr(&buf, value);\n+\t\t\texpand_notes_ref(&buf);\n+\t\t\tstring_list_append(&rev->notes_opt.extra_notes_refs,\n+\t\t\t\t\tstrbuf_detach(&buf, NULL));\n+\t\t}\n+\t\treturn 0;\n+\t}\n \n \treturn git_log_config(var, value, cb);\n }\n@@ -1617,8 +1633,8 @@ int cmd_format_patch(int argc, const char **argv, const char *prefix)\n \textra_to.strdup_strings = 1;\n \textra_cc.strdup_strings = 1;\n \tinit_log_defaults();\n-\tgit_config(git_format_config, NULL);\n \trepo_init_revisions(the_repository, &rev, prefix);\n+\tgit_config(git_format_config, &rev);\n \trev.commit_format = CMIT_FMT_EMAIL;\n \trev.expand_tabs_in_log_default = 0;\n \trev.verbose_header = 1;\ndiff --git a/t/t4014-format-patch.sh b/t/t4014-format-patch.sh\nindex b6e2fdbc44..e0127282ba 100755\n--- a/t/t4014-format-patch.sh\n+++ b/t/t4014-format-patch.sh\n@@ -738,6 +738,76 @@ test_expect_success 'format-patch --notes --signoff' '\n \tsed \"1,/^---$/d\" out | grep \"test message\"\n '\n \n+test_expect_success 'format-patch notes output control' '\n+\tgit notes add -m \"notes config message\" HEAD &&\n+\ttest_when_finished git notes remove HEAD &&\n+\n+\tgit format-patch -1 --stdout >out &&\n+\t! grep \"notes config message\" out &&\n+\tgit format-patch -1 --stdout --notes >out &&\n+\tgrep \"notes config message\" out &&\n+\tgit format-patch -1 --stdout --no-notes >out &&\n+\t! grep \"notes config message\" out &&\n+\tgit format-patch -1 --stdout --notes --no-notes >out &&\n+\t! grep \"notes config message\" out &&\n+\tgit format-patch -1 --stdout --no-notes --notes >out &&\n+\tgrep \"notes config message\" out &&\n+\n+\ttest_config format.notes standard &&\n+\tgit format-patch -1 --stdout >out &&\n+\tgrep \"notes config message\" out &&\n+\tgit format-patch -1 --stdout --notes >out &&\n+\tgrep \"notes config message\" out &&\n+\tgit format-patch -1 --stdout --no-notes >out &&\n+\t! grep \"notes config message\" out &&\n+\tgit format-patch -1 --stdout --notes --no-notes >out &&\n+\t! grep \"notes config message\" out &&\n+\tgit format-patch -1 --stdout --no-notes --notes >out &&\n+\tgrep \"notes config message\" out\n+'\n+\n+test_expect_success 'format-patch with multiple notes refs' '\n+\tgit notes --ref note1 add -m \"this is note 1\" HEAD &&\n+\ttest_when_finished git notes --ref note1 remove HEAD &&\n+\tgit notes --ref note2 add -m \"this is note 2\" HEAD &&\n+\ttest_when_finished git notes --ref note2 remove HEAD &&\n+\n+\tgit format-patch -1 --stdout >out &&\n+\t! grep \"this is note 1\" out &&\n+\t! grep \"this is note 2\" out &&\n+\tgit format-patch -1 --stdout --notes=note1 >out &&\n+\tgrep \"this is note 1\" out &&\n+\t! grep \"this is note 2\" out &&\n+\tgit format-patch -1 --stdout --notes=note2 >out &&\n+\t! grep \"this is note 1\" out &&\n+\tgrep \"this is note 2\" out &&\n+\tgit format-patch -1 --stdout --notes=note1 --notes=note2 >out &&\n+\tgrep \"this is note 1\" out &&\n+\tgrep \"this is note 2\" out &&\n+\n+\ttest_config format.notes note1 &&\n+\tgit format-patch -1 --stdout >out &&\n+\tgrep \"this is note 1\" out &&\n+\t! grep \"this is note 2\" out &&\n+\tgit format-patch -1 --stdout --no-notes >out &&\n+\t! grep \"this is note 1\" out &&\n+\t! grep \"this is note 2\" out &&\n+\tgit format-patch -1 --stdout --notes=note2 >out &&\n+\tgrep \"this is note 1\" out &&\n+\tgrep \"this is note 2\" out &&\n+\tgit format-patch -1 --stdout --no-notes --notes=note2 >out &&\n+\t! grep \"this is note 1\" out &&\n+\tgrep \"this is note 2\" out &&\n+\n+\tgit config --add format.notes note2 &&\n+\tgit format-patch -1 --stdout >out &&\n+\tgrep \"this is note 1\" out &&\n+\tgrep \"this is note 2\" out &&\n+\tgit format-patch -1 --stdout --no-notes >out &&\n+\t! grep \"this is note 1\" out &&\n+\t! grep \"this is note 2\" out\n+'\n+\n echo \"fatal: --name-only does not make sense\" > expect.name-only\n echo \"fatal: --name-status does not make sense\" > expect.name-status\n echo \"fatal: --check does not make sense\" > expect.check\n-- \n2.21.0.1049.geb646f7864\n\n"},{"id":"375168","messageId":"dbd01507-d56e-4353-c953-f0b05dfdf510@drbeat.li","threadId":"51002","inReplyTo":"fe674bf63e8d5b8a06a3f880db4dc4bcfd2183f6.1557327652.git.liu.denton@gmail.com","subject":"Re: [PATCH v2 2/2] format-patch: teach format.notes config option","fromName":"Beat Bolli","fromEmail":"dev+git@drbeat.li","sentAt":"2019-05-08T17:18:18Z","receivedAt":"2019-05-08T17:18:31Z","isPatch":true,"sender":{"key":"dev+git@drbeat.li","avatar":"https://avatars.githubusercontent.com/u/21444?v=4"},"body":"On 08.05.19 17:02, Denton Liu wrote:\n> In git-format-patch, notes can be appended with the `--notes` option.\n> However, this must be specified by the user on an\n> invocation-by-invocation basis. If a user is not careful, it's possible\n> that they may forget to include it and generate a patch series without\n> notes.\n> \n> Teach git-format-patch the `format.notes` config option its value is a\n\ns/its/. Its/\n\n> notes ref that will be automatically be appended. The special value of\n\nDrop the second \"be \".\n\n> \"standard\" can be used to specify the standard notes. This option is\n> overridable with the `--no-notes` option in case a user wishes not to\n> append notes.\n> \n> Signed-off-by: Denton Liu <liu.denton@gmail.com>\n> ---\n> One thing I'm worried about is that I'm not really sure using \"standard\"\n> as the special value is a good idea. Would \"auto\" be a better special\n> value?\n> \n>  Documentation/config/format.txt    | 13 ++++++\n>  Documentation/git-format-patch.txt |  3 ++\n>  builtin/log.c                      | 18 +++++++-\n>  t/t4014-format-patch.sh            | 70 ++++++++++++++++++++++++++++++\n>  4 files changed, 103 insertions(+), 1 deletion(-)\n> \n> diff --git a/Documentation/config/format.txt b/Documentation/config/format.txt\n> index dc77941c48..e25f9cfc61 100644\n> --- a/Documentation/config/format.txt\n> +++ b/Documentation/config/format.txt\n> @@ -85,3 +85,16 @@ format.outputDirectory::\n>  format.useAutoBase::\n>  \tA boolean value which lets you enable the `--base=auto` option of\n>  \tformat-patch by default.\n> +\n> +format.notes::\n> +\tA ref which specifies where to get the notes (see\n> +\tlinkgit:git-notes[1]) that are appended for the commit after the\n> +\tthree-dash line.\n> ++\n> +If the special value of \"standard\" is specified, then the standard notes\n> +ref is used (i.e. the notes ref used by `git notes` when no `--ref`\n> +argument is specified). If one wishes to use the ref\n> +`ref/notes/standard`, please use that literal instead.\n> ++\n> +This configuration can be specified multiple times in order to allow\n> +multiple notes refs to be included.\n> diff --git a/Documentation/git-format-patch.txt b/Documentation/git-format-patch.txt\n> index 2c3971390e..9ce5b8aaee 100644\n> --- a/Documentation/git-format-patch.txt\n> +++ b/Documentation/git-format-patch.txt\n> @@ -275,6 +275,9 @@ these explanations after `format-patch` has run but before sending,\n>  keeping them as Git notes allows them to be maintained between versions\n>  of the patch series (but see the discussion of the `notes.rewrite`\n>  configuration options in linkgit:git-notes[1] to use this workflow).\n> ++\n> +The default is `--no-notes`, unless the `format.notes` configuration is\n> +set.\n>  \n>  --[no-]signature=<signature>::\n>  \tAdd a signature to each message produced. Per RFC 3676 the signature\n> diff --git a/builtin/log.c b/builtin/log.c\n> index e43ee12fb1..24954e42b0 100644\n> --- a/builtin/log.c\n> +++ b/builtin/log.c\n> @@ -779,6 +779,8 @@ enum {\n>  \n>  static int git_format_config(const char *var, const char *value, void *cb)\n>  {\n> +\tstruct rev_info *rev = cb;\n> +\n>  \tif (!strcmp(var, \"format.headers\")) {\n>  \t\tif (!value)\n>  \t\t\tdie(_(\"format.headers without value\"));\n> @@ -864,6 +866,20 @@ static int git_format_config(const char *var, const char *value, void *cb)\n>  \t\t\tfrom = NULL;\n>  \t\treturn 0;\n>  \t}\n> +\tif (!strcmp(var, \"format.notes\")) {\n> +\t\tstruct strbuf buf = STRBUF_INIT;\n> +\n> +\t\trev->show_notes = 1;\n> +\t\tif (!strcmp(value, \"standard\"))\n> +\t\t\trev->notes_opt.use_default_notes = 1;\n> +\t\telse {\n\nUse braces on both parts of the \"if\", if one part needs them.\n\n> +\t\t\tstrbuf_addstr(&buf, value);\n> +\t\t\texpand_notes_ref(&buf);\n> +\t\t\tstring_list_append(&rev->notes_opt.extra_notes_refs,\n> +\t\t\t\t\tstrbuf_detach(&buf, NULL));\n> +\t\t}\n> +\t\treturn 0;\n> +\t}\n>  \n>  \treturn git_log_config(var, value, cb);\n>  }\n> @@ -1617,8 +1633,8 @@ int cmd_format_patch(int argc, const char **argv, const char *prefix)\n>  \textra_to.strdup_strings = 1;\n>  \textra_cc.strdup_strings = 1;\n>  \tinit_log_defaults();\n> -\tgit_config(git_format_config, NULL);\n>  \trepo_init_revisions(the_repository, &rev, prefix);\n> +\tgit_config(git_format_config, &rev);\n>  \trev.commit_format = CMIT_FMT_EMAIL;\n>  \trev.expand_tabs_in_log_default = 0;\n>  \trev.verbose_header = 1;\n> diff --git a/t/t4014-format-patch.sh b/t/t4014-format-patch.sh\n> index b6e2fdbc44..e0127282ba 100755\n> --- a/t/t4014-format-patch.sh\n> +++ b/t/t4014-format-patch.sh\n> @@ -738,6 +738,76 @@ test_expect_success 'format-patch --notes --signoff' '\n>  \tsed \"1,/^---$/d\" out | grep \"test message\"\n>  '\n>  \n> +test_expect_success 'format-patch notes output control' '\n> +\tgit notes add -m \"notes config message\" HEAD &&\n> +\ttest_when_finished git notes remove HEAD &&\n> +\n> +\tgit format-patch -1 --stdout >out &&\n> +\t! grep \"notes config message\" out &&\n> +\tgit format-patch -1 --stdout --notes >out &&\n> +\tgrep \"notes config message\" out &&\n> +\tgit format-patch -1 --stdout --no-notes >out &&\n> +\t! grep \"notes config message\" out &&\n> +\tgit format-patch -1 --stdout --notes --no-notes >out &&\n> +\t! grep \"notes config message\" out &&\n> +\tgit format-patch -1 --stdout --no-notes --notes >out &&\n> +\tgrep \"notes config message\" out &&\n> +\n> +\ttest_config format.notes standard &&\n> +\tgit format-patch -1 --stdout >out &&\n> +\tgrep \"notes config message\" out &&\n> +\tgit format-patch -1 --stdout --notes >out &&\n> +\tgrep \"notes config message\" out &&\n> +\tgit format-patch -1 --stdout --no-notes >out &&\n> +\t! grep \"notes config message\" out &&\n> +\tgit format-patch -1 --stdout --notes --no-notes >out &&\n> +\t! grep \"notes config message\" out &&\n> +\tgit format-patch -1 --stdout --no-notes --notes >out &&\n> +\tgrep \"notes config message\" out\n> +'\n> +\n> +test_expect_success 'format-patch with multiple notes refs' '\n> +\tgit notes --ref note1 add -m \"this is note 1\" HEAD &&\n> +\ttest_when_finished git notes --ref note1 remove HEAD &&\n> +\tgit notes --ref note2 add -m \"this is note 2\" HEAD &&\n> +\ttest_when_finished git notes --ref note2 remove HEAD &&\n> +\n> +\tgit format-patch -1 --stdout >out &&\n> +\t! grep \"this is note 1\" out &&\n> +\t! grep \"this is note 2\" out &&\n> +\tgit format-patch -1 --stdout --notes=note1 >out &&\n> +\tgrep \"this is note 1\" out &&\n> +\t! grep \"this is note 2\" out &&\n> +\tgit format-patch -1 --stdout --notes=note2 >out &&\n> +\t! grep \"this is note 1\" out &&\n> +\tgrep \"this is note 2\" out &&\n> +\tgit format-patch -1 --stdout --notes=note1 --notes=note2 >out &&\n> +\tgrep \"this is note 1\" out &&\n> +\tgrep \"this is note 2\" out &&\n> +\n> +\ttest_config format.notes note1 &&\n> +\tgit format-patch -1 --stdout >out &&\n> +\tgrep \"this is note 1\" out &&\n> +\t! grep \"this is note 2\" out &&\n> +\tgit format-patch -1 --stdout --no-notes >out &&\n> +\t! grep \"this is note 1\" out &&\n> +\t! grep \"this is note 2\" out &&\n> +\tgit format-patch -1 --stdout --notes=note2 >out &&\n> +\tgrep \"this is note 1\" out &&\n> +\tgrep \"this is note 2\" out &&\n> +\tgit format-patch -1 --stdout --no-notes --notes=note2 >out &&\n> +\t! grep \"this is note 1\" out &&\n> +\tgrep \"this is note 2\" out &&\n> +\n> +\tgit config --add format.notes note2 &&\n> +\tgit format-patch -1 --stdout >out &&\n> +\tgrep \"this is note 1\" out &&\n> +\tgrep \"this is note 2\" out &&\n> +\tgit format-patch -1 --stdout --no-notes >out &&\n> +\t! grep \"this is note 1\" out &&\n> +\t! grep \"this is note 2\" out\n> +'\n> +\n>  echo \"fatal: --name-only does not make sense\" > expect.name-only\n>  echo \"fatal: --name-status does not make sense\" > expect.name-status\n>  echo \"fatal: --check does not make sense\" > expect.check\n> \n\nCheers, Beat\n\n"},{"id":"375171","messageId":"20190508173122.GA23712@archbookpro.localdomain","threadId":"51002","inReplyTo":"dbd01507-d56e-4353-c953-f0b05dfdf510@drbeat.li","subject":"Re: [PATCH v2 2/2] format-patch: teach format.notes config option","fromName":"Denton Liu","fromEmail":"liu.denton@gmail.com","sentAt":"2019-05-08T17:31:22Z","receivedAt":"2019-05-08T17:31:27Z","isPatch":true,"sender":{"key":"liu.denton@gmail.com","avatar":"https://avatars.githubusercontent.com/u/9620836?v=4"},"body":"Hi Beat,\n\nOn Wed, May 08, 2019 at 07:18:18PM +0200, Beat Bolli wrote:\n> On 08.05.19 17:02, Denton Liu wrote:\n> > In git-format-patch, notes can be appended with the `--notes` option.\n> > However, this must be specified by the user on an\n> > invocation-by-invocation basis. If a user is not careful, it's possible\n> > that they may forget to include it and generate a patch series without\n> > notes.\n> > \n> > Teach git-format-patch the `format.notes` config option its value is a\n> \n> s/its/. Its/\n> \n> > notes ref that will be automatically be appended. The special value of\n> \n> Drop the second \"be \".\n\nThanks, I should've read through the log message more carefully before\nsending.\n\n> \n> > \"standard\" can be used to specify the standard notes. This option is\n> > overridable with the `--no-notes` option in case a user wishes not to\n> > append notes.\n> > \n> > Signed-off-by: Denton Liu <liu.denton@gmail.com>\n> > ---\n> > One thing I'm worried about is that I'm not really sure using \"standard\"\n> > as the special value is a good idea. Would \"auto\" be a better special\n> > value?\n> > \n> >  Documentation/config/format.txt    | 13 ++++++\n> >  Documentation/git-format-patch.txt |  3 ++\n> >  builtin/log.c                      | 18 +++++++-\n> >  t/t4014-format-patch.sh            | 70 ++++++++++++++++++++++++++++++\n> >  4 files changed, 103 insertions(+), 1 deletion(-)\n> > \n> > diff --git a/Documentation/config/format.txt b/Documentation/config/format.txt\n> > index dc77941c48..e25f9cfc61 100644\n> > --- a/Documentation/config/format.txt\n> > +++ b/Documentation/config/format.txt\n> > @@ -85,3 +85,16 @@ format.outputDirectory::\n> >  format.useAutoBase::\n> >  \tA boolean value which lets you enable the `--base=auto` option of\n> >  \tformat-patch by default.\n> > +\n> > +format.notes::\n> > +\tA ref which specifies where to get the notes (see\n> > +\tlinkgit:git-notes[1]) that are appended for the commit after the\n> > +\tthree-dash line.\n> > ++\n> > +If the special value of \"standard\" is specified, then the standard notes\n> > +ref is used (i.e. the notes ref used by `git notes` when no `--ref`\n> > +argument is specified). If one wishes to use the ref\n> > +`ref/notes/standard`, please use that literal instead.\n> > ++\n> > +This configuration can be specified multiple times in order to allow\n> > +multiple notes refs to be included.\n> > diff --git a/Documentation/git-format-patch.txt b/Documentation/git-format-patch.txt\n> > index 2c3971390e..9ce5b8aaee 100644\n> > --- a/Documentation/git-format-patch.txt\n> > +++ b/Documentation/git-format-patch.txt\n> > @@ -275,6 +275,9 @@ these explanations after `format-patch` has run but before sending,\n> >  keeping them as Git notes allows them to be maintained between versions\n> >  of the patch series (but see the discussion of the `notes.rewrite`\n> >  configuration options in linkgit:git-notes[1] to use this workflow).\n> > ++\n> > +The default is `--no-notes`, unless the `format.notes` configuration is\n> > +set.\n> >  \n> >  --[no-]signature=<signature>::\n> >  \tAdd a signature to each message produced. Per RFC 3676 the signature\n> > diff --git a/builtin/log.c b/builtin/log.c\n> > index e43ee12fb1..24954e42b0 100644\n> > --- a/builtin/log.c\n> > +++ b/builtin/log.c\n> > @@ -779,6 +779,8 @@ enum {\n> >  \n> >  static int git_format_config(const char *var, const char *value, void *cb)\n> >  {\n> > +\tstruct rev_info *rev = cb;\n> > +\n> >  \tif (!strcmp(var, \"format.headers\")) {\n> >  \t\tif (!value)\n> >  \t\t\tdie(_(\"format.headers without value\"));\n> > @@ -864,6 +866,20 @@ static int git_format_config(const char *var, const char *value, void *cb)\n> >  \t\t\tfrom = NULL;\n> >  \t\treturn 0;\n> >  \t}\n> > +\tif (!strcmp(var, \"format.notes\")) {\n> > +\t\tstruct strbuf buf = STRBUF_INIT;\n> > +\n> > +\t\trev->show_notes = 1;\n> > +\t\tif (!strcmp(value, \"standard\"))\n> > +\t\t\trev->notes_opt.use_default_notes = 1;\n> > +\t\telse {\n> \n> Use braces on both parts of the \"if\", if one part needs them.\n\nI thought that the style preference in this project is to not use braces\nwhenever it's unnecessary, even if it's on just one arm of an if-else.\n\nThanks,\n\nDenton\n\n> \n> > +\t\t\tstrbuf_addstr(&buf, value);\n> > +\t\t\texpand_notes_ref(&buf);\n> > +\t\t\tstring_list_append(&rev->notes_opt.extra_notes_refs,\n> > +\t\t\t\t\tstrbuf_detach(&buf, NULL));\n> > +\t\t}\n> > +\t\treturn 0;\n> > +\t}\n> >  \n> >  \treturn git_log_config(var, value, cb);\n> >  }\n> > @@ -1617,8 +1633,8 @@ int cmd_format_patch(int argc, const char **argv, const char *prefix)\n> >  \textra_to.strdup_strings = 1;\n> >  \textra_cc.strdup_strings = 1;\n> >  \tinit_log_defaults();\n> > -\tgit_config(git_format_config, NULL);\n> >  \trepo_init_revisions(the_repository, &rev, prefix);\n> > +\tgit_config(git_format_config, &rev);\n> >  \trev.commit_format = CMIT_FMT_EMAIL;\n> >  \trev.expand_tabs_in_log_default = 0;\n> >  \trev.verbose_header = 1;\n> > diff --git a/t/t4014-format-patch.sh b/t/t4014-format-patch.sh\n> > index b6e2fdbc44..e0127282ba 100755\n> > --- a/t/t4014-format-patch.sh\n> > +++ b/t/t4014-format-patch.sh\n> > @@ -738,6 +738,76 @@ test_expect_success 'format-patch --notes --signoff' '\n> >  \tsed \"1,/^---$/d\" out | grep \"test message\"\n> >  '\n> >  \n> > +test_expect_success 'format-patch notes output control' '\n> > +\tgit notes add -m \"notes config message\" HEAD &&\n> > +\ttest_when_finished git notes remove HEAD &&\n> > +\n> > +\tgit format-patch -1 --stdout >out &&\n> > +\t! grep \"notes config message\" out &&\n> > +\tgit format-patch -1 --stdout --notes >out &&\n> > +\tgrep \"notes config message\" out &&\n> > +\tgit format-patch -1 --stdout --no-notes >out &&\n> > +\t! grep \"notes config message\" out &&\n> > +\tgit format-patch -1 --stdout --notes --no-notes >out &&\n> > +\t! grep \"notes config message\" out &&\n> > +\tgit format-patch -1 --stdout --no-notes --notes >out &&\n> > +\tgrep \"notes config message\" out &&\n> > +\n> > +\ttest_config format.notes standard &&\n> > +\tgit format-patch -1 --stdout >out &&\n> > +\tgrep \"notes config message\" out &&\n> > +\tgit format-patch -1 --stdout --notes >out &&\n> > +\tgrep \"notes config message\" out &&\n> > +\tgit format-patch -1 --stdout --no-notes >out &&\n> > +\t! grep \"notes config message\" out &&\n> > +\tgit format-patch -1 --stdout --notes --no-notes >out &&\n> > +\t! grep \"notes config message\" out &&\n> > +\tgit format-patch -1 --stdout --no-notes --notes >out &&\n> > +\tgrep \"notes config message\" out\n> > +'\n> > +\n> > +test_expect_success 'format-patch with multiple notes refs' '\n> > +\tgit notes --ref note1 add -m \"this is note 1\" HEAD &&\n> > +\ttest_when_finished git notes --ref note1 remove HEAD &&\n> > +\tgit notes --ref note2 add -m \"this is note 2\" HEAD &&\n> > +\ttest_when_finished git notes --ref note2 remove HEAD &&\n> > +\n> > +\tgit format-patch -1 --stdout >out &&\n> > +\t! grep \"this is note 1\" out &&\n> > +\t! grep \"this is note 2\" out &&\n> > +\tgit format-patch -1 --stdout --notes=note1 >out &&\n> > +\tgrep \"this is note 1\" out &&\n> > +\t! grep \"this is note 2\" out &&\n> > +\tgit format-patch -1 --stdout --notes=note2 >out &&\n> > +\t! grep \"this is note 1\" out &&\n> > +\tgrep \"this is note 2\" out &&\n> > +\tgit format-patch -1 --stdout --notes=note1 --notes=note2 >out &&\n> > +\tgrep \"this is note 1\" out &&\n> > +\tgrep \"this is note 2\" out &&\n> > +\n> > +\ttest_config format.notes note1 &&\n> > +\tgit format-patch -1 --stdout >out &&\n> > +\tgrep \"this is note 1\" out &&\n> > +\t! grep \"this is note 2\" out &&\n> > +\tgit format-patch -1 --stdout --no-notes >out &&\n> > +\t! grep \"this is note 1\" out &&\n> > +\t! grep \"this is note 2\" out &&\n> > +\tgit format-patch -1 --stdout --notes=note2 >out &&\n> > +\tgrep \"this is note 1\" out &&\n> > +\tgrep \"this is note 2\" out &&\n> > +\tgit format-patch -1 --stdout --no-notes --notes=note2 >out &&\n> > +\t! grep \"this is note 1\" out &&\n> > +\tgrep \"this is note 2\" out &&\n> > +\n> > +\tgit config --add format.notes note2 &&\n> > +\tgit format-patch -1 --stdout >out &&\n> > +\tgrep \"this is note 1\" out &&\n> > +\tgrep \"this is note 2\" out &&\n> > +\tgit format-patch -1 --stdout --no-notes >out &&\n> > +\t! grep \"this is note 1\" out &&\n> > +\t! grep \"this is note 2\" out\n> > +'\n> > +\n> >  echo \"fatal: --name-only does not make sense\" > expect.name-only\n> >  echo \"fatal: --name-status does not make sense\" > expect.name-status\n> >  echo \"fatal: --check does not make sense\" > expect.check\n> > \n> \n> Cheers, Beat\n"},{"id":"375174","messageId":"d5dc0655-9753-6343-2235-6cbd1bd2e198@drbeat.li","threadId":"51002","inReplyTo":"20190508173122.GA23712@archbookpro.localdomain","subject":"Re: [PATCH v2 2/2] format-patch: teach format.notes config option","fromName":"Beat Bolli","fromEmail":"dev+git@drbeat.li","sentAt":"2019-05-08T17:52:20Z","receivedAt":"2019-05-08T17:52:27Z","isPatch":true,"sender":{"key":"dev+git@drbeat.li","avatar":"https://avatars.githubusercontent.com/u/21444?v=4"},"body":"On 08.05.19 19:31, Denton Liu wrote:\n> Hi Beat,\n> \n> On Wed, May 08, 2019 at 07:18:18PM +0200, Beat Bolli wrote:\n>> On 08.05.19 17:02, Denton Liu wrote:\n>>> In git-format-patch, notes can be appended with the `--notes` option.\n>>> However, this must be specified by the user on an\n>>> invocation-by-invocation basis. If a user is not careful, it's possible\n>>> that they may forget to include it and generate a patch series without\n>>> notes.\n>>>\n>>> Teach git-format-patch the `format.notes` config option its value is a\n>>\n>> s/its/. Its/\n>>\n>>> notes ref that will be automatically be appended. The special value of\n>>\n>> Drop the second \"be \".\n> \n> Thanks, I should've read through the log message more carefully before\n> sending.\n> \n>>\n>>> \"standard\" can be used to specify the standard notes. This option is\n>>> overridable with the `--no-notes` option in case a user wishes not to\n>>> append notes.\n>>>\n>>> Signed-off-by: Denton Liu <liu.denton@gmail.com>\n>>> ---\n>>> One thing I'm worried about is that I'm not really sure using \"standard\"\n>>> as the special value is a good idea. Would \"auto\" be a better special\n>>> value?\n>>>\n>>>  Documentation/config/format.txt    | 13 ++++++\n>>>  Documentation/git-format-patch.txt |  3 ++\n>>>  builtin/log.c                      | 18 +++++++-\n>>>  t/t4014-format-patch.sh            | 70 ++++++++++++++++++++++++++++++\n>>>  4 files changed, 103 insertions(+), 1 deletion(-)\n>>>\n>>> diff --git a/Documentation/config/format.txt b/Documentation/config/format.txt\n>>> index dc77941c48..e25f9cfc61 100644\n>>> --- a/Documentation/config/format.txt\n>>> +++ b/Documentation/config/format.txt\n>>> @@ -85,3 +85,16 @@ format.outputDirectory::\n>>>  format.useAutoBase::\n>>>  \tA boolean value which lets you enable the `--base=auto` option of\n>>>  \tformat-patch by default.\n>>> +\n>>> +format.notes::\n>>> +\tA ref which specifies where to get the notes (see\n>>> +\tlinkgit:git-notes[1]) that are appended for the commit after the\n>>> +\tthree-dash line.\n>>> ++\n>>> +If the special value of \"standard\" is specified, then the standard notes\n>>> +ref is used (i.e. the notes ref used by `git notes` when no `--ref`\n>>> +argument is specified). If one wishes to use the ref\n>>> +`ref/notes/standard`, please use that literal instead.\n>>> ++\n>>> +This configuration can be specified multiple times in order to allow\n>>> +multiple notes refs to be included.\n>>> diff --git a/Documentation/git-format-patch.txt b/Documentation/git-format-patch.txt\n>>> index 2c3971390e..9ce5b8aaee 100644\n>>> --- a/Documentation/git-format-patch.txt\n>>> +++ b/Documentation/git-format-patch.txt\n>>> @@ -275,6 +275,9 @@ these explanations after `format-patch` has run but before sending,\n>>>  keeping them as Git notes allows them to be maintained between versions\n>>>  of the patch series (but see the discussion of the `notes.rewrite`\n>>>  configuration options in linkgit:git-notes[1] to use this workflow).\n>>> ++\n>>> +The default is `--no-notes`, unless the `format.notes` configuration is\n>>> +set.\n>>>  \n>>>  --[no-]signature=<signature>::\n>>>  \tAdd a signature to each message produced. Per RFC 3676 the signature\n>>> diff --git a/builtin/log.c b/builtin/log.c\n>>> index e43ee12fb1..24954e42b0 100644\n>>> --- a/builtin/log.c\n>>> +++ b/builtin/log.c\n>>> @@ -779,6 +779,8 @@ enum {\n>>>  \n>>>  static int git_format_config(const char *var, const char *value, void *cb)\n>>>  {\n>>> +\tstruct rev_info *rev = cb;\n>>> +\n>>>  \tif (!strcmp(var, \"format.headers\")) {\n>>>  \t\tif (!value)\n>>>  \t\t\tdie(_(\"format.headers without value\"));\n>>> @@ -864,6 +866,20 @@ static int git_format_config(const char *var, const char *value, void *cb)\n>>>  \t\t\tfrom = NULL;\n>>>  \t\treturn 0;\n>>>  \t}\n>>> +\tif (!strcmp(var, \"format.notes\")) {\n>>> +\t\tstruct strbuf buf = STRBUF_INIT;\n>>> +\n>>> +\t\trev->show_notes = 1;\n>>> +\t\tif (!strcmp(value, \"standard\"))\n>>> +\t\t\trev->notes_opt.use_default_notes = 1;\n>>> +\t\telse {\n>>\n>> Use braces on both parts of the \"if\", if one part needs them.\n> \n> I thought that the style preference in this project is to not use braces\n> whenever it's unnecessary, even if it's on just one arm of an if-else.\n\nNo, Documentation/CodingGuidelines mentions this case explicitly. Search\nfor \"multiple arms\".\n\nATB, Beat\n\n"},{"id":"375308","messageId":"cover.1557513353.git.liu.denton@gmail.com","threadId":"51002","inReplyTo":"cover.1557327652.git.liu.denton@gmail.com","subject":"[PATCH v3 0/2] format-patch: teach format.notes config option","fromName":"Denton Liu","fromEmail":"liu.denton@gmail.com","sentAt":"2019-05-10T18:37:00Z","receivedAt":"2019-05-10T18:37:05Z","isPatch":true,"sender":{"key":"liu.denton@gmail.com","avatar":"https://avatars.githubusercontent.com/u/9620836?v=4"},"body":"Hi Beat, thanks for catching the style errors. This version fixes those.\n\nChanges since v2:\n\n* Fixed if-else code style\n* Fixed typoed errors in 2/2 log message\n\nChanges since v1:\n\n* Made format.notes accept a notes ref instead of a boolean\n\n\nDenton Liu (2):\n  git-format-patch.txt: document --no-notes option\n  format-patch: teach format.notes config option\n\n Documentation/config/format.txt    | 13 ++++++\n Documentation/git-format-patch.txt |  7 ++-\n builtin/log.c                      | 18 +++++++-\n t/t4014-format-patch.sh            | 70 ++++++++++++++++++++++++++++++\n 4 files changed, 106 insertions(+), 2 deletions(-)\n\nRange-diff against v2:\n1:  4c3535f25b = 1:  4c3535f25b git-format-patch.txt: document --no-notes option\n2:  fe674bf63e ! 2:  df864c4adf format-patch: teach format.notes config option\n    @@ -8,8 +8,8 @@\n         that they may forget to include it and generate a patch series without\n         notes.\n     \n    -    Teach git-format-patch the `format.notes` config option its value is a\n    -    notes ref that will be automatically be appended. The special value of\n    +    Teach git-format-patch the `format.notes` config option. Its value is a\n    +    notes ref that will be automatically appended. The special value of\n         \"standard\" can be used to specify the standard notes. This option is\n         overridable with the `--no-notes` option in case a user wishes not to\n         append notes.\n    @@ -71,9 +71,9 @@\n     +\t\tstruct strbuf buf = STRBUF_INIT;\n     +\n     +\t\trev->show_notes = 1;\n    -+\t\tif (!strcmp(value, \"standard\"))\n    ++\t\tif (!strcmp(value, \"standard\")) {\n     +\t\t\trev->notes_opt.use_default_notes = 1;\n    -+\t\telse {\n    ++\t\t} else {\n     +\t\t\tstrbuf_addstr(&buf, value);\n     +\t\t\texpand_notes_ref(&buf);\n     +\t\t\tstring_list_append(&rev->notes_opt.extra_notes_refs,\n-- \n2.21.0.1049.geb646f7864\n\n"},{"id":"375309","messageId":"4c3535f25bdffc8d94617c74f7c078cce59a044f.1557513353.git.liu.denton@gmail.com","threadId":"51002","inReplyTo":"cover.1557513353.git.liu.denton@gmail.com","subject":"[PATCH v3 1/2] git-format-patch.txt: document --no-notes option","fromName":"Denton Liu","fromEmail":"liu.denton@gmail.com","sentAt":"2019-05-10T18:37:03Z","receivedAt":"2019-05-10T18:37:19Z","isPatch":true,"sender":{"key":"liu.denton@gmail.com","avatar":"https://avatars.githubusercontent.com/u/9620836?v=4"},"body":"Internally, git-format-patch uses the `handle_revision_opt` parser. The\nparser handles the `--no-notes` option to negate an earlier `--notes`\noption, but it isn't documented. Document this option so that users are\naware of it.\n\nSigned-off-by: Denton Liu <liu.denton@gmail.com>\n---\n Documentation/git-format-patch.txt | 4 +++-\n 1 file changed, 3 insertions(+), 1 deletion(-)\n\ndiff --git a/Documentation/git-format-patch.txt b/Documentation/git-format-patch.txt\nindex 1af85d404f..2c3971390e 100644\n--- a/Documentation/git-format-patch.txt\n+++ b/Documentation/git-format-patch.txt\n@@ -22,7 +22,8 @@ SYNOPSIS\n \t\t   [--rfc] [--subject-prefix=Subject-Prefix]\n \t\t   [(--reroll-count|-v) <n>]\n \t\t   [--to=<email>] [--cc=<email>]\n-\t\t   [--[no-]cover-letter] [--quiet] [--notes[=<ref>]]\n+\t\t   [--[no-]cover-letter] [--quiet]\n+\t\t   [--no-notes | --notes[=<ref>]]\n \t\t   [--interdiff=<previous>]\n \t\t   [--range-diff=<previous> [--creation-factor=<percent>]]\n \t\t   [--progress]\n@@ -263,6 +264,7 @@ material (this may change in the future).\n \tfor details.\n \n --notes[=<ref>]::\n+--no-notes::\n \tAppend the notes (see linkgit:git-notes[1]) for the commit\n \tafter the three-dash line.\n +\n-- \n2.21.0.1049.geb646f7864\n\n"},{"id":"375310","messageId":"df864c4adf4dcab5f959007f87b1c4d0eafecb52.1557513353.git.liu.denton@gmail.com","threadId":"51002","inReplyTo":"cover.1557513353.git.liu.denton@gmail.com","subject":"[PATCH v3 2/2] format-patch: teach format.notes config option","fromName":"Denton Liu","fromEmail":"liu.denton@gmail.com","sentAt":"2019-05-10T18:37:05Z","receivedAt":"2019-05-10T18:37:20Z","isPatch":true,"sender":{"key":"liu.denton@gmail.com","avatar":"https://avatars.githubusercontent.com/u/9620836?v=4"},"body":"In git-format-patch, notes can be appended with the `--notes` option.\nHowever, this must be specified by the user on an\ninvocation-by-invocation basis. If a user is not careful, it's possible\nthat they may forget to include it and generate a patch series without\nnotes.\n\nTeach git-format-patch the `format.notes` config option. Its value is a\nnotes ref that will be automatically appended. The special value of\n\"standard\" can be used to specify the standard notes. This option is\noverridable with the `--no-notes` option in case a user wishes not to\nappend notes.\n\nSigned-off-by: Denton Liu <liu.denton@gmail.com>\n---\n Documentation/config/format.txt    | 13 ++++++\n Documentation/git-format-patch.txt |  3 ++\n builtin/log.c                      | 18 +++++++-\n t/t4014-format-patch.sh            | 70 ++++++++++++++++++++++++++++++\n 4 files changed, 103 insertions(+), 1 deletion(-)\n\ndiff --git a/Documentation/config/format.txt b/Documentation/config/format.txt\nindex dc77941c48..e25f9cfc61 100644\n--- a/Documentation/config/format.txt\n+++ b/Documentation/config/format.txt\n@@ -85,3 +85,16 @@ format.outputDirectory::\n format.useAutoBase::\n \tA boolean value which lets you enable the `--base=auto` option of\n \tformat-patch by default.\n+\n+format.notes::\n+\tA ref which specifies where to get the notes (see\n+\tlinkgit:git-notes[1]) that are appended for the commit after the\n+\tthree-dash line.\n++\n+If the special value of \"standard\" is specified, then the standard notes\n+ref is used (i.e. the notes ref used by `git notes` when no `--ref`\n+argument is specified). If one wishes to use the ref\n+`ref/notes/standard`, please use that literal instead.\n++\n+This configuration can be specified multiple times in order to allow\n+multiple notes refs to be included.\ndiff --git a/Documentation/git-format-patch.txt b/Documentation/git-format-patch.txt\nindex 2c3971390e..9ce5b8aaee 100644\n--- a/Documentation/git-format-patch.txt\n+++ b/Documentation/git-format-patch.txt\n@@ -275,6 +275,9 @@ these explanations after `format-patch` has run but before sending,\n keeping them as Git notes allows them to be maintained between versions\n of the patch series (but see the discussion of the `notes.rewrite`\n configuration options in linkgit:git-notes[1] to use this workflow).\n++\n+The default is `--no-notes`, unless the `format.notes` configuration is\n+set.\n \n --[no-]signature=<signature>::\n \tAdd a signature to each message produced. Per RFC 3676 the signature\ndiff --git a/builtin/log.c b/builtin/log.c\nindex e43ee12fb1..9d26e0f248 100644\n--- a/builtin/log.c\n+++ b/builtin/log.c\n@@ -779,6 +779,8 @@ enum {\n \n static int git_format_config(const char *var, const char *value, void *cb)\n {\n+\tstruct rev_info *rev = cb;\n+\n \tif (!strcmp(var, \"format.headers\")) {\n \t\tif (!value)\n \t\t\tdie(_(\"format.headers without value\"));\n@@ -864,6 +866,20 @@ static int git_format_config(const char *var, const char *value, void *cb)\n \t\t\tfrom = NULL;\n \t\treturn 0;\n \t}\n+\tif (!strcmp(var, \"format.notes\")) {\n+\t\tstruct strbuf buf = STRBUF_INIT;\n+\n+\t\trev->show_notes = 1;\n+\t\tif (!strcmp(value, \"standard\")) {\n+\t\t\trev->notes_opt.use_default_notes = 1;\n+\t\t} else {\n+\t\t\tstrbuf_addstr(&buf, value);\n+\t\t\texpand_notes_ref(&buf);\n+\t\t\tstring_list_append(&rev->notes_opt.extra_notes_refs,\n+\t\t\t\t\tstrbuf_detach(&buf, NULL));\n+\t\t}\n+\t\treturn 0;\n+\t}\n \n \treturn git_log_config(var, value, cb);\n }\n@@ -1617,8 +1633,8 @@ int cmd_format_patch(int argc, const char **argv, const char *prefix)\n \textra_to.strdup_strings = 1;\n \textra_cc.strdup_strings = 1;\n \tinit_log_defaults();\n-\tgit_config(git_format_config, NULL);\n \trepo_init_revisions(the_repository, &rev, prefix);\n+\tgit_config(git_format_config, &rev);\n \trev.commit_format = CMIT_FMT_EMAIL;\n \trev.expand_tabs_in_log_default = 0;\n \trev.verbose_header = 1;\ndiff --git a/t/t4014-format-patch.sh b/t/t4014-format-patch.sh\nindex b6e2fdbc44..e0127282ba 100755\n--- a/t/t4014-format-patch.sh\n+++ b/t/t4014-format-patch.sh\n@@ -738,6 +738,76 @@ test_expect_success 'format-patch --notes --signoff' '\n \tsed \"1,/^---$/d\" out | grep \"test message\"\n '\n \n+test_expect_success 'format-patch notes output control' '\n+\tgit notes add -m \"notes config message\" HEAD &&\n+\ttest_when_finished git notes remove HEAD &&\n+\n+\tgit format-patch -1 --stdout >out &&\n+\t! grep \"notes config message\" out &&\n+\tgit format-patch -1 --stdout --notes >out &&\n+\tgrep \"notes config message\" out &&\n+\tgit format-patch -1 --stdout --no-notes >out &&\n+\t! grep \"notes config message\" out &&\n+\tgit format-patch -1 --stdout --notes --no-notes >out &&\n+\t! grep \"notes config message\" out &&\n+\tgit format-patch -1 --stdout --no-notes --notes >out &&\n+\tgrep \"notes config message\" out &&\n+\n+\ttest_config format.notes standard &&\n+\tgit format-patch -1 --stdout >out &&\n+\tgrep \"notes config message\" out &&\n+\tgit format-patch -1 --stdout --notes >out &&\n+\tgrep \"notes config message\" out &&\n+\tgit format-patch -1 --stdout --no-notes >out &&\n+\t! grep \"notes config message\" out &&\n+\tgit format-patch -1 --stdout --notes --no-notes >out &&\n+\t! grep \"notes config message\" out &&\n+\tgit format-patch -1 --stdout --no-notes --notes >out &&\n+\tgrep \"notes config message\" out\n+'\n+\n+test_expect_success 'format-patch with multiple notes refs' '\n+\tgit notes --ref note1 add -m \"this is note 1\" HEAD &&\n+\ttest_when_finished git notes --ref note1 remove HEAD &&\n+\tgit notes --ref note2 add -m \"this is note 2\" HEAD &&\n+\ttest_when_finished git notes --ref note2 remove HEAD &&\n+\n+\tgit format-patch -1 --stdout >out &&\n+\t! grep \"this is note 1\" out &&\n+\t! grep \"this is note 2\" out &&\n+\tgit format-patch -1 --stdout --notes=note1 >out &&\n+\tgrep \"this is note 1\" out &&\n+\t! grep \"this is note 2\" out &&\n+\tgit format-patch -1 --stdout --notes=note2 >out &&\n+\t! grep \"this is note 1\" out &&\n+\tgrep \"this is note 2\" out &&\n+\tgit format-patch -1 --stdout --notes=note1 --notes=note2 >out &&\n+\tgrep \"this is note 1\" out &&\n+\tgrep \"this is note 2\" out &&\n+\n+\ttest_config format.notes note1 &&\n+\tgit format-patch -1 --stdout >out &&\n+\tgrep \"this is note 1\" out &&\n+\t! grep \"this is note 2\" out &&\n+\tgit format-patch -1 --stdout --no-notes >out &&\n+\t! grep \"this is note 1\" out &&\n+\t! grep \"this is note 2\" out &&\n+\tgit format-patch -1 --stdout --notes=note2 >out &&\n+\tgrep \"this is note 1\" out &&\n+\tgrep \"this is note 2\" out &&\n+\tgit format-patch -1 --stdout --no-notes --notes=note2 >out &&\n+\t! grep \"this is note 1\" out &&\n+\tgrep \"this is note 2\" out &&\n+\n+\tgit config --add format.notes note2 &&\n+\tgit format-patch -1 --stdout >out &&\n+\tgrep \"this is note 1\" out &&\n+\tgrep \"this is note 2\" out &&\n+\tgit format-patch -1 --stdout --no-notes >out &&\n+\t! grep \"this is note 1\" out &&\n+\t! grep \"this is note 2\" out\n+'\n+\n echo \"fatal: --name-only does not make sense\" > expect.name-only\n echo \"fatal: --name-status does not make sense\" > expect.name-status\n echo \"fatal: --check does not make sense\" > expect.check\n-- \n2.21.0.1049.geb646f7864\n\n"},{"id":"375356","messageId":"xmqqimufdqey.fsf@gitster-ct.c.googlers.com","threadId":"51002","inReplyTo":"df864c4adf4dcab5f959007f87b1c4d0eafecb52.1557513353.git.liu.denton@gmail.com","subject":"Re: [PATCH v3 2/2] format-patch: teach format.notes config option","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2019-05-13T02:44:21Z","receivedAt":"2019-05-13T02:44:26Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Denton Liu <liu.denton@gmail.com> writes:\n\n> @@ -864,6 +866,20 @@ static int git_format_config(const char *var, const char *value, void *cb)\n>  \t\t\tfrom = NULL;\n>  \t\treturn 0;\n>  \t}\n> +\tif (!strcmp(var, \"format.notes\")) {\n> +\t\tstruct strbuf buf = STRBUF_INIT;\n> +\n> +\t\trev->show_notes = 1;\n> +\t\tif (!strcmp(value, \"standard\")) {\n> +\t\t\trev->notes_opt.use_default_notes = 1;\n> +\t\t} else {\n> +\t\t\tstrbuf_addstr(&buf, value);\n> +\t\t\texpand_notes_ref(&buf);\n> +\t\t\tstring_list_append(&rev->notes_opt.extra_notes_refs,\n> +\t\t\t\t\tstrbuf_detach(&buf, NULL));\n> +\t\t}\n> +\t\treturn 0;\n> +\t}\n\nUnlike the command line option parser, this does not seem to touch\nrev->show_notes_given at all.  Intended?  I am wondering how well\nthis implementation meshes with what 66b2ed09 (\"Fix \"log\" family not\nto be too agressive about showing notes\", 2010-01-20) wanted to do,\nwhich 894a9d33 (\"Support showing notes from more than one notes\ntree\", 2010-03-12) later extended.\n\n> +test_expect_success 'format-patch notes output control' '\n> +\tgit notes add -m \"notes config message\" HEAD &&\n> +\ttest_when_finished git notes remove HEAD &&\n> +\n> +\tgit format-patch -1 --stdout >out &&\n> +\t! grep \"notes config message\" out &&\n> +\tgit format-patch -1 --stdout --notes >out &&\n> +\tgrep \"notes config message\" out &&\n> +\tgit format-patch -1 --stdout --no-notes >out &&\n> +\t! grep \"notes config message\" out &&\n> +\tgit format-patch -1 --stdout --notes --no-notes >out &&\n> +\t! grep \"notes config message\" out &&\n> +\tgit format-patch -1 --stdout --no-notes --notes >out &&\n> +\tgrep \"notes config message\" out &&\n> +\n> +\ttest_config format.notes standard &&\n\nI think we tend to spell these things \"default\".\n\nAlternatively, the format.notes configuration can be \"bool or text\",\nand make the variable set to 'true' mean \"show notes, using the\ndefault ref\".\n\n> +\tgit format-patch -1 --stdout >out &&\n> +\tgrep \"notes config message\" out &&\n> +\tgit format-patch -1 --stdout --notes >out &&\n> +\tgrep \"notes config message\" out &&\n> +\tgit format-patch -1 --stdout --no-notes >out &&\n> +\t! grep \"notes config message\" out &&\n> +\tgit format-patch -1 --stdout --notes --no-notes >out &&\n> +\t! grep \"notes config message\" out &&\n> +\tgit format-patch -1 --stdout --no-notes --notes >out &&\n> +\tgrep \"notes config message\" out\n> +'\n\nOK.\n\n> +test_expect_success 'format-patch with multiple notes refs' '\n> +\tgit notes --ref note1 add -m \"this is note 1\" HEAD &&\n> +\ttest_when_finished git notes --ref note1 remove HEAD &&\n> +\tgit notes --ref note2 add -m \"this is note 2\" HEAD &&\n> +\ttest_when_finished git notes --ref note2 remove HEAD &&\n> + ...\n> +\tgit format-patch -1 --stdout --notes=note1 --notes=note2 >out &&\n> +\tgrep \"this is note 1\" out &&\n> +\tgrep \"this is note 2\" out &&\n\nDo we promise the order in which these two lines appear in the output?\n\n> +\ttest_config format.notes note1 &&\n> +\tgit format-patch -1 --stdout >out &&\n> +\tgrep \"this is note 1\" out &&\n> +\t! grep \"this is note 2\" out &&\n> +\tgit format-patch -1 --stdout --no-notes >out &&\n> +\t! grep \"this is note 1\" out &&\n> +\t! grep \"this is note 2\" out &&\n> +\tgit format-patch -1 --stdout --notes=note2 >out &&\n> +\tgrep \"this is note 1\" out &&\n> +\tgrep \"this is note 2\" out &&\n\nSo format.notes say note1 but the command line explicitly asks it\nwants note from note2, but the command still gives from note1\nanyway.\n\n> +\tgit format-patch -1 --stdout --no-notes --notes=note2 >out &&\n> +\t! grep \"this is note 1\" out &&\n> +\tgrep \"this is note 2\" out &&\n\nAnd there is a way to work it around, i.e. clear everything\nconfigured with --no-notes and then name the one you want from the\ncommand line.\n\nI am not sure if the above is consistent with how our options and\nconfigurations interact in general.  Shouldn't the --notes=note2\nalone in the earlier example cancel format.notes=note1 configured?\n\n> +\tgit config --add format.notes note2 &&\n> +\tgit format-patch -1 --stdout >out &&\n> +\tgrep \"this is note 1\" out &&\n> +\tgrep \"this is note 2\" out &&\n> +\tgit format-patch -1 --stdout --no-notes >out &&\n> +\t! grep \"this is note 1\" out &&\n> +\t! grep \"this is note 2\" out\n> +'\n> +\n>  echo \"fatal: --name-only does not make sense\" > expect.name-only\n>  echo \"fatal: --name-status does not make sense\" > expect.name-status\n>  echo \"fatal: --check does not make sense\" > expect.check\n"},{"id":"375545","messageId":"20190514170107.GA4151@archbookpro.localdomain","threadId":"51002","inReplyTo":"xmqqimufdqey.fsf@gitster-ct.c.googlers.com","subject":"Re: [PATCH v3 2/2] format-patch: teach format.notes config option","fromName":"Denton Liu","fromEmail":"liu.denton@gmail.com","sentAt":"2019-05-14T17:01:07Z","receivedAt":"2019-05-14T17:01:13Z","isPatch":true,"sender":{"key":"liu.denton@gmail.com","avatar":"https://avatars.githubusercontent.com/u/9620836?v=4"},"body":"Hi Junio,\n\nOn Mon, May 13, 2019 at 11:44:21AM +0900, Junio C Hamano wrote:\n> Denton Liu <liu.denton@gmail.com> writes:\n> \n> > @@ -864,6 +866,20 @@ static int git_format_config(const char *var, const char *value, void *cb)\n> >  \t\t\tfrom = NULL;\n> >  \t\treturn 0;\n> >  \t}\n> > +\tif (!strcmp(var, \"format.notes\")) {\n> > +\t\tstruct strbuf buf = STRBUF_INIT;\n> > +\n> > +\t\trev->show_notes = 1;\n> > +\t\tif (!strcmp(value, \"standard\")) {\n> > +\t\t\trev->notes_opt.use_default_notes = 1;\n> > +\t\t} else {\n> > +\t\t\tstrbuf_addstr(&buf, value);\n> > +\t\t\texpand_notes_ref(&buf);\n> > +\t\t\tstring_list_append(&rev->notes_opt.extra_notes_refs,\n> > +\t\t\t\t\tstrbuf_detach(&buf, NULL));\n> > +\t\t}\n> > +\t\treturn 0;\n> > +\t}\n> \n> Unlike the command line option parser, this does not seem to touch\n> rev->show_notes_given at all.  Intended?  I am wondering how well\n> this implementation meshes with what 66b2ed09 (\"Fix \"log\" family not\n> to be too agressive about showing notes\", 2010-01-20) wanted to do,\n> which 894a9d33 (\"Support showing notes from more than one notes\n> tree\", 2010-03-12) later extended.\n\nThis was intended but I'm not 100% sure that it's correct.\n\nFrom what I could gleam from reading the code, `show_notes_given` is\nonly used by the `cmd_log_init` function, which is not called by\nformat-patch. As a result, I opted to not set that flag since it's not\nreally \"given\" in the sense that a user didn't explicitly pass in a\ncommand-line option indicating they wanted notes.\n\n> \n> > +test_expect_success 'format-patch notes output control' '\n> > +\tgit notes add -m \"notes config message\" HEAD &&\n> > +\ttest_when_finished git notes remove HEAD &&\n> > +\n> > +\tgit format-patch -1 --stdout >out &&\n> > +\t! grep \"notes config message\" out &&\n> > +\tgit format-patch -1 --stdout --notes >out &&\n> > +\tgrep \"notes config message\" out &&\n> > +\tgit format-patch -1 --stdout --no-notes >out &&\n> > +\t! grep \"notes config message\" out &&\n> > +\tgit format-patch -1 --stdout --notes --no-notes >out &&\n> > +\t! grep \"notes config message\" out &&\n> > +\tgit format-patch -1 --stdout --no-notes --notes >out &&\n> > +\tgrep \"notes config message\" out &&\n> > +\n> > +\ttest_config format.notes standard &&\n> \n> I think we tend to spell these things \"default\".\n> \n> Alternatively, the format.notes configuration can be \"bool or text\",\n> and make the variable set to 'true' mean \"show notes, using the\n> default ref\".\n\nI think I'l go with this approach.\n\n> \n> > +\tgit format-patch -1 --stdout >out &&\n> > +\tgrep \"notes config message\" out &&\n> > +\tgit format-patch -1 --stdout --notes >out &&\n> > +\tgrep \"notes config message\" out &&\n> > +\tgit format-patch -1 --stdout --no-notes >out &&\n> > +\t! grep \"notes config message\" out &&\n> > +\tgit format-patch -1 --stdout --notes --no-notes >out &&\n> > +\t! grep \"notes config message\" out &&\n> > +\tgit format-patch -1 --stdout --no-notes --notes >out &&\n> > +\tgrep \"notes config message\" out\n> > +'\n> \n> OK.\n> \n> > +test_expect_success 'format-patch with multiple notes refs' '\n> > +\tgit notes --ref note1 add -m \"this is note 1\" HEAD &&\n> > +\ttest_when_finished git notes --ref note1 remove HEAD &&\n> > +\tgit notes --ref note2 add -m \"this is note 2\" HEAD &&\n> > +\ttest_when_finished git notes --ref note2 remove HEAD &&\n> > + ...\n> > +\tgit format-patch -1 --stdout --notes=note1 --notes=note2 >out &&\n> > +\tgrep \"this is note 1\" out &&\n> > +\tgrep \"this is note 2\" out &&\n> \n> Do we promise the order in which these two lines appear in the output?\n\nAccording to the code, the order is stable. However, I just read through\nthe documentation and I realised that the ablility to provide multiple\nnotes refs is undocumented.\n\nIn a future reroll, I'll document the fact that --notes can be provided\nmultiple times.\n\n> \n> > +\ttest_config format.notes note1 &&\n> > +\tgit format-patch -1 --stdout >out &&\n> > +\tgrep \"this is note 1\" out &&\n> > +\t! grep \"this is note 2\" out &&\n> > +\tgit format-patch -1 --stdout --no-notes >out &&\n> > +\t! grep \"this is note 1\" out &&\n> > +\t! grep \"this is note 2\" out &&\n> > +\tgit format-patch -1 --stdout --notes=note2 >out &&\n> > +\tgrep \"this is note 1\" out &&\n> > +\tgrep \"this is note 2\" out &&\n> \n> So format.notes say note1 but the command line explicitly asks it\n> wants note from note2, but the command still gives from note1\n> anyway.\n> \n> > +\tgit format-patch -1 --stdout --no-notes --notes=note2 >out &&\n> > +\t! grep \"this is note 1\" out &&\n> > +\tgrep \"this is note 2\" out &&\n> \n> And there is a way to work it around, i.e. clear everything\n> configured with --no-notes and then name the one you want from the\n> command line.\n> \n> I am not sure if the above is consistent with how our options and\n> configurations interact in general.  Shouldn't the --notes=note2\n> alone in the earlier example cancel format.notes=note1 configured?\n\nI borrowed this behaviour from how format.to behaves. In format-patch,\n`--to` gives a recipient that is used _in addition_ to any format.to\nvariables. `--no-to` can override this. I made format.notes behave\nsimilarly.\n\n> \n> > +\tgit config --add format.notes note2 &&\n> > +\tgit format-patch -1 --stdout >out &&\n> > +\tgrep \"this is note 1\" out &&\n> > +\tgrep \"this is note 2\" out &&\n> > +\tgit format-patch -1 --stdout --no-notes >out &&\n> > +\t! grep \"this is note 1\" out &&\n> > +\t! grep \"this is note 2\" out\n> > +'\n> > +\n> >  echo \"fatal: --name-only does not make sense\" > expect.name-only\n> >  echo \"fatal: --name-status does not make sense\" > expect.name-status\n> >  echo \"fatal: --check does not make sense\" > expect.check\n"}]}