notes: create init_display_notes() helper
We currently open code the initialization for revs->notes_opt. Abstract this away into a helper function so that the logic can be reused in a future commit. This is slightly wasteful as we memset the struct twice but this is only run once so it shouldn't have any major effect. Signed-off-by: Denton Liu <liu.denton@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Denton Liu committed
Dec 9, 2019 at 05:10 UTC
e6e230eeae0f3cb46c4c356e6cd0a0f1119a2a83
3 files changed
+12
-1
notes.c
+6
@@ -1039,6 +1039,12 @@ struct notes_tree **load_notes_trees(struct string_list *refs, int flags)
1039
return trees;
1040
}
1041
1042
+void init_display_notes(struct display_notes_opt *opt)
1043
+{
1044
+ memset(opt, 0, sizeof(*opt));
1045
+ opt->use_default_notes = -1;
1046
+}
1047
+
1048
void load_display_notes(struct display_notes_opt *opt)
1049
{
1050
char *display_ref_env;
notes.h
+5
@@ -260,6 +260,11 @@ struct display_notes_opt {
260
struct string_list extra_notes_refs;
261
};
262
263
+/*
264
+ * Initialize a display_notes_opt to its default value.
265
+ */
266
+void init_display_notes(struct display_notes_opt *opt);
267
+
268
/*
269
* Load the notes machinery for displaying several notes trees.
270
*
revision.c
+1
-1
@@ -1637,7 +1637,7 @@ void repo_init_revisions(struct repository *r,
1637
revs->diffopt.prefix_length = strlen(prefix);
1638
}
1639
1640
- revs->notes_opt.use_default_notes = -1;
1640
+ init_display_notes(&revs->notes_opt);
1641
}
1642
1643
static void add_pending_commit_list(struct rev_info *revs,