mirror of
https://github.com/git/git
synced 2024-10-30 04:01:21 +00:00
builtin/apply: make create_file() return -1 on error
To libify `git apply` functionality we have to signal errors to the caller instead of exit()ing. To do that in a compatible manner with the rest of the error handling in "builtin/apply.c", create_file() should just return what add_conflicted_stages_file() and add_index_file() are returning instead of calling exit(). Signed-off-by: Christian Couder <chriscool@tuxfamily.org> Signed-off-by: Junio C Hamano <gitster@pobox.com>
This commit is contained in:
parent
69e1609f81
commit
8f5b5445d7
1 changed files with 13 additions and 12 deletions
|
@ -4269,7 +4269,7 @@ static int add_conflicted_stages_file(struct apply_state *state,
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void create_file(struct apply_state *state, struct patch *patch)
|
static int create_file(struct apply_state *state, struct patch *patch)
|
||||||
{
|
{
|
||||||
char *path = patch->new_name;
|
char *path = patch->new_name;
|
||||||
unsigned mode = patch->new_mode;
|
unsigned mode = patch->new_mode;
|
||||||
|
@ -4280,13 +4280,10 @@ static void create_file(struct apply_state *state, struct patch *patch)
|
||||||
mode = S_IFREG | 0644;
|
mode = S_IFREG | 0644;
|
||||||
create_one_file(state, path, mode, buf, size);
|
create_one_file(state, path, mode, buf, size);
|
||||||
|
|
||||||
if (patch->conflicted_threeway) {
|
if (patch->conflicted_threeway)
|
||||||
if (add_conflicted_stages_file(state, patch))
|
return add_conflicted_stages_file(state, patch);
|
||||||
exit(128);
|
else
|
||||||
} else {
|
return add_index_file(state, path, mode, buf, size);
|
||||||
if (add_index_file(state, path, mode, buf, size))
|
|
||||||
exit(128);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* phase zero is to remove, phase one is to create */
|
/* phase zero is to remove, phase one is to create */
|
||||||
|
@ -4302,8 +4299,10 @@ static void write_out_one_result(struct apply_state *state,
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (patch->is_new > 0 || patch->is_copy) {
|
if (patch->is_new > 0 || patch->is_copy) {
|
||||||
if (phase == 1)
|
if (phase == 1) {
|
||||||
create_file(state, patch);
|
if (create_file(state, patch))
|
||||||
|
exit(128);
|
||||||
|
}
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
/*
|
/*
|
||||||
|
@ -4314,8 +4313,10 @@ static void write_out_one_result(struct apply_state *state,
|
||||||
if (remove_file(state, patch, patch->is_rename))
|
if (remove_file(state, patch, patch->is_rename))
|
||||||
exit(128);
|
exit(128);
|
||||||
}
|
}
|
||||||
if (phase == 1)
|
if (phase == 1) {
|
||||||
create_file(state, patch);
|
if (create_file(state, patch))
|
||||||
|
exit(128);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static int write_out_one_reject(struct apply_state *state, struct patch *patch)
|
static int write_out_one_reject(struct apply_state *state, struct patch *patch)
|
||||||
|
|
Loading…
Reference in a new issue