Newlines in source code [message #1271261] |
Fri, 14 March 2014 17:25 |
Hernan Gonzalez Messages: 188 Registered: October 2010 Location: Buenos Aires, Argentina |
Senior Member |
|
|
If I'm not mistaken, currently the Graphiti project is mixing UNIX (\n) and Windows (CRLF) newlines in their text files, specifically the Java source.
For example, cloning the repository from //git.eclipse.org/gitroot/graphiti/org.eclipse.graphiti.git
the current HEAD (b453e93bb2df Fri Mar 14 15:22:03 2014 +0100) the directory plugin has 55 java source files with Windows newlines, and 687 with UNIX newlines
($ find -name '*.java' -exec file '{}' \; | grep CRLF | wc )
For example:
org.eclipse.graphiti/src/org/eclipse/graphiti/platform/IDiagramBehavior.java: CRLF
org.eclipse.graphiti/src/org/eclipse/graphiti/platform/AbstractExtension.java: LF
I don't know if this has been discussed, or if there is some decision/standard about this, but I think this is bad practice and causes unnecesary pains.
There are no silver bullets for this, Git have several related settings, but all have their problems. I have been dealing with these pains in other projects of mine, and I have adopted the following strategy:
- Prefer UNIX in textual Eclipse text files, also in Windows environment.
- Don't attempt to force an universal normalization: for example, some source code might be created by code generators instead of being coded by hand. We will live with that.
Hence the following instructive:
1. Don't apply EOL normalization in GIT, never:
Set autocrlf=false and add '* -text' to .gitattribute
2. In Eclipse, select always (in Linux and Windows) the UNIX newline preference:
Preferences -> General -> Workspace -> TextFile delimiter= Unix , Encoding UTF-8
This specific strategy/instructive is a mere suggestion. But I think that some standard should be adopted.
[Updated on: Fri, 14 March 2014 17:26] Report message to a moderator
|
|
|
Re: Newlines in source code [message #1273237 is a reply to message #1271261] |
Wed, 19 March 2014 19:19 |
Hernan Gonzalez Messages: 188 Registered: October 2010 Location: Buenos Aires, Argentina |
Senior Member |
|
|
In a similar (perhaps irrelevant?) vein, a standard for the charset encoding should be defined at the project level; usually, it's UTF-8. As today, it seems that ISO-8859-1 is (the facto?) used in
./org.eclipse.graphiti/src/org/eclipse/graphiti/services/IPeCreateService.java
./org.eclipse.graphiti.ui/src/org/eclipse/graphiti/ui/internal/util/draw2d/TransparentGhostFigure.java
(search for 'zier' , at Bézier curve). It's only in comments, but, again, this kind of thing can make trouble for GIT comparisons.
[Updated on: Wed, 19 March 2014 19:23] Report message to a moderator
|
|
|
|
|
Powered by
FUDForum. Page generated in 0.03322 seconds