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

Function emit_diff_symbol_from_struct

diff.c:1398–1631  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1396}
1397
1398static void emit_diff_symbol_from_struct(struct diff_options *o,
1399 struct emitted_diff_symbol *eds)
1400{
1401 const char *context, *reset, *set, *set_sign, *meta, *fraginfo;
1402
1403 enum diff_symbol s = eds->s;
1404 const char *line = eds->line;
1405 int len = eds->len;
1406 unsigned flags = eds->flags;
1407
1408 if (!o->file)
1409 return;
1410
1411 switch (s) {
1412 case DIFF_SYMBOL_SUBMODULE_HEADER:
1413 case DIFF_SYMBOL_SUBMODULE_ERROR:
1414 case DIFF_SYMBOL_SUBMODULE_PIPETHROUGH:
1415 case DIFF_SYMBOL_STATS_SUMMARY_INSERTS_DELETES:
1416 case DIFF_SYMBOL_SUMMARY:
1417 case DIFF_SYMBOL_STATS_LINE:
1418 case DIFF_SYMBOL_BINARY_DIFF_BODY:
1419 case DIFF_SYMBOL_CONTEXT_FRAGINFO:
1420 emit_line(o, "", "", line, len);
1421 break;
1422 case DIFF_SYMBOL_CONTEXT_INCOMPLETE:
1423 if ((flags & WS_INCOMPLETE_LINE) &&
1424 (flags & o->ws_error_highlight))
1425 set = diff_get_color_opt(o, DIFF_WHITESPACE);
1426 else
1427 set = diff_get_color_opt(o, DIFF_CONTEXT);
1428 reset = diff_get_color_opt(o, DIFF_RESET);
1429 emit_line(o, set, reset, line, len);
1430 break;
1431 case DIFF_SYMBOL_CONTEXT_MARKER:
1432 context = diff_get_color_opt(o, DIFF_CONTEXT);
1433 reset = diff_get_color_opt(o, DIFF_RESET);
1434 emit_line(o, context, reset, line, len);
1435 break;
1436 case DIFF_SYMBOL_SEPARATOR:
1437 fprintf(o->file, "%s%c",
1438 diff_line_prefix(o),
1439 o->line_termination);
1440 break;
1441 case DIFF_SYMBOL_CONTEXT:
1442 set = diff_get_color_opt(o, DIFF_CONTEXT);
1443 reset = diff_get_color_opt(o, DIFF_RESET);
1444 set_sign = NULL;
1445 if (o->flags.dual_color_diffed_diffs) {
1446 char c = !len ? 0 : line[0];
1447
1448 if (c == '+')
1449 set = diff_get_color_opt(o, DIFF_FILE_NEW);
1450 else if (c == '@')
1451 set = diff_get_color_opt(o, DIFF_FRAGINFO);
1452 else if (c == '-')
1453 set = diff_get_color_opt(o, DIFF_FILE_OLD);
1454 }
1455 emit_line_ws_markup(o, set_sign, set, reset,

Callers 2

emit_diff_symbolFunction · 0.85

Calls 4

emit_lineFunction · 0.85
diff_line_prefixFunction · 0.85
emit_line_ws_markupFunction · 0.85
diff_get_colorFunction · 0.85

Tested by

no test coverage detected