[clang] 5a77b95 - [NFC] Improve doc string to mention that paths in diff are used as-is

Christopher Tetreault via cfe-commits cfe-commits at lists.llvm.org
Wed May 6 15:20:24 PDT 2020


Author: Christopher Tetreault
Date: 2020-05-06T15:20:05-07:00
New Revision: 5a77b958e250fbf156474b42ccf5a82e8a36db72

URL: https://github.com/llvm/llvm-project/commit/5a77b958e250fbf156474b42ccf5a82e8a36db72
DIFF: https://github.com/llvm/llvm-project/commit/5a77b958e250fbf156474b42ccf5a82e8a36db72.diff

LOG: [NFC] Improve doc string to mention that paths in diff are used as-is

Summary:
Add --relative to the suggested git-diff one liner. If the user does not
pass this argument, then git will produce a diff with the path relative
to the repository root. If the user's working directory is not the
repository root, then clang-format will complain that the file is not
found. The --relative argument makes git produce a diff with the files
relative to the working directory.

Add note to doc string to warn users about the fact that filenames
embedded in the diff are used as-is with no attempts to "do what they
mean, not what they say"

Reviewers: djasper, alexfh, efriedma, klimek, thakis

Reviewed By: efriedma

Subscribers: cfe-commits

Tags: #clang

Differential Revision: https://reviews.llvm.org/D79054

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 24c6f4ae456c..5977ab056515 100755
--- a/clang/tools/clang-format/clang-format-
diff .py
+++ b/clang/tools/clang-format/clang-format-
diff .py
@@ -13,9 +13,13 @@
 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 HEAD^ | clang-format-
diff .py -p1 -i
+  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
 
+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
+should be careful to ensure that the path in the 
diff  is correct relative to the
+current working directory.
 """
 from __future__ import absolute_import, division, print_function
 


        


More information about the cfe-commits mailing list