diff options
Diffstat (limited to 'share/clang/clang-format-diff.py')
| -rwxr-xr-x | share/clang/clang-format-diff.py | 16 |
1 files changed, 10 insertions, 6 deletions
diff --git a/share/clang/clang-format-diff.py b/share/clang/clang-format-diff.py index 122db49..6e653a1 100755 --- a/share/clang/clang-format-diff.py +++ b/share/clang/clang-format-diff.py @@ -13,9 +13,13 @@ This script reads input from a unified diff and reformats all the changed lines. This is useful to reformat all the lines touched by a specific patch. Example usage for git/svn users: - git diff -U0 --no-color HEAD^ | clang-format-diff.py -p1 -i + git diff -U0 --no-color --relative HEAD^ | clang-format-diff.py -p1 -i svn diff --diff-cmd=diff -x-U0 | clang-format-diff.py -i +It should be noted that the filename contained in the diff is used unmodified +to determine the source file to update. Users calling this script directly +should be careful to ensure that the path in the diff is correct relative to the +current working directory. """ from __future__ import absolute_import, division, print_function @@ -43,8 +47,8 @@ def main(): help='custom pattern selecting file paths to reformat ' '(case sensitive, overrides -iregex)') parser.add_argument('-iregex', metavar='PATTERN', default= - r'.*\.(cpp|cc|c\+\+|cxx|c|cl|h|hh|hpp|m|mm|inc|js|ts|proto' - r'|protodevel|java|cs)', + r'.*\.(cpp|cc|c\+\+|cxx|c|cl|h|hh|hpp|hxx|m|mm|inc|js|ts' + r'|proto|protodevel|java|cs)', help='custom pattern selecting file paths to reformat ' '(case insensitive, overridden by -regex)') parser.add_argument('-sort-includes', action='store_true', default=False, @@ -52,8 +56,8 @@ def main(): parser.add_argument('-v', '--verbose', action='store_true', help='be more verbose, ineffective without -i') parser.add_argument('-style', - help='formatting style to apply (LLVM, Google, Chromium, ' - 'Mozilla, WebKit)') + help='formatting style to apply (LLVM, GNU, Google, Chromium, ' + 'Microsoft, Mozilla, WebKit)') parser.add_argument('-binary', default='clang-format', help='location of binary to use for clang-format') args = parser.parse_args() @@ -65,7 +69,7 @@ def main(): match = re.search(r'^\+\+\+\ (.*?/){%s}(\S*)' % args.p, line) if match: filename = match.group(2) - if filename == None: + if filename is None: continue if args.regex is not None: |
