From 48639aa8fc3f63ecf01341acc4ac5d6ca7070364 Mon Sep 17 00:00:00 2001 From: Brad King Date: Tue, 17 Jan 2023 14:23:59 -0500 Subject: clang-format.bash: Use generic clang-format attribute Specify the clang-format version in the attribute value instead of its name. Issue: #24315 --- .gitattributes | 4 ++-- Source/.gitattributes | 2 +- Source/CursesDialog/form/.gitattributes | 2 +- Tests/CSharpLinkFromCxx/.gitattributes | 2 +- Tests/CompileFeatures/.gitattributes | 2 +- Tests/PositionIndependentTargets/.gitattributes | 2 +- Tests/RunCMake/CommandLine/cmake_depends/.gitattributes | 2 +- Tests/RunCMake/GenerateExportHeader/reference/.gitattributes | 2 +- Tests/VSWinStorePhone/Direct3DApp1/.gitattributes | 2 +- Utilities/.gitattributes | 6 +++--- Utilities/Scripts/clang-format.bash | 10 ++++------ 11 files changed, 17 insertions(+), 19 deletions(-) diff --git a/.gitattributes b/.gitattributes index 71ecacf..43ad3b7 100644 --- a/.gitattributes +++ b/.gitattributes @@ -4,11 +4,11 @@ .editorconfig export-ignore # Custom attribute to mark sources as using our C code style. -[attr]our-c-style whitespace=tab-in-indent format.clang-format-6.0 +[attr]our-c-style whitespace=tab-in-indent format.clang-format=6.0 # Custom attribute to mark sources as generated. # Do not perform whitespace checks. Do not format. -[attr]generated whitespace=-tab-in-indent,-indent-with-non-tab -format.clang-format-6.0 +[attr]generated whitespace=-tab-in-indent,-indent-with-non-tab -format.clang-format bootstrap eol=lf configure eol=lf diff --git a/Source/.gitattributes b/Source/.gitattributes index d0aedc2..4b868dd 100644 --- a/Source/.gitattributes +++ b/Source/.gitattributes @@ -1,4 +1,4 @@ CMakeVersion.cmake export-subst # Do not format third-party sources. -/kwsys/** -format.clang-format-6.0 +/kwsys/** -format.clang-format diff --git a/Source/CursesDialog/form/.gitattributes b/Source/CursesDialog/form/.gitattributes index 6dfa627..6e255e4 100644 --- a/Source/CursesDialog/form/.gitattributes +++ b/Source/CursesDialog/form/.gitattributes @@ -1,2 +1,2 @@ * -whitespace -* -format.clang-format-6.0 +* -format.clang-format diff --git a/Tests/CSharpLinkFromCxx/.gitattributes b/Tests/CSharpLinkFromCxx/.gitattributes index cf9d355..57a39049 100644 --- a/Tests/CSharpLinkFromCxx/.gitattributes +++ b/Tests/CSharpLinkFromCxx/.gitattributes @@ -1 +1 @@ -UsefulManagedCppClass.* -format.clang-format-6.0 +UsefulManagedCppClass.* -format.clang-format diff --git a/Tests/CompileFeatures/.gitattributes b/Tests/CompileFeatures/.gitattributes index 95a8956..83da28d 100644 --- a/Tests/CompileFeatures/.gitattributes +++ b/Tests/CompileFeatures/.gitattributes @@ -1,2 +1,2 @@ # Do not format a source containing C++11 '>>' syntax as C++98. -cxx_right_angle_brackets.cpp -format.clang-format-6.0 +cxx_right_angle_brackets.cpp -format.clang-format diff --git a/Tests/PositionIndependentTargets/.gitattributes b/Tests/PositionIndependentTargets/.gitattributes index 61b2751..ed36631 100644 --- a/Tests/PositionIndependentTargets/.gitattributes +++ b/Tests/PositionIndependentTargets/.gitattributes @@ -1,2 +1,2 @@ # Do not format a source where we want a long line preserved. -pic_test.h -format.clang-format-6.0 +pic_test.h -format.clang-format diff --git a/Tests/RunCMake/CommandLine/cmake_depends/.gitattributes b/Tests/RunCMake/CommandLine/cmake_depends/.gitattributes index d9a4db4..9c22288 100644 --- a/Tests/RunCMake/CommandLine/cmake_depends/.gitattributes +++ b/Tests/RunCMake/CommandLine/cmake_depends/.gitattributes @@ -1,2 +1,2 @@ # Do not format a source encoded in UTF-16. -test_UTF-16LE.h -format.clang-format-6.0 +test_UTF-16LE.h -format.clang-format diff --git a/Tests/RunCMake/GenerateExportHeader/reference/.gitattributes b/Tests/RunCMake/GenerateExportHeader/reference/.gitattributes index d9b566e..883a7f1 100644 --- a/Tests/RunCMake/GenerateExportHeader/reference/.gitattributes +++ b/Tests/RunCMake/GenerateExportHeader/reference/.gitattributes @@ -1,2 +1,2 @@ # Exclude reference content from formatting. -* -format.clang-format-6.0 +* -format.clang-format diff --git a/Tests/VSWinStorePhone/Direct3DApp1/.gitattributes b/Tests/VSWinStorePhone/Direct3DApp1/.gitattributes index 78a5469..601c97b 100644 --- a/Tests/VSWinStorePhone/Direct3DApp1/.gitattributes +++ b/Tests/VSWinStorePhone/Direct3DApp1/.gitattributes @@ -1 +1 @@ -Direct3DApp1.cpp -format.clang-format-6.0 +Direct3DApp1.cpp -format.clang-format diff --git a/Utilities/.gitattributes b/Utilities/.gitattributes index 81bbf26..f799e88 100644 --- a/Utilities/.gitattributes +++ b/Utilities/.gitattributes @@ -3,6 +3,6 @@ SetupForDevelopment.sh export-ignore # Do not format third-party sources. -/KWIML/** -format.clang-format-6.0 -/cm*/** -format.clang-format-6.0 -/cmcurl/curltest.c format.clang-format-6.0 +/KWIML/** -format.clang-format +/cm*/** -format.clang-format +/cmcurl/curltest.c format.clang-format=6.0 diff --git a/Utilities/Scripts/clang-format.bash b/Utilities/Scripts/clang-format.bash index 7ca4433..9b38a5b 100755 --- a/Utilities/Scripts/clang-format.bash +++ b/Utilities/Scripts/clang-format.bash @@ -40,7 +40,7 @@ Example to format files modified by the most recent commit: Utilities/Scripts/clang-format.bash --amend -Example to format all files: +Example to format all files tracked by Git: Utilities/Scripts/clang-format.bash --tracked @@ -115,10 +115,8 @@ esac $git_ls | # Select sources with our attribute. - git check-attr --stdin format.clang-format-6.0 | - grep -e ': format\.clang-format-6\.0: set$' | - sed -n 's/:[^:]*:[^:]*$//p' | + git check-attr --stdin format.clang-format | + sed -n '/: format\.clang-format: \(set\|6\.0\)$/ {s/:[^:]*:[^:]*$//p}' | # Update sources in-place. - tr '\n' '\0' | - xargs -0 "$clang_format" -i + xargs -d '\n' "$clang_format" -i -- cgit v0.12