blame: rename origin structure to blame_origin

The origin structure is core to the blame interface. Since origin will become more exposed, rename it to blame_origin to clarify what it is a part of. Signed-off-by: Jeff Smith <whydoubt@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>

Jeff Smith committed May 24, 2017 at 00:15 UTC f84afb9c4ee09d640b2d6cbe38fe6f0d14ca70be
1 file changed +57 -57
builtin/blame.c
+57 -57
@@ -87,10 +87,10 @@ static unsigned blame_copy_score;
87 /*
88 * One blob in a commit that is being suspected
89 */
90 -struct origin {
90 +struct blame_origin {
91 int refcnt;
92 /* Record preceding blame record for this blob */
93 - struct origin *previous;
93 + struct blame_origin *previous;
94 /* origins are put in a list linked via `next' hanging off the
95 * corresponding commit's util field in order to make finding
96 * them fast. The presence in this chain does not count
@@ -108,7 +108,7 @@ struct origin {
108 * us get tripped up by this case, it certainly does not seem
109 * worth optimizing for.
110 */
111 - struct origin *next;
111 + struct blame_origin *next;
112 struct commit *commit;
113 /* `suspects' contains blame entries that may be attributed to
114 * this origin's commit or to parent commits. When a commit
@@ -151,7 +151,7 @@ static int diff_hunks(mmfile_t *file_a, mmfile_t *file_b,
151 * diff machinery
152 */
153 static void fill_origin_blob(struct diff_options *opt,
154 - struct origin *o, mmfile_t *file)
154 + struct blame_origin *o, mmfile_t *file)
155 {
156 if (!o->file.ptr) {
157 enum object_type type;
@@ -180,17 +180,17 @@ static void fill_origin_blob(struct diff_options *opt,
180 * Origin is refcounted and usually we keep the blob contents to be
181 * reused.
182 */
183 -static inline struct origin *origin_incref(struct origin *o)
183 +static inline struct blame_origin *origin_incref(struct blame_origin *o)
184 {
185 if (o)
186 o->refcnt++;
187 return o;
188 }
189
190 -static void origin_decref(struct origin *o)
190 +static void origin_decref(struct blame_origin *o)
191 {
192 if (o && --o->refcnt <= 0) {
193 - struct origin *p, *l = NULL;
193 + struct blame_origin *p, *l = NULL;
194 if (o->previous)
195 origin_decref(o->previous);
196 free(o->file.ptr);
@@ -209,7 +209,7 @@ static void origin_decref(struct origin *o)
209 }
210 }
211
212 -static void drop_origin_blob(struct origin *o)
212 +static void drop_origin_blob(struct blame_origin *o)
213 {
214 if (o->file.ptr) {
215 free(o->file.ptr);
@@ -238,7 +238,7 @@ struct blame_entry {
238 int num_lines;
239
240 /* the commit that introduced this group into the final image */
241 - struct origin *suspect;
241 + struct blame_origin *suspect;
242
243 /* the line number of the first line of this group in the
244 * suspect's file; internally all line numbers are 0 based.
@@ -410,13 +410,13 @@ static void coalesce(struct scoreboard *sb)
410 * the commit priority queue of the score board.
411 */
412
413 -static void queue_blames(struct scoreboard *sb, struct origin *porigin,
413 +static void queue_blames(struct scoreboard *sb, struct blame_origin *porigin,
414 struct blame_entry *sorted)
415 {
416 if (porigin->suspects)
417 porigin->suspects = blame_merge(porigin->suspects, sorted);
418 else {
419 - struct origin *o;
419 + struct blame_origin *o;
420 for (o = porigin->commit->util; o; o = o->next) {
421 if (o->suspects) {
422 porigin->suspects = sorted;
@@ -434,9 +434,9 @@ static void queue_blames(struct scoreboard *sb, struct origin *porigin,
434 * get_origin() to obtain shared, refcounted copy instead of calling
435 * this function directly.
436 */
437 -static struct origin *make_origin(struct commit *commit, const char *path)
437 +static struct blame_origin *make_origin(struct commit *commit, const char *path)
438 {
439 - struct origin *o;
439 + struct blame_origin *o;
440 FLEX_ALLOC_STR(o, path, path);
441 o->commit = commit;
442 o->refcnt = 1;
@@ -449,9 +449,9 @@ static struct origin *make_origin(struct commit *commit, const char *path)
449 * Locate an existing origin or create a new one.
450 * This moves the origin to front position in the commit util list.
451 */
452 -static struct origin *get_origin(struct commit *commit, const char *path)
452 +static struct blame_origin *get_origin(struct commit *commit, const char *path)
453 {
454 - struct origin *o, *l;
454 + struct blame_origin *o, *l;
455
456 for (o = commit->util, l = NULL; o; l = o, o = o->next) {
457 if (!strcmp(o->path, path)) {
@@ -476,7 +476,7 @@ static struct origin *get_origin(struct commit *commit, const char *path)
476 *
477 * This also fills origin->mode for corresponding tree path.
478 */
479 -static int fill_blob_sha1_and_mode(struct origin *origin)
479 +static int fill_blob_sha1_and_mode(struct blame_origin *origin)
480 {
481 if (!is_null_oid(&origin->blob_oid))
482 return 0;
@@ -497,10 +497,10 @@ static int fill_blob_sha1_and_mode(struct origin *origin)
497 * We have an origin -- check if the same path exists in the
498 * parent and return an origin structure to represent it.
499 */
500 -static struct origin *find_origin(struct commit *parent,
501 - struct origin *origin)
500 +static struct blame_origin *find_origin(struct commit *parent,
501 + struct blame_origin *origin)
502 {
503 - struct origin *porigin;
503 + struct blame_origin *porigin;
504 struct diff_options diff_opts;
505 const char *paths[2];
506
@@ -585,10 +585,10 @@ static struct origin *find_origin(struct commit *parent,
585 * We have an origin -- find the path that corresponds to it in its
586 * parent and return an origin structure to represent it.
587 */
588 -static struct origin *find_rename(struct commit *parent,
589 - struct origin *origin)
588 +static struct blame_origin *find_rename(struct commit *parent,
589 + struct blame_origin *origin)
590 {
591 - struct origin *porigin = NULL;
591 + struct blame_origin *porigin = NULL;
592 struct diff_options diff_opts;
593 int i;
594
@@ -680,7 +680,7 @@ static const char *nth_line_cb(void *data, long lno)
680 static void split_overlap(struct blame_entry *split,
681 struct blame_entry *e,
682 int tlno, int plno, int same,
683 - struct origin *parent)
683 + struct blame_origin *parent)
684 {
685 int chunk_end_lno;
686 memset(split, 0, sizeof(struct blame_entry [3]));
@@ -804,7 +804,7 @@ static struct blame_entry *reverse_blame(struct blame_entry *head,
804 */
805 static void blame_chunk(struct blame_entry ***dstq, struct blame_entry ***srcq,
806 int tlno, int offset, int same,
807 - struct origin *parent)
807 + struct blame_origin *parent)
808 {
809 struct blame_entry *e = **srcq;
810 struct blame_entry *samep = NULL, *diffp = NULL;
@@ -895,7 +895,7 @@ static void blame_chunk(struct blame_entry ***dstq, struct blame_entry ***srcq,
895 }
896
897 struct blame_chunk_cb_data {
898 - struct origin *parent;
898 + struct blame_origin *parent;
899 long offset;
900 struct blame_entry **dstq;
901 struct blame_entry **srcq;
@@ -920,8 +920,8 @@ static int blame_chunk_cb(long start_a, long count_a,
920 * which lines came from parent and pass blame for them.
921 */
922 static void pass_blame_to_parent(struct scoreboard *sb,
923 - struct origin *target,
924 - struct origin *parent)
923 + struct blame_origin *target,
924 + struct blame_origin *parent)
925 {
926 mmfile_t file_p, file_o;
927 struct blame_chunk_cb_data d;
@@ -1023,7 +1023,7 @@ static void copy_split_if_better(struct scoreboard *sb,
1023 static void handle_split(struct scoreboard *sb,
1024 struct blame_entry *ent,
1025 int tlno, int plno, int same,
1026 - struct origin *parent,
1026 + struct blame_origin *parent,
1027 struct blame_entry *split)
1028 {
1029 if (ent->num_lines <= tlno)
@@ -1041,7 +1041,7 @@ static void handle_split(struct scoreboard *sb,
1041 struct handle_split_cb_data {
1042 struct scoreboard *sb;
1043 struct blame_entry *ent;
1044 - struct origin *parent;
1044 + struct blame_origin *parent;
1045 struct blame_entry *split;
1046 long plno;
1047 long tlno;
@@ -1065,7 +1065,7 @@ static int handle_split_cb(long start_a, long count_a,
1065 */
1066 static void find_copy_in_blob(struct scoreboard *sb,
1067 struct blame_entry *ent,
1068 - struct origin *parent,
1068 + struct blame_origin *parent,
1069 struct blame_entry *split,
1070 mmfile_t *file_p)
1071 {
@@ -1129,8 +1129,8 @@ static struct blame_entry **filter_small(struct scoreboard *sb,
1129 static void find_move_in_parent(struct scoreboard *sb,
1130 struct blame_entry ***blamed,
1131 struct blame_entry **toosmall,
1132 - struct origin *target,
1133 - struct origin *parent)
1132 + struct blame_origin *target,
1133 + struct blame_origin *parent)
1134 {
1135 struct blame_entry *e, split[3];
1136 struct blame_entry *unblamed = target->suspects;
@@ -1205,9 +1205,9 @@ static struct blame_list *setup_blame_list(struct blame_entry *unblamed,
1205 static void find_copy_in_parent(struct scoreboard *sb,
1206 struct blame_entry ***blamed,
1207 struct blame_entry **toosmall,
1208 - struct origin *target,
1208 + struct blame_origin *target,
1209 struct commit *parent,
1210 - struct origin *porigin,
1210 + struct blame_origin *porigin,
1211 int opt)
1212 {
1213 struct diff_options diff_opts;
@@ -1254,7 +1254,7 @@ static void find_copy_in_parent(struct scoreboard *sb,
1254
1255 for (i = 0; i < diff_queued_diff.nr; i++) {
1256 struct diff_filepair *p = diff_queued_diff.queue[i];
1257 - struct origin *norigin;
1257 + struct blame_origin *norigin;
1258 mmfile_t file_p;
1259 struct blame_entry this[3];
1260
@@ -1309,7 +1309,7 @@ static void find_copy_in_parent(struct scoreboard *sb,
1309 * origin is suspected for can be blamed on the parent.
1310 */
1311 static void pass_whole_blame(struct scoreboard *sb,
1312 - struct origin *origin, struct origin *porigin)
1312 + struct blame_origin *origin, struct blame_origin *porigin)
1313 {
1314 struct blame_entry *e, *suspects;
1315
@@ -1361,7 +1361,7 @@ static void distribute_blame(struct scoreboard *sb, struct blame_entry *blamed)
1361 blamed = blame_sort(blamed, compare_blame_suspect);
1362 while (blamed)
1363 {
1364 - struct origin *porigin = blamed->suspect;
1364 + struct blame_origin *porigin = blamed->suspect;
1365 struct blame_entry *suspects = NULL;
1366 do {
1367 struct blame_entry *next = blamed->next;
@@ -1376,14 +1376,14 @@ static void distribute_blame(struct scoreboard *sb, struct blame_entry *blamed)
1376
1377 #define MAXSG 16
1378
1379 -static void pass_blame(struct scoreboard *sb, struct origin *origin, int opt)
1379 +static void pass_blame(struct scoreboard *sb, struct blame_origin *origin, int opt)
1380 {
1381 struct rev_info *revs = sb->revs;
1382 int i, pass, num_sg;
1383 struct commit *commit = origin->commit;
1384 struct commit_list *sg;
1385 - struct origin *sg_buf[MAXSG];
1386 - struct origin *porigin, **sg_origin = sg_buf;
1385 + struct blame_origin *sg_buf[MAXSG];
1386 + struct blame_origin *porigin, **sg_origin = sg_buf;
1387 struct blame_entry *toosmall = NULL;
1388 struct blame_entry *blames, **blametail = &blames;
1389
@@ -1400,7 +1400,7 @@ static void pass_blame(struct scoreboard *sb, struct origin *origin, int opt)
1400 * common cases, then we look for renames in the second pass.
1401 */
1402 for (pass = 0; pass < 2 - no_whole_file_rename; pass++) {
1403 - struct origin *(*find)(struct commit *, struct origin *);
1403 + struct blame_origin *(*find)(struct commit *, struct blame_origin *);
1404 find = pass ? find_rename : find_origin;
1405
1406 for (i = 0, sg = first_scapegoat(revs, commit);
@@ -1438,7 +1438,7 @@ static void pass_blame(struct scoreboard *sb, struct origin *origin, int opt)
1438 for (i = 0, sg = first_scapegoat(revs, commit);
1439 i < num_sg && sg;
1440 sg = sg->next, i++) {
1441 - struct origin *porigin = sg_origin[i];
1441 + struct blame_origin *porigin = sg_origin[i];
1442 if (!porigin)
1443 continue;
1444 if (!origin->previous) {
@@ -1459,7 +1459,7 @@ static void pass_blame(struct scoreboard *sb, struct origin *origin, int opt)
1459 for (i = 0, sg = first_scapegoat(revs, commit);
1460 i < num_sg && sg;
1461 sg = sg->next, i++) {
1462 - struct origin *porigin = sg_origin[i];
1462 + struct blame_origin *porigin = sg_origin[i];
1463 if (!porigin)
1464 continue;
1465 find_move_in_parent(sb, &blametail, &toosmall, origin, porigin);
@@ -1486,7 +1486,7 @@ static void pass_blame(struct scoreboard *sb, struct origin *origin, int opt)
1486 for (i = 0, sg = first_scapegoat(revs, commit);
1487 i < num_sg && sg;
1488 sg = sg->next, i++) {
1489 - struct origin *porigin = sg_origin[i];
1489 + struct blame_origin *porigin = sg_origin[i];
1490 find_copy_in_parent(sb, &blametail, &toosmall,
1491 origin, sg->item, porigin, opt);
1492 if (!origin->suspects)
@@ -1665,10 +1665,10 @@ static void get_commit_info(struct commit *commit,
1665 * To allow LF and other nonportable characters in pathnames,
1666 * they are c-style quoted as needed.
1667 */
1668 -static void write_filename_info(struct origin *suspect)
1668 +static void write_filename_info(struct blame_origin *suspect)
1669 {
1670 if (suspect->previous) {
1671 - struct origin *prev = suspect->previous;
1671 + struct blame_origin *prev = suspect->previous;
1672 printf("previous %s ", oid_to_hex(&prev->commit->object.oid));
1673 write_name_quoted(prev->path, stdout, '\n');
1674 }
@@ -1682,7 +1682,7 @@ static void write_filename_info(struct origin *suspect)
1682 * the first time each commit appears in the output (unless the
1683 * user has specifically asked for us to repeat).
1684 */
1685 -static int emit_one_suspect_detail(struct origin *suspect, int repeat)
1685 +static int emit_one_suspect_detail(struct blame_origin *suspect, int repeat)
1686 {
1687 struct commit_info ci;
1688
@@ -1716,7 +1716,7 @@ static void found_guilty_entry(struct blame_entry *ent,
1716 struct progress_info *pi)
1717 {
1718 if (incremental) {
1719 - struct origin *suspect = ent->suspect;
1719 + struct blame_origin *suspect = ent->suspect;
1720
1721 printf("%s %d %d %d\n",
1722 oid_to_hex(&suspect->commit->object.oid),
@@ -1745,7 +1745,7 @@ static void assign_blame(struct scoreboard *sb, int opt)
1745
1746 while (commit) {
1747 struct blame_entry *ent;
1748 - struct origin *suspect = commit->util;
1748 + struct blame_origin *suspect = commit->util;
1749
1750 /* find one suspect to break down */
1751 while (suspect && !suspect->suspects)
@@ -1842,7 +1842,7 @@ static const char *format_time(timestamp_t time, const char *tz_str,
1842 #define OUTPUT_SHOW_EMAIL 0400
1843 #define OUTPUT_LINE_PORCELAIN 01000
1844
1845 -static void emit_porcelain_details(struct origin *suspect, int repeat)
1845 +static void emit_porcelain_details(struct blame_origin *suspect, int repeat)
1846 {
1847 if (emit_one_suspect_detail(suspect, repeat) ||
1848 (suspect->commit->object.flags & MORE_THAN_ONE_PATH))
@@ -1855,7 +1855,7 @@ static void emit_porcelain(struct scoreboard *sb, struct blame_entry *ent,
1855 int repeat = opt & OUTPUT_LINE_PORCELAIN;
1856 int cnt;
1857 const char *cp;
1858 - struct origin *suspect = ent->suspect;
1858 + struct blame_origin *suspect = ent->suspect;
1859 char hex[GIT_MAX_HEXSZ + 1];
1860
1861 oid_to_hex_r(hex, &suspect->commit->object.oid);
@@ -1892,7 +1892,7 @@ static void emit_other(struct scoreboard *sb, struct blame_entry *ent, int opt)
1892 {
1893 int cnt;
1894 const char *cp;
1895 - struct origin *suspect = ent->suspect;
1895 + struct blame_origin *suspect = ent->suspect;
1896 struct commit_info ci;
1897 char hex[GIT_MAX_HEXSZ + 1];
1898 int show_raw_time = !!(opt & OUTPUT_RAW_TIMESTAMP);
@@ -1974,7 +1974,7 @@ static void output(struct scoreboard *sb, int option)
1974 if (option & OUTPUT_PORCELAIN) {
1975 for (ent = sb->ent; ent; ent = ent->next) {
1976 int count = 0;
1977 - struct origin *suspect;
1977 + struct blame_origin *suspect;
1978 struct commit *commit = ent->suspect->commit;
1979 if (commit->object.flags & MORE_THAN_ONE_PATH)
1980 continue;
@@ -2052,7 +2052,7 @@ static int read_ancestry(const char *graft_file)
2052 return 0;
2053 }
2054
2055 -static int update_auto_abbrev(int auto_abbrev, struct origin *suspect)
2055 +static int update_auto_abbrev(int auto_abbrev, struct blame_origin *suspect)
2056 {
2057 const char *uniq = find_unique_abbrev(suspect->commit->object.oid.hash,
2058 auto_abbrev);
@@ -2076,7 +2076,7 @@ static void find_alignment(struct scoreboard *sb, int *option)
2076 int auto_abbrev = DEFAULT_ABBREV;
2077
2078 for (e = sb->ent; e; e = e->next) {
2079 - struct origin *suspect = e->suspect;
2079 + struct blame_origin *suspect = e->suspect;
2080 int num;
2081
2082 if (compute_auto_abbrev)
@@ -2268,7 +2268,7 @@ static struct commit *fake_working_tree_commit(struct diff_options *opt,
2268 const char *contents_from)
2269 {
2270 struct commit *commit;
2271 - struct origin *origin;
2271 + struct blame_origin *origin;
2272 struct commit_list **parent_tail, *parent;
2273 struct object_id head_oid;
2274 struct strbuf buf = STRBUF_INIT;
@@ -2523,7 +2523,7 @@ int cmd_blame(int argc, const char **argv, const char *prefix)
2523 struct rev_info revs;
2524 const char *path;
2525 struct scoreboard sb;
2526 - struct origin *o;
2526 + struct blame_origin *o;
2527 struct blame_entry *ent = NULL;
2528 long dashdash_pos, lno;
2529 char *final_commit_name = NULL;