@@ -107,6 +107,23 @@ def run_clang_format_diff(args, file):
107
107
raise DiffError (str (exc ))
108
108
invocation = [args .clang_format_executable , file ]
109
109
110
+ # Add debug output for clang-format configuration
111
+ if hasattr (args , 'show_config' ) and args .show_config :
112
+ config_invocation = [args .clang_format_executable , '--dump-config' , file ]
113
+ try :
114
+ config_proc = subprocess .Popen (
115
+ config_invocation ,
116
+ stdout = subprocess .PIPE ,
117
+ stderr = subprocess .PIPE ,
118
+ universal_newlines = True )
119
+ config_stdout , config_stderr = config_proc .communicate ()
120
+ if config_proc .returncode == 0 :
121
+ print ("Clang-format configuration for {}:" .format (file ))
122
+ print (config_stdout )
123
+ print ("=" * 50 )
124
+ except Exception as e :
125
+ print ("Could not dump config: {}" .format (e ))
126
+
110
127
# Use of utf-8 to decode the process output.
111
128
#
112
129
# Hopefully, this is the correct thing to do.
@@ -244,6 +261,10 @@ def main():
244
261
default = [],
245
262
help = 'exclude paths matching the given glob-like pattern(s)'
246
263
' from recursive search' )
264
+ parser .add_argument (
265
+ '--show-config' ,
266
+ action = 'store_true' ,
267
+ help = 'dump the clang-format configuration being used' )
247
268
248
269
args = parser .parse_args ()
249
270
0 commit comments