git-2.22.0/rerere.c
/*
 * The path indicated by rr_item may still have conflict for which we
 * have a recorded resolution, in which case replay it and optionally
 * update it.  Or it may have been resolved by the user and we may
 * only have the preimage for that conflict, in which case the result
 * needs to be recorded as a resolution in a postimage file.
 */
The path indicated by rr_item may still have conflict for which we
have a recorded resolution, in which case replay it and optionally
update it.  Or it may have been resolved by the user and we may
only have the preimage for that conflict, in which case the result
needs to be recorded as a resolution in a postimage file.
The path indicated by rr_item may still have conflict for which we have a recorded resolution in which case replay it and optionally update it . Or it may have been resolved by the user and we may only have the preimage for that conflict in which case the result needs to be recorded as a resolution in a postimage file .
static void do_rerere_one_path(struct index_state *istate,
			       struct string_list_item *rr_item,
			       struct string_list *update)
{
	const char *path = rr_item->string;
	struct rerere_id *id = rr_item->util;
	struct rerere_dir *rr_dir = id->collection;
	int variant;
	variant = id->variant;
	if (variant >= 0) {
		if (!handle_file(istate, path, NULL, NULL)) {
			copy_file(rerere_path(id, "postimage"), path, 0666);
			id->collection->status[variant] |= RR_HAS_POSTIMAGE;
			fprintf_ln(stderr, _("Recorded resolution for '%s'."), path);
			free_rerere_id(rr_item);
			rr_item->util = NULL;
			return;
		}
	}
	for (variant = 0; variant < rr_dir->status_nr; variant++) {
		const int both = RR_HAS_PREIMAGE | RR_HAS_POSTIMAGE;
		struct rerere_id vid = *id;
		if ((rr_dir->status[variant] & both) != both)
			continue;
		vid.variant = variant;
		if (merge(istate, &vid, path))
			continue; 
		if (0 <= id->variant && id->variant != variant)
			remove_variant(id);
		if (rerere_autoupdate)
			string_list_insert(update, path);
		else
			fprintf_ln(stderr,
				   _("Resolved '%s' using previous resolution."),
				   path);
		free_rerere_id(rr_item);
		rr_item->util = NULL;
		return;
	}
	assign_variant(id);
	variant = id->variant;
	handle_file(istate, path, NULL, rerere_path(id, "preimage"));
	if (id->collection->status[variant] & RR_HAS_POSTIMAGE) {
		const char *path = rerere_path(id, "postimage");
		if (unlink(path))
			die_errno(_("cannot unlink stray '%s'"), path);
		id->collection->status[variant] &= ~RR_HAS_POSTIMAGE;
	}
	id->collection->status[variant] |= RR_HAS_PREIMAGE;
	fprintf_ln(stderr, _("Recorded preimage for '%s'"), path);
}
static void do_rerere_one_path ( struct index_state * istate , struct string_list_item * rr_item , struct string_list * update ) { const char * path = rr_item -> string ; struct rerere_id * id = rr_item -> util ; struct rerere_dir * rr_dir = id -> collection ; int variant ; variant = id -> variant ; if ( variant >= 0 ) { if ( ! handle_file ( istate , path , NULL , NULL ) ) { copy_file ( rerere_path ( id , " " ) , path , 0666 ) ; id -> collection -> status [ variant ] |= RR_HAS_POSTIMAGE ; fprintf_ln ( stderr , _ ( " " ) , path ) ; free_rerere_id ( rr_item ) ; rr_item -> util = NULL ; return ; } } for ( variant = 0 ; variant < rr_dir -> status_nr ; variant ++ ) { const int both = RR_HAS_PREIMAGE | RR_HAS_POSTIMAGE ; struct rerere_id vid = * id ; if ( ( rr_dir -> status [ variant ] & both ) != both ) continue ; vid . variant = variant ; if ( merge ( istate , & vid , path ) ) continue ; if ( 0 <= id -> variant && id -> variant != variant ) remove_variant ( id ) ; if ( rerere_autoupdate ) string_list_insert ( update , path ) ; else fprintf_ln ( stderr , _ ( " " ) , path ) ; free_rerere_id ( rr_item ) ; rr_item -> util = NULL ; return ; } assign_variant ( id ) ; variant = id -> variant ; handle_file ( istate , path , NULL , rerere_path ( id , " " ) ) ; if ( id -> collection -> status [ variant ] & RR_HAS_POSTIMAGE ) { const char * path = rerere_path ( id , " " ) ; if ( unlink ( path ) ) die_errno ( _ ( " " ) , path ) ; id -> collection -> status [ variant ] &= ~ RR_HAS_POSTIMAGE ; } id -> collection -> status [ variant ] |= RR_HAS_PREIMAGE ; fprintf_ln ( stderr , _ ( " " ) , path ) ; }
The path indicated by rr_item may still have conflict for which we
 have a recorded resolution, in which case replay it and optionally
 update it.
The path indicated by rr_item may still have conflict for which we have a recorded resolution in which case replay it and optionally update it .
/* Has the user resolved it already? */ /*
		 * There may be other variants that can cleanly
		 * replay.  Try them and update the variant number for
		 * this one.
		 */ /* Does any existing resolution apply cleanly? */ /* failed to replay */ /*
		 * If there already is a different variant that applies
		 * cleanly, there is no point maintaining our own variant.
		 */ /* None of the existing one applies; we need a new variant */