UFO:Alien Invasion

Development => Coding => Topic started by: Punkie on November 18, 2010, 12:56:47 pm

Title: Trailing blank lines
Post by: Punkie on November 18, 2010, 12:56:47 pm
gcc needs one, git reject two.
It is possible to check, and adapt, any file automatically using git hooks (http://www.kernel.org/pub/software/scm/git/docs/githooks.html). As this mail (http://lists.freedesktop.org/archives/cairo/2006-June/007062.html) illustrates it can happen client side. I suppose that saveguarding the official git repo of ufoai should be useful, shouldnt it?

Is there some mechanism that might push those hooks to the clients? Such that everyone can have this enabled on their own gitclone?
Title: Re: Trailing blank lines
Post by: Mattn on November 18, 2010, 01:27:17 pm
sorry... what is the problem here?
Title: Re: Trailing blank lines
Post by: Punkie on November 18, 2010, 01:32:58 pm
From the coding guidelines (http://ufoai.ninex.info/wiki/index.php/Coding_guidelines)
Quote
# remember to put a blank line at the end of the file (GCC will complain if you don't.)
# don't put more than one blank line at the end of the file (GIT will complain if you do.)

I thought that some form of automatic formatting might take away these sorrows and guard the repo against unwanted coding.
Title: Re: Trailing blank lines
Post by: Mattn on November 19, 2010, 12:19:45 am
the repo is guarded against this. there is a hook script that won't allow to push your commits if you have 'whitespace-bugs' in your commit(s)
Title: Re: Trailing blank lines
Post by: Punkie on November 19, 2010, 12:43:07 am
How can we saveguard our own git copy? Pushing the checks as early as possible...
Title: Re: Trailing blank lines
Post by: bayo on November 19, 2010, 11:11:38 am
You can use the precommit script from contrib/git/precommit
You must copy it in ufoairoot/.git/hooks/precommit
Title: Re: Trailing blank lines
Post by: Duke on December 14, 2010, 12:36:52 am
What about a different approach:
If the script is able to *detect* the excessive CRLF it should as well be able to strip it off on commit...