Signed-off-by: Christian Couder <chrisc...@tuxfamily.org>
---
 builtin/apply.c | 38 ++++++++++++++++----------------------
 1 file changed, 16 insertions(+), 22 deletions(-)

diff --git a/builtin/apply.c b/builtin/apply.c
index ebac9ee..dae89e2 100644
--- a/builtin/apply.c
+++ b/builtin/apply.c
@@ -4271,36 +4271,29 @@ static int create_file(struct apply_state *state, 
struct patch *patch)
 }
 
 /* phase zero is to remove, phase one is to create */
-static void write_out_one_result(struct apply_state *state,
-                                struct patch *patch,
-                                int phase)
+static int write_out_one_result(struct apply_state *state,
+                               struct patch *patch,
+                               int phase)
 {
        if (patch->is_delete > 0) {
-               if (phase == 0) {
-                       if (remove_file(state, patch, 1))
-                               exit(1);
-               }
-               return;
+               if (phase == 0)
+                       return remove_file(state, patch, 1);
+               return 0;
        }
        if (patch->is_new > 0 || patch->is_copy) {
-               if (phase == 1) {
-                       if (create_file(state, patch))
-                               exit(1);
-               }
-               return;
+               if (phase == 1)
+                       return create_file(state, patch);
+               return 0;
        }
        /*
         * Rename or modification boils down to the same
         * thing: remove the old, write the new
         */
-       if (phase == 0) {
-               if (remove_file(state, patch, patch->is_rename))
-                       exit(1);
-       }
-       if (phase == 1) {
-               if (create_file(state, patch))
-                       exit(1);
-       }
+       if (phase == 0)
+               return remove_file(state, patch, patch->is_rename);
+       if (phase == 1)
+               return create_file(state, patch);
+       return 0;
 }
 
 static int write_out_one_reject(struct apply_state *state, struct patch *patch)
@@ -4387,7 +4380,8 @@ static int write_out_results(struct apply_state *state, 
struct patch *list)
                        if (l->rejected)
                                errs = 1;
                        else {
-                               write_out_one_result(state, l, phase);
+                               if (write_out_one_result(state, l, phase))
+                                       exit(1);
                                if (phase == 1) {
                                        if (write_out_one_reject(state, l))
                                                errs = 1;
-- 
2.8.1.300.g5fed0c0

--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Reply via email to