Openwall GNU/*/Linux - a small security-enhanced Linux distro for servers
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Date: Wed, 29 May 2013 08:08:59 +0200
From: magnum <john.magnum@...hmail.com>
To: john-dev@...ts.openwall.com
Subject: Re: pre-commit hooks (was: Unify internal form of mscash2 hashes?)

On 29 May, 2013, at 8:00 , magnum <john.magnum@...hmail.com> wrote:
> On 29 May, 2013, at 5:43 , Sayantan Datta <std2048@...il.com> wrote:
>> I was partially wrong about the hook not working on multiple files but still the hook is far from perfect. I didn't edit much and used the 2nd one which had a minor error.  I am attaching the script.  The script works only if I follow certain steps:
>> 1. Modify the files and deliberately add trailing white space to any line. Hook doesn't detect any white space in a file unless an extra white space is added to the file before staging them. 
>> 2. Do git add -A 
>> 3. Do git commit (pre-commit hook should eliminate all trailing white spaces from all modified files)
>> 4. Again do git add -A (stage the files with no trailing white spaces)
>> 5. Do git commit --no-verify (byepass the hook)   
> 
> That sounds overly complicated to me and it doesn't even drop all trailing white space. To do that, change 's/ *$//' to 's/[[:space::]]+$//'.

BTW that latter line probably needs -r:

sed -ri 's/[[:space::]]+$//' "$FILE"

Another problem with your script is that is will bug out if a file name contains spaces. To fix that you need to change IFS. But I (and many much more clever guys than me) still recommend to use a hook that just warns, not tries to fix anything.

magnum

Powered by blists - more mailing lists

Your e-mail address:

Powered by Openwall GNU/*/Linux - Powered by OpenVZ