0 votes
1 view
in Devops and Agile by (20k points)

When doing a git diff it says "No newline at end of file".

Ok, there is no newline at end of file. What's the big deal?

What's the significance of the message and what's it trying to tell us?

1 Answer

0 votes
by (28.4k points)

It indicates that you do not have a newline (usually '\n', aka CR or CRLF) at the end of file. In layman's terms the last byte (or bytes if you're on Windows) in the file is not a newline.

That message is displayed because otherwise there is no way to tell the difference between a file where there is a newline at the end and one where is not. Diff has to output a newline anyway, or the result would be harder to read or process automatically.

Also note that it is a good style to always put the newline as a last character if it is allowed by the file format. For instance, for C and C++ header files it is required by the language standard

Welcome to Intellipaat Community. Get your technical queries answered by top developers !


Categories

...