[clang-format][PR46043] Parse git config w/ implicit values

Summary:
https://bugs.llvm.org/show_bug.cgi?id=46043

Git's config is generally of the format 'key=val', but a setting
'key=true' can be written as just 'key'.  The git-clang-format script
expects a value and crashes in this case; this change handles implicit
'true' values in the script.

Reviewers: MyDeveloperDay, krasimir, sammccall

Subscribers: cfe-commits

Tags: #clang

Differential Revision: https://reviews.llvm.org/D80486
This commit is contained in:
Jake Merdich 2020-05-23 22:21:10 -04:00
parent d0da5d2bbe
commit 52b03aaa22
1 changed files with 6 additions and 1 deletions

View File

@ -192,7 +192,12 @@ def load_git_config(non_string_options=None):
out = {}
for entry in run('git', 'config', '--list', '--null').split('\0'):
if entry:
name, value = entry.split('\n', 1)
if '\n' in entry:
name, value = entry.split('\n', 1)
else:
# A setting with no '=' ('\n' with --null) is implicitly 'true'
name = entry
value = 'true'
if name in non_string_options:
value = run('git', 'config', non_string_options[name], name)
out[name] = value