[clang-format] Allow git-clang-format to handle empty extensions.

Most of libc++'s header files don't use extension. This prevents
using git-clang-format on them, which is frustrating.

This patch allows empty extensions to be passed using either
the --extensions option, or the clangformat.extensions git-config
value.

llvm-svn: 305437
This commit is contained in:
Eric Fiselier 2017-06-15 00:54:08 +00:00
parent 4a2cc96f1f
commit eea71e8f0e
1 changed files with 2 additions and 0 deletions

View File

@ -324,6 +324,8 @@ def filter_by_extension(dictionary, allowed_extensions):
allowed_extensions = frozenset(allowed_extensions)
for filename in list(dictionary.keys()):
base_ext = filename.rsplit('.', 1)
if len(base_ext) == 1 and '' in allowed_extensions:
continue
if len(base_ext) == 1 or base_ext[1].lower() not in allowed_extensions:
del dictionary[filename]