Re: [PATCH 20/22] sequencer: remember do_recursive_merge()'s return value
Jakub Narębski writes: > W dniu 29.08.2016 o 10:06, Johannes Schindelin pisze: > >> diff --git a/sequencer.c b/sequencer.c >> index 5ec956f..0614b90 100644 >> --- a/sequencer.c >> +++ b/sequencer.c >> @@ -623,7 +623,7 @@ static int do_pick_commit(enum todo_command command, >> struct commit *commit, >> const char *base_label, *next_label; >> struct commit_message msg = { NULL, NULL, NULL, NULL }; >> struct strbuf msgbuf = STRBUF_INIT; >> -int res, unborn = 0, allow; >> +int res = 0, unborn = 0, allow; > > Not that I am against this part of change, making initialization > explicit, but why we are initializing automatic variables with 0, > which would be the default value anyway? Because an on-stack "auto" begins its life with an undefined value, unlike a file-scope static (and global variables) that can be in BSS segment. > I thought our coding > guidelines discourage initializing with 0 or NULL... You are confused between the two, I am afraid.
Re: [PATCH 20/22] sequencer: remember do_recursive_merge()'s return value
W dniu 29.08.2016 o 10:06, Johannes Schindelin pisze: > diff --git a/sequencer.c b/sequencer.c > index 5ec956f..0614b90 100644 > --- a/sequencer.c > +++ b/sequencer.c > @@ -623,7 +623,7 @@ static int do_pick_commit(enum todo_command command, > struct commit *commit, > const char *base_label, *next_label; > struct commit_message msg = { NULL, NULL, NULL, NULL }; > struct strbuf msgbuf = STRBUF_INIT; > - int res, unborn = 0, allow; > + int res = 0, unborn = 0, allow; Not that I am against this part of change, making initialization explicit, but why we are initializing automatic variables with 0, which would be the default value anyway? I thought our coding guidelines discourage initializing with 0 or NULL... Puzzled, -- Jakub Narębski
Re: [PATCH 20/22] sequencer: remember do_recursive_merge()'s return value
Hi Dennis, On Mon, 29 Aug 2016, Dennis Kaarsemaker wrote: > On ma, 2016-08-29 at 10:06 +0200, Johannes Schindelin wrote: > > > The return value of do_recursive_merge() may be positive (indicating merge > > conflicts), se let's OR later error conditions so as not to overwrite them > > with 0. > > s/se/so/? Good eyes. Fixed, Dscho
Re: [PATCH 20/22] sequencer: remember do_recursive_merge()'s return value
On ma, 2016-08-29 at 10:06 +0200, Johannes Schindelin wrote: > The return value of do_recursive_merge() may be positive (indicating merge > conflicts), se let's OR later error conditions so as not to overwrite them > with 0. s/se/so/? D.
[PATCH 20/22] sequencer: remember do_recursive_merge()'s return value
The return value of do_recursive_merge() may be positive (indicating merge conflicts), se let's OR later error conditions so as not to overwrite them with 0. This is not yet a problem, but preparing for the patches to come: we will teach the sequencer to do rebase -i's job. Signed-off-by: Johannes Schindelin --- sequencer.c | 11 ++- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/sequencer.c b/sequencer.c index 5ec956f..0614b90 100644 --- a/sequencer.c +++ b/sequencer.c @@ -623,7 +623,7 @@ static int do_pick_commit(enum todo_command command, struct commit *commit, const char *base_label, *next_label; struct commit_message msg = { NULL, NULL, NULL, NULL }; struct strbuf msgbuf = STRBUF_INIT; - int res, unborn = 0, allow; + int res = 0, unborn = 0, allow; if (opts->no_commit) { /* @@ -734,7 +734,7 @@ static int do_pick_commit(enum todo_command command, struct commit *commit, } if (!opts->strategy || !strcmp(opts->strategy, "recursive") || command == TODO_REVERT) { - res = do_recursive_merge(base, next, base_label, next_label, + res |= do_recursive_merge(base, next, base_label, next_label, head, &msgbuf, opts); if (res < 0) return res; @@ -743,7 +743,7 @@ static int do_pick_commit(enum todo_command command, struct commit *commit, struct commit_list *common = NULL; struct commit_list *remotes = NULL; - res = write_message(&msgbuf, git_path_merge_msg()); + res |= write_message(&msgbuf, git_path_merge_msg()); commit_list_insert(base, &common); commit_list_insert(next, &remotes); @@ -780,11 +780,12 @@ static int do_pick_commit(enum todo_command command, struct commit *commit, allow = allow_empty(opts, commit); if (allow < 0) { - res = allow; + res |= allow; goto leave; } if (!opts->no_commit) - res = sequencer_commit(opts->edit ? NULL : git_path_merge_msg(), + res |= sequencer_commit(opts->edit ? + NULL : git_path_merge_msg(), opts, allow, opts->edit, 0, 0); leave: -- 2.10.0.rc1.114.g2bd6b38