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

Re: [PATCH 2/2] apply: handle assertion failure gracefully

From
Junio C Hamano <gitster@pobox.com>
Date
Jun 27, 2017, 21:39 UTC
Message-ID
<xmqqbmp9yutm.fsf@gitster.mtv.corp.google.com>
In-Reply-To
<1374711c-2cf5-ae8e-16e0-7c10be253a08@web.de>
René Scharfe <l.s.r@web.de> writes:
> Hmm, pondering that, it seems I forgot to reset its value after each
> patch.  Or better just move it into struct patch, next to the extension
> bits:
Good catch.
Show 44 quoted lines
> -- >8 --
> Subject: fixup! apply: check git diffs for mutually exclusive header lines
> ---
>  apply.c | 7 ++++---
>  apply.h | 1 -
>  2 files changed, 4 insertions(+), 4 deletions(-)
>
> diff --git a/apply.c b/apply.c
> index db38bc3cdd..c442b89328 100644
> --- a/apply.c
> +++ b/apply.c
> @@ -211,6 +211,7 @@ struct patch {
>  	unsigned ws_rule;
>  	int lines_added, lines_deleted;
>  	int score;
> +	int extension_linenr; /* first line specifying delete/new/rename/copy */
>  	unsigned int is_toplevel_relative:1;
>  	unsigned int inaccurate_eof:1;
>  	unsigned int is_binary:1;
> @@ -1325,9 +1326,9 @@ static int check_header_line(struct apply_state *state, struct patch *patch)
>  			 (patch->is_rename == 1) + (patch->is_copy == 1);
>  	if (extensions > 1)
>  		return error(_("inconsistent header lines %d and %d"),
> -			     state->extension_linenr, state->linenr);
> -	if (extensions && !state->extension_linenr)
> -		state->extension_linenr = state->linenr;
> +			     patch->extension_linenr, state->linenr);
> +	if (extensions && !patch->extension_linenr)
> +		patch->extension_linenr = state->linenr;
>  	return 0;
>  }
>  
> diff --git a/apply.h b/apply.h
> index b52078b486..b3d6783d55 100644
> --- a/apply.h
> +++ b/apply.h
> @@ -79,7 +79,6 @@ struct apply_state {
>  
>  	/* Various "current state" */
>  	int linenr; /* current line number */
> -	int extension_linenr; /* first line specifying delete/new/rename/copy */
>  	struct string_list symlink_changes; /* we have to track symlinks */
>  
>  	/*
Previous: René ScharfeNext: René Scharfe
Message 11 of 19 in “apply: guard against renames of non-existant empty files”
  1. 1/2 apply: guard against renames of non-existant empty filesVegard Nossum, Feb 25, 2017
  2. 2/2 apply: handle assertion failure gracefullyVegard Nossum, Feb 25, 2017
  3. René ScharfeFeb 25, 2017
  4. Junio C HamanoFeb 27, 2017
  5. René ScharfeFeb 27, 2017
  6. Junio C HamanoFeb 27, 2017
  7. René ScharfeFeb 28, 2017
  8. René ScharfeJun 27, 2017
  9. Junio C HamanoJun 27, 2017
  10. René ScharfeJun 27, 2017
  11. Junio C HamanoJun 27, 2017
  12. René ScharfeJun 27, 2017
  13. Philip OakleyFeb 25, 2017
  14. Vegard NossumFeb 25, 2017
  15. Philip OakleyFeb 25, 2017
  16. René ScharfeFeb 25, 2017
  17. Junio C HamanoFeb 27, 2017
  18. René ScharfeFeb 27, 2017
  19. René ScharfeJun 27, 2017

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.