MCPcopy Create free account
hub / github.com/git/git / dim_moved_lines

Function dim_moved_lines

diff.c:1303–1360  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1301}
1302
1303static void dim_moved_lines(struct diff_options *o)
1304{
1305 int n;
1306 for (n = 0; n < o->emitted_symbols->nr; n++) {
1307 struct emitted_diff_symbol *prev = (n != 0) ?
1308 &o->emitted_symbols->buf[n - 1] : NULL;
1309 struct emitted_diff_symbol *l = &o->emitted_symbols->buf[n];
1310 struct emitted_diff_symbol *next =
1311 (n < o->emitted_symbols->nr - 1) ?
1312 &o->emitted_symbols->buf[n + 1] : NULL;
1313
1314 /* Not a plus or minus line? */
1315 if (l->s != DIFF_SYMBOL_PLUS && l->s != DIFF_SYMBOL_MINUS)
1316 continue;
1317
1318 /* Not a moved line? */
1319 if (!(l->flags & DIFF_SYMBOL_MOVED_LINE))
1320 continue;
1321
1322 /*
1323 * If prev or next are not a plus or minus line,
1324 * pretend they don't exist
1325 */
1326 if (prev && prev->s != DIFF_SYMBOL_PLUS &&
1327 prev->s != DIFF_SYMBOL_MINUS)
1328 prev = NULL;
1329 if (next && next->s != DIFF_SYMBOL_PLUS &&
1330 next->s != DIFF_SYMBOL_MINUS)
1331 next = NULL;
1332
1333 /* Inside a block? */
1334 if ((prev &&
1335 (prev->flags & DIFF_SYMBOL_MOVED_LINE_ZEBRA_MASK) ==
1336 (l->flags & DIFF_SYMBOL_MOVED_LINE_ZEBRA_MASK)) &&
1337 (next &&
1338 (next->flags & DIFF_SYMBOL_MOVED_LINE_ZEBRA_MASK) ==
1339 (l->flags & DIFF_SYMBOL_MOVED_LINE_ZEBRA_MASK))) {
1340 l->flags |= DIFF_SYMBOL_MOVED_LINE_UNINTERESTING;
1341 continue;
1342 }
1343
1344 /* Check if we are at an interesting bound: */
1345 if (prev && (prev->flags & DIFF_SYMBOL_MOVED_LINE) &&
1346 (prev->flags & DIFF_SYMBOL_MOVED_LINE_ALT) !=
1347 (l->flags & DIFF_SYMBOL_MOVED_LINE_ALT))
1348 continue;
1349 if (next && (next->flags & DIFF_SYMBOL_MOVED_LINE) &&
1350 (next->flags & DIFF_SYMBOL_MOVED_LINE_ALT) !=
1351 (l->flags & DIFF_SYMBOL_MOVED_LINE_ALT))
1352 continue;
1353
1354 /*
1355 * The boundary to prev and next are not interesting,
1356 * so this line is not interesting as a whole
1357 */
1358 l->flags |= DIFF_SYMBOL_MOVED_LINE_UNINTERESTING;
1359 }
1360}

Callers 1

Calls

no outgoing calls

Tested by

no test coverage detected