* Returns: * -1 if an error happened * 0 if the patch applied cleanly * 1 if the patch did not apply cleanly */
| 4808 | * 1 if the patch did not apply cleanly |
| 4809 | */ |
| 4810 | static int write_out_results(struct apply_state *state, struct patch *list) |
| 4811 | { |
| 4812 | int phase; |
| 4813 | int errs = 0; |
| 4814 | struct patch *l; |
| 4815 | struct string_list cpath = STRING_LIST_INIT_DUP; |
| 4816 | |
| 4817 | for (phase = 0; phase < 2; phase++) { |
| 4818 | l = list; |
| 4819 | while (l) { |
| 4820 | if (l->rejected) |
| 4821 | errs = 1; |
| 4822 | else { |
| 4823 | if (write_out_one_result(state, l, phase)) { |
| 4824 | string_list_clear(&cpath, 0); |
| 4825 | return -1; |
| 4826 | } |
| 4827 | if (phase == 1) { |
| 4828 | if (write_out_one_reject(state, l)) |
| 4829 | errs = 1; |
| 4830 | if (l->conflicted_threeway) { |
| 4831 | string_list_append(&cpath, l->new_name); |
| 4832 | errs = 1; |
| 4833 | } |
| 4834 | } |
| 4835 | } |
| 4836 | l = l->next; |
| 4837 | } |
| 4838 | } |
| 4839 | |
| 4840 | if (cpath.nr) { |
| 4841 | struct string_list_item *item; |
| 4842 | |
| 4843 | string_list_sort(&cpath); |
| 4844 | if (state->apply_verbosity > verbosity_silent) { |
| 4845 | for_each_string_list_item(item, &cpath) |
| 4846 | fprintf(stderr, "U %s\n", item->string); |
| 4847 | } |
| 4848 | string_list_clear(&cpath, 0); |
| 4849 | |
| 4850 | /* |
| 4851 | * rerere relies on the partially merged result being in the working |
| 4852 | * tree with conflict markers, but that isn't written with --cached. |
| 4853 | */ |
| 4854 | if (!state->cached) |
| 4855 | repo_rerere(state->repo, 0); |
| 4856 | } |
| 4857 | |
| 4858 | return errs; |
| 4859 | } |
| 4860 | |
| 4861 | /* |
| 4862 | * Try to apply a patch. |
no test coverage detected