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

Re: [PATCH] add-interactive: fix bogus diff header line ordering

From
Junio C Hamano <gitster@pobox.com>
Date
Feb 22, 2010, 22:25 UTC
Message-ID
<7vbpfg6h80.fsf@alter.siamese.dyndns.org>
In-Reply-To
<20100222103256.GA10557@coredump.intra.peff.net>
Jeff King <peff@peff.net> writes:
Show 24 quoted lines
>  git-add--interactive.perl |   17 ++++++++++++++++-
>  t/t2016-checkout-patch.sh |    8 ++++++++
>  2 files changed, 24 insertions(+), 1 deletions(-)
>
> diff --git a/git-add--interactive.perl b/git-add--interactive.perl
> index bfd1003..4173200 100755
> --- a/git-add--interactive.perl
> +++ b/git-add--interactive.perl
> @@ -979,6 +979,21 @@ sub coalesce_overlapping_hunks {
>  	return @out;
>  }
>  
> +sub reassemble_patch {
> +	my $head = shift;
> +	return (
> +		# Include everything in the header except the beginning of the
> +		# diff.
> +		(grep { !/^[-+]{3}/ } @$head),
> +		# Then include any other non-diff header lines from the hunks.
> +		(grep { !/^[@ +-]/ } @_),
> +		# Then begin the diff.
> +		(grep { /^[-+]{3}/ } @$head),
> +		# And then the hunk diff lines.
> +		(grep { /^[@ +-]/ } @_)
Hmm.  Are you handling "\No newline at the end of the file" correctly?
Previous: Jeff KingNext: Jeff King
Message 2 of 5 in “add-interactive: fix bogus diff header line ordering”
  1. add-interactive: fix bogus diff header line orderingJeff King, Feb 22, 2010
  2. Junio C HamanoFeb 22, 2010
  3. Jeff KingFeb 23, 2010
  4. add-interactive: fix bogus diff header line orderingJeff King, Feb 23, 2010
  5. Junio C HamanoFeb 23, 2010

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.