aboutsummaryrefslogtreecommitdiff
path: root/clang/tools/clang-format/clang-format-diff.py
diff options
context:
space:
mode:
authorserge-sans-paille <sguelton@mozilla.com>2023-11-28 13:46:37 +0000
committerGitHub <noreply@github.com>2023-11-28 13:46:37 +0000
commitced0f28a35b8a14759e6bd9418e8c8a7c35775c8 (patch)
tree12c3b746da0fadb63718a51ecfae6d398a8dd2f8 /clang/tools/clang-format/clang-format-diff.py
parent2c729d29aa1390253508c19b4d83dbedb233098d (diff)
downloadllvm-ced0f28a35b8a14759e6bd9418e8c8a7c35775c8.zip
llvm-ced0f28a35b8a14759e6bd9418e8c8a7c35775c8.tar.gz
llvm-ced0f28a35b8a14759e6bd9418e8c8a7c35775c8.tar.bz2
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.
Diffstat (limited to 'clang/tools/clang-format/clang-format-diff.py')
-rwxr-xr-xclang/tools/clang-format/clang-format-diff.py9
1 files changed, 6 insertions, 3 deletions
diff --git a/clang/tools/clang-format/clang-format-diff.py b/clang/tools/clang-format/clang-format-diff.py
index 892c1e3..b25ee8f 100755
--- a/clang/tools/clang-format/clang-format-diff.py
+++ b/clang/tools/clang-format/clang-format-diff.py
@@ -13,8 +13,8 @@ This script reads input from a unified diff and reformats all the changed
lines. This is useful to reformat all the lines touched by a specific patch.
Example usage for git/svn users:
- git diff -U0 --no-color --relative HEAD^ | clang-format-diff.py -p1 -i
- svn diff --diff-cmd=diff -x-U0 | clang-format-diff.py -i
+ git diff -U0 --no-color --relative HEAD^ | {clang_format_diff} -p1 -i
+ svn diff --diff-cmd=diff -x-U0 | {clang_format_diff} -i
It should be noted that the filename contained in the diff is used unmodified
to determine the source file to update. Users calling this script directly
@@ -25,6 +25,7 @@ from __future__ import absolute_import, division, print_function
import argparse
import difflib
+import os
import re
import subprocess
import sys
@@ -36,8 +37,10 @@ else:
def main():
+ basename = os.path.basename(sys.argv[0])
parser = argparse.ArgumentParser(
- description=__doc__, formatter_class=argparse.RawDescriptionHelpFormatter
+ description=__doc__.format(clang_format_diff=basename),
+ formatter_class=argparse.RawDescriptionHelpFormatter,
)
parser.add_argument(
"-i",