You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@subversion.apache.org by Russ Brown <pi...@gmail.com> on 2005/06/21 13:11:59 UTC

Re: Formating C/C++ code before commit with indent

Servico Tpd Rodrigo Alfonso Menezes Madera wrote:
> 
> 
> 
> Dear Subversionists:
> 
> Since I´ve notest the huge biological cluster that we have here, I am
> wondering if anyone has a ingenious way of solving this problem.
> 
> All of our C/C++ projects follow a well defined format (wich can be
> represented via indent params) and we wish to run indent just before the
> commits. This is important because our programmers very different setting
> in their editors such as tab spaces and formatting styles. The indent
> program handles this ok. It just has to be executed before the commit.
> 
> Right now we have a policy that explicitly tells the programmer to run the
> "prepare" script before the commit. But, naturally, people have made some
> mistakes.
> 
> One way I though of doing this was to write wrapper scripts to the commit
> action, so the user would execute: SvnCommit instead of the command
> directly. The only thing is that this is quite anoying and doesn´t work
> with other plugins (unless you edit them, of course) like the Anjuta
> Subversion plugin.
> 
> Also, many other actions would have to be wrapped.
> 
> Any suggestions?
> 

You could run the committed files against the formatter in the
pre-commit hook, and if they don't match the original file the user
didn't run the file through before committing, and you can reject the
commit. That would force the users to run the files through the
formatter first, though it wouldn't do it automatically.

> Thanks for the brainstorming,
> Rodrigo Madera
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@subversion.tigris.org
> For additional commands, e-mail: users-help@subversion.tigris.org
> 
> 


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@subversion.tigris.org
For additional commands, e-mail: users-help@subversion.tigris.org

Re: Formating C/C++ code before commit with indent

Posted by Ulrich Eckhardt <ec...@satorlaser.com>.
Russ Brown wrote:
> Servico Tpd Rodrigo Alfonso Menezes Madera wrote:
> > All of our C/C++ projects follow a well defined format (wich can be
> > represented via indent params) and we wish to run indent just before the
> > commits. This is important because our programmers very different setting
> > in their editors such as tab spaces and formatting styles. The indent
> > program handles this ok. It just has to be executed before the commit.
[...]
> You could run the committed files against the formatter in the
> pre-commit hook, and if they don't match the original file the user
> didn't run the file through before committing, and you can reject the
> commit. That would force the users to run the files through the
> formatter first, though it wouldn't do it automatically.

Just for your info, there is no sane way to modify the data that was 
committed. The reason is that if you modified the data that a user committed, 
the user's local data would be out of sync with the data on the server, 
leading to all kinds of trouble. Yes, there are possible solutions, but these 
are rather complicated and not in Subversion.

That is the reason why you can only reject malformatted data, but not format 
it yourself.

cheers

Uli

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@subversion.tigris.org
For additional commands, e-mail: users-help@subversion.tigris.org