[Qgis-developer] using indentation scripts

Mayeul Kauffmann mayeul.kauffmann at free.fr
Thu May 5 17:49:20 EDT 2011


Hi Jef,
Following your comments on indentation in my patch, I tried to use
prepare-commit.sh for more than one hour in vain. When applied after git
commit it says nothing has changed (in effect, after commit, my working
copy is ahead). So I created a new branch locally to restart from
scratch, reapplied my patch, tried the script, in vain again. The best I
get is:
"Unable to determine upstream SVN information from working tree history"

The only help I could find is a few lines on the following page:
http://www.qgis.org/wiki/Developers_Manual#Coding_Style

"There is a scripts/prepare-commit.sh that looks up the changed files
and reindents them using astyle. This should be run before committing.
As newer versions of astyle indent differently than the version used to
do a complete reindentation of the source, the script uses an old astyle
version, that we include in our repository."

I had to guess by reading the source code of the script that I needed to
install flip (and astyle?), and pass the path to the project as first
parameter, but I could not find any documentation on this. Should the
script be run form the root folder? Should I install astyle or not? (the
comment above on the astyle versions puzzles me).

Finally the following command took 10 minutes:
cd /hometb/mk/sig/dev/release-1_7_0-4May/Quantum-GIS
./scrips/prepare-commit.sh .
before telling me:
"Unable to determine upstream SVN information from working tree history"

I tried from several places with relative or absolute path, in vain.

So I tried to follow this advice on the same wiki:
"There is a .indent.pro file in the QGIS src directory that contains the
switches to be used when indenting code using the GNU indent program. If
you don't use GNU indent, you should emulate these settings."

So I installed GNU indent... but could not find the .indent.pro file in
the QGIS src directory. What indent options should I use?

If I cannot make scrips/prepare-commit.sh work, I do not mind formatting
my code manually, but which guidelines? The manual only says "Tab
spacing should be set to 2 spaces" and "Braces should start on the line
following the expression", which I tried to follow.
I do not mind to try and "emulate these settings", if I know where to
look for.


Still, thank you jef for you comments on coding style and other hints.
Could you please give me some hints on how to solve the above
indentation problem?

Thanks a lot in advance!

Mayeul

jef-n wrote at https://github.com/qgis/Quantum-GIS/pull/3/files#r26150 :
> > @@ -348,7 +348,7 @@ QgsFeatureRendererV2* QgsFeatureRendererV2::load( QDomElement& element )
> >    QgsFeatureRendererV2* r = m->createRenderer( element );
> >    if ( r )
> >      r->setUsingSymbolLevels( element.attribute( "symbollevels", "0" ).toInt() );
> > -
> > +    r->setUsingFirstRule( element.attribute( "firstrule", "0" ).toInt() );
> 
> use scripts/prepare-commit.sh please and braces here.
> 

See also:

http://osgeo-org.1803224.n2.nabble.com/indentation-scripts-td3194208.html




More information about the Qgis-developer mailing list