llvmbot wrote:
<!--LLVM PR SUMMARY COMMENT--> @llvm/pr-subscribers-clang-format Author: Andrej Pištek (apdofficial) <details> <summary>Changes</summary> --- Full diff: https://github.com/llvm/llvm-project/pull/137609.diff 1 Files Affected: - (modified) clang/tools/clang-format/git-clang-format (+22-2) ``````````diff diff --git a/clang/tools/clang-format/git-clang-format b/clang/tools/clang-format/git-clang-format index e709803d9a3f1..99373630d59f5 100755 --- a/clang/tools/clang-format/git-clang-format +++ b/clang/tools/clang-format/git-clang-format @@ -189,6 +189,14 @@ def main(): default=config.get("clangformat.style", None), help="passed to clang-format", ), + p.add_argument( + "--fallback-style", + default=None, + help="The name of the predefined style used as a" + "fallback in case clang-format is invoked with" + "-style=file, but can not find the .clang-format" + "file to use.", + ), p.add_argument( "-v", "--verbose", @@ -279,7 +287,11 @@ def main(): old_tree = create_tree_from_workdir(changed_lines) revision = None new_tree = run_clang_format_and_save_to_tree( - changed_lines, revision, binary=opts.binary, style=opts.style + changed_lines, + revision, + binary=opts.binary, + style=opts.style, + fallback_style=opts.fallback_style, ) if opts.verbose >= 1: print("old tree: %s" % old_tree) @@ -531,7 +543,11 @@ def create_tree_from_index(filenames): def run_clang_format_and_save_to_tree( - changed_lines, revision=None, binary="clang-format", style=None + changed_lines, + revision=None, + binary="clang-format", + style=None, + fallback_style=None, ): """Run clang-format on each file and save the result to a git tree. @@ -583,6 +599,7 @@ def run_clang_format_and_save_to_tree( revision=revision, binary=binary, style=style, + fallback_style=fallback_style, env=env, ) yield "%s %s\t%s" % (mode, blob_id, filename) @@ -616,6 +633,7 @@ def clang_format_to_blob( revision=None, binary="clang-format", style=None, + fallback_style=None, env=None, ): """Run clang-format on the given file and save the result to a git blob. @@ -628,6 +646,8 @@ def clang_format_to_blob( clang_format_cmd = [binary] if style: clang_format_cmd.extend(["--style=" + style]) + if fallback_style: + clang_format_cmd.extend(["--fallback-style=" + fallback_style]) clang_format_cmd.extend( [ "--lines=%s:%s" % (start_line, start_line + line_count - 1) `````````` </details> https://github.com/llvm/llvm-project/pull/137609 _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits