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

Re: git apply/am whitespace errors

From
Junio C Hamano <gitster@pobox.com>
Date
Sep 26, 2011, 19:44 UTC
Message-ID
<7vzkhr142r.fsf@alter.siamese.dyndns.org>
In-Reply-To
<CALFxCvxxbsgZnhqK9nN7h=1ASJzfDJ7aVF+rM-8RUyKhpv8FzQ@mail.gmail.com>
neubyr <neubyr@gmail.com> writes:
Show 7 quoted lines
> I am getting  following error while applying a patch using git-apply.
>
> {{{
> /tmp/patches/ticket11/0002-Commit-for-ticket-11.patch:51: new blank line at EOF.
> }}}
>
> What does number '51' after colon ':' indicate?

Looks like "apply --whitespace=error" is not reporting the optimal line number for the blank at EOF case.

It ideally should point at the line number of the offending patch in the input patch file (i.e. "cat -n .git/apply-rebase/patch" would show the "+" line that adds a blank line on 51th line), but it seems that it instead points at the beginning of the hunk that introduces the issue.

E.g. if we add an empty line at the end of COPYING (which is 360 lines long), we would get a patch file that looks like this:

     1	diff --git a/COPYING b/COPYING$
     2	index 536e555..ccf4c7f 100644$
     3	--- a/COPYING$
     4	+++ b/COPYING$
     5	@@ -358,3 +358,4 @@ proprietary programs.  If your program is a subroutine library, you may$
     6	 consider it more useful to permit linking proprietary applications with the$
     7	 library.  If this is what you want to do, use the GNU Lesser General$
     8	 Public License instead of this License.$
     9	+$

and "git apply --whitespace=error P.diff" would report the hunk that begins at line 5 is wrong:

     P.diff:5: new blank line at EOF.
     +
     fatal: 1 line adds whitespace errors.
when the true offending line is at line #9.
Previous: neubyrNext: Junio C Hamano
Message 2 of 3 in “git apply/am whitespace errors”
  1. neubyrSep 26, 2011
  2. Junio C HamanoSep 26, 2011
  3. Junio C HamanoSep 26, 2011

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.