summary refs log tree commit diff
path: root/notes.c
diff options
context:
space:
mode:
authorJunio C Hamano <gitster@pobox.com>2019-12-25 11:21:58 -0800
committerJunio C Hamano <gitster@pobox.com>2019-12-25 11:21:58 -0800
commit17066bea38d14a9f9a7a174f40cd9dc1fd720210 (patch)
tree66c932b0150f221909cd2dac863511fb3579217d /notes.c
parent135365dd991f9520406012e30ab27a8d22951df8 (diff)
parente0f9095aaa56f5c731faced2e61ca48df5caedfb (diff)
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()
Diffstat (limited to 'notes.c')
-rw-r--r--notes.c33
1 files changed, 33 insertions, 0 deletions
diff --git a/notes.c b/notes.c
index 03e7d0cd2d..0c79964c26 100644
--- a/notes.c
+++ b/notes.c
@@ -1043,6 +1043,39 @@ struct notes_tree **load_notes_trees(struct string_list *refs, int flags)
 
 void init_display_notes(struct display_notes_opt *opt)
 {
+	memset(opt, 0, sizeof(*opt));
+	opt->use_default_notes = -1;
+}
+
+void enable_default_display_notes(struct display_notes_opt *opt, int *show_notes)
+{
+	opt->use_default_notes = 1;
+	*show_notes = 1;
+}
+
+void enable_ref_display_notes(struct display_notes_opt *opt, int *show_notes,
+		const char *ref) {
+	struct strbuf buf = STRBUF_INIT;
+	strbuf_addstr(&buf, ref);
+	expand_notes_ref(&buf);
+	string_list_append(&opt->extra_notes_refs,
+			strbuf_detach(&buf, NULL));
+	*show_notes = 1;
+}
+
+void disable_display_notes(struct display_notes_opt *opt, int *show_notes)
+{
+	opt->use_default_notes = -1;
+	/* we have been strdup'ing ourselves, so trick
+	 * string_list into free()ing strings */
+	opt->extra_notes_refs.strdup_strings = 1;
+	string_list_clear(&opt->extra_notes_refs, 0);
+	opt->extra_notes_refs.strdup_strings = 0;
+	*show_notes = 0;
+}
+
+void load_display_notes(struct display_notes_opt *opt)
+{
 	char *display_ref_env;
 	int load_config_refs = 0;
 	display_notes_refs.strdup_strings = 1;