| 4279 | } |
| 4280 | |
| 4281 | static void builtin_checkdiff(const char *name_a, const char *name_b, |
| 4282 | const char *attr_path, |
| 4283 | struct diff_filespec *one, |
| 4284 | struct diff_filespec *two, |
| 4285 | struct diff_options *o) |
| 4286 | { |
| 4287 | mmfile_t mf1, mf2; |
| 4288 | struct checkdiff_t data; |
| 4289 | |
| 4290 | if (!two) |
| 4291 | return; |
| 4292 | |
| 4293 | memset(&data, 0, sizeof(data)); |
| 4294 | data.filename = name_b ? name_b : name_a; |
| 4295 | data.lineno = 0; |
| 4296 | data.o = o; |
| 4297 | data.ws_rule = whitespace_rule(o->repo->index, attr_path); |
| 4298 | data.conflict_marker_size = ll_merge_marker_size(o->repo->index, attr_path); |
| 4299 | |
| 4300 | /* symlink being an incomplete line is not a news */ |
| 4301 | if (DIFF_FILE_VALID(two) && S_ISLNK(two->mode)) |
| 4302 | data.ws_rule &= ~WS_INCOMPLETE_LINE; |
| 4303 | |
| 4304 | if (fill_mmfile(o->repo, &mf1, one) < 0 || |
| 4305 | fill_mmfile(o->repo, &mf2, two) < 0) |
| 4306 | die("unable to read files to diff"); |
| 4307 | |
| 4308 | /* |
| 4309 | * All the other codepaths check both sides, but not checking |
| 4310 | * the "old" side here is deliberate. We are checking the newly |
| 4311 | * introduced changes, and as long as the "new" side is text, we |
| 4312 | * can and should check what it introduces. |
| 4313 | */ |
| 4314 | if (diff_filespec_is_binary(o->repo, two)) |
| 4315 | goto free_and_return; |
| 4316 | else { |
| 4317 | /* Crazy xdl interfaces.. */ |
| 4318 | xpparam_t xpp; |
| 4319 | xdemitconf_t xecfg; |
| 4320 | |
| 4321 | memset(&xpp, 0, sizeof(xpp)); |
| 4322 | memset(&xecfg, 0, sizeof(xecfg)); |
| 4323 | xecfg.ctxlen = 1; /* at least one context line */ |
| 4324 | xpp.flags = 0; |
| 4325 | if (xdi_diff_outf(&mf1, &mf2, checkdiff_consume_hunk, |
| 4326 | checkdiff_consume, &data, |
| 4327 | &xpp, &xecfg)) |
| 4328 | die("unable to generate checkdiff for %s", one->path); |
| 4329 | |
| 4330 | if (data.ws_rule & WS_BLANK_AT_EOF) { |
| 4331 | struct emit_callback ecbdata; |
| 4332 | int blank_at_eof; |
| 4333 | |
| 4334 | ecbdata.ws_rule = data.ws_rule; |
| 4335 | check_blank_at_eof(&mf1, &mf2, &ecbdata); |
| 4336 | blank_at_eof = ecbdata.blank_at_eof_in_postimage; |
| 4337 | |
| 4338 | if (blank_at_eof) { |
no test coverage detected