@matheusbsbs / matheus-bagliano / commits / fd4b1d2193
Fork 0

combine-diff: add safety check to --cc.

The earlier change implemented "only two version" check but without checking if the change rewrites from all the parents. This implements a check to make sure that a change introduced by the merge from all the parents is caught to be interesting. Signed-off-by: Junio C Hamano <junkio@cox.net>

Junio C Hamano committed Feb 2, 2006 at 01:28 UTC fd4b1d2193640009c9303daa784691fc5e102018
1 file changed +18 -2
combine-diff.c
+18 -2
@@ -397,7 +397,23 @@ static int make_hunks(struct sline *sline, unsigned long cnt,
397 hunk_end = j;
398
399 /* [i..hunk_end) are interesting. Now is it really
400 - * interesting?
400 + * interesting? We check if there are only two versions
401 + * and the result matches one of them. That is, we look
402 + * at:
403 + * (+) line, which records lines added to which parents;
404 + * this line appears in the result.
405 + * (-) line, which records from what parents the line
406 + * was removed; this line does not appear in the result.
407 + * then check the set of parents the result has difference
408 + * from, from all lines. If there are lines that has
409 + * different set of parents that the result has differences
410 + * from, that means we have more than two versions.
411 + *
412 + * Even when we have only two versions, if the result does
413 + * not match any of the parents, the it should be considered
414 + * interesting. In such a case, we would have all '+' line.
415 + * After passing the above "two versions" test, that would
416 + * appear as "the same set of parents" to be "all parents".
417 */
418 same_diff = 0;
419 has_interesting = 0;
@@ -429,7 +445,7 @@ static int make_hunks(struct sline *sline, unsigned long cnt,
445 }
446 }
447
432 - if (!has_interesting) {
448 + if (!has_interesting && same_diff != all_mask) {
449 /* This hunk is not that interesting after all */
450 for (j = hunk_begin; j < hunk_end; j++)
451 sline[j].flag &= ~mark;