From: Christian Couder Date: Sun, 24 Apr 2016 13:34:09 GMT Subject: [PATCH 69/83] builtin/apply: make add_conflicted_stages_file() return -1 on error Message-ID: <1461504863-15946-70-git-send-email-chriscool@tuxfamily.org> In-Reply-To: <1461504863-15946-1-git-send-email-chriscool@tuxfamily.org> Signed-off-by: Christian Couder --- builtin/apply.c | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/builtin/apply.c b/builtin/apply.c index 89118c1..5a5be49 100644 --- a/builtin/apply.c +++ b/builtin/apply.c @@ -4210,7 +4210,7 @@ static void create_one_file(struct apply_state *state, 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; @@ -4218,7 +4218,7 @@ static void add_conflicted_stages_file(struct apply_state *state, 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); @@ -4234,8 +4234,11 @@ static void add_conflicted_stages_file(struct apply_state *state, 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); + 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) @@ -4249,9 +4252,10 @@ 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(1); + } else add_index_file(state, path, mode, buf, size); } -- 2.8.1.300.g5fed0c0