die_errno(_("unable to write file '%s' mode %o"), path, mode);
}
-static void add_conflicted_stages_file(struct apply_state *state,
+static int add_conflicted_stages_file(struct apply_state *state,
struct patch *patch)
{
int stage, namelen;
struct cache_entry *ce;
if (!state->update_index)
- return;
+ return 0;
namelen = strlen(patch->new_name);
ce_size = cache_entry_size(namelen);
mode = patch->new_mode ? patch->new_mode : (S_IFREG | 0644);
ce->ce_flags = create_ce_flags(stage);
ce->ce_namelen = namelen;
hashcpy(ce->sha1, patch->threeway_stage[stage - 1].hash);
- if (add_cache_entry(ce, ADD_CACHE_OK_TO_ADD) < 0)
- die(_("unable to add cache entry for %s"), patch->new_name);
+ if (add_cache_entry(ce, ADD_CACHE_OK_TO_ADD) < 0) {
+ free(ce);
+ return error(_("unable to add cache entry for %s"),
+ patch->new_name);
+ }
}
+
+ return 0;
}
static void create_file(struct apply_state *state, struct patch *patch)
mode = S_IFREG | 0644;
create_one_file(state, path, mode, buf, size);
- if (patch->conflicted_threeway)
- add_conflicted_stages_file(state, patch);
- else
+ if (patch->conflicted_threeway) {
+ if (add_conflicted_stages_file(state, patch))
+ exit(128);
+ } else
add_index_file(state, path, mode, buf, size);
}