diff options
author | Vincent Ambo <tazjin@google.com> | 2020-05-25T23·06+0100 |
---|---|---|
committer | Vincent Ambo <tazjin@google.com> | 2020-05-25T23·06+0100 |
commit | 93ba78d6f4632ef1c5228965e3edc8c0faf88c1e (patch) | |
tree | 85730c182a9f5f492ade8e8ccdb1c2356f9900bd /third_party/git/notes.c | |
parent | 6f8fbf4aa4b1654ab27d4829e114538761817de0 (diff) |
revert(3p/git): Revert merge of git upstream at v2.26.2 r/852
This causes cgit to serve error pages, which is undesirable. This reverts commit 5229c9b232de5bfa959ad6ebbb4c8192ac513352, reversing changes made to f2b211131f2347342dde63975b09cf603149f1a3.
Diffstat (limited to 'third_party/git/notes.c')
-rw-r--r-- | third_party/git/notes.c | 69 |
1 files changed, 16 insertions, 53 deletions
diff --git a/third_party/git/notes.c b/third_party/git/notes.c index 564baac64d76..75c028b3005a 100644 --- a/third_party/git/notes.c +++ b/third_party/git/notes.c @@ -269,10 +269,8 @@ static int note_tree_insert(struct notes_tree *t, struct int_node *tree, case PTR_TYPE_NOTE: if (oideq(&l->key_oid, &entry->key_oid)) { /* skip concatenation if l == entry */ - if (oideq(&l->val_oid, &entry->val_oid)) { - free(entry); + if (oideq(&l->val_oid, &entry->val_oid)) return 0; - } ret = combine_notes(&l->val_oid, &entry->val_oid); @@ -460,7 +458,7 @@ static void load_subtree(struct notes_tree *t, struct leaf_node *subtree, die("Failed to load %s %s into notes tree " "from %s", type == PTR_TYPE_NOTE ? "note" : "subtree", - oid_to_hex(&object_oid), t->ref); + oid_to_hex(&l->key_oid), t->ref); continue; @@ -576,16 +574,16 @@ redo: * the note tree that have not yet been explored. There * is a direct relationship between subtree entries at * level 'n' in the tree, and the 'fanout' variable: - * Subtree entries at level 'n < 2 * fanout' should be + * Subtree entries at level 'n <= 2 * fanout' should be * preserved, since they correspond exactly to a fanout * directory in the on-disk structure. However, subtree - * entries at level 'n >= 2 * fanout' should NOT be + * entries at level 'n > 2 * fanout' should NOT be * preserved, but rather consolidated into the above * notes tree level. We achieve this by unconditionally * unpacking subtree entries that exist below the * threshold level at 'n = 2 * fanout'. */ - if (n < 2 * fanout && + if (n <= 2 * fanout && flags & FOR_EACH_NOTE_YIELD_SUBTREES) { /* invoke callback with subtree */ unsigned int path_len = @@ -602,7 +600,7 @@ redo: path, cb_data); } - if (n >= 2 * fanout || + if (n > fanout * 2 || !(flags & FOR_EACH_NOTE_DONT_UNPACK_SUBTREES)) { /* unpack subtree and resume traversal */ tree->a[i] = NULL; @@ -723,15 +721,13 @@ static int write_each_note_helper(struct tree_write_stack *tws, struct write_each_note_data { struct tree_write_stack *root; - struct non_note **nn_list; - struct non_note *nn_prev; + struct non_note *next_non_note; }; static int write_each_non_note_until(const char *note_path, struct write_each_note_data *d) { - struct non_note *p = d->nn_prev; - struct non_note *n = p ? p->next : *d->nn_list; + struct non_note *n = d->next_non_note; int cmp = 0, ret; while (n && (!note_path || (cmp = strcmp(n->path, note_path)) <= 0)) { if (note_path && cmp == 0) @@ -742,10 +738,9 @@ static int write_each_non_note_until(const char *note_path, if (ret) return ret; } - p = n; n = n->next; } - d->nn_prev = p; + d->next_non_note = n; return 0; } @@ -1046,39 +1041,6 @@ 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; @@ -1180,8 +1142,7 @@ int write_notes_tree(struct notes_tree *t, struct object_id *result) strbuf_init(&root.buf, 256 * (32 + the_hash_algo->hexsz)); /* assume 256 entries */ root.path[0] = root.path[1] = '\0'; cb_data.root = &root; - cb_data.nn_list = &(t->first_non_note); - cb_data.nn_prev = NULL; + cb_data.next_non_note = t->first_non_note; /* Write tree objects representing current notes tree */ flags = FOR_EACH_NOTE_DONT_UNPACK_SUBTREES | @@ -1283,8 +1244,10 @@ static void format_note(struct notes_tree *t, const struct object_id *object_oid if (!ref || !strcmp(ref, GIT_NOTES_DEFAULT_REF)) { strbuf_addstr(sb, "\nNotes:\n"); } else { - skip_prefix(ref, "refs/", &ref); - skip_prefix(ref, "notes/", &ref); + if (starts_with(ref, "refs/")) + ref += 5; + if (starts_with(ref, "notes/")) + ref += 6; strbuf_addf(sb, "\nNotes (%s):\n", ref); } } @@ -1334,9 +1297,9 @@ void expand_notes_ref(struct strbuf *sb) if (starts_with(sb->buf, "refs/notes/")) return; /* we're happy */ else if (starts_with(sb->buf, "notes/")) - strbuf_insertstr(sb, 0, "refs/"); + strbuf_insert(sb, 0, "refs/", 5); else - strbuf_insertstr(sb, 0, "refs/notes/"); + strbuf_insert(sb, 0, "refs/notes/", 11); } void expand_loose_notes_ref(struct strbuf *sb) |