Merge branch 'dl/format-patch-notes-config-fixup'
"git format-patch" can take a set of configured format.notes values to specify which notes refs to use in the log message part of the output. The behaviour of this was not consistent with multiple --notes command line options, which has been corrected. * dl/format-patch-notes-config-fixup: notes.h: fix typos in comment notes: break set_display_notes() into smaller functions config/format.txt: clarify behavior of multiple format.notes format-patch: move git_config() before repo_init_revisions() format-patch: use --notes behavior for format.notes notes: extract logic into set_display_notes() notes: create init_display_notes() helper notes: rename to load_display_notes()
This commit is contained in:
@ -208,7 +208,7 @@ static void cmd_log_init_finish(int argc, const char **argv, const char *prefix,
|
||||
if (!rev->show_notes_given && (!rev->pretty_given || w.notes))
|
||||
rev->show_notes = 1;
|
||||
if (rev->show_notes)
|
||||
init_display_notes(&rev->notes_opt);
|
||||
load_display_notes(&rev->notes_opt);
|
||||
|
||||
if ((rev->diffopt.pickaxe_opts & DIFF_PICKAXE_KINDS_MASK) ||
|
||||
rev->diffopt.filter || rev->diffopt.flags.follow_renames)
|
||||
@ -795,6 +795,8 @@ static const char *signature_file;
|
||||
static enum cover_setting config_cover_letter;
|
||||
static const char *config_output_directory;
|
||||
static enum cover_from_description cover_from_description_mode = COVER_FROM_MESSAGE;
|
||||
static int show_notes;
|
||||
static struct display_notes_opt notes_opt;
|
||||
|
||||
static enum cover_from_description parse_cover_from_description(const char *arg)
|
||||
{
|
||||
@ -814,8 +816,6 @@ static enum cover_from_description parse_cover_from_description(const char *arg)
|
||||
|
||||
static int git_format_config(const char *var, const char *value, void *cb)
|
||||
{
|
||||
struct rev_info *rev = cb;
|
||||
|
||||
if (!strcmp(var, "format.headers")) {
|
||||
if (!value)
|
||||
die(_("format.headers without value"));
|
||||
@ -902,19 +902,13 @@ static int git_format_config(const char *var, const char *value, void *cb)
|
||||
return 0;
|
||||
}
|
||||
if (!strcmp(var, "format.notes")) {
|
||||
struct strbuf buf = STRBUF_INIT;
|
||||
int b = git_parse_maybe_bool(value);
|
||||
if (!b)
|
||||
return 0;
|
||||
rev->show_notes = 1;
|
||||
if (b < 0) {
|
||||
strbuf_addstr(&buf, value);
|
||||
expand_notes_ref(&buf);
|
||||
string_list_append(&rev->notes_opt.extra_notes_refs,
|
||||
strbuf_detach(&buf, NULL));
|
||||
} else {
|
||||
rev->notes_opt.use_default_notes = 1;
|
||||
}
|
||||
if (b < 0)
|
||||
enable_ref_display_notes(¬es_opt, &show_notes, value);
|
||||
else if (b)
|
||||
enable_default_display_notes(¬es_opt, &show_notes);
|
||||
else
|
||||
disable_display_notes(¬es_opt, &show_notes);
|
||||
return 0;
|
||||
}
|
||||
if (!strcmp(var, "format.coverfromdescription")) {
|
||||
@ -1719,8 +1713,11 @@ int cmd_format_patch(int argc, const char **argv, const char *prefix)
|
||||
extra_to.strdup_strings = 1;
|
||||
extra_cc.strdup_strings = 1;
|
||||
init_log_defaults();
|
||||
init_display_notes(¬es_opt);
|
||||
git_config(git_format_config, NULL);
|
||||
repo_init_revisions(the_repository, &rev, prefix);
|
||||
git_config(git_format_config, &rev);
|
||||
rev.show_notes = show_notes;
|
||||
memcpy(&rev.notes_opt, ¬es_opt, sizeof(notes_opt));
|
||||
rev.commit_format = CMIT_FMT_EMAIL;
|
||||
rev.expand_tabs_in_log_default = 0;
|
||||
rev.verbose_header = 1;
|
||||
@ -1839,7 +1836,7 @@ int cmd_format_patch(int argc, const char **argv, const char *prefix)
|
||||
rev.diffopt.flags.binary = 1;
|
||||
|
||||
if (rev.show_notes)
|
||||
init_display_notes(&rev.notes_opt);
|
||||
load_display_notes(&rev.notes_opt);
|
||||
|
||||
if (!output_directory && !use_stdout)
|
||||
output_directory = config_output_directory;
|
||||
|
Reference in New Issue
Block a user