From 5190efbdd58d44e5f8b874e50a063300f25e392f Mon Sep 17 00:00:00 2001 From: hao0012 <709704094@qq.com> Date: Wed, 25 Dec 2024 18:32:42 +0800 Subject: [PATCH] fix(run_clang_format.py): Add early return for empty `formatted_filenames` in check function. If `formatted_filenames` is empty, it will run `clang-format` with the `-i` flag on an empty list, resulting `error: cannot use -i when reading from stdin` --- build_support/run_clang_format.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/build_support/run_clang_format.py b/build_support/run_clang_format.py index 584c4cc4d..fb1160f07 100755 --- a/build_support/run_clang_format.py +++ b/build_support/run_clang_format.py @@ -40,6 +40,8 @@ def check(arguments, source_dir): [filename for filename in source_files if not any((fnmatch.fnmatch(filename, exclude_glob) for exclude_glob in exclude_globs))]) + if len(formatted_filenames) == 0: + return if arguments.fix: if not arguments.quiet: