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
This page took 0.025279 seconds and 4 git commands to generate.