]> git.ipfire.org Git - thirdparty/git.git/commitdiff
notes: create init_display_notes() helper
authorDenton Liu <liu.denton@gmail.com>
Mon, 9 Dec 2019 13:10:41 +0000 (05:10 -0800)
committerJunio C Hamano <gitster@pobox.com>
Mon, 9 Dec 2019 21:36:44 +0000 (13:36 -0800)
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>
notes.c
notes.h
revision.c

diff --git a/notes.c b/notes.c
index fd6cef14a3b73456638924311268b64dc696eee6..53d1e7767ce459e53aa4ffeae129672d599d1859 100644 (file)
--- a/notes.c
+++ b/notes.c
@@ -1039,6 +1039,12 @@ struct notes_tree **load_notes_trees(struct string_list *refs, int flags)
        return trees;
 }
 
+void init_display_notes(struct display_notes_opt *opt)
+{
+       memset(opt, 0, sizeof(*opt));
+       opt->use_default_notes = -1;
+}
+
 void load_display_notes(struct display_notes_opt *opt)
 {
        char *display_ref_env;
diff --git a/notes.h b/notes.h
index 1ce528442a55371c3f7c96c5dd525ea2c071e311..c0b712371cc28df7aa45aa10b0af01bc2bdc3a42 100644 (file)
--- a/notes.h
+++ b/notes.h
@@ -260,6 +260,11 @@ struct display_notes_opt {
        struct string_list extra_notes_refs;
 };
 
+/*
+ * Initialize a display_notes_opt to its default value.
+ */
+void init_display_notes(struct display_notes_opt *opt);
+
 /*
  * Load the notes machinery for displaying several notes trees.
  *
index d4aaf0ef257943029923f741b4ae383bb00d7f5f..24ad974590bf6609586d53be3b78cfab89470510 100644 (file)
@@ -1637,7 +1637,7 @@ void repo_init_revisions(struct repository *r,
                revs->diffopt.prefix_length = strlen(prefix);
        }
 
-       revs->notes_opt.use_default_notes = -1;
+       init_display_notes(&revs->notes_opt);
 }
 
 static void add_pending_commit_list(struct rev_info *revs,