@@ -205,6 +205,12 @@ def main():
205205 "commits"
206206 ),
207207 )
208+ p .add_argument (
209+ "-0" ,
210+ "--null" ,
211+ action = "store_true" ,
212+ help = "print the affected paths with null-terminated characters" ,
213+ )
208214 # We gather all the remaining positional arguments into 'args' since we need
209215 # to use some heuristics to determine whether or not <commit> was present.
210216 # However, to print pretty messages, we make use of metavar and help.
@@ -261,11 +267,11 @@ def main():
261267 "ignored by clang-format):"
262268 )
263269 for filename in ignored_files :
264- print ( " %s" % filename )
270+ print_filename ( filename , opts . null )
265271 if changed_lines :
266272 print ("Running clang-format on the following files:" )
267273 for filename in changed_lines :
268- print ( " %s" % filename )
274+ print_filename ( filename , opts . null )
269275
270276 if not changed_lines :
271277 if opts .verbose >= 0 :
@@ -304,7 +310,7 @@ def main():
304310 if (opts .verbose >= 0 and not opts .patch ) or opts .verbose >= 1 :
305311 print ("changed files:" )
306312 for filename in changed_files :
307- print ( " %s" % filename )
313+ print_filename ( filename , opts . null )
308314
309315 return 1
310316
@@ -869,5 +875,12 @@ def convert_string(bytes_input):
869875 return str (bytes_input )
870876
871877
878+ def print_filename (filename , null = False ):
879+ if null :
880+ print (filename + "\0 " , end = "" )
881+ else :
882+ print (" %s" % filename )
883+
884+
872885if __name__ == "__main__" :
873886 sys .exit (main ())
0 commit comments