| 750 | } |
| 751 | |
| 752 | static void dump_sline(struct sline *sline, const char *line_prefix, |
| 753 | unsigned long cnt, int num_parent, |
| 754 | enum git_colorbool use_color, int result_deleted) |
| 755 | { |
| 756 | unsigned long mark = (1UL<<num_parent); |
| 757 | unsigned long no_pre_delete = (2UL<<num_parent); |
| 758 | int i; |
| 759 | unsigned long lno = 0; |
| 760 | const char *c_frag = diff_get_color(use_color, DIFF_FRAGINFO); |
| 761 | const char *c_func = diff_get_color(use_color, DIFF_FUNCINFO); |
| 762 | const char *c_new = diff_get_color(use_color, DIFF_FILE_NEW); |
| 763 | const char *c_old = diff_get_color(use_color, DIFF_FILE_OLD); |
| 764 | const char *c_context = diff_get_color(use_color, DIFF_CONTEXT); |
| 765 | const char *c_reset = diff_get_color(use_color, DIFF_RESET); |
| 766 | |
| 767 | if (result_deleted) |
| 768 | return; /* result deleted */ |
| 769 | |
| 770 | while (1) { |
| 771 | unsigned long hunk_end; |
| 772 | unsigned long rlines; |
| 773 | const char *hunk_comment = NULL; |
| 774 | unsigned long null_context = 0; |
| 775 | |
| 776 | while (lno <= cnt && !(sline[lno].flag & mark)) { |
| 777 | if (hunk_comment_line(sline[lno].bol)) |
| 778 | hunk_comment = sline[lno].bol; |
| 779 | lno++; |
| 780 | } |
| 781 | if (cnt < lno) |
| 782 | break; |
| 783 | else { |
| 784 | for (hunk_end = lno + 1; hunk_end <= cnt; hunk_end++) |
| 785 | if (!(sline[hunk_end].flag & mark)) |
| 786 | break; |
| 787 | } |
| 788 | rlines = hunk_end - lno; |
| 789 | if (cnt < hunk_end) |
| 790 | rlines--; /* pointing at the last delete hunk */ |
| 791 | |
| 792 | if (!context) { |
| 793 | /* |
| 794 | * Even when running with --unified=0, all |
| 795 | * lines in the hunk needs to be processed in |
| 796 | * the loop below in order to show the |
| 797 | * deletion recorded in lost_head. However, |
| 798 | * we do not want to show the resulting line |
| 799 | * with all blank context markers in such a |
| 800 | * case. Compensate. |
| 801 | */ |
| 802 | unsigned long j; |
| 803 | for (j = lno; j < hunk_end; j++) |
| 804 | if (!(sline[j].flag & (mark-1))) |
| 805 | null_context++; |
| 806 | rlines -= null_context; |
| 807 | } |
| 808 | |
| 809 | printf("%s%s", line_prefix, c_frag); |
no test coverage detected