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

Jake Merdich via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Sat May 23 19:38:16 PDT 2020


JakeMerdichAMD created this revision.
JakeMerdichAMD added reviewers: MyDeveloperDay, krasimir, sammccall.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

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.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D80486

Files:
  clang/tools/clang-format/git-clang-format


Index: clang/tools/clang-format/git-clang-format
===================================================================
--- clang/tools/clang-format/git-clang-format
+++ clang/tools/clang-format/git-clang-format
@@ -192,7 +192,12 @@
   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


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D80486.265904.patch
Type: text/x-patch
Size: 703 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20200524/49c5f39e/attachment-0001.bin>


More information about the cfe-commits mailing list