Skip to content

Commit ced0f28

Browse files
Improve clang-format-diff help output (#73491)
It is quite common to symlink clang-format-diff.py to clang-format-diff, and in that case the help output still refers to the .py version. Compute it instead to work in both setup.
1 parent 2c729d2 commit ced0f28

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

clang/tools/clang-format/clang-format-diff.py

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,8 @@
1313
lines. This is useful to reformat all the lines touched by a specific patch.
1414
Example usage for git/svn users:
1515
16-
git diff -U0 --no-color --relative HEAD^ | clang-format-diff.py -p1 -i
17-
svn diff --diff-cmd=diff -x-U0 | clang-format-diff.py -i
16+
git diff -U0 --no-color --relative HEAD^ | {clang_format_diff} -p1 -i
17+
svn diff --diff-cmd=diff -x-U0 | {clang_format_diff} -i
1818
1919
It should be noted that the filename contained in the diff is used unmodified
2020
to determine the source file to update. Users calling this script directly
@@ -25,6 +25,7 @@
2525

2626
import argparse
2727
import difflib
28+
import os
2829
import re
2930
import subprocess
3031
import sys
@@ -36,8 +37,10 @@
3637

3738

3839
def main():
40+
basename = os.path.basename(sys.argv[0])
3941
parser = argparse.ArgumentParser(
40-
description=__doc__, formatter_class=argparse.RawDescriptionHelpFormatter
42+
description=__doc__.format(clang_format_diff=basename),
43+
formatter_class=argparse.RawDescriptionHelpFormatter,
4144
)
4245
parser.add_argument(
4346
"-i",

0 commit comments

Comments
 (0)