@matheusbsbs / matheus-bagliano / commits / 1732a1fd94
Fork 0

git-blame: somewhat better commenting.

Signed-off-by: Junio C Hamano <junkio@cox.net>

Junio C Hamano committed Jan 29, 2007 at 17:36 UTC 1732a1fd942f00b9a77a47acc09df0cd62c770bd
1 file changed +255 -38
builtin-blame.c
+255 -38
@@ -77,6 +77,10 @@ struct origin {
77 char path[FLEX_ARRAY];
78 };
79
80 +/*
81 + * Given an origin, prepare mmfile_t structure to be used by the
82 + * diff machinery
83 + */
84 static char *fill_origin_blob(struct origin *o, mmfile_t *file)
85 {
86 if (!o->file.ptr) {
@@ -91,6 +95,10 @@ static char *fill_origin_blob(struct origin *o, mmfile_t *file)
95 return file->ptr;
96 }
97
98 +/*
99 + * Origin is refcounted and usually we keep the blob contents to be
100 + * reused.
101 + */
102 static inline struct origin *origin_incref(struct origin *o)
103 {
104 if (o)
@@ -108,6 +116,11 @@ static void origin_decref(struct origin *o)
116 }
117 }
118
119 +/*
120 + * Each group of lines is described by a blame_entry; it can be split
121 + * as we pass blame to the parents. They form a linked list in the
122 + * scoreboard structure, sorted by the target line number.
123 + */
124 struct blame_entry {
125 struct blame_entry *prev;
126 struct blame_entry *next;
@@ -134,19 +147,24 @@ struct blame_entry {
147 int s_lno;
148
149 /* how significant this entry is -- cached to avoid
137 - * scanning the lines over and over
150 + * scanning the lines over and over.
151 */
152 unsigned score;
153 };
154
155 +/*
156 + * The current state of the blame assignment.
157 + */
158 struct scoreboard {
159 /* the final commit (i.e. where we started digging from) */
160 struct commit *final;
161
162 const char *path;
163
148 - /* the contents in the final; pointed into by buf pointers of
149 - * blame_entries
164 + /*
165 + * The contents in the final image.
166 + * Used by many functions to obtain contents of the nth line,
167 + * indexed with scoreboard.lineno[blame_entry.lno].
168 */
169 const char *final_buf;
170 unsigned long final_buf_size;
@@ -171,6 +189,11 @@ static int cmp_suspect(struct origin *a, struct origin *b)
189
190 static void sanity_check_refcnt(struct scoreboard *);
191
192 +/*
193 + * If two blame entries that are next to each other came from
194 + * contiguous lines in the same origin (i.e. <commit, path> pair),
195 + * merge them together.
196 + */
197 static void coalesce(struct scoreboard *sb)
198 {
199 struct blame_entry *ent, *next;
@@ -194,6 +217,12 @@ static void coalesce(struct scoreboard *sb)
217 sanity_check_refcnt(sb);
218 }
219
220 +/*
221 + * Given a commit and a path in it, create a new origin structure.
222 + * The callers that add blame to the scoreboard should use
223 + * get_origin() to obtain shared, refcounted copy instead of calling
224 + * this function directly.
225 + */
226 static struct origin *make_origin(struct commit *commit, const char *path)
227 {
228 struct origin *o;
@@ -204,6 +233,9 @@ static struct origin *make_origin(struct commit *commit, const char *path)
233 return o;
234 }
235
236 +/*
237 + * Locate an existing origin or create a new one.
238 + */
239 static struct origin *get_origin(struct scoreboard *sb,
240 struct commit *commit,
241 const char *path)
@@ -218,6 +250,13 @@ static struct origin *get_origin(struct scoreboard *sb,
250 return make_origin(commit, path);
251 }
252
253 +/*
254 + * Fill the blob_sha1 field of an origin if it hasn't, so that later
255 + * call to fill_origin_blob() can use it to locate the data. blob_sha1
256 + * for an origin is also used to pass the blame for the entire file to
257 + * the parent to detect the case where a child's blob is identical to
258 + * that of its parent's.
259 + */
260 static int fill_blob_sha1(struct origin *origin)
261 {
262 unsigned mode;
@@ -238,6 +277,10 @@ static int fill_blob_sha1(struct origin *origin)
277 return -1;
278 }
279
280 +/*
281 + * We have an origin -- check if the same path exists in the
282 + * parent and return an origin structure to represent it.
283 + */
284 static struct origin *find_origin(struct scoreboard *sb,
285 struct commit *parent,
286 struct origin *origin)
@@ -247,12 +290,26 @@ static struct origin *find_origin(struct scoreboard *sb,
290 const char *paths[2];
291
292 if (parent->util) {
250 - /* This is a freestanding copy of origin and not
251 - * refcounted.
293 + /*
294 + * Each commit object can cache one origin in that
295 + * commit. This is a freestanding copy of origin and
296 + * not refcounted.
297 */
298 struct origin *cached = parent->util;
299 if (!strcmp(cached->path, origin->path)) {
300 + /*
301 + * The same path between origin and its parent
302 + * without renaming -- the most common case.
303 + */
304 porigin = get_origin(sb, parent, cached->path);
305 +
306 + /*
307 + * If the origin was newly created (i.e. get_origin
308 + * would call make_origin if none is found in the
309 + * scoreboard), it does not know the blob_sha1,
310 + * so copy it. Otherwise porigin was in the
311 + * scoreboard and already knows blob_sha1.
312 + */
313 if (porigin->refcnt == 1)
314 hashcpy(porigin->blob_sha1, cached->blob_sha1);
315 return porigin;
@@ -309,7 +366,13 @@ static struct origin *find_origin(struct scoreboard *sb,
366 }
367 diff_flush(&diff_opts);
368 if (porigin) {
369 + /*
370 + * Create a freestanding copy that is not part of
371 + * the refcounted origin found in the scoreboard, and
372 + * cache it in the commit.
373 + */
374 struct origin *cached;
375 +
376 cached = make_origin(porigin->commit, porigin->path);
377 hashcpy(cached->blob_sha1, porigin->blob_sha1);
378 parent->util = cached;
@@ -317,6 +380,10 @@ static struct origin *find_origin(struct scoreboard *sb,
380 return porigin;
381 }
382
383 +/*
384 + * We have an origin -- find the path that corresponds to it in its
385 + * parent and return an origin structure to represent it.
386 + */
387 static struct origin *find_rename(struct scoreboard *sb,
388 struct commit *parent,
389 struct origin *origin)
@@ -353,6 +420,9 @@ static struct origin *find_rename(struct scoreboard *sb,
420 return porigin;
421 }
422
423 +/*
424 + * Parsing of patch chunks...
425 + */
426 struct chunk {
427 /* line number in postimage; up to but not including this
428 * line is the same as preimage
@@ -454,6 +524,11 @@ static struct patch *compare_buffer(mmfile_t *file_p, mmfile_t *file_o,
524 return state.ret;
525 }
526
527 +/*
528 + * Run diff between two origins and grab the patch output, so that
529 + * we can pass blame for lines origin is currently suspected for
530 + * to its parent.
531 + */
532 static struct patch *get_patch(struct origin *parent, struct origin *origin)
533 {
534 mmfile_t file_p, file_o;
@@ -474,6 +549,10 @@ static void free_patch(struct patch *p)
549 free(p);
550 }
551
552 +/*
553 + * Link in a new blame entry to the scorebord. Entries that cover the
554 + * same line range have been removed from the scoreboard previously.
555 + */
556 static void add_blame_entry(struct scoreboard *sb, struct blame_entry *e)
557 {
558 struct blame_entry *ent, *prev = NULL;
@@ -497,6 +576,12 @@ static void add_blame_entry(struct scoreboard *sb, struct blame_entry *e)
576 e->next->prev = e;
577 }
578
579 +/*
580 + * src typically is on-stack; we want to copy the information in it to
581 + * an malloced blame_entry that is already on the linked list of the
582 + * scoreboard. The origin of dst loses a refcnt while the origin of src
583 + * gains one.
584 + */
585 static void dup_entry(struct blame_entry *dst, struct blame_entry *src)
586 {
587 struct blame_entry *p, *n;
@@ -516,25 +601,25 @@ static const char *nth_line(struct scoreboard *sb, int lno)
601 return sb->final_buf + sb->lineno[lno];
602 }
603
604 +/*
605 + * It is known that lines between tlno to same came from parent, and e
606 + * has an overlap with that range. it also is known that parent's
607 + * line plno corresponds to e's line tlno.
608 + *
609 + * <---- e ----->
610 + * <------>
611 + * <------------>
612 + * <------------>
613 + * <------------------>
614 + *
615 + * Split e into potentially three parts; before this chunk, the chunk
616 + * to be blamed for the parent, and after that portion.
617 + */
618 static void split_overlap(struct blame_entry *split,
619 struct blame_entry *e,
620 int tlno, int plno, int same,
621 struct origin *parent)
622 {
524 - /* it is known that lines between tlno to same came from
525 - * parent, and e has an overlap with that range. it also is
526 - * known that parent's line plno corresponds to e's line tlno.
527 - *
528 - * <---- e ----->
529 - * <------>
530 - * <------------>
531 - * <------------>
532 - * <------------------>
533 - *
534 - * Potentially we need to split e into three parts; before
535 - * this chunk, the chunk to be blamed for parent, and after
536 - * that portion.
537 - */
623 int chunk_end_lno;
624 memset(split, 0, sizeof(struct blame_entry [3]));
625
@@ -564,11 +649,20 @@ static void split_overlap(struct blame_entry *split,
649 chunk_end_lno = e->lno + e->num_lines;
650 split[1].num_lines = chunk_end_lno - split[1].lno;
651
652 + /*
653 + * if it turns out there is nothing to blame the parent for,
654 + * forget about the splitting. !split[1].suspect signals this.
655 + */
656 if (split[1].num_lines < 1)
657 return;
658 split[1].suspect = origin_incref(parent);
659 }
660
661 +/*
662 + * split_overlap() divided an existing blame e into up to three parts
663 + * in split. Adjust the linked list of blames in the scoreboard to
664 + * reflect the split.
665 + */
666 static void split_blame(struct scoreboard *sb,
667 struct blame_entry *split,
668 struct blame_entry *e)
@@ -576,21 +670,27 @@ static void split_blame(struct scoreboard *sb,
670 struct blame_entry *new_entry;
671
672 if (split[0].suspect && split[2].suspect) {
579 - /* we need to split e into two and add another for parent */
673 + /* The first part (reuse storage for the existing entry e) */
674 dup_entry(e, &split[0]);
675
676 + /* The last part -- me */
677 new_entry = xmalloc(sizeof(*new_entry));
678 memcpy(new_entry, &(split[2]), sizeof(struct blame_entry));
679 add_blame_entry(sb, new_entry);
680
681 + /* ... and the middle part -- parent */
682 new_entry = xmalloc(sizeof(*new_entry));
683 memcpy(new_entry, &(split[1]), sizeof(struct blame_entry));
684 add_blame_entry(sb, new_entry);
685 }
686 else if (!split[0].suspect && !split[2].suspect)
591 - /* parent covers the entire area */
687 + /*
688 + * The parent covers the entire area; reuse storage for
689 + * e and replace it with the parent.
690 + */
691 dup_entry(e, &split[1]);
692 else if (split[0].suspect) {
693 + /* me and then parent */
694 dup_entry(e, &split[0]);
695
696 new_entry = xmalloc(sizeof(*new_entry));
@@ -598,6 +698,7 @@ static void split_blame(struct scoreboard *sb,
698 add_blame_entry(sb, new_entry);
699 }
700 else {
701 + /* parent and then me */
702 dup_entry(e, &split[1]);
703
704 new_entry = xmalloc(sizeof(*new_entry));
@@ -628,6 +729,10 @@ static void split_blame(struct scoreboard *sb,
729 }
730 }
731
732 +/*
733 + * After splitting the blame, the origins used by the
734 + * on-stack blame_entry should lose one refcnt each.
735 + */
736 static void decref_split(struct blame_entry *split)
737 {
738 int i;
@@ -636,6 +741,10 @@ static void decref_split(struct blame_entry *split)
741 origin_decref(split[i].suspect);
742 }
743
744 +/*
745 + * Helper for blame_chunk(). blame_entry e is known to overlap with
746 + * the patch hunk; split it and pass blame to the parent.
747 + */
748 static void blame_overlap(struct scoreboard *sb, struct blame_entry *e,
749 int tlno, int plno, int same,
750 struct origin *parent)
@@ -648,6 +757,9 @@ static void blame_overlap(struct scoreboard *sb, struct blame_entry *e,
757 decref_split(split);
758 }
759
760 +/*
761 + * Find the line number of the last line the target is suspected for.
762 + */
763 static int find_last_in_target(struct scoreboard *sb, struct origin *target)
764 {
765 struct blame_entry *e;
@@ -662,6 +774,11 @@ static int find_last_in_target(struct scoreboard *sb, struct origin *target)
774 return last_in_target;
775 }
776
777 +/*
778 + * Process one hunk from the patch between the current suspect for
779 + * blame_entry e and its parent. Find and split the overlap, and
780 + * pass blame to the overlapping part to the parent.
781 + */
782 static void blame_chunk(struct scoreboard *sb,
783 int tlno, int plno, int same,
784 struct origin *target, struct origin *parent)
@@ -678,6 +795,11 @@ static void blame_chunk(struct scoreboard *sb,
795 }
796 }
797
798 +/*
799 + * We are looking at the origin 'target' and aiming to pass blame
800 + * for the lines it is suspected to its parent. Run diff to find
801 + * which lines came from parent and pass blame for them.
802 + */
803 static int pass_blame_to_parent(struct scoreboard *sb,
804 struct origin *target,
805 struct origin *parent)
@@ -698,13 +820,22 @@ static int pass_blame_to_parent(struct scoreboard *sb,
820 plno = chunk->p_next;
821 tlno = chunk->t_next;
822 }
701 - /* rest (i.e. anything above tlno) are the same as parent */
823 + /* The rest (i.e. anything after tlno) are the same as the parent */
824 blame_chunk(sb, tlno, plno, last_in_target, target, parent);
825
826 free_patch(patch);
827 return 0;
828 }
829
830 +/*
831 + * The lines in blame_entry after splitting blames many times can become
832 + * very small and trivial, and at some point it becomes pointless to
833 + * blame the parents. E.g. "\t\t}\n\t}\n\n" appears everywhere in any
834 + * ordinary C program, and it is not worth to say it was copied from
835 + * totally unrelated file in the parent.
836 + *
837 + * Compute how trivial the lines in the blame_entry are.
838 + */
839 static unsigned ent_score(struct scoreboard *sb, struct blame_entry *e)
840 {
841 unsigned score;
@@ -726,6 +857,12 @@ static unsigned ent_score(struct scoreboard *sb, struct blame_entry *e)
857 return score;
858 }
859
860 +/*
861 + * best_so_far[] and this[] are both a split of an existing blame_entry
862 + * that passes blame to the parent. Maintain best_so_far the best split
863 + * so far, by comparing this and best_so_far and copying this into
864 + * bst_so_far as needed.
865 + */
866 static void copy_split_if_better(struct scoreboard *sb,
867 struct blame_entry *best_so_far,
868 struct blame_entry *this)
@@ -745,6 +882,11 @@ static void copy_split_if_better(struct scoreboard *sb,
882 memcpy(best_so_far, this, sizeof(struct blame_entry [3]));
883 }
884
885 +/*
886 + * Find the lines from parent that are the same as ent so that
887 + * we can pass blames to it. file_p has the blob contents for
888 + * the parent.
889 + */
890 static void find_copy_in_blob(struct scoreboard *sb,
891 struct blame_entry *ent,
892 struct origin *parent,
@@ -757,6 +899,9 @@ static void find_copy_in_blob(struct scoreboard *sb,
899 struct patch *patch;
900 int i, plno, tlno;
901
902 + /*
903 + * Prepare mmfile that contains only the lines in ent.
904 + */
905 cp = nth_line(sb, ent->lno);
906 file_o.ptr = (char*) cp;
907 cnt = ent->num_lines;
@@ -792,6 +937,10 @@ static void find_copy_in_blob(struct scoreboard *sb,
937 free_patch(patch);
938 }
939
940 +/*
941 + * See if lines currently target is suspected for can be attributed to
942 + * parent.
943 + */
944 static int find_move_in_parent(struct scoreboard *sb,
945 struct origin *target,
946 struct origin *parent)
@@ -826,12 +975,15 @@ static int find_move_in_parent(struct scoreboard *sb,
975 return 0;
976 }
977
829 -
978 struct blame_list {
979 struct blame_entry *ent;
980 struct blame_entry split[3];
981 };
982
983 +/*
984 + * Count the number of entries the target is suspected for,
985 + * and prepare a list of entry and the best split.
986 + */
987 static struct blame_list *setup_blame_list(struct scoreboard *sb,
988 struct origin *target,
989 int *num_ents_p)
@@ -840,9 +992,6 @@ static struct blame_list *setup_blame_list(struct scoreboard *sb,
992 int num_ents, i;
993 struct blame_list *blame_list = NULL;
994
843 - /* Count the number of entries the target is suspected for,
844 - * and prepare a list of entry and the best split.
845 - */
995 for (e = sb->ent, num_ents = 0; e; e = e->next)
996 if (!e->guilty && !cmp_suspect(e->suspect, target))
997 num_ents++;
@@ -856,6 +1005,11 @@ static struct blame_list *setup_blame_list(struct scoreboard *sb,
1005 return blame_list;
1006 }
1007
1008 +/*
1009 + * For lines target is suspected for, see if we can find code movement
1010 + * across file boundary from the parent commit. porigin is the path
1011 + * in the parent we already tried.
1012 + */
1013 static int find_copy_in_parent(struct scoreboard *sb,
1014 struct origin *target,
1015 struct commit *parent,
@@ -956,7 +1110,8 @@ static int find_copy_in_parent(struct scoreboard *sb,
1110 return retval;
1111 }
1112
959 -/* The blobs of origin and porigin exactly match, so everything
1113 +/*
1114 + * The blobs of origin and porigin exactly match, so everything
1115 * origin is suspected for can be blamed on the parent.
1116 */
1117 static void pass_whole_blame(struct scoreboard *sb,
@@ -1041,7 +1196,7 @@ static void pass_blame(struct scoreboard *sb, struct origin *origin, int opt)
1196 }
1197
1198 /*
1044 - * Optionally run "miff" to find moves in parents' files here.
1199 + * Optionally find moves in parents' files.
1200 */
1201 if (opt & PICKAXE_BLAME_MOVE)
1202 for (i = 0, parent = commit->parents;
@@ -1055,7 +1210,7 @@ static void pass_blame(struct scoreboard *sb, struct origin *origin, int opt)
1210 }
1211
1212 /*
1058 - * Optionally run "ciff" to find copies from parents' files here.
1213 + * Optionally find copies from parents' files.
1214 */
1215 if (opt & PICKAXE_BLAME_COPY)
1216 for (i = 0, parent = commit->parents;
@@ -1072,6 +1227,9 @@ static void pass_blame(struct scoreboard *sb, struct origin *origin, int opt)
1227 origin_decref(parent_origin[i]);
1228 }
1229
1230 +/*
1231 + * Information on commits, used for output.
1232 + */
1233 struct commit_info
1234 {
1235 char *author;
@@ -1088,6 +1246,9 @@ struct commit_info
1246 char *summary;
1247 };
1248
1249 +/*
1250 + * Parse author/committer line in the commit object buffer
1251 + */
1252 static void get_ac_line(const char *inbuf, const char *what,
1253 int bufsz, char *person, char **mail,
1254 unsigned long *time, char **tz)
@@ -1142,7 +1303,8 @@ static void get_commit_info(struct commit *commit,
1303 static char committer_buf[1024];
1304 static char summary_buf[1024];
1305
1145 - /* We've operated without save_commit_buffer, so
1306 + /*
1307 + * We've operated without save_commit_buffer, so
1308 * we now need to populate them for output.
1309 */
1310 if (!commit->buffer) {
@@ -1182,6 +1344,10 @@ static void get_commit_info(struct commit *commit,
1344 summary_buf[len] = 0;
1345 }
1346
1347 +/*
1348 + * To allow LF and other nonportable characters in pathnames,
1349 + * they are c-style quoted as needed.
1350 + */
1351 static void write_filename_info(const char *path)
1352 {
1353 printf("filename ");
@@ -1189,6 +1355,10 @@ static void write_filename_info(const char *path)
1355 putchar('\n');
1356 }
1357
1358 +/*
1359 + * The blame_entry is found to be guilty for the range. Mark it
1360 + * as such, and show it in incremental output.
1361 + */
1362 static void found_guilty_entry(struct blame_entry *ent)
1363 {
1364 if (ent->guilty)
@@ -1220,6 +1390,11 @@ static void found_guilty_entry(struct blame_entry *ent)
1390 }
1391 }
1392
1393 +/*
1394 + * The main loop -- while the scoreboard has lines whose true origin
1395 + * is still unknown, pick one brame_entry, and allow its current
1396 + * suspect to pass blames to its parents.
1397 + */
1398 static void assign_blame(struct scoreboard *sb, struct rev_info *revs, int opt)
1399 {
1400 while (1) {
@@ -1234,12 +1409,16 @@ static void assign_blame(struct scoreboard *sb, struct rev_info *revs, int opt)
1409 if (!suspect)
1410 return; /* all done */
1411
1412 + /*
1413 + * We will use this suspect later in the loop,
1414 + * so hold onto it in the meantime.
1415 + */
1416 origin_incref(suspect);
1417 commit = suspect->commit;
1418 if (!commit->object.parsed)
1419 parse_commit(commit);
1420 if (!(commit->object.flags & UNINTERESTING) &&
1242 - !(revs->max_age != -1 && commit->date < revs->max_age))
1421 + !(revs->max_age != -1 && commit->date < revs->max_age))
1422 pass_blame(sb, suspect, opt);
1423 else {
1424 commit->object.flags |= UNINTERESTING;
@@ -1431,6 +1610,10 @@ static void output(struct scoreboard *sb, int option)
1610 }
1611 }
1612
1613 +/*
1614 + * To allow quick access to the contents of nth line in the
1615 + * final image, prepare an index in the scoreboard.
1616 + */
1617 static int prepare_lines(struct scoreboard *sb)
1618 {
1619 const char *buf = sb->final_buf;
@@ -1458,6 +1641,11 @@ static int prepare_lines(struct scoreboard *sb)
1641 return sb->num_lines;
1642 }
1643
1644 +/*
1645 + * Add phony grafts for use with -S; this is primarily to
1646 + * support git-cvsserver that wants to give a linear history
1647 + * to its clients.
1648 + */
1649 static int read_ancestry(const char *graft_file)
1650 {
1651 FILE *fp = fopen(graft_file, "r");
@@ -1475,6 +1663,9 @@ static int read_ancestry(const char *graft_file)
1663 return 0;
1664 }
1665
1666 +/*
1667 + * How many columns do we need to show line numbers in decimal?
1668 + */
1669 static int lineno_width(int lines)
1670 {
1671 int i, width;
@@ -1484,6 +1675,10 @@ static int lineno_width(int lines)
1675 return width;
1676 }
1677
1678 +/*
1679 + * How many columns do we need to show line numbers, authors,
1680 + * and filenames?
1681 + */
1682 static void find_alignment(struct scoreboard *sb, int *option)
1683 {
1684 int longest_src_lines = 0;
@@ -1522,6 +1717,10 @@ static void find_alignment(struct scoreboard *sb, int *option)
1717 max_score_digits = lineno_width(largest_score);
1718 }
1719
1720 +/*
1721 + * For debugging -- origin is refcounted, and this asserts that
1722 + * we do not underflow.
1723 + */
1724 static void sanity_check_refcnt(struct scoreboard *sb)
1725 {
1726 int baa = 0;
@@ -1543,8 +1742,9 @@ static void sanity_check_refcnt(struct scoreboard *sb)
1742 ent->suspect->refcnt = -ent->suspect->refcnt;
1743 }
1744 for (ent = sb->ent; ent; ent = ent->next) {
1546 - /* then pick each and see if they have the the correct
1547 - * refcnt.
1745 + /*
1746 + * ... then pick each and see if they have the the
1747 + * correct refcnt.
1748 */
1749 int found;
1750 struct blame_entry *e;
@@ -1574,6 +1774,10 @@ static void sanity_check_refcnt(struct scoreboard *sb)
1774 }
1775 }
1776
1777 +/*
1778 + * Used for the command line parsing; check if the path exists
1779 + * in the working tree.
1780 + */
1781 static int has_path_in_work_tree(const char *path)
1782 {
1783 struct stat st;
@@ -1596,6 +1800,9 @@ static const char *add_prefix(const char *prefix, const char *path)
1800 return prefix_path(prefix, strlen(prefix), path);
1801 }
1802
1803 +/*
1804 + * Parsing of (comma separated) one item in the -L option
1805 + */
1806 static const char *parse_loc(const char *spec,
1807 struct scoreboard *sb, long lno,
1808 long begin, long *ret)
@@ -1670,6 +1877,9 @@ static const char *parse_loc(const char *spec,
1877 }
1878 }
1879
1880 +/*
1881 + * Parsing of -L option
1882 + */
1883 static void prepare_blame_range(struct scoreboard *sb,
1884 const char *bottomtop,
1885 long lno,
@@ -1788,7 +1998,8 @@ int cmd_blame(int argc, const char **argv, const char *prefix)
1998 if (!blame_copy_score)
1999 blame_copy_score = BLAME_DEFAULT_COPY_SCORE;
2000
1791 - /* We have collected options unknown to us in argv[1..unk]
2001 + /*
2002 + * We have collected options unknown to us in argv[1..unk]
2003 * which are to be passed to revision machinery if we are
2004 * going to do the "bottom" procesing.
2005 *
@@ -1868,7 +2079,8 @@ int cmd_blame(int argc, const char **argv, const char *prefix)
2079 if (final_commit_name)
2080 argv[unk++] = final_commit_name;
2081
1871 - /* Now we got rev and path. We do not want the path pruning
2082 + /*
2083 + * Now we got rev and path. We do not want the path pruning
2084 * but we may want "bottom" processing.
2085 */
2086 argv[unk++] = "--"; /* terminate the rev name */
@@ -1878,7 +2090,8 @@ int cmd_blame(int argc, const char **argv, const char *prefix)
2090 setup_revisions(unk, argv, &revs, "HEAD");
2091 memset(&sb, 0, sizeof(sb));
2092
1881 - /* There must be one and only one positive commit in the
2093 + /*
2094 + * There must be one and only one positive commit in the
2095 * revs->pending array.
2096 */
2097 for (i = 0; i < revs.pending.nr; i++) {
@@ -1899,7 +2112,10 @@ int cmd_blame(int argc, const char **argv, const char *prefix)
2112 }
2113
2114 if (!sb.final) {
1902 - /* "--not A B -- path" without anything positive */
2115 + /*
2116 + * "--not A B -- path" without anything positive;
2117 + * default to HEAD.
2118 + */
2119 unsigned char head_sha1[20];
2120
2121 final_commit_name = "HEAD";
@@ -1909,7 +2125,8 @@ int cmd_blame(int argc, const char **argv, const char *prefix)
2125 add_pending_object(&revs, &(sb.final->object), "HEAD");
2126 }
2127
1912 - /* If we have bottom, this will mark the ancestors of the
2128 + /*
2129 + * If we have bottom, this will mark the ancestors of the
2130 * bottom commits we would reach while traversing as
2131 * uninteresting.
2132 */