]> git.ipfire.org Git - thirdparty/git.git/blobdiff - notes.c
config/format.txt: clarify behavior of multiple format.notes
[thirdparty/git.git] / notes.c
diff --git a/notes.c b/notes.c
index be72780a8f3bb5c28341b0125c06caa513ec1488..c93feff4abd306bc9fdc59aa775e3a0c924cfd2a 100644 (file)
--- a/notes.c
+++ b/notes.c
@@ -988,7 +988,7 @@ void init_notes(struct notes_tree *t, const char *notes_ref,
                combine_notes_fn combine_notes, int flags)
 {
        struct object_id oid, object_oid;
-       unsigned mode;
+       unsigned short mode;
        struct leaf_node root_tree;
 
        if (!t)
@@ -1040,6 +1040,36 @@ 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;
+}
+
+int set_display_notes(struct display_notes_opt *opt, int show_notes, const char *opt_ref)
+{
+       if (show_notes) {
+               if (opt_ref) {
+                       struct strbuf buf = STRBUF_INIT;
+                       strbuf_addstr(&buf, opt_ref);
+                       expand_notes_ref(&buf);
+                       string_list_append(&opt->extra_notes_refs,
+                                          strbuf_detach(&buf, NULL));
+               } else {
+                       opt->use_default_notes = 1;
+               }
+       } else {
+               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;
+       }
+
+       return !!show_notes;
+}
+
+void load_display_notes(struct display_notes_opt *opt)
 {
        char *display_ref_env;
        int load_config_refs = 0;