From: Junio C Hamano Date: Thu, 26 Jan 2006 11:53:01 +0000 (-0800) Subject: combine-diff: better hunk splitting. X-Git-Tag: v1.2.0~100^3~1 X-Git-Url: https://git.verplant.org/?a=commitdiff_plain;h=3ec1909fdaa1189a8f9d23f84e33b45d9d7600cd;p=git.git combine-diff: better hunk splitting. It considered an otherwise unchanged line that had line removals in front of it an interesting line, which caused hunks to have one extra the trailing context line. Signed-off-by: Junio C Hamano --- diff --git a/combine-diff.c b/combine-diff.c index 3b219a01..df52fa20 100644 --- a/combine-diff.c +++ b/combine-diff.c @@ -323,52 +323,141 @@ static unsigned long line_all_diff(struct sline *sline, unsigned long all_mask) return different; } -static int make_hunks(struct sline *sline, unsigned long cnt, - int num_parent, int dense) +static unsigned long adjust_hunk_tail(struct sline *sline, + unsigned long all_mask, + unsigned long hunk_begin, + unsigned long i) +{ + /* i points at the first uninteresting line. + * If the last line of the hunk was interesting + * only because it has some deletion, then + * it is not all that interesting for the + * purpose of giving trailing context lines. + */ + if ((hunk_begin + 1 <= i) && + ((sline[i-1].flag & all_mask) == all_mask)) + i--; + return i; +} + +static unsigned long next_interesting(struct sline *sline, + unsigned long mark, + unsigned long i, + unsigned long cnt, + int uninteresting) +{ + while (i < cnt) + if (uninteresting ? + !(sline[i].flag & mark) : + (sline[i].flag & mark)) + return i; + else + i++; + return cnt; +} + +static int give_context(struct sline *sline, unsigned long cnt, int num_parent) { unsigned long all_mask = (1UL<