[clang] ced0f28 - Improve clang-format-diff help output (#73491)
via cfe-commits
cfe-commits at lists.llvm.org
Tue Nov 28 05:46:42 PST 2023
Author: serge-sans-paille
Date: 2023-11-28T13:46:37Z
New Revision: ced0f28a35b8a14759e6bd9418e8c8a7c35775c8
URL: https://github.com/llvm/llvm-project/commit/ced0f28a35b8a14759e6bd9418e8c8a7c35775c8
DIFF: https://github.com/llvm/llvm-project/commit/ced0f28a35b8a14759e6bd9418e8c8a7c35775c8.diff
LOG: 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.
Added:
Modified:
clang/tools/clang-format/clang-format-diff.py
Removed:
################################################################################
diff --git a/clang/tools/clang-format/clang-format-
diff .py b/clang/tools/clang-format/clang-format-
diff .py
index 892c1e38a462ff4..b25ee8f4337518e 100755
--- a/clang/tools/clang-format/clang-format-
diff .py
+++ b/clang/tools/clang-format/clang-format-
diff .py
@@ -13,8 +13,8 @@
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 @@
import argparse
import
diff lib
+import os
import re
import subprocess
import sys
@@ -36,8 +37,10 @@
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",
More information about the cfe-commits
mailing list