What does “1 line add space errors” mean when applying the patch?

I am editing some markup files for a cloned remote repository and wanted to test the creation and application of patches from one branch to another. However, every time I make any changes, the following message appears during git apply :

 0001-b.patch:16: trailing whitespace. warning: 1 line adds whitespace errors. 

(This happens on my Mac, and I don't know where the source code was created.)

What does the warning message mean and do I need to take care?

+74
git whitespace patch
Sep 12
source share
4 answers

You do not need to care.

A warning introduces a standard for text file cleanliness with respect to spaces, which many programmers tend to take care of. As the manual explains:

What is considered a space error is controlled by the core.whitespace configuration. By default, trailing spaces (including lines that consist solely of spaces) and a space character, immediately followed by a tab character inside the initial indent of a line, are considered a space error.

By default, the command displays warning messages, but applies the patch.

Thus, “error” means that the change introduces a trailing blank space, only a white space or a space preceding the tab. Apart from this fact, there is nothing wrong with the change, and it will be applied cleanly and correctly. In other words, if you don't care about the “wrong” space, feel free to ignore the warning or disable it with git config apply.whitespace nowarn .

+84
Sep 12
source share

One of the cases where you can legitimately take care is that you want to distinguish between the “old” whitespase error (which you might want to keep for the old reason) and the “new” space errors (which you want to avoid).

For this, Git 2.5+ (Q2 2015) will offer a more specific option for detecting spaces.

See commits 0e383e1 , 0ad782f , and d55ef3e [May 26, 2015] Junio gitster Hamano ( gitster ) .
( Junio merge in commit 709cd91 , June 11, 2015)

diff.c : --ws-error-highlight=<kind> option

Traditionally, we only cared for declared spaces in new lines.
Some people want to draw spaces on old lines too. When they see the firmware gap on a new line, they can reveal the same gap spread on the corresponding old line and I want to say: "Ah, there are these breakdowns, but they were inherited from the original, so don’t touch them now."

Enter the parameter --ws-error-highlight=<kind> , which allows them to go through the list, separated by commas old , new and context , to indicate which lines highlight the space errors.

The documentation includes :

 --ws-error-highlight=<kind> 

Highlight space errors in the lines specified by <kind> in the color specified by color.diff.whitespace .
<kind> is a comma separated list of old , new , context .
If this option is not specified, only whitespace errors in the new lines are highlighted.

eg. --ws-error-highlight=new,old highlights whitespace errors for both deleted and added lines.
all can be used as short for old,new,context .

For example, the old commit had one space error ( bbb ), but you can only focus on the new errors (at the end of still bbb and ccc ):

old and new shitespace errors

(test runs after t/t4015-diff-whitespace.sh )

+3
Jun 12 '15 at 13:15
source share
+1
Jan 07 '15 at 12:21
source share

Since the line starts with TAB istead SPACE . Go to the patch file and replace TAB with SPACE . For example. on vim on line + from a patch file of type x to remove the space, rather than remove the + sign and insert a space (CTRL) on eqiv to its original size.

0
Aug 11 '15 at 8:56
source share



All Articles