From: Junio C Hamano Date: Fri, 19 Jul 2019 18:30:20 +0000 (-0700) Subject: Merge branch 'br/blame-ignore' X-Git-Tag: v2.23.0-rc0~39 X-Git-Url: https://git.lorimer.id.au/gitweb.git/diff_plain/209f0755934a0c9b448408f9b7c9849c15041ecc Merge branch 'br/blame-ignore' "git blame" learned to "ignore" commits in the history, whose effects (as well as their presence) get ignored. * br/blame-ignore: t8014: remove unnecessary braces blame: drop some unused function parameters blame: add a test to cover blame_coalesce() blame: use the fingerprint heuristic to match ignored lines blame: add a fingerprint heuristic to match ignored lines blame: optionally track line fingerprints during fill_blame_origin() blame: add config options for the output of ignored or unblamable lines blame: add the ability to ignore commits and their changes blame: use a helper function in blame_chunk() Move oidset_parse_file() to oidset.c fsck: rename and touch up init_skiplist() --- 209f0755934a0c9b448408f9b7c9849c15041ecc diff --cc blame.h index d62f80fa74,5dd877bb78..4a9e1270b0 --- a/blame.h +++ b/blame.h @@@ -51,8 -51,10 +51,10 @@@ struct blame_origin */ struct blame_entry *suspects; mmfile_t file; + int num_lines; + void *fingerprints; struct object_id blob_oid; - unsigned mode; + unsigned short mode; /* guilty gets set when shipping any suspects to the final * blame list instead of other commits */ diff --cc oidset.c index 8bdecb13de,584be63e52..f63ce818f6 --- a/oidset.c +++ b/oidset.c @@@ -32,6 -32,41 +32,41 @@@ int oidset_remove(struct oidset *set, c void oidset_clear(struct oidset *set) { - kh_release_oid(&set->set); + kh_release_oid_set(&set->set); oidset_init(set, 0); } + + void oidset_parse_file(struct oidset *set, const char *path) + { + FILE *fp; + struct strbuf sb = STRBUF_INIT; + struct object_id oid; + + fp = fopen(path, "r"); + if (!fp) + die("could not open object name list: %s", path); + while (!strbuf_getline(&sb, fp)) { + const char *p; + const char *name; + + /* + * Allow trailing comments, leading whitespace + * (including before commits), and empty or whitespace + * only lines. + */ + name = strchr(sb.buf, '#'); + if (name) + strbuf_setlen(&sb, name - sb.buf); + strbuf_trim(&sb); + if (!sb.len) + continue; + + if (parse_oid_hex(sb.buf, &oid, &p) || *p != '\0') + die("invalid object name: %s", sb.buf); + oidset_insert(set, &oid); + } + if (ferror(fp)) + die_errno("Could not read '%s'", path); + fclose(fp); + strbuf_release(&sb); + } diff --cc oidset.h index 505fad578b,c4807749df..5346563b0b --- a/oidset.h +++ b/oidset.h @@@ -61,8 -73,16 +61,16 @@@ int oidset_remove(struct oidset *set, c */ void oidset_clear(struct oidset *set); + /** + * Add the contents of the file 'path' to an initialized oidset. Each line is + * an unabbreviated object name. Comments begin with '#', and trailing comments + * are allowed. Leading whitespace and empty or white-space only lines are + * ignored. + */ + void oidset_parse_file(struct oidset *set, const char *path); + struct oidset_iter { - kh_oid_t *set; + kh_oid_set_t *set; khiter_t iter; };