Code

Merge branch 'ph/rerere-doc' into maint-1.7.8
[git.git] / notes.c
diff --git a/notes.c b/notes.c
index a013c1bc638dbf5a8111183a3f9d154721ec5e04..93e9868d5d1aa536b70e981d3a4cd3c7969764d3 100644 (file)
--- a/notes.c
+++ b/notes.c
@@ -1053,7 +1053,8 @@ void init_display_notes(struct display_notes_opt *opt)
 
        assert(!display_notes_trees);
 
-       if (!opt || !opt->suppress_default_notes) {
+       if (!opt || opt->use_default_notes > 0 ||
+           (opt->use_default_notes == -1 && !opt->extra_notes_refs.nr)) {
                string_list_append(&display_notes_refs, default_notes_ref());
                display_ref_env = getenv(GIT_NOTES_DISPLAY_REF_ENVIRONMENT);
                if (display_ref_env) {
@@ -1066,9 +1067,9 @@ void init_display_notes(struct display_notes_opt *opt)
 
        git_config(notes_display_config, &load_config_refs);
 
-       if (opt && opt->extra_notes_refs) {
+       if (opt) {
                struct string_list_item *item;
-               for_each_string_list_item(item, opt->extra_notes_refs)
+               for_each_string_list_item(item, &opt->extra_notes_refs)
                        string_list_add_refs_by_glob(&display_notes_refs,
                                                     item->string);
        }
@@ -1104,7 +1105,7 @@ int remove_note(struct notes_tree *t, const unsigned char *object_sha1)
        hashcpy(l.key_sha1, object_sha1);
        hashclr(l.val_sha1);
        note_tree_remove(t, t->root, 0, &l);
-       if (is_null_sha1(l.val_sha1)) // no note was removed
+       if (is_null_sha1(l.val_sha1)) /* no note was removed */
                return 1;
        t->dirty = 1;
        return 0;
@@ -1285,3 +1286,13 @@ int copy_note(struct notes_tree *t,
 
        return 0;
 }
+
+void expand_notes_ref(struct strbuf *sb)
+{
+       if (!prefixcmp(sb->buf, "refs/notes/"))
+               return; /* we're happy */
+       else if (!prefixcmp(sb->buf, "notes/"))
+               strbuf_insert(sb, 0, "refs/", 5);
+       else
+               strbuf_insert(sb, 0, "refs/notes/", 11);
+}