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

Function output_pair_header

range-diff.c:399–468  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

397}
398
399static void output_pair_header(struct diff_options *diffopt,
400 int patch_no_width,
401 struct strbuf *buf,
402 struct strbuf *dashes,
403 struct patch_util *a_util,
404 struct patch_util *b_util)
405{
406 struct object_id *oid = a_util ? &a_util->oid : &b_util->oid;
407 struct commit *commit;
408 char status;
409 const char *color_reset = diff_get_color_opt(diffopt, DIFF_RESET);
410 const char *color_old = diff_get_color_opt(diffopt, DIFF_FILE_OLD);
411 const char *color_new = diff_get_color_opt(diffopt, DIFF_FILE_NEW);
412 const char *color_commit = diff_get_color_opt(diffopt, DIFF_COMMIT);
413 const char *color;
414 int abbrev = diffopt->abbrev;
415
416 if (abbrev < 0)
417 abbrev = DEFAULT_ABBREV;
418
419 if (!dashes->len)
420 strbuf_addchars(dashes, '-',
421 strlen(repo_find_unique_abbrev(the_repository, oid, abbrev)));
422
423 if (!b_util) {
424 color = color_old;
425 status = '<';
426 } else if (!a_util) {
427 color = color_new;
428 status = '>';
429 } else if (strcmp(a_util->patch, b_util->patch)) {
430 color = color_commit;
431 status = '!';
432 } else {
433 color = color_commit;
434 status = '=';
435 }
436
437 strbuf_reset(buf);
438 strbuf_addstr(buf, status == '!' ? color_old : color);
439 if (!a_util)
440 strbuf_addf(buf, "%*s: %s ", patch_no_width, "-", dashes->buf);
441 else
442 strbuf_addf(buf, "%*d: %s ", patch_no_width, a_util->i + 1,
443 repo_find_unique_abbrev(the_repository, &a_util->oid, abbrev));
444
445 if (status == '!')
446 strbuf_addf(buf, "%s%s", color_reset, color);
447 strbuf_addch(buf, status);
448 if (status == '!')
449 strbuf_addf(buf, "%s%s", color_reset, color_new);
450
451 if (!b_util)
452 strbuf_addf(buf, " %*s: %s", patch_no_width, "-", dashes->buf);
453 else
454 strbuf_addf(buf, " %*d: %s", patch_no_width, b_util->i + 1,
455 repo_find_unique_abbrev(the_repository, &b_util->oid, abbrev));
456

Callers 1

outputFunction · 0.85

Calls 7

strbuf_addcharsFunction · 0.85
repo_find_unique_abbrevFunction · 0.85
strbuf_addstrFunction · 0.85
strbuf_addfFunction · 0.85
strbuf_addchFunction · 0.85
lookup_commit_referenceFunction · 0.85
pp_commit_easyFunction · 0.85

Tested by

no test coverage detected