From 1aeb8d21076ba50bf423379364158cd71e933bf9 Mon Sep 17 00:00:00 2001 From: Bowgo Tsai Date: Wed, 8 Mar 2017 16:32:23 +0800 Subject: [PATCH] Add a PREUPLOAD.cfg file to run git-clang-format on every commit The style file .clang-format is copied from adb/.clang-format. Each sub folders still can have different style by adding their own .clang-format because git-clang-format uses the style file located in one of the parent directories of the *source file*. Also see the following link for previous discussions: https://android-review.googlesource.com/#/c/340106 Bug: 36046320 Test: repo upload, checks pre-submit fails when the uploading commit doesn't meet the style Change-Id: I94369af197da1ccce581bbd861c8737f6a197429 --- .clang-format | 13 +++++++++++++ PREUPLOAD.cfg | 5 +++++ 2 files changed, 18 insertions(+) create mode 100644 .clang-format create mode 100644 PREUPLOAD.cfg diff --git a/.clang-format b/.clang-format new file mode 100644 index 000000000..fc4eb1bc0 --- /dev/null +++ b/.clang-format @@ -0,0 +1,13 @@ +BasedOnStyle: Google +AllowShortBlocksOnASingleLine: false +AllowShortFunctionsOnASingleLine: false + +AccessModifierOffset: -2 +ColumnLimit: 100 +CommentPragmas: NOLINT:.* +DerivePointerAlignment: false +IndentWidth: 4 +PointerAlignment: Left +TabWidth: 4 +UseTab: Never +PenaltyExcessCharacter: 32 diff --git a/PREUPLOAD.cfg b/PREUPLOAD.cfg new file mode 100644 index 000000000..c8dbf77fa --- /dev/null +++ b/PREUPLOAD.cfg @@ -0,0 +1,5 @@ +[Builtin Hooks] +clang_format = true + +[Builtin Hooks Options] +clang_format = --commit ${PREUPLOAD_COMMIT} --style file --extensions c,h,cc,cpp