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/blame.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/blame.c')
-rw-r--r-- | third_party/git/blame.c | 27 |
1 files changed, 12 insertions, 15 deletions
diff --git a/third_party/git/blame.c b/third_party/git/blame.c index 29770e5c81c0..36a2e7ef119d 100644 --- a/third_party/git/blame.c +++ b/third_party/git/blame.c @@ -144,7 +144,7 @@ static void append_merge_parents(struct repository *r, while (!strbuf_getwholeline_fd(&line, merge_head, '\n')) { struct object_id oid; - if (get_oid_hex(line.buf, &oid)) + if (line.len < GIT_SHA1_HEXSZ || get_oid_hex(line.buf, &oid)) die("unknown line in '%s': %s", git_path_merge_head(r), line.buf); tail = append_parent(r, tail, &oid); @@ -417,15 +417,14 @@ static void get_fingerprint(struct fingerprint *result, /* Ignore whitespace pairs */ if (hash == 0) continue; - hashmap_entry_init(&entry->entry, hash); + hashmap_entry_init(entry, hash); - found_entry = hashmap_get_entry(&result->map, entry, - /* member name */ entry, NULL); + found_entry = hashmap_get(&result->map, entry, NULL); if (found_entry) { found_entry->count += 1; } else { entry->count = 1; - hashmap_add(&result->map, &entry->entry); + hashmap_add(&result->map, entry); ++entry; } } @@ -433,7 +432,7 @@ static void get_fingerprint(struct fingerprint *result, static void free_fingerprint(struct fingerprint *f) { - hashmap_free(&f->map); + hashmap_free(&f->map, 0); free(f->entries); } @@ -450,10 +449,10 @@ static int fingerprint_similarity(struct fingerprint *a, struct fingerprint *b) struct hashmap_iter iter; const struct fingerprint_entry *entry_a, *entry_b; - hashmap_for_each_entry(&b->map, &iter, entry_b, - entry /* member name */) { - entry_a = hashmap_get_entry(&a->map, entry_b, entry, NULL); - if (entry_a) { + hashmap_iter_init(&b->map, &iter); + + while ((entry_b = hashmap_iter_next(&iter))) { + if ((entry_a = hashmap_get(&a->map, entry_b, NULL))) { intersection += entry_a->count < entry_b->count ? entry_a->count : entry_b->count; } @@ -471,12 +470,10 @@ static void fingerprint_subtract(struct fingerprint *a, struct fingerprint *b) hashmap_iter_init(&b->map, &iter); - hashmap_for_each_entry(&b->map, &iter, entry_b, - entry /* member name */) { - entry_a = hashmap_get_entry(&a->map, entry_b, entry, NULL); - if (entry_a) { + while ((entry_b = hashmap_iter_next(&iter))) { + if ((entry_a = hashmap_get(&a->map, entry_b, NULL))) { if (entry_a->count <= entry_b->count) - hashmap_remove(&a->map, &entry_b->entry, NULL); + hashmap_remove(&a->map, entry_b, NULL); else entry_a->count -= entry_b->count; } |