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

Function handle_file

rerere.c:468–508  ·  view source on GitHub ↗

* Scan the path for conflicts, do the "handle_path()" thing above, and * return the number of conflict hunks found. */

Source from the content-addressed store, hash-verified

466 * return the number of conflict hunks found.
467 */
468static int handle_file(struct index_state *istate,
469 const char *path, unsigned char *hash, const char *output)
470{
471 int has_conflicts = 0;
472 struct rerere_io_file io;
473 int marker_size = ll_merge_marker_size(istate, path);
474
475 memset(&io, 0, sizeof(io));
476 io.io.getline = rerere_file_getline;
477 io.input = fopen(path, "r");
478 io.io.wrerror = 0;
479 if (!io.input)
480 return error_errno(_("could not open '%s'"), path);
481
482 if (output) {
483 io.io.output = fopen(output, "w");
484 if (!io.io.output) {
485 error_errno(_("could not write '%s'"), output);
486 fclose(io.input);
487 return -1;
488 }
489 }
490
491 has_conflicts = handle_path(hash, (struct rerere_io *)&io, marker_size);
492
493 fclose(io.input);
494 if (io.io.wrerror)
495 error(_("there were errors while writing '%s' (%s)"),
496 path, strerror(io.io.wrerror));
497 if (io.io.output && fclose(io.io.output))
498 io.io.wrerror = error_errno(_("failed to flush '%s'"), path);
499
500 if (has_conflicts < 0) {
501 if (output)
502 unlink_or_warn(output);
503 return error(_("could not parse conflict hunks in '%s'"), path);
504 }
505 if (io.io.wrerror)
506 return -1;
507 return has_conflicts;
508}
509
510/*
511 * Look at a cache entry at "i" and see if it is not conflicting,

Callers 3

mergeFunction · 0.85
do_rerere_one_pathFunction · 0.85
do_plain_rerereFunction · 0.85

Calls 5

ll_merge_marker_sizeFunction · 0.85
error_errnoFunction · 0.85
handle_pathFunction · 0.85
errorFunction · 0.85
unlink_or_warnFunction · 0.85

Tested by

no test coverage detected