<html>
  <head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
  </head>
  <body>
    <p>I'd suggest you use pre-commit so that clang-format is
      automatically run on git commit operations like we have done with
      GDAL. Then it is a no-brainer to do changes.<br>
    </p>
    <p>You need to add a .pre-commit-config.yaml at the root of the
      repository (<span class="pl-s">only the part referencing
        clang-format at
        <a class="moz-txt-link-freetext" href="https://github.com/OSGeo/gdal/blob/master/.pre-commit-config.yaml#L30">https://github.com/OSGeo/gdal/blob/master/.pre-commit-config.yaml#L30</a>
        is relevant for you)</span>:<br>
    </p>
    <p><a class="moz-txt-link-freetext" href="https://github.com/OSGeo/gdal/blob/master/.pre-commit-config.yaml">https://github.com/OSGeo/gdal/blob/master/.pre-commit-config.yaml</a></p>
    <p>Once that file is in place:<br>
    </p>
    <p>-  "pip install pre-commit" : just once</p>
    <p>- "pre-commit install": just once per repository</p>
    <p>Cf <a class="moz-txt-link-freetext" href="https://gdal.org/development/dev_practices.html#commit-hooks">https://gdal.org/development/dev_practices.html#commit-hooks</a></p>
    <p>Even<br>
    </p>
    <div class="moz-cite-prefix">Le 02/01/2023 à 19:20, Nicklas Larsson
      via grass-dev a écrit :<br>
    </div>
    <blockquote type="cite"
      cite="mid:C9C90726-AC48-4DF2-B7BF-C6A284173AD2@yahoo.com">
      <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
      Markus,
      <div class=""><br class="">
        <div><br class="">
          <blockquote type="cite" class="">
            <div class="">On 2 Jan 2023, at 13:48, Markus Neteler <<a
                href="mailto:neteler@osgeo.org"
                class="moz-txt-link-freetext" moz-do-not-send="true">neteler@osgeo.org</a>>
              wrote:</div>
            <br class="Apple-interchange-newline">
            <div class="">
              <div class="">Hi Nicklas,<br class="">
                <br class="">
                On Wed, Dec 21, 2022 at 9:25 PM Nicklas Larsson via
                grass-dev<br class="">
                <<a href="mailto:grass-dev@lists.osgeo.org"
                  class="moz-txt-link-freetext" moz-do-not-send="true">grass-dev@lists.osgeo.org</a>>
                wrote:<br class="">
                <blockquote type="cite" class=""><br class="">
                  I understand there is agreement on using the
                  .clang-format formatting rules suggested with [1],
                  which I just merged.<br class="">
                  <br class="">
                  I have formatted the whole source base with
                  clang-format v.15.0.6, in 7 different PRs [2-8]. I
                  will start merging them tomorrow if there are no
                  objections.<br class="">
                  <br class="">
                  I have also filed a PR [9] which adds a CI check for
                  clang-format errors.<br class="">
                </blockquote>
                <br class="">
                Thanks for your efforts on the code reformatting!<br
                  class="">
              </div>
            </div>
          </blockquote>
          <div><br class="">
          </div>
          <div>:-)</div>
          <br class="">
          <blockquote type="cite" class="">
            <div class="">
              <div class=""><br class="">
                <blockquote type="cite" class="">Installing clang-format
                  is perhaps most easily done with:<br class="">
                  python -m pip install 'clang-format==15.0.6'<br
                    class="">
                  <br class="">
                  Formatting may be done with something like (following
                  works on Mac):<br class="">
                  find -E . -regex '.*\.(cpp|hpp|c|h)' -exec
                  clang-format -i {} \+<br class="">
                </blockquote>
                <br class="">
                ... it fails on Linux, though<br class="">
                <br class="">
                find: unknown predicate `-E')<br class="">
              </div>
            </div>
          </blockquote>
          <div><br class="">
          </div>
          <div><br class="">
          </div>
          <div>I was pretty sure this would deviate from Mac/BSD on
            Linux systems:</div>
          <div><br class="">
          </div>
          <div><br class="">
          </div>
          <div>Try something like (untested):</div>
          <div><br class="">
          </div>
          <div>find . -regex '.*\.(cpp|hpp|c|h)' -exec clang-format -i
            {} <span style="color: var(--black-800); font-family:
              var(--ff-mono); font-size: var(--_pr-code-fs); font-style:
              inherit; font-variant-caps: inherit; white-space:
              inherit;" class="">\;</span></div>
          <div class=""><br class="">
          </div>
          <div>or manually with:</div>
          <div>clang-format -I <file></div>
          <div><br class="">
          </div>
          <br class="">
          <blockquote type="cite" class="">
            <div class="">
              <div class=""><br class="">
                <blockquote type="cite" class="">Contribution rules must
                  be updated, I will start putting up a draft ASAP.<br
                    class="">
                </blockquote>
                <br class="">
                I am trying to fix the conflicts in<br class="">
                <a href="https://github.com/OSGeo/grass/pull/2684"
                  class="moz-txt-link-freetext" moz-do-not-send="true">https://github.com/OSGeo/grass/pull/2684</a><br
                  class="">
                <br class="">
                Conflicting files:<br class="">
                <br class="">
                include/grass/iostream/mm.h<br class="">
                lib/db/dbmi_base/dbmscap.c<br class="">
                lib/external/ccmath/ccmath.h<br class="">
                lib/gis/spawn.c<br class="">
                lib/gis/user_config.c<br class="">
                lib/iostream/rtimer.cpp<br class="">
                lib/pngdriver/graph_set.c<br class="">
                lib/rst/interp_float/point2d.c<br class="">
                raster/r.terraflow/filldepr.cpp<br class="">
                raster/r.terraflow/flow.cpp<br class="">
                raster/r.terraflow/main.cpp<br class="">
                raster/r.viewshed/statusstructure.cpp<br class="">
                <br class="">
                The reason will be the missing clang-format update which
                I don't know<br class="">
                how to apply on Linux.<br class="">
              </div>
            </div>
          </blockquote>
          <div><br class="">
          </div>
          <div>Not quite sure what you mean. Did you try:</div>
          <div><br class="">
          </div>
          <div>python -m pip install 'clang-format==15.0.6’</div>
          <div><br class="">
          </div>
          <div>But I suspect any version 15 will do, perhaps even v. 14.</div>
          <div><br class="">
          </div>
          <div><br class="">
          </div>
          <div>A tip to use the .clang-format file from main for
            branches without it:</div>
          <div><br class="">
          </div>
          <div>1. git checkout main</div>
          <div>2. cp .clang-forrmat ../.clang-format</div>
          <div>3. check out branch</div>
          <div>4. clang-format searches upwards in dir hierarchy  for
            next ‘.clang-format’ file</div>
          <div>5. run clang-format from grass source dir</div>
          <div><br class="">
          </div>
        </div>
        <br class="">
      </div>
      <br>
      <fieldset class="moz-mime-attachment-header"></fieldset>
      <pre class="moz-quote-pre" wrap="">_______________________________________________
grass-dev mailing list
<a class="moz-txt-link-abbreviated" href="mailto:grass-dev@lists.osgeo.org">grass-dev@lists.osgeo.org</a>
<a class="moz-txt-link-freetext" href="https://lists.osgeo.org/mailman/listinfo/grass-dev">https://lists.osgeo.org/mailman/listinfo/grass-dev</a>
</pre>
    </blockquote>
    <pre class="moz-signature" cols="72">-- 
<a class="moz-txt-link-freetext" href="http://www.spatialys.com">http://www.spatialys.com</a>
My software is free, but my time generally not.</pre>
  </body>
</html>