git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: [PATCH v13 10/14] apply: change error_routine when silent

From
Christian Couder <christian.couder@gmail.com>
Date
Sep 1, 2016, 08:19 UTC
Message-ID
<CAP8UFD2Lwd_1+cWT702deF8=iFmBRKCi9gLSOizPbyLmeKepsw@mail.gmail.com>
In-Reply-To
<CAGZ79kbdoF-1=ZBZG8y3sEz6LVaNP4Ou+KVk+=M7y9PSzQ1J0Q@mail.gmail.com>
On Thu, Sep 1, 2016 at 12:20 AM, Stefan Beller <sbeller@google.com> wrote:
Show 32 quoted lines
> On Sat, Aug 27, 2016 at 11:45 AM, Christian Couder
> <christian.couder@gmail.com> wrote:
>> To avoid printing anything when applying with
>> `state->apply_verbosity == verbosity_silent`, let's save the
>> existing warn and error routines before applying, and let's
>> replace them with a routine that does nothing.
>>
>> Then after applying, let's restore the saved routines.
>>
>> Helped-by: Stefan Beller <sbeller@google.com>
>> Signed-off-by: Christian Couder <chriscool@tuxfamily.org>
>> ---
>>  apply.c | 21 ++++++++++++++++++++-
>>  apply.h |  8 ++++++++
>>  2 files changed, 28 insertions(+), 1 deletion(-)
>>
>> diff --git a/apply.c b/apply.c
>> index ddbb0a2..bf81b70 100644
>> --- a/apply.c
>> +++ b/apply.c
>> @@ -112,6 +112,11 @@ void clear_apply_state(struct apply_state *state)
>>         /* &state->fn_table is cleared at the end of apply_patch() */
>>  }
>>
>> +static void mute_routine(const char *bla, va_list params)
>
> Instead of 'bla' you could go with 'format' as the man page for
> [f]printf puts it.
> Or you could leave it empty, i.e.
>
>     static void mute_routine(const char *, va_list)
>     ...
Ok to do that.
Show 13 quoted lines
> I personally do not mind bla, as I know that the first parameter is
> supposed to be the format, but let's not add unneeded information.
> (Side question: Is there a culture that doesn't recognize 'bla' as a
> fill word?)
>
>> @@ -4864,7 +4876,7 @@ int apply_all_patches(struct apply_state *state,
>>                 state->newfd = -1;
>>         }
>>
>> -       return !!errs;
>> +       res = !!errs;
>
> I am trying to understand this and the next chunk (they work together?)
Yes, they work together.
Show 20 quoted lines
>>  end:
>>         if (state->newfd >= 0) {
>> @@ -4872,5 +4884,12 @@ int apply_all_patches(struct apply_state *state,
>>                 state->newfd = -1;
>>         }
>>
>> +       if (state->apply_verbosity <= verbosity_silent) {
>> +               set_error_routine(state->saved_error_routine);
>> +               set_warn_routine(state->saved_warn_routine);
>> +       }
>> +
>> +       if (res > -1)
>> +               return res;
>>         return (res == -1 ? 1 : 128);
>
> So anything > -1 is returned as is, and == -1 returns 1 and <-1  returns 128 ?
>
> So I guess a reminder/explanation on why we need to fiddle with return codes
> in the commit message would help. (I do not understand how the
> verbosity influences return codes.)

It doesn't influence return codes, but we need to restore error routines just before returning, so we cannot return early anymore. I will add something to the commit message.

Previous: Stefan BellerNext: Christian Couder
Message 23 of 38 in “libify apply and use lib in am, part 3”
  1. 00/14 libify apply and use lib in am, part 3Christian Couder, Aug 27, 2016
  2. 04/14 apply: make some parsing functions static againChristian Couder, Aug 27, 2016
  3. Stefan BellerAug 31, 2016
  4. 02/14 apply: rename and move opt constants to apply.hChristian Couder, Aug 27, 2016
  5. Stefan BellerAug 31, 2016
  6. Christian CouderSep 1, 2016
  7. 01/14 builtin/apply: rename option parsing functionsChristian Couder, Aug 27, 2016
  8. 05/14 apply: use error_errno() where possibleChristian Couder, Aug 27, 2016
  9. Stefan BellerAug 31, 2016
  10. 07/14 apply: don't print on stdout in verbosity_silent modeChristian Couder, Aug 27, 2016
  11. 06/14 apply: make it possible to silently applyChristian Couder, Aug 27, 2016
  12. Stefan BellerAug 31, 2016
  13. Christian CouderSep 1, 2016
  14. Stefan BellerSep 1, 2016
  15. 08/14 usage: add set_warn_routine()Christian Couder, Aug 27, 2016
  16. 14/14 builtin/am: use apply API in run_apply()Christian Couder, Aug 27, 2016
  17. Stefan BellerAug 31, 2016
  18. Christian CouderSep 1, 2016
  19. 13/14 apply: learn to use a different index fileChristian Couder, Aug 27, 2016
  20. 11/14 apply: refactor `git apply` option parsingChristian Couder, Aug 27, 2016
  21. 10/14 apply: change error_routine when silentChristian Couder, Aug 27, 2016
  22. Stefan BellerAug 31, 2016
  23. Christian CouderSep 1, 2016
  24. Christian CouderSep 4, 2016
  25. Ramsay JonesSep 4, 2016
  26. Christian CouderSep 4, 2016
  27. 09/14 usage: add get_error_routine() and get_warn_routine()Christian Couder, Aug 27, 2016
  28. 12/14 apply: pass apply state to build_fake_ancestor()Christian Couder, Aug 27, 2016
  29. Christian CouderAug 27, 2016
  30. Junio C HamanoAug 29, 2016
  31. Junio C HamanoAug 29, 2016
  32. Christian CouderAug 30, 2016
  33. Junio C HamanoAug 31, 2016
  34. Christian CouderSep 1, 2016
  35. Junio C HamanoSep 1, 2016
  36. Christian CouderSep 4, 2016
  37. Stefan BellerAug 31, 2016
  38. Christian CouderSep 1, 2016

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.