Subject: Re: [PATCH 26/48] merge-recursive: Allow make_room_for_path() to remove D/F entries

From: Johannes Sixt <[email-masked]>
Date: Wed, 13 Jul 2011 09:17:57 +0200

Am 6/8/2011 9:30, schrieb Elijah Newren:
> +static int make_room_for_path(const struct merge_options *o, const char *path)
>  {
> -	int status;
> +	int status, i;
>  	const char *msg = "failed to create path '%s'%s";
>  
> +	/* Unlink any D/F conflict files that are in the way */
> +	for (i = 0; i < o->df_conflict_file_set.nr; i++) {
> +		const char *df_path = o->df_conflict_file_set.items[i].string;
> +		size_t pathlen = strlen(path);
> +		size_t df_pathlen = strlen(df_path);
> +		if (df_pathlen < pathlen && strncmp(path, df_path, df_pathlen) == 0) {
> +			unlink(df_path);
> +			break;
> +		}
> +	}

Each time this loop is entered it tries to remove the same path again,
even if it does not exist anymore or was morphed into a directory in the
meantime. I suggest to remove a path from o->df_conflict_file_set after it
was unlinked. Or even better: have a separate "make room" phase somewhere
in the merge process.

-- Hannes