project-navigation
Personal tools

Author Topic: Trailing blank lines  (Read 5741 times)

Offline Punkie

  • Rookie
  • ***
  • Posts: 20
    • View Profile
Trailing blank lines
« 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. As this mail 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?

Offline Mattn

  • Administrator
  • PHALANX Commander
  • *****
  • Posts: 4831
  • https://github.com/mgerhardy/vengi
    • View Profile
    • Vengi Voxel Tools
Re: Trailing blank lines
« Reply #1 on: November 18, 2010, 01:27:17 pm »
sorry... what is the problem here?

Offline Punkie

  • Rookie
  • ***
  • Posts: 20
    • View Profile
Re: Trailing blank lines
« Reply #2 on: November 18, 2010, 01:32:58 pm »
From the 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.

Offline Mattn

  • Administrator
  • PHALANX Commander
  • *****
  • Posts: 4831
  • https://github.com/mgerhardy/vengi
    • View Profile
    • Vengi Voxel Tools
Re: Trailing blank lines
« Reply #3 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)

Offline Punkie

  • Rookie
  • ***
  • Posts: 20
    • View Profile
Re: Trailing blank lines
« Reply #4 on: November 19, 2010, 12:43:07 am »
How can we saveguard our own git copy? Pushing the checks as early as possible...

Offline bayo

  • Professional loser
  • Project Coder
  • Captain
  • ***
  • Posts: 733
    • View Profile
Re: Trailing blank lines
« Reply #5 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

Offline Duke

  • Administrator
  • PHALANX veteran
  • *****
  • Posts: 1037
    • View Profile
Re: Trailing blank lines
« Reply #6 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...