Re: [PATCH 26/48] merge-recursive: Allow make_room_for_path() to remove D/F entries
- From
Johannes Sixt <j.sixt@viscovery.net>
- Date
- Jul 13, 2011, 07:17 UTC
- Message-ID
- <4E1D46A5.6050904@viscovery.net>
- In-Reply-To
- <1307518278-23814-27-git-send-email-newren@gmail.com>
Am 6/8/2011 9:30, schrieb Elijah Newren:
Show 16 quoted lines
> +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