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

Re: [PATCH 4/5] apply: error message in `record_ws_error()`

From
Junio C Hamano <gitster@pobox.com>
Date
Aug 27, 2024, 00:44 UTC
Message-ID
<xmqqjzg2eqvc.fsf@gitster.g>
In-Reply-To
<a8ce6f0d-f0f2-4467-bf16-e7ce78c6ce2d@gmail.com>
Rubén Justo <rjusto@gmail.com> writes:
Show 6 quoted lines
> It does not make sense to construct an error message if we're not
> going to use it, especially when the process involves memory
> allocations that need to be freed immediately.
>
> If we know in advance that we won't use the message, not getting it
> slightly reduces the workload and simplifies the code a bit.
Makes sense.
>
> Do it.

No need to say this when the above two paragraphs are clear enough, like in this patch.

Show 35 quoted lines
>
> Signed-off-by: Rubén Justo <rjusto@gmail.com>
> ---
>  apply.c | 9 ++++-----
>  1 file changed, 4 insertions(+), 5 deletions(-)
>
> diff --git a/apply.c b/apply.c
> index e1b4d14dba..e6df8b6ab4 100644
> --- a/apply.c
> +++ b/apply.c
> @@ -1642,8 +1642,6 @@ static void record_ws_error(struct apply_state *state,
>  			    int len,
>  			    int linenr)
>  {
> -	char *err;
> -
>  	if (!result)
>  		return;
>  
> @@ -1652,11 +1650,12 @@ static void record_ws_error(struct apply_state *state,
>  	    state->squelch_whitespace_errors < state->whitespace_error)
>  		return;
>  
> -	err = whitespace_error_string(result);
> -	if (state->apply_verbosity > verbosity_silent)
> +	if (state->apply_verbosity > verbosity_silent) {
> +		char *err = whitespace_error_string(result);
>  		fprintf(stderr, "%s:%d: %s.\n%.*s\n",
>  			state->patch_input_file, linenr, err, len, line);
> -	free(err);
> +		free(err);
> +	}
>  }
>  
>  static void check_whitespace(struct apply_state *state,
Previous: Rubén JustoNext: Rubén Justo
Message 17 of 18 in “`--whitespace=fix` with `--no-ignore-whitespace`”
  1. 0/5 `--whitespace=fix` with `--no-ignore-whitespace`Rubén Justo, Aug 25, 2024
  2. 1/5 apply: introduce `ignore_ws_default`Rubén Justo, Aug 25, 2024
  3. Junio C HamanoAug 27, 2024
  4. 2/5 apply: honor `ignore_ws_none` with `correct_ws_error`Rubén Justo, Aug 25, 2024
  5. Junio C HamanoAug 27, 2024
  6. Rubén JustoAug 29, 2024
  7. Junio C HamanoAug 29, 2024
  8. Rubén JustoSep 3, 2024
  9. Junio C HamanoSep 4, 2024
  10. Rubén JustoSep 4, 2024
  11. 3/5 apply: whitespace errors in context lines if we haveRubén Justo, Aug 25, 2024
  12. Junio C HamanoAug 27, 2024
  13. Junio C HamanoAug 27, 2024
  14. Junio C HamanoAug 27, 2024
  15. Junio C HamanoAug 27, 2024
  16. 4/5 apply: error message in `record_ws_error()`Rubén Justo, Aug 25, 2024
  17. Junio C HamanoAug 27, 2024
  18. 5/5 t4124: move test preparation into the test contextRubén Justo, Aug 25, 2024

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.