Browse Source

Merge topic 'clang-format-attr'

48639aa8fc clang-format.bash: Use generic clang-format attribute

Acked-by: Kitware Robot <[email protected]>
Merge-request: !8085
Brad King 2 years ago
parent
commit
bcf28839f4

+ 2 - 2
.gitattributes

@@ -4,11 +4,11 @@
 .editorconfig    export-ignore
 .editorconfig    export-ignore
 
 
 # Custom attribute to mark sources as using our C code style.
 # 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.
 # Custom attribute to mark sources as generated.
 # Do not perform whitespace checks.  Do not format.
 # 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
 bootstrap        eol=lf
 configure        eol=lf
 configure        eol=lf

+ 1 - 1
Source/.gitattributes

@@ -1,4 +1,4 @@
 CMakeVersion.cmake    export-subst
 CMakeVersion.cmake    export-subst
 
 
 # Do not format third-party sources.
 # Do not format third-party sources.
-/kwsys/**                                  -format.clang-format-6.0
+/kwsys/**                                  -format.clang-format

+ 1 - 1
Source/CursesDialog/form/.gitattributes

@@ -1,2 +1,2 @@
 * -whitespace
 * -whitespace
-* -format.clang-format-6.0
+* -format.clang-format

+ 1 - 1
Tests/CSharpLinkFromCxx/.gitattributes

@@ -1 +1 @@
-UsefulManagedCppClass.* -format.clang-format-6.0
+UsefulManagedCppClass.* -format.clang-format

+ 1 - 1
Tests/CompileFeatures/.gitattributes

@@ -1,2 +1,2 @@
 # Do not format a source containing C++11 '>>' syntax as C++98.
 # 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

+ 1 - 1
Tests/PositionIndependentTargets/.gitattributes

@@ -1,2 +1,2 @@
 # Do not format a source where we want a long line preserved.
 # 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

+ 1 - 1
Tests/RunCMake/CommandLine/cmake_depends/.gitattributes

@@ -1,2 +1,2 @@
 # Do not format a source encoded in UTF-16.
 # 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

+ 1 - 1
Tests/RunCMake/GenerateExportHeader/reference/.gitattributes

@@ -1,2 +1,2 @@
 # Exclude reference content from formatting.
 # Exclude reference content from formatting.
-* -format.clang-format-6.0
+* -format.clang-format

+ 1 - 1
Tests/VSWinStorePhone/Direct3DApp1/.gitattributes

@@ -1 +1 @@
-Direct3DApp1.cpp -format.clang-format-6.0
+Direct3DApp1.cpp -format.clang-format

+ 3 - 3
Utilities/.gitattributes

@@ -3,6 +3,6 @@
 SetupForDevelopment.sh  export-ignore
 SetupForDevelopment.sh  export-ignore
 
 
 # Do not format third-party sources.
 # 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

+ 4 - 6
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
     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
     Utilities/Scripts/clang-format.bash --tracked
 
 
@@ -115,10 +115,8 @@ esac
 $git_ls |
 $git_ls |
 
 
   # Select sources with our attribute.
   # 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.
   # Update sources in-place.
-  tr '\n' '\0'                               |
-  xargs -0 "$clang_format" -i
+  xargs -d '\n' "$clang_format" -i