MCPcopy Index your code
hub / github.com/git/git / combine_diff

Function combine_diff

combine-diff.c:420–489  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

418}
419
420static void combine_diff(struct repository *r,
421 const struct object_id *parent, unsigned int mode,
422 mmfile_t *result_file,
423 struct sline *sline, unsigned int cnt, int n,
424 int num_parent, int result_deleted,
425 struct userdiff_driver *textconv,
426 const char *path, long flags)
427{
428 unsigned int p_lno, lno;
429 unsigned long nmask = (1UL << n);
430 xpparam_t xpp;
431 xdemitconf_t xecfg;
432 mmfile_t parent_file;
433 struct combine_diff_state state;
434 unsigned long sz;
435
436 if (result_deleted)
437 return; /* result deleted */
438
439 parent_file.ptr = grab_blob(r, parent, mode, &sz, textconv, path);
440 parent_file.size = sz;
441 memset(&xpp, 0, sizeof(xpp));
442 xpp.flags = flags;
443 memset(&xecfg, 0, sizeof(xecfg));
444 memset(&state, 0, sizeof(state));
445 state.nmask = nmask;
446 state.sline = sline;
447 state.lno = 1;
448 state.num_parent = num_parent;
449 state.n = n;
450
451 if (xdi_diff_outf(&parent_file, result_file, consume_hunk,
452 consume_line, &state, &xpp, &xecfg))
453 die("unable to generate combined diff for %s",
454 oid_to_hex(parent));
455 free(parent_file.ptr);
456
457 /* Assign line numbers for this parent.
458 *
459 * sline[lno].p_lno[n] records the first line number
460 * (counting from 1) for parent N if the final hunk display
461 * started by showing sline[lno] (possibly showing the lost
462 * lines attached to it first).
463 */
464 for (lno = 0, p_lno = 1; lno <= cnt; lno++) {
465 struct lline *ll;
466 sline[lno].p_lno[n] = p_lno;
467
468 /* Coalesce new lines */
469 if (sline[lno].plost.lost_head) {
470 struct sline *sl = &sline[lno];
471 sl->lost = coalesce_lines(sl->lost, &sl->lenlost,
472 sl->plost.lost_head,
473 sl->plost.len, n, flags);
474 sl->plost.lost_head = sl->plost.lost_tail = NULL;
475 sl->plost.len = 0;
476 }
477

Callers 1

show_patch_diffFunction · 0.85

Calls 5

grab_blobFunction · 0.85
xdi_diff_outfFunction · 0.85
oid_to_hexFunction · 0.85
coalesce_linesFunction · 0.85
dieFunction · 0.70

Tested by

no test coverage detected