@@ -107,6 +107,23 @@ def run_clang_format_diff(args, file):
107107 raise DiffError (str (exc ))
108108 invocation = [args .clang_format_executable , file ]
109109
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+
110127 # Use of utf-8 to decode the process output.
111128 #
112129 # Hopefully, this is the correct thing to do.
@@ -244,6 +261,10 @@ def main():
244261 default = [],
245262 help = 'exclude paths matching the given glob-like pattern(s)'
246263 ' from recursive search' )
264+ parser .add_argument (
265+ '--show-config' ,
266+ action = 'store_true' ,
267+ help = 'dump the clang-format configuration being used' )
247268
248269 args = parser .parse_args ()
249270
0 commit comments