[svn.haxx.se] · SVN Dev · SVN Users · SVN Org · TSVN Dev · TSVN Users · Subclipse Dev · Subclipse Users · this month's index

Re: altering files with a pre-commit hook?

From: Ryan Schmidt <subversion-2009b_at_ryandesign.com>
Date: Sun, 21 Jun 2009 00:40:43 -0500

On Jun 20, 2009, at 22:32, Kenneth Riddile wrote:

> My team writes portable C/C++ that is all written with Visual
> Studio on Windows and is then used on both Windows and Unix. GCC
> on Unix complains when files don't end in newlines while Visual
> Studio does not. I already have a pre-commit hook that fails the
> commit when a source file doesn't end in a newline. I was
> wondering if someone knows of a way to automatically append a
> newline to those files at pre-commit time instead of forcing the
> user to go and add them manually. I won't be surprised if this
> can't be done since the ability to transparently modify files
> committed by the user could certainly be dangerous.

Thou shalt not modify the transaction in the pre-commit hook. :) But
you can, if you insist, have the hook commit a second revision
immediately following the first to add that trailing newline if
necessary. Your hook script might then have to maintain a working
copy of its own in which to make such modifications. It might become
a nontrivial script. Personally I'd just leave your pre-commit hook
as-is, and get your developers to add the newline. My editor has a
setting for doing this automatically when saving any file; hopefully
the one your developers are using does too.

------------------------------------------------------
http://subversion.tigris.org/ds/viewMessage.do?dsForumId=1065&dsMessageId=2363907

To unsubscribe from this discussion, e-mail: [users-unsubscribe_at_subversion.tigris.org].
Received on 2009-06-21 07:41:41 CEST

This is an archived mail posted to the Subversion Users mailing list.

This site is subject to the Apache Privacy Policy and the Apache Public Forum Archive Policy.