[PATCH v10 19/40] builtin/apply: make build_fake_ancestor() return -1 on error

2016-08-08 Thread Christian Couder
To libify `git apply` functionality we have to signal errors to the caller instead of die()ing. To do that in a compatible manner with the rest of the error handling in "builtin/apply.c", build_fake_ancestor() should return -1 instead of calling die(). Helped-by: Eric Sunshine Sig

[PATCH v10 18/40] builtin/apply: change die_on_unsafe_path() to check_unsafe_path()

2016-08-08 Thread Christian Couder
To libify `git apply` functionality we have to signal errors to the caller instead of die()ing. To do that in a compatible manner with the rest of the error handling in "builtin/apply.c", die_on_unsafe_path() should return a negative integer instead of calling die(), so while doing

[PATCH v10 35/40] apply: don't print on stdout in verbosity_silent mode

2016-08-08 Thread Christian Couder
When apply_verbosity is set to verbosity_silent nothing should be printed on both stderr and stdout. To avoid printing on stdout, we can just skip calling the following functions: - stat_patch_list(), - numstat_patch_list(), - summary_patch_list(). It is safe to do that b

[PATCH v10 01/40] apply: make some names more specific

2016-08-08 Thread Christian Couder
To prepare for some structs and constants being moved from builtin/apply.c to apply.h, we should give them some more specific names to avoid possible name collisions in th global namespace. Signed-off-by: Christian Couder --- builtin/apply.c | 20 ++-- 1 file changed, 10 insertio

[PATCH v10 14/40] builtin/apply: make apply_all_patches() return 128 or 1 on error

2016-08-08 Thread Christian Couder
To finish libifying the apply functionality, apply_all_patches() should not die() or exit() in case of error, but return either 128 or 1, so that it gives the same exit code as when die() or exit(1) is called. This way scripts relying on the exit code don't need to be changed. While doing th

[PATCH v10 28/40] builtin/apply: rename option parsing functions

2016-08-08 Thread Christian Couder
As these functions are going to be part of the libified apply api, let's give them a name that is more specific to the apply api. Signed-off-by: Christian Couder --- builtin/apply.c | 40 1 file changed, 20 insertions(+), 20 deletions(-) diff --

[PATCH v10 15/40] builtin/apply: make parse_traditional_patch() return -1 on error

2016-08-08 Thread Christian Couder
To libify `git apply` functionality we have to signal errors to the caller instead of die()ing. To do that in a compatible manner with the rest of the error handling in "builtin/apply.c", parse_traditional_patch() should return -1 instead of calling die(). Signed-off-by: Christ

[PATCH v10 31/40] apply: make some parsing functions static again

2016-08-08 Thread Christian Couder
Some parsing functions that were used in both "apply.c" and "builtin/apply.c" are now only used in the former, so they can be made static to "apply.c". Signed-off-by: Christian Couder --- apply.c | 6 +++--- apply.h | 5 - 2 files changed, 3 insertions(+), 8 deletions(-) diff --git a/apply.

[PATCH v10 25/40] builtin/apply: make write_out_results() return -1 on error

2016-08-08 Thread Christian Couder
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", write_out_results() should return -1 instead of calling exit(). Helped-by: Eric Sunshine Sig

[PATCH v10 13/40] builtin/apply: move check_apply_state() to apply.c

2016-08-08 Thread Christian Couder
To libify `git apply` functionality we must make check_apply_state() usable outside "builtin/apply.c". Let's do that by moving it into "apply.c". Signed-off-by: Christian Couder --- apply.c | 32 apply.h |

[PATCH v10 17/40] builtin/apply: make gitdiff_*() return -1 on error

2016-08-08 Thread Christian Couder
To libify `git apply` functionality we have to signal errors to the caller instead of die()ing. To do that in a compatible manner with the rest of the error handling in "builtin/apply.c", gitdiff_*() functions should return -1 instead of calling die(). A previous patch made it po

[PATCH v10 07/40] builtin/apply: make parse_single_patch() return -1 on error

2016-08-08 Thread Christian Couder
To libify `git apply` functionality we have to signal errors to the caller instead of die()ing. To do that in a compatible manner with the rest of the error handling in builtin/apply.c, parse_single_patch() should return a negative integer instead of calling die(). Let's do that by using

[PATCH v10 20/40] builtin/apply: make remove_file() return -1 on error

2016-08-08 Thread Christian Couder
To libify `git apply` functionality we have to signal errors to the caller instead of die()ing. To do that in a compatible manner with the rest of the error handling in "builtin/apply.c", remove_file() should return -1 instead of calling die(). Signed-off-by: Christian Couder --

[PATCH v10 11/40] apply: make init_apply_state() return -1 instead of exit()ing

2016-08-08 Thread Christian Couder
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", init_apply_state() should return -1 instead of calling exit(). Signed-off-by: Christ

[PATCH v10 23/40] builtin/apply: make create_file() return -1 on error

2016-08-08 Thread Christian Couder
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

[PATCH v10 21/40] builtin/apply: make add_conflicted_stages_file() return -1 on error

2016-08-08 Thread Christian Couder
To libify `git apply` functionality we have to signal errors to the caller instead of die()ing. To do that in a compatible manner with the rest of the error handling in "builtin/apply.c", add_conflicted_stages_file() should return -1 instead of calling die(). Helped-by: Eric Sunshine

[PATCH v10 06/40] builtin/apply: make parse_chunk() return a negative integer on error

2016-08-08 Thread Christian Couder
To libify `git apply` functionality we have to signal errors to the caller instead of die()ing or exit()ing. To do that in a compatible manner with the rest of the error handling in builtin/apply.c, parse_chunk() should return a negative integer instead of calling die() or exit(). As parse_chunk

[PATCH v10 03/40] builtin/apply: make apply_patch() return -1 or -128 instead of die()ing

2016-08-08 Thread Christian Couder
To libify `git apply` functionality we have to signal errors to the caller instead of die()ing. As a first step in this direction, let's make apply_patch() return -1 or -128 in case of errors instead of dying. For now its only caller apply_all_patches() will exit(128) when apply_patch() r

[PATCH v10 09/40] builtin/apply: make parse_ignorewhitespace_option() return -1 instead of die()ing

2016-08-08 Thread Christian Couder
To libify `git apply` functionality we have to signal errors to the caller instead of die()ing. To do that in a compatible manner with the rest of the error handling in "builtin/apply.c", parse_ignorewhitespace_option() should return -1 instead of calling die(). Signed-off-by: Christ

[PATCH v10 05/40] builtin/apply: make find_header() return -128 instead of die()ing

2016-08-08 Thread Christian Couder
To libify `git apply` functionality we have to signal errors to the caller instead of die()ing. To do that in a compatible manner with the rest of the error handling in builtin/apply.c, let's make find_header() return -128 instead of calling die(). We could make it return -1, unfortun

[PATCH v10 02/40] apply: move 'struct apply_state' to apply.h

2016-08-08 Thread Christian Couder
To libify `git apply` functionality we must make 'struct apply_state' usable outside "builtin/apply.c". Let's do that by creating a new "apply.h" and moving 'struct apply_state' there. Signed-off-by:

[PATCH v10 12/40] builtin/apply: make check_apply_state() return -1 instead of die()ing

2016-08-08 Thread Christian Couder
To libify `git apply` functionality we have to signal errors to the caller instead of die()ing. To do that in a compatible manner with the rest of the error handling in "builtin/apply.c", check_apply_state() should return -1 instead of calling die(). Signed-off-by: Christian Couder --

[PATCH v10 22/40] builtin/apply: make add_index_file() return -1 on error

2016-08-08 Thread Christian Couder
To libify `git apply` functionality we have to signal errors to the caller instead of die()ing. To do that in a compatible manner with the rest of the error handling in "builtin/apply.c", add_index_file() should return -1 instead of calling die(). Signed-off-by: Christian Couder --

[PATCH v10 10/40] builtin/apply: move init_apply_state() to apply.c

2016-08-08 Thread Christian Couder
To libify `git apply` functionality we must make init_apply_state() usable outside "builtin/apply.c". Let's do that by moving it into a new "apply.c". Helped-by: Eric Sunshine Signed-off-by: Christian Couder --- Makefile|

[PATCH v10 04/40] builtin/apply: read_patch_file() return -1 instead of die()ing

2016-08-08 Thread Christian Couder
To libify `git apply` functionality we have to signal errors to the caller instead of die()ing. Let's do that by returning -1 instead of die()ing in read_patch_file(). Helped-by: Stefan Beller Signed-off-by: Christian Couder --- builtin/apply.c | 8 +--- 1 file changed, 5 insertions(

[PATCH v10 00/40] libify apply and use lib in am, part 2

2016-08-08 Thread Christian Couder
Goal This is a patch series about libifying `git apply` functionality, and using this libified functionality in `git am`, so that no 'git apply' process is spawn anymore. This makes `git am` significantly faster, so `git rebase`, when it uses the am backend, is also significan

Re: [PATCH v9 39/41] apply: change error_routine when silent

2016-08-08 Thread Christian Couder
On Mon, Aug 1, 2016 at 6:58 PM, Stefan Beller wrote: > On Sat, Jul 30, 2016 at 10:25 AM, Christian Couder > wrote: >> + /* This is to save some reporting routines */ > > some? > > In case of a reroll could you be more specific? > Specifically mention that we use these for the > muting/when

Re: [PATCH] apply: mark some file-local symbols static

2016-08-07 Thread Christian Couder
Hi Dscho, On Wed, Aug 3, 2016 at 4:37 PM, Johannes Schindelin wrote: > Hi Christian, > > On Wed, 3 Aug 2016, Christian Couder wrote: > >> Now there are different options to fix this: >> >> 1) remove the symbols in 9f87c22 ("apply: refactor `git apply` option &g

Re: [PATCH] apply: mark some file-local symbols static

2016-08-03 Thread Johannes Schindelin
Hi Christian, On Wed, 3 Aug 2016, Christian Couder wrote: > Now there are different options to fix this: > > 1) remove the symbols in 9f87c22 ("apply: refactor `git apply` option > parsing") at the end of the series, or > 2) move 4820e13 (apply: make some parsing f

Re: [PATCH] apply: mark some file-local symbols static

2016-08-03 Thread Ramsay Jones
i Christian, >>> [snip] >>> What am I missing? > > These symbols are still used in builtin/apply.c until 9f87c22 ("apply: > refactor `git apply` option parsing") at the end of the series, for > example: > > $ git checkout 4

Re: [PATCH] apply: mark some file-local symbols static

2016-08-03 Thread Christian Couder
Hi Ramsay, On Wed, Aug 3, 2016 at 12:44 AM, Junio C Hamano wrote: > On Tue, Aug 2, 2016 at 3:33 PM, Ramsay Jones > wrote: >> >> Signed-off-by: Ramsay Jones >> --- >> >> Hi Christian, >> >> I had intended to ask you to squash this into your '

[PATCH] apply: mark some file-local symbols static

2016-08-02 Thread Ramsay Jones
Signed-off-by: Ramsay Jones --- Hi Christian, I had intended to ask you to squash this into your 'cc/apply-am' branch, specifically commit 4d18b33a (apply: move libified code from builtin/apply.c to apply.{c,h}, 30-07-2016). However, having read that commit a little closer, it seem

Re: [PATCH] apply: mark some file-local symbols static

2016-08-02 Thread Junio C Hamano
On Tue, Aug 2, 2016 at 3:33 PM, Ramsay Jones wrote: > > Signed-off-by: Ramsay Jones > --- > > Hi Christian, > > I had intended to ask you to squash this into your 'cc/apply-am' > branch, specifically commit 4d18b33a (apply: move libified code > from built

Re: [PATCH v9 00/41] libify apply and use lib in am, part 2

2016-08-01 Thread Junio C Hamano
Christian Couder writes: > On Sat, Jul 30, 2016 at 7:24 PM, Christian Couder > wrote: >> >> I will send a diff between this version and the previous one, as a >> reply to this email. > > Here is the diff: The "verbosity" bits, and also deduplication of parse_options, are both welcome changes.

Re: [PATCH v9 35/41] apply: make it possible to silently apply

2016-08-01 Thread Junio C Hamano
Christian Couder writes: > +enum apply_verbosity { > + verbosity_silent = -1, > + verbosity_normal = 0, > + verbosity_verbose = 1, Drop the trailing comma from the last element in enum definition (comma after the last element in an array is OK). -- To unsubscribe from this list: send

Re: [PATCH v9 39/41] apply: change error_routine when silent

2016-08-01 Thread Stefan Beller
On Sat, Jul 30, 2016 at 10:25 AM, Christian Couder wrote: > + /* This is to save some reporting routines */ some? In case of a reroll could you be more specific? Specifically mention that we use these for the muting/when silence is requested. e.g. /* These control reporting routines, and a

Re: [PATCH v9 03/41] builtin/apply: make apply_patch() return -1 or -128 instead of die()ing

2016-08-01 Thread Stefan Beller
On Sat, Jul 30, 2016 at 10:24 AM, Christian Couder wrote: > + * Try to apply a patch. > + * > + * Returns: > + * -128 if a bad error happened (like patch unreadable) > + * -1 if patch did not apply and user cannot deal with it > + * 0 if the patch applied > + * 1 if th

Re: [PATCH v9 04/41] builtin/apply: read_patch_file() return -1 instead of die()ing

2016-08-01 Thread Stefan Beller
On Sat, Jul 30, 2016 at 10:24 AM, Christian Couder wrote: > -static void read_patch_file(struct strbuf *sb, int fd) > +static int read_patch_file(struct strbuf *sb, int fd) > { > if (strbuf_read(sb, fd, 0) < 0) > - die_errno("gi

Re: [PATCH v9 00/41] libify apply and use lib in am, part 2

2016-07-30 Thread Christian Couder
,8 @@ int check_apply_state(struct apply_state *state, int force_apply) } if (state->apply_with_reject) { state->apply = 1; -if (!state->be_silent) -state->apply_verbosely = 1; +if (state->apply_verbosity == verbosity_normal) +

[PATCH v9 08/41] builtin/apply: make parse_whitespace_option() return -1 instead of die()ing

2016-07-30 Thread Christian Couder
To libify `git apply` functionality we have to signal errors to the caller instead of die()ing. To do that in a compatible manner with the rest of the error handling in builtin/apply.c, parse_whitespace_option() should return -1 instead of calling die(). Signed-off-by: Christian Couder

[PATCH v9 11/41] apply: make init_apply_state() return -1 instead of exit()ing

2016-07-30 Thread Christian Couder
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", init_apply_state() should return -1 instead of calling exit(). Signed-off-by: Christ

[PATCH v9 09/41] builtin/apply: make parse_ignorewhitespace_option() return -1 instead of die()ing

2016-07-30 Thread Christian Couder
To libify `git apply` functionality we have to signal errors to the caller instead of die()ing. To do that in a compatible manner with the rest of the error handling in "builtin/apply.c", parse_ignorewhitespace_option() should return -1 instead of calling die(). Signed-off-by: Christ

Re: [PATCH v8 00/41] libify apply and use lib in am, part 2

2016-07-30 Thread Christian Couder
On Wed, Jul 27, 2016 at 6:24 PM, Junio C Hamano wrote: > Christian Couder writes: > >>> The early part up to and including "apply: make some parsing >>> functions static again" looked good and we could treat them as a >>> continuation of the earlier cc

[PATCH v9 13/41] builtin/apply: move check_apply_state() to apply.c

2016-07-30 Thread Christian Couder
To libify `git apply` functionality we must make check_apply_state() usable outside "builtin/apply.c". Let's do that by moving it into "apply.c". Signed-off-by: Christian Couder --- apply.c | 32 apply.h |

[PATCH v9 12/41] builtin/apply: make check_apply_state() return -1 instead of die()ing

2016-07-30 Thread Christian Couder
To libify `git apply` functionality we have to signal errors to the caller instead of die()ing. To do that in a compatible manner with the rest of the error handling in "builtin/apply.c", check_apply_state() should return -1 instead of calling die(). Signed-off-by: Christian Couder --

[PATCH v9 10/41] builtin/apply: move init_apply_state() to apply.c

2016-07-30 Thread Christian Couder
To libify `git apply` functionality we must make init_apply_state() usable outside "builtin/apply.c". Let's do that by moving it into a new "apply.c". Helped-by: Eric Sunshine Signed-off-by: Christian Couder --- Makefile|

[PATCH v9 14/41] builtin/apply: make apply_all_patches() return 128 or 1 on error

2016-07-30 Thread Christian Couder
To finish libifying the apply functionality, apply_all_patches() should not die() or exit() in case of error, but return either 128 or 1, so that it gives the same exit code as when die() or exit(1) is called. This way scripts relying on the exit code don't need to be changed. While doing th

[PATCH v9 15/41] builtin/apply: make parse_traditional_patch() return -1 on error

2016-07-30 Thread Christian Couder
To libify `git apply` functionality we have to signal errors to the caller instead of die()ing. To do that in a compatible manner with the rest of the error handling in "builtin/apply.c", parse_traditional_patch() should return -1 instead of calling die(). Signed-off-by: Christ

[PATCH v9 36/41] apply: don't print on stdout in verbosity_silent mode

2016-07-30 Thread Christian Couder
When apply_verbosity is set to verbosity_silent nothing should be printed on both stderr and stdout. To avoid printing on stdout, we can just skip calling the following functions: - stat_patch_list(), - numstat_patch_list(), - summary_patch_list(). It is safe to do that b

[PATCH v9 35/41] apply: make it possible to silently apply

2016-07-30 Thread Christian Couder
into 'verbosity_verbose'. The new added state is 'verbosity_silent'. It should prevent anything to be printed on both stderr and stdout. This is needed because `git am` wants to first call apply functionality silently, if it can then fall back on 3-way merge in case of error. Printing

[PATCH v9 39/41] apply: change error_routine when silent

2016-07-30 Thread Christian Couder
To avoid printing anything when applying with `state->apply_verbosity == verbosity_silent`, let's save the existing warn and error routines before applying and replace them with a routine that does nothing. Then after applying, let's restore the saved routines. Signed-off-by: Christian Couder --

[PATCH v9 17/41] builtin/apply: make gitdiff_*() return -1 on error

2016-07-30 Thread Christian Couder
To libify `git apply` functionality we have to signal errors to the caller instead of die()ing. To do that in a compatible manner with the rest of the error handling in "builtin/apply.c", gitdiff_*() functions should return -1 instead of calling die(). A previous patch made it po

[PATCH v9 28/41] builtin/apply: rename option parsing functions

2016-07-30 Thread Christian Couder
As these functions are going to be part of the libified apply api, let's give them a name that is more specific to the apply api. Signed-off-by: Christian Couder --- builtin/apply.c | 40 1 file changed, 20 insertions(+), 20 deletions(-) diff --

[PATCH v9 26/41] builtin/apply: make try_create_file() return -1 on error

2016-07-30 Thread Christian Couder
To libify `git apply` functionality we have to signal errors to the caller instead of die()ing. To do that in a compatible manner with the rest of the error handling in "builtin/apply.c", try_create_file() should return -1 in case of error. Unfortunately try_create_file() currently ret

[PATCH v9 19/41] builtin/apply: make build_fake_ancestor() return -1 on error

2016-07-30 Thread Christian Couder
To libify `git apply` functionality we have to signal errors to the caller instead of die()ing. To do that in a compatible manner with the rest of the error handling in "builtin/apply.c", build_fake_ancestor() should return -1 instead of calling die(). Helped-by: Eric Sunshine Sig

[PATCH v9 31/41] apply: make some parsing functions static again

2016-07-30 Thread Christian Couder
Some parsing functions that were used in both "apply.c" and "builtin/apply.c" are now only used in the former, so they can be made static to "apply.c". Signed-off-by: Christian Couder --- apply.c | 6 +++--- apply.h | 5 - 2 files changed, 3 insertions(+), 8 deletions(-) diff --git a/apply.

[PATCH v9 22/41] builtin/apply: make add_index_file() return -1 on error

2016-07-30 Thread Christian Couder
To libify `git apply` functionality we have to signal errors to the caller instead of die()ing. To do that in a compatible manner with the rest of the error handling in "builtin/apply.c", add_index_file() should return -1 instead of calling die(). Signed-off-by: Christian Couder --

[PATCH v9 32/41] apply: use error_errno() where possible

2016-07-30 Thread Christian Couder
To avoid possible mistakes and to uniformly show the errno related messages, let's use error_errno() where possible. Signed-off-by: Christian Couder --- apply.c | 18 +- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/apply.c b/apply.c index 12cad24..7ccb6b5 100644

[PATCH v9 40/41] apply: refactor `git apply` option parsing

2016-07-30 Thread Christian Couder
Parsing `git apply` options can be useful to other commands that want to call the libified apply functionality, because this way they can easily pass some options from their own command line to the libified apply functionality. This will be used by `git am` in a following patch. To make this

[PATCH v9 41/41] builtin/am: use apply api in run_apply()

2016-07-30 Thread Christian Couder
This replaces run_apply() implementation with a new one that uses the apply api that has been previously prepared in apply.c and apply.h. This shoud improve performance a lot in certain cases. As the previous implementation was creating a new `git apply` process to apply each patch, it could be

[PATCH v9 27/41] builtin/apply: make create_one_file() return -1 on error

2016-07-30 Thread Christian Couder
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_one_file() should return -1 instead of calling exit(). Signed-off-by: Christian Couder --

[PATCH v9 23/41] builtin/apply: make create_file() return -1 on error

2016-07-30 Thread Christian Couder
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

[PATCH v9 21/41] builtin/apply: make add_conflicted_stages_file() return -1 on error

2016-07-30 Thread Christian Couder
To libify `git apply` functionality we have to signal errors to the caller instead of die()ing. To do that in a compatible manner with the rest of the error handling in "builtin/apply.c", add_conflicted_stages_file() should return -1 instead of calling die(). Helped-by: Eric Sunshine

[PATCH v9 25/41] builtin/apply: make write_out_results() return -1 on error

2016-07-30 Thread Christian Couder
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", write_out_results() should return -1 instead of calling exit(). Helped-by: Eric Sunshine Sig

[PATCH v9 29/41] apply: rename and move opt constants to apply.h

2016-07-30 Thread Christian Couder
ly.c index c7e570a..486e5f7 100644 --- a/builtin/apply.c +++ b/builtin/apply.c @@ -4460,9 +4460,6 @@ static int write_out_results(struct apply_state *state, struct patch *list) static struct lock_file lock_file; -#define INACCURATE_EOF (1<<0) -#define RECOUNT(1<<1) - /*

[PATCH v9 18/41] builtin/apply: change die_on_unsafe_path() to check_unsafe_path()

2016-07-30 Thread Christian Couder
To libify `git apply` functionality we have to signal errors to the caller instead of die()ing. To do that in a compatible manner with the rest of the error handling in "builtin/apply.c", die_on_unsafe_path() should return a negative integer instead of calling die(), so while doing

[PATCH v9 24/41] builtin/apply: make write_out_one_result() return -1 on error

2016-07-30 Thread Christian Couder
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", write_out_one_result() should just return what remove_file() and create_file() are returning

[PATCH v9 20/41] builtin/apply: make remove_file() return -1 on error

2016-07-30 Thread Christian Couder
To libify `git apply` functionality we have to signal errors to the caller instead of die()ing. To do that in a compatible manner with the rest of the error handling in "builtin/apply.c", remove_file() should return -1 instead of calling die(). Signed-off-by: Christian Couder --

[PATCH v9 16/41] builtin/apply: make gitdiff_*() return 1 at end of header

2016-07-30 Thread Christian Couder
The gitdiff_*() functions that are called as p->fn() in parse_git_header() should return 1 instead of -1 in case of end of header or unrecognized input, as these are not real errors. It just instructs the parser to break out. This makes it possible for gitdiff_*() functions to return -1 in case of

[PATCH v9 01/41] apply: make some names more specific

2016-07-30 Thread Christian Couder
To prepare for some structs and constants being moved from builtin/apply.c to apply.h, we should give them some more specific names to avoid possible name collisions in th global namespace. Signed-off-by: Christian Couder --- builtin/apply.c | 20 ++-- 1 file changed, 10 insertio

[PATCH v9 05/41] builtin/apply: make find_header() return -128 instead of die()ing

2016-07-30 Thread Christian Couder
To libify `git apply` functionality we have to signal errors to the caller instead of die()ing. To do that in a compatible manner with the rest of the error handling in builtin/apply.c, let's make find_header() return -128 instead of calling die(). We could make it return -1, unfortun

[PATCH v9 06/41] builtin/apply: make parse_chunk() return a negative integer on error

2016-07-30 Thread Christian Couder
To libify `git apply` functionality we have to signal errors to the caller instead of die()ing or exit()ing. To do that in a compatible manner with the rest of the error handling in builtin/apply.c, parse_chunk() should return a negative integer instead of calling die() or exit(). As parse_chunk

[PATCH v9 04/41] builtin/apply: read_patch_file() return -1 instead of die()ing

2016-07-30 Thread Christian Couder
To libify `git apply` functionality we have to signal errors to the caller instead of die()ing. Let's do that by returning -1 instead of die()ing in read_patch_file(). Signed-off-by: Christian Couder --- builtin/apply.c | 8 +--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --

[PATCH v9 03/41] builtin/apply: make apply_patch() return -1 or -128 instead of die()ing

2016-07-30 Thread Christian Couder
To libify `git apply` functionality we have to signal errors to the caller instead of die()ing. As a first step in this direction, let's make apply_patch() return -1 or -128 in case of errors instead of dying. For now its only caller apply_all_patches() will exit(128) when apply_patch() r

[PATCH v9 07/41] builtin/apply: make parse_single_patch() return -1 on error

2016-07-30 Thread Christian Couder
To libify `git apply` functionality we have to signal errors to the caller instead of die()ing. To do that in a compatible manner with the rest of the error handling in builtin/apply.c, parse_single_patch() should return a negative integer instead of calling die(). Let's do that by using

[PATCH v9 02/41] apply: move 'struct apply_state' to apply.h

2016-07-30 Thread Christian Couder
To libify `git apply` functionality we must make 'struct apply_state' usable outside "builtin/apply.c". Let's do that by creating a new "apply.h" and moving 'struct apply_state' there. Signed-off-by:

[PATCH v9 00/41] libify apply and use lib in am, part 2

2016-07-30 Thread Christian Couder
Goal This is a patch series about libifying `git apply` functionality, and using this libified functionality in `git am`, so that no 'git apply' process is spawn anymore. This makes `git am` significantly faster, so `git rebase`, when it uses the am backend, is also significan

Re: [PATCH v8 00/41] libify apply and use lib in am, part 2

2016-07-27 Thread Junio C Hamano
Christian Couder writes: >> I finally found time to get back to finish reviewing this. > > Great, thanks! No, thank _you_ for working on this. >> The early part up to and including "apply: make some parsing >> functions static again" looked good and we could

Re: [PATCH v8 00/41] libify apply and use lib in am, part 2

2016-07-26 Thread Christian Couder
On Tue, Jul 26, 2016 at 11:18 PM, Junio C Hamano wrote: > Christian Couder writes: > >> Sorry if this patch series is still long. I can split it into two or >> more series if it is prefered. >> ... >> Christian Couder (41): >> apply: make some names mo

Re: [PATCH v8 00/41] libify apply and use lib in am, part 2

2016-07-26 Thread Junio C Hamano
Christian Couder writes: > Sorry if this patch series is still long. I can split it into two or > more series if it is prefered. > ... > Christian Couder (41): > apply: make some names more specific > apply: move 'struct apply_state' to apply.h > builtin/appl

Re: [PATCH v8 40/41] builtin/am: use apply api in run_apply()

2016-07-26 Thread Junio C Hamano
N_("ignore changes in whitespace when finding context"), > + PARSE_OPT_NOARG, apply_option_parse_space_change }, > + { OPTION_CALLBACK, 0, "directory", &apply_state, N_("root"), > + N_("prepend to all filenames"), >

Re: [PATCH v8 36/41] apply: don't print on stdout when be_silent is set

2016-07-26 Thread Junio C Hamano
Christian Couder writes: > This variable should prevent anything to be printed on both stderr > and stdout. You have to mention that skipping the entire callchain, not just the "printing" part, is safe. I can see numstat_patch_list() is probably safe as it does not do any computation other than

Re: [PATCH v8 35/41] apply: make 'be_silent' incompatible with 'apply_verbosely'

2016-07-26 Thread Junio C Hamano
Christian Couder writes: > It should be an error to have both be_silent and apply_verbosely set, > so let's check that in check_apply_state(). Doesn't that suggest that we do not want to have a new be_silent field at all? Perhaps we used to have apply_verbosely = resulting in only two verbosit

Re: [PATCH v8 34/41] apply: add 'be_silent' variable to 'struct apply_state'

2016-07-26 Thread Junio C Hamano
apply_one_fragment(struct apply_state *state, >* Warn if it was necessary to reduce the number >* of context lines. > */ > - if ((leading != frag->leading) || > - (trailing != frag->trailing)) > +

Re: [PATCH] builtin/apply: include declaration of cmd_apply()

2016-06-30 Thread Christian Couder
Hi Ramsay, On Thu, Jun 30, 2016 at 3:47 AM, Ramsay Jones wrote: > > Hi Christian, > > If you need to re-roll your 'cc/apply-am' branch, could you please > squash this into the relevant patch. Commit 95a3b0ba ("apply: move > libified code from builtin/ap

[PATCH] builtin/apply: include declaration of cmd_apply()

2016-06-29 Thread Ramsay Jones
Signed-off-by: Ramsay Jones --- Hi Christian, If you need to re-roll your 'cc/apply-am' branch, could you please squash this into the relevant patch. Commit 95a3b0ba ("apply: move libified code from builtin/apply.c to apply.{c,h}", 22-04-2016) removed this '#include

Re: [PATCH v8 00/41] libify apply and use lib in am, part 2

2016-06-27 Thread Christian Couder
if (!patchsize) { static const char git_binary[] = "GIT binary patch\n"; @@ -2172,8 +2177,10 @@ static int parse_chunk(struct apply_state *state, char *buffer, unsigned long si * empty to us here. */ if ((state->apply |

[PATCH v8 17/41] builtin/apply: make gitdiff_*() return -1 on error

2016-06-27 Thread Christian Couder
To libify `git apply` functionality we have to signal errors to the caller instead of die()ing. To do that in a compatible manner with the rest of the error handling in "builtin/apply.c", gitdiff_*() functions should return -1 instead of calling die(). A previous patch made it po

[PATCH v8 10/41] builtin/apply: move init_apply_state() to apply.c

2016-06-27 Thread Christian Couder
To libify `git apply` functionality we must make init_apply_state() usable outside "builtin/apply.c". Let's do that by moving it into a new "apply.c". Helped-by: Eric Sunshine Signed-off-by: Christian Couder --- Makefile|

[PATCH v8 18/41] builtin/apply: change die_on_unsafe_path() to check_unsafe_path()

2016-06-27 Thread Christian Couder
To libify `git apply` functionality we have to signal errors to the caller instead of die()ing. To do that in a compatible manner with the rest of the error handling in "builtin/apply.c", die_on_unsafe_path() should return a negative integer instead of calling die(), so while doing

[PATCH v8 05/41] builtin/apply: make find_header() return -128 instead of die()ing

2016-06-27 Thread Christian Couder
To libify `git apply` functionality we have to signal errors to the caller instead of die()ing. To do that in a compatible manner with the rest of the error handling in builtin/apply.c, let's make find_header() return -128 instead of calling die(). We could make it return -1, unfortun

[PATCH v8 07/41] builtin/apply: make parse_single_patch() return -1 on error

2016-06-27 Thread Christian Couder
To libify `git apply` functionality we have to signal errors to the caller instead of die()ing. To do that in a compatible manner with the rest of the error handling in builtin/apply.c, parse_single_patch() should return a negative integer instead of calling die(). Let's do that by using

[PATCH v8 26/41] builtin/apply: make try_create_file() return -1 on error

2016-06-27 Thread Christian Couder
To libify `git apply` functionality we have to signal errors to the caller instead of die()ing. To do that in a compatible manner with the rest of the error handling in "builtin/apply.c", try_create_file() should return -1 in case of error. Unfortunately try_create_file() currently ret

[PATCH v8 23/41] builtin/apply: make create_file() return -1 on error

2016-06-27 Thread Christian Couder
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

[PATCH v8 21/41] builtin/apply: make add_conflicted_stages_file() return -1 on error

2016-06-27 Thread Christian Couder
To libify `git apply` functionality we have to signal errors to the caller instead of die()ing. To do that in a compatible manner with the rest of the error handling in "builtin/apply.c", add_conflicted_stages_file() should return -1 instead of calling die(). Helped-by: Eric Sunshine

[PATCH v8 11/41] apply: make init_apply_state() return -1 instead of exit()ing

2016-06-27 Thread Christian Couder
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", init_apply_state() should return -1 instead of calling exit(). Signed-off-by: Christ

[PATCH v8 34/41] apply: add 'be_silent' variable to 'struct apply_state'

2016-06-27 Thread Christian Couder
* of context lines. */ - if ((leading != frag->leading) || - (trailing != frag->trailing)) + if ((leading != frag->leading || +trailing != frag->trailing) && !state->be_silent) fp

[PATCH v8 09/41] builtin/apply: make parse_ignorewhitespace_option() return -1 instead of die()ing

2016-06-27 Thread Christian Couder
To libify `git apply` functionality we have to signal errors to the caller instead of die()ing. To do that in a compatible manner with the rest of the error handling in "builtin/apply.c", parse_ignorewhitespace_option() should return -1 instead of calling die(). Signed-off-by: Christ

[PATCH v8 39/41] apply: change error_routine when be_silent is set

2016-06-27 Thread Christian Couder
To avoid printing anything when applying with be_silent set, let's save the existing warn and error routines before applying and replace them with a routine that does nothing. Then after applying, let's restore the saved routines. Signed-off-by: Christian Couder --- apply.c | 21 +++

[PATCH v8 35/41] apply: make 'be_silent' incompatible with 'apply_verbosely'

2016-06-27 Thread Christian Couder
ate->check_index = 1; } - if (state->apply_with_reject) - state->apply = state->apply_verbosely = 1; + if (state->apply_with_reject) { + state->apply = 1; + if (!state->be_silent) + state-&

<    1   2   3   4   5   6   7   8   9   10   >