Skip to content

Commit 09ac67a

Browse files
Denton-Lgitster
authored andcommitted
format-patch: move git_config() before repo_init_revisions()
In 13cdf78 (format-patch: teach format.notes config option, 2019-05-16), the order in which git_config() and repo_init_revisions() were swapped so that `rev.notes_opt` would be initialized before git_config() was called. This is problematic, however, as git_config() should generally be called before repo_init_revisions(). Break this circular dependency by creating `show_notes` and `notes_opt` which git_config() reads into. Then, copy these values over to `rev.show_notes` and `rev.notes_opt` after repo_init_revisions() is called. Signed-off-by: Denton Liu <liu.denton@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
1 parent 8164c96 commit 09ac67a

File tree

1 file changed

+7
-4
lines changed

1 file changed

+7
-4
lines changed

builtin/log.c

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -769,6 +769,8 @@ static const char *signature = git_version_string;
769769
static const char *signature_file;
770770
static int config_cover_letter;
771771
static const char *config_output_directory;
772+
static int show_notes;
773+
static struct display_notes_opt notes_opt;
772774

773775
enum {
774776
COVER_UNSET,
@@ -779,8 +781,6 @@ enum {
779781

780782
static int git_format_config(const char *var, const char *value, void *cb)
781783
{
782-
struct rev_info *rev = cb;
783-
784784
if (!strcmp(var, "format.headers")) {
785785
if (!value)
786786
die(_("format.headers without value"));
@@ -868,7 +868,7 @@ static int git_format_config(const char *var, const char *value, void *cb)
868868
}
869869
if (!strcmp(var, "format.notes")) {
870870
int b = git_parse_maybe_bool(value);
871-
rev->show_notes = set_display_notes(&rev->notes_opt, b, b < 0 ? value : NULL);
871+
show_notes = set_display_notes(&notes_opt, b, b < 0 ? value : NULL);
872872
return 0;
873873
}
874874

@@ -1624,8 +1624,11 @@ int cmd_format_patch(int argc, const char **argv, const char *prefix)
16241624
extra_to.strdup_strings = 1;
16251625
extra_cc.strdup_strings = 1;
16261626
init_log_defaults();
1627+
init_display_notes(&notes_opt);
1628+
git_config(git_format_config, NULL);
16271629
repo_init_revisions(the_repository, &rev, prefix);
1628-
git_config(git_format_config, &rev);
1630+
rev.show_notes = show_notes;
1631+
memcpy(&rev.notes_opt, &notes_opt, sizeof(notes_opt));
16291632
rev.commit_format = CMIT_FMT_EMAIL;
16301633
rev.expand_tabs_in_log_default = 0;
16311634
rev.verbose_header = 1;

0 commit comments

Comments
 (0)