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

Re: [PATCH] apply: Allow blank *trailing* context lines to match beyond EOF

From
Junio C Hamano <gitster@pobox.com>
Date
Apr 8, 2010, 05:32 UTC
Message-ID
<7vd3ya8q7f.fsf@alter.siamese.dyndns.org>
In-Reply-To
<4BBD5827.7030003@gmail.com>
Björn Gustavsson <bgustavsson@gmail.com> writes:
Show 30 quoted lines
> This patch should fix the problem observed by Junio, but note that
> there will be one or more blank lines left at the end of the
> file.
>
> I am not sure whether that should be fixed. In this particular
> case, the blank lines are part of the context but not part of
> the file being patched, so it could be argued that the blank
> lines should not be added back.
>
> But there are already other circumstances in which
> "--whitespace=fix" does not guarantee that the file does
> not end with blank lines, for instance if we have:
>
>  a
>  b
>  (blank line)
>  (blank line)
>  (blank line)
>  (blank line)
>  c
>  d
>
> and then delete the "c" and "d" lines:
>
>  a
>  b
>  (blank line)
>  (blank line)
>  (blank line)
>  (blank line)

Even though I think these are both worth fixing, I do not think it should happen as part of this patch. Because the code that needs to "fix" the "extra blank bug" this patch introduces will need to deal with exactly the same horizon effect as your "deleting c and d at the end will not have the blank immediately after b in the context" example, I expect we will fix the fallout from this patch when we fix that "delete c and d at the end" example.

Previous: Björn Gustavsson
Message 2 of 2 in “apply: Allow blank *trailing* context lines to match beyond EOF”
  1. apply: Allow blank *trailing* context lines to match beyond EOFBjörn Gustavsson, Apr 8, 2010
  2. Junio C HamanoApr 8, 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.