tools/format-cpp: accept optional starting directory
authorPhilippe Proulx <eeppeliteloop@gmail.com>
Thu, 26 Oct 2023 13:25:16 +0000 (09:25 -0400)
committerPhilippe Proulx <eeppeliteloop@gmail.com>
Mon, 30 Oct 2023 18:15:46 +0000 (14:15 -0400)
commit3e6740247afd3bf18fa282452f4b5c7fc03f065f
tree6573db6af604623001d79f42a3eee232cd6d7e32
parented6ecdedb8fc3d055ef2a6858a8370982cb3712d
tools/format-cpp: accept optional starting directory

This patch makes `tools/format-cpp` accept an optional starting
directory (instead of the root directory of the project) as its first
argument:

    $ pwd
    /home/dboucher/Mes Logiciels/babeltrace/src/plugins/ctf

    $ ../../../tools/format-cpp .
    clang-format -i /home/eepp/dev/babeltrace/src/plugins/ctf/fs-src/fs.cpp
    clang-format -i /home/eepp/dev/babeltrace/src/plugins/ctf/fs-src/file.cpp
    clang-format -i /home/eepp/dev/babeltrace/src/plugins/ctf/fs-src/query.cpp
    ...
    clang-format -i /home/eepp/dev/babeltrace/src/plugins/ctf/lttng-live/metadata.hpp
    clang-format -i /home/eepp/dev/babeltrace/src/plugins/ctf/lttng-live/data-stream.hpp

Using realpath(1) to transform the starting directory because find(1)
will only consider file names relative to its starting point, therefore
if the starting point is `.` (and the CWD is `src/cpp-common`),
`*/src/cpp-common/optional.hpp` and so on don't match anything and the
script will format files to be excluded.

Using `-path` instead of `-wholename` which is more precise and also
seems more portable.

Signed-off-by: Philippe Proulx <eeppeliteloop@gmail.com>
Change-Id: I46219035e9b815dffe9200bb924478e4a7b02a04
Reviewed-on: https://review.lttng.org/c/babeltrace/+/11145
CONTRIBUTING.adoc
tools/format-cpp
This page took 0.02505 seconds and 4 git commands to generate.