[Cmake-commits] CMake branch, next, updated. v3.5.2-1509-ga639d9b

Brad King brad.king at kitware.com
Fri May 20 13:57:42 EDT 2016


This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "CMake".

The branch, next has been updated
       via  a639d9b9828a57142d53847fc033fcca59ee4fab (commit)
       via  2f2117e7d4b1b28170c17ddced5faa092ca43530 (commit)
      from  c1f682fc1e292bfd6040d19002bd93675d282fa9 (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.

- Log -----------------------------------------------------------------
https://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=a639d9b9828a57142d53847fc033fcca59ee4fab
commit a639d9b9828a57142d53847fc033fcca59ee4fab
Merge: c1f682f 2f2117e
Author:     Brad King <brad.king at kitware.com>
AuthorDate: Fri May 20 13:57:41 2016 -0400
Commit:     CMake Topic Stage <kwrobot at kitware.com>
CommitDate: Fri May 20 13:57:41 2016 -0400

    Merge topic 'clang-format-script' into next
    
    2f2117e7 clang-format.bash: Limit formatting to files selected by options


https://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=2f2117e7d4b1b28170c17ddced5faa092ca43530
commit 2f2117e7d4b1b28170c17ddced5faa092ca43530
Author:     Brad King <brad.king at kitware.com>
AuthorDate: Fri May 20 13:29:37 2016 -0400
Commit:     Brad King <brad.king at kitware.com>
CommitDate: Fri May 20 13:57:25 2016 -0400

    clang-format.bash: Limit formatting to files selected by options
    
    Now that our one-shot clang-format run is complete we rarely need to
    filter the entire tree anymore.  Filter nothing if no options are given
    and just print the usage message.  Offer options to specify selection of
    some set of files from Git as needed for various workflows.

diff --git a/Utilities/Scripts/clang-format.bash b/Utilities/Scripts/clang-format.bash
index 2090a1a..760a8d4 100755
--- a/Utilities/Scripts/clang-format.bash
+++ b/Utilities/Scripts/clang-format.bash
@@ -17,7 +17,34 @@
 
 usage='usage: clang-format.bash [<options>] [--]
 
-    --clang-format <tool>              Use given clang-format tool.
+    --help                     Print usage plus more detailed help.
+
+    --clang-format <tool>      Use given clang-format tool.
+
+    --amend                    Filter files changed by HEAD.
+    --cached                   Filter files locally staged for commit.
+    --modified                 Filter files locally modified from HEAD.
+    --tracked                  Filter files tracked by Git.
+'
+
+help="$usage"'
+Example to format locally modified files:
+
+    Utilities/Scripts/clang-format.bash --modified
+
+Example to format locally modified files staged for commit:
+
+    Utilities/Scripts/clang-format.bash --cached
+
+Example to format the current topic:
+
+    git filter-branch \
+      --tree-filter "Utilities/Scripts/clang-format.bash --amend" \
+      master..
+
+Example to format all files:
+
+    Utilities/Scripts/clang-format.bash --tracked
 '
 
 die() {
@@ -28,9 +55,15 @@ die() {
 
 # Parse command-line arguments.
 clang_format=''
+mode=''
 while test "$#" != 0; do
     case "$1" in
+    --amend) mode="amend" ;;
+    --cached) mode="cached" ;;
     --clang-format) shift; clang_format="$1" ;;
+    --help) echo "$help"; exit 0 ;;
+    --modified) mode="modified" ;;
+    --tracked) mode="tracked" ;;
     --) shift ; break ;;
     -*) die "$usage" ;;
     *) break ;;
@@ -59,8 +92,18 @@ if ! type -p "$clang_format" >/dev/null; then
     exit 1
 fi
 
+# Select listing mode.
+case "$mode" in
+    '')       echo "$usage"; exit 0 ;;
+    amend)    git_ls='git diff-tree  --diff-filter=AM --name-only HEAD -r --no-commit-id' ;;
+    cached)   git_ls='git diff-index --diff-filter=AM --name-only HEAD --cached' ;;
+    modified) git_ls='git diff-index --diff-filter=AM --name-only HEAD' ;;
+    tracked)  git_ls='git ls-files' ;;
+    *) die "invalid mode: $mode" ;;
+esac
+
 # Filter sources to which our style should apply.
-git ls-files -z -- '*.c' '*.cc' '*.cpp' '*.cxx' '*.h' '*.hh' '*.hpp' '*.hxx' |
+$git_ls -z -- '*.c' '*.cc' '*.cpp' '*.cxx' '*.h' '*.hh' '*.hpp' '*.hxx' |
 
   # Exclude lexer/parser generator input and output.
   egrep -z -v '^Source/cmCommandArgumentLexer\.' |

-----------------------------------------------------------------------

Summary of changes:
 Utilities/Scripts/clang-format.bash |   47 +++++++++++++++++++++++++++++++++--
 1 file changed, 45 insertions(+), 2 deletions(-)


hooks/post-receive
-- 
CMake


More information about the Cmake-commits mailing list