Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
What's new
10
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Open sidebar
Daniel Pfeifer
KWSys
Commits
d22c2743
Commit
d22c2743
authored
Mar 24, 2017
by
Brad King
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
clang-format.bash: Use Git attributes to mark files for formatting
parent
6365886c
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
12 additions
and
11 deletions
+12
-11
.gitattributes
.gitattributes
+1
-1
clang-format.bash
clang-format.bash
+11
-10
No files found.
.gitattributes
View file @
d22c2743
...
...
@@ -3,7 +3,7 @@
.hooks* export-ignore
# Custom attribute to mark sources as using our C code style.
[attr]our-c-style whitespace=tab-in-indent
[attr]our-c-style whitespace=tab-in-indent
format.clang-format
/GitSetup export-ignore
/*.sh export-ignore eol=lf
...
...
clang-format.bash
View file @
d22c2743
#!/usr/bin/env bash
#=============================================================================
# Copyright 2015-201
6
Kitware, Inc.
# Copyright 2015-201
7
Kitware, Inc.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
...
...
@@ -106,17 +106,18 @@ case "$mode" in
*
)
die
"invalid mode:
$mode
"
;;
esac
# Filter sources to which our style should apply.
list_cfg_files
()
{
$git_ls
-z
--
'*.c.in'
'*.h.in'
'*.hxx.in'
}
list_all_files
()
{
$git_ls
-z
--
'*.c'
'*.c.in'
'*.cxx'
'*.h'
'*.h.in'
'*.hxx'
'*.hxx.in'
# List files as selected above.
list_files
()
{
$git_ls
|
# Select sources with our attribute.
git check-attr
--stdin
format.clang-format |
sed
-n
'/: format\.clang-format: set$/ {s/:[^:]*:[^:]*$//p}'
}
# Transform configured sources to protect @SYMBOLS@.
list_
cfg_
files | xargs
-
0
-r
sed
-i
's/@\(KWSYS_[A-Z0-9_]\+\)@/x\1x/g'
list_files | xargs
-
d
'\n'
sed
-i
's/@\(KWSYS_[A-Z0-9_]\+\)@/x\1x/g'
# Update sources in-place.
list_
all_
files | xargs
-
0
"
$clang_format
"
-i
list_files | xargs
-
d
'\n'
"
$clang_format
"
-i
# Transform configured sources to restore @SYMBOLS@.
list_
cfg_
files | xargs
-
0
-r
sed
-i
's/x\(KWSYS_[A-Z0-9_]\+\)x/@\1@/g'
list_files | xargs
-
d
'\n'
sed
-i
's/x\(KWSYS_[A-Z0-9_]\+\)x/@\1@/g'
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment