git-2.22.0/rerere.c
/*
 * Scan the path for conflicts, do the "handle_path()" thing above, and
 * return the number of conflict hunks found.
 */
Scan the path for conflicts, do the "handle_path()" thing above, and
return the number of conflict hunks found.
Scan the path for conflicts do the " handle_path () " thing above and return the number of conflict hunks found .
static int handle_file(struct index_state *istate,
		       const char *path, unsigned char *hash, const char *output)
{
	int has_conflicts = 0;
	struct rerere_io_file io;
	int marker_size = ll_merge_marker_size(istate, path);
	memset(&io, 0, sizeof(io));
	io.io.getline = rerere_file_getline;
	io.input = fopen(path, "r");
	io.io.wrerror = 0;
	if (!io.input)
		return error_errno(_("could not open '%s'"), path);
	if (output) {
		io.io.output = fopen(output, "w");
		if (!io.io.output) {
			error_errno(_("could not write '%s'"), output);
			fclose(io.input);
			return -1;
		}
	}
	has_conflicts = handle_path(hash, (struct rerere_io *)&io, marker_size);
	fclose(io.input);
	if (io.io.wrerror)
		error(_("there were errors while writing '%s' (%s)"),
		      path, strerror(io.io.wrerror));
	if (io.io.output && fclose(io.io.output))
		io.io.wrerror = error_errno(_("failed to flush '%s'"), path);
	if (has_conflicts < 0) {
		if (output)
			unlink_or_warn(output);
		return error(_("could not parse conflict hunks in '%s'"), path);
	}
	if (io.io.wrerror)
		return -1;
	return has_conflicts;
}
static int handle_file ( struct index_state * istate , const char * path , unsigned char * hash , const char * output ) { int has_conflicts = 0 ; struct rerere_io_file io ; int marker_size = ll_merge_marker_size ( istate , path ) ; memset ( & io , 0 , sizeof ( io ) ) ; io . io . getline = rerere_file_getline ; io . input = fopen ( path , " " ) ; io . io . wrerror = 0 ; if ( ! io . input ) return error_errno ( _ ( " " ) , path ) ; if ( output ) { io . io . output = fopen ( output , " " ) ; if ( ! io . io . output ) { error_errno ( _ ( " " ) , output ) ; fclose ( io . input ) ; return -1 ; } } has_conflicts = handle_path ( hash , ( struct rerere_io * ) & io , marker_size ) ; fclose ( io . input ) ; if ( io . io . wrerror ) error ( _ ( " " ) , path , strerror ( io . io . wrerror ) ) ; if ( io . io . output && fclose ( io . io . output ) ) io . io . wrerror = error_errno ( _ ( " " ) , path ) ; if ( has_conflicts < 0 ) { if ( output ) unlink_or_warn ( output ) ; return error ( _ ( " " ) , path ) ; } if ( io . io . wrerror ) return -1 ; return has_conflicts ; }
Scan the path for conflicts, do the "handle_path()" thing above, and
 return the number of conflict hunks found.
Scan the path for conflicts do the " handle_path () " thing above and return the number of conflict hunks found .