aboutsummaryrefslogtreecommitdiffstats
path: root/meson.build
diff options
context:
space:
mode:
authorKarthik Nayak <karthik.188@gmail.com>2025-07-02 11:23:20 +0200
committerJunio C Hamano <gitster@pobox.com>2025-07-02 09:05:29 -0700
commit3f7e447aaf40724e54fe81c99bee104829e3d23d (patch)
tree56e0ae7a4cafeceddf4bee10e747a7289daf1380 /meson.build
parent73d8380e56087ac0a4285596e74444e26d01fb89 (diff)
downloadgit-3f7e447aaf40724e54fe81c99bee104829e3d23d.tar.gz
meson: add rule to run 'git clang-format'
The Makefile has a 'style' rule to run 'git clang-format'. While Meson intrinsically supports a 'clang-format' target, which can be run when using the ninja backend by running 'ninja clang-format', this runs the formatting on all existing files. Our Meson build doesn't yet support a way to run 'git clang-format', which runs the formatter between the working directory and commit provided. Add a new 'style' target to Meson to mimic the target in the Makefile. Signed-off-by: Karthik Nayak <karthik.188@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'meson.build')
-rw-r--r--meson.build12
1 files changed, 12 insertions, 0 deletions
diff --git a/meson.build b/meson.build
index 596f5ac711..7f2d7b5f8c 100644
--- a/meson.build
+++ b/meson.build
@@ -2132,6 +2132,18 @@ if headers_to_check.length() != 0 and compiler.get_argument_syntax() == 'gcc'
alias_target('check-headers', hdr_check)
endif
+git_clang_format = find_program('git-clang-format', required: false, native: true)
+if git_clang_format.found()
+ run_target('style',
+ command: [
+ git_clang_format,
+ '--style', 'file',
+ '--diff',
+ '--extensions', 'c,h'
+ ]
+ )
+endif
+
foreach key, value : {
'DIFF': diff.full_path(),
'GIT_SOURCE_DIR': meson.project_source_root(),