Branch Coverage

deps/libgit2/src/xdiff/xmerge.c
Criterion Covered Total %
branch 162 342 47.3


line true false branch
56 0 11 if (m && (i1 <= m->i1 + m->chg1 || i2 <= m->i2 + m->chg2)) {
0 0 if (m && (i1 <= m->i1 + m->chg1 || i2 <= m->i2 + m->chg2)) {
0 0 if (m && (i1 <= m->i1 + m->chg1 || i2 <= m->i2 + m->chg2)) {
57 0 0 if (mode != m->mode)
64 0 11 if (!m)
74 0 11 if (*merge)
87 11 11 for (; c; c = next_c) {
88 8 3 if (c->mode == 0)
103 9 0 for (i = 0; i < line_count; i++) {
106 9 0 if (!result)
119 0 82 recs = (use_orig ? xe->xdf1.recs : xe->xdf2.recs) + i;
121 40 42 if (count < 1)
124 46 42 for (i = 0; i < count; ) {
125 23 23 if (dest)
128 0 46 GIT_ERROR_CHECK_ALLOC_ADD(&size, size, recs[i++]->size);
0 46 GIT_ERROR_CHECK_ALLOC_ADD(&size, size, recs[i++]->size);
131 32 10 if (add_nl) {
133 32 0 if (i == 0 || recs[count - 1]->ptr[i - 1] != '\n') {
32 0 if (i == 0 || recs[count - 1]->ptr[i - 1] != '\n') {
134 0 32 if (needs_cr) {
135 0 0 if (dest)
137 0 0 GIT_ERROR_CHECK_ALLOC_ADD(&size, size, 1);
0 0 GIT_ERROR_CHECK_ALLOC_ADD(&size, size, 1);
140 16 16 if (dest)
143 0 32 GIT_ERROR_CHECK_ALLOC_ADD(&size, size, 1);
0 32 GIT_ERROR_CHECK_ALLOC_ADD(&size, size, 1);
170 4 48 if (i < file->nrec - 1)
172 4 0 return (size = file->recs[i]->size) > 1 &&
0 4 return (size = file->recs[i]->size) > 1 &&
174 0 48 if (!file->nrec)
177 48 0 if ((size = file->recs[i]->size) &&
0 48 if ((size = file->recs[i]->size) &&
180 0 0 return size > 1 &&
0 0 return size > 1 &&
182 48 0 if (!i)
186 0 0 return (size = file->recs[i - 1]->size) > 1 &&
0 0 return (size = file->recs[i - 1]->size) > 1 &&
195 4 16 needs_cr = is_eol_crlf(&xe1->xdf2, m->i1 ? m->i1 - 1 : 0);
196 16 4 if (needs_cr)
197 0 16 needs_cr = is_eol_crlf(&xe2->xdf2, m->i2 ? m->i2 - 1 : 0);
199 16 4 if (needs_cr)
211 16 0 int marker1_size = (name1 ? (int)strlen(name1) + 1 : 0);
212 16 0 int marker2_size = (name2 ? (int)strlen(name2) + 1 : 0);
213 16 0 int marker3_size = (name3 ? (int)strlen(name3) + 1 : 0);
219 14 2 if (marker_size <= 0)
223 8 8 if (xdl_recs_copy(&copied, xe1, i, m->i1 - i, 0, 0,
0 16 if (xdl_recs_copy(&copied, xe1, i, m->i1 - i, 0, 0,
227 0 16 GIT_ERROR_CHECK_ALLOC_ADD(&size, size, copied);
0 16 GIT_ERROR_CHECK_ALLOC_ADD(&size, size, copied);
229 8 8 if (!dest) {
230 0 8 GIT_ERROR_CHECK_ALLOC_ADD5(&size, size, marker_size, 1, needs_cr, marker1_size);
0 8 GIT_ERROR_CHECK_ALLOC_ADD5(&size, size, marker_size, 1, needs_cr, marker1_size);
0 8 GIT_ERROR_CHECK_ALLOC_ADD5(&size, size, marker_size, 1, needs_cr, marker1_size);
0 8 GIT_ERROR_CHECK_ALLOC_ADD5(&size, size, marker_size, 1, needs_cr, marker1_size);
234 8 0 if (marker1_size) {
239 0 8 if (needs_cr)
245 8 8 if (xdl_recs_copy(&copied, xe1, m->i1, m->chg1, needs_cr, 1,
0 16 if (xdl_recs_copy(&copied, xe1, m->i1, m->chg1, needs_cr, 1,
249 0 16 GIT_ERROR_CHECK_ALLOC_ADD(&size, size, copied);
0 16 GIT_ERROR_CHECK_ALLOC_ADD(&size, size, copied);
251 0 16 if (style == XDL_MERGE_DIFF3) {
253 0 0 if (!dest) {
254 0 0 GIT_ERROR_CHECK_ALLOC_ADD5(&size, size, marker_size, 1, needs_cr, marker3_size);
0 0 GIT_ERROR_CHECK_ALLOC_ADD5(&size, size, marker_size, 1, needs_cr, marker3_size);
0 0 GIT_ERROR_CHECK_ALLOC_ADD5(&size, size, marker_size, 1, needs_cr, marker3_size);
0 0 GIT_ERROR_CHECK_ALLOC_ADD5(&size, size, marker_size, 1, needs_cr, marker3_size);
258 0 0 if (marker3_size) {
263 0 0 if (needs_cr)
268 0 0 if (xdl_orig_copy(&copied, xe1, m->i0, m->chg0, needs_cr, 1,
0 0 if (xdl_orig_copy(&copied, xe1, m->i0, m->chg0, needs_cr, 1,
271 0 0 GIT_ERROR_CHECK_ALLOC_ADD(&size, size, copied);
0 0 GIT_ERROR_CHECK_ALLOC_ADD(&size, size, copied);
274 8 8 if (!dest) {
275 0 8 GIT_ERROR_CHECK_ALLOC_ADD4(&size, size, marker_size, 1, needs_cr);
0 8 GIT_ERROR_CHECK_ALLOC_ADD4(&size, size, marker_size, 1, needs_cr);
0 8 GIT_ERROR_CHECK_ALLOC_ADD4(&size, size, marker_size, 1, needs_cr);
279 0 8 if (needs_cr)
286 8 8 if (xdl_recs_copy(&copied, xe2, m->i2, m->chg2, needs_cr, 1,
0 16 if (xdl_recs_copy(&copied, xe2, m->i2, m->chg2, needs_cr, 1,
289 0 16 GIT_ERROR_CHECK_ALLOC_ADD(&size, size, copied);
0 16 GIT_ERROR_CHECK_ALLOC_ADD(&size, size, copied);
291 8 8 if (!dest) {
292 0 8 GIT_ERROR_CHECK_ALLOC_ADD5(&size, size, marker_size, 1, needs_cr, marker2_size);
0 8 GIT_ERROR_CHECK_ALLOC_ADD5(&size, size, marker_size, 1, needs_cr, marker2_size);
0 8 GIT_ERROR_CHECK_ALLOC_ADD5(&size, size, marker_size, 1, needs_cr, marker2_size);
0 8 GIT_ERROR_CHECK_ALLOC_ADD5(&size, size, marker_size, 1, needs_cr, marker2_size);
296 8 0 if (marker2_size) {
301 0 8 if (needs_cr)
323 22 22 for (size = i = 0; m; m = m->next) {
324 6 16 if (favor && !m->mode)
3 3 if (favor && !m->mode)
327 16 6 if (m->mode == 0) {
328 0 16 if (fill_conflict_hunk(&size, xe1, name1, xe2, name2,
334 6 0 else if (m->mode & 3) {
336 3 3 if (xdl_recs_copy(&copied, xe1, i, m->i1 - i, 0, 0,
0 6 if (xdl_recs_copy(&copied, xe1, i, m->i1 - i, 0, 0,
339 0 6 GIT_ERROR_CHECK_ALLOC_ADD(&size, size, copied);
0 6 GIT_ERROR_CHECK_ALLOC_ADD(&size, size, copied);
342 4 2 if (m->mode & 1) {
345 2 2 if (xdl_recs_copy(&copied, xe1, m->i1, m->chg1, needs_cr, (m->mode & 2),
0 4 if (xdl_recs_copy(&copied, xe1, m->i1, m->chg1, needs_cr, (m->mode & 2),
348 0 4 GIT_ERROR_CHECK_ALLOC_ADD(&size, size, copied);
0 4 GIT_ERROR_CHECK_ALLOC_ADD(&size, size, copied);
352 2 4 if (m->mode & 2) {
353 1 1 if (xdl_recs_copy(&copied, xe2, m->i2, m->chg2, 0, 0,
0 2 if (xdl_recs_copy(&copied, xe2, m->i2, m->chg2, 0, 0,
356 0 2 GIT_ERROR_CHECK_ALLOC_ADD(&size, size, copied);
0 2 GIT_ERROR_CHECK_ALLOC_ADD(&size, size, copied);
363 11 11 if (xdl_recs_copy(&copied, xe1, i, xe1->xdf2.nrec - i, 0, 0,
0 22 if (xdl_recs_copy(&copied, xe1, i, xe1->xdf2.nrec - i, 0, 0,
366 0 22 GIT_ERROR_CHECK_ALLOC_ADD(&size, size, copied);
0 22 GIT_ERROR_CHECK_ALLOC_ADD(&size, size, copied);
379 11 11 for (; m; m = m->next) {
386 0 11 if (m->mode)
390 11 0 if (m->chg1 == 0 || m->chg2 == 0)
0 11 if (m->chg1 == 0 || m->chg2 == 0)
403 0 11 if (xdl_do_diff(&t1, &t2, xpp, &xe) < 0)
406 0 11 xdl_change_compact(&xe.xdf2, &xe.xdf1, xpp->flags) < 0 ||
411 0 11 if (!xscr) {
422 0 11 while (xscr->next) {
424 0 0 if (!m2) {
447 0 0 while (size--)
448 0 0 if (isalnum((unsigned char)*(ptr++)))
455 0 0 for (; chg; chg--, i++)
456 0 0 if (line_contains_alnum(xe->xdf2.recs[i]->ptr,
485 0 11 if (!m)
491 11 0 if (!next_m)
497 0 0 if (m->mode != 0 || next_m->mode != 0 ||
0 0 if (m->mode != 0 || next_m->mode != 0 ||
0 0 if (m->mode != 0 || next_m->mode != 0 ||
498 0 0 (end - begin > 3 &&
499 0 0 (!simplify_if_no_alnum ||
532 0 11 if (style == XDL_MERGE_DIFF3) {
537 0 0 if (XDL_MERGE_EAGER < level)
543 11 11 while (xscr1 && xscr2) {
11 0 while (xscr1 && xscr2) {
544 11 0 if (!changes)
546 0 11 if (xscr1->i1 + xscr1->chg1 < xscr2->i1) {
553 0 0 if (xdl_append_merge(&c, 1,
561 0 11 if (xscr2->i1 + xscr2->chg1 < xscr1->i1) {
568 0 0 if (xdl_append_merge(&c, 2,
576 11 0 if (level == XDL_MERGE_MINIMAL || xscr1->i1 != xscr2->i1 ||
11 0 if (level == XDL_MERGE_MINIMAL || xscr1->i1 != xscr2->i1 ||
11 0 if (level == XDL_MERGE_MINIMAL || xscr1->i1 != xscr2->i1 ||
577 9 2 xscr1->chg1 != xscr2->chg1 ||
578 9 0 xscr1->chg2 != xscr2->chg2 ||
589 0 11 if (off > 0) {
598 0 11 if (ffo < 0) {
603 0 11 if (xdl_append_merge(&c, 0,
613 11 0 if (i1 >= i2)
615 11 0 if (i2 >= i1)
618 0 11 while (xscr1) {
619 0 0 if (!changes)
627 0 0 if (xdl_append_merge(&c, 1,
634 0 11 while (xscr2) {
635 0 0 if (!changes)
643 0 0 if (xdl_append_merge(&c, 2,
650 11 0 if (!changes)
654 0 11 (xdl_refine_conflicts(xe1, xe2, changes, xpp) < 0 ||
661 11 0 if (result) {
665 0 11 if (xdl_fill_merge_buffer(&size, xe1, name1, xe2, name2,
672 0 11 if (!result->ptr) {
677 0 11 if (xdl_fill_merge_buffer(&size, xe1, name1, xe2, name2,
696 0 11 if (xdl_do_diff(orig, mf1, xpp, &xe1) < 0) {
699 0 11 if (xdl_do_diff(orig, mf2, xpp, &xe2) < 0) {
704 0 11 xdl_change_compact(&xe1.xdf2, &xe1.xdf1, xpp->flags) < 0 ||
710 0 11 xdl_change_compact(&xe2.xdf2, &xe2.xdf1, xpp->flags) < 0 ||
718 0 11 if (!xscr1) {
720 0 0 if (!result->ptr) {
728 0 11 } else if (!xscr2) {
730 0 0 if (!result->ptr) {