From a38fcbb5b007da0e3411271009ef978dc0191256 Mon Sep 17 00:00:00 2001 From: Igor Murashkin Date: Mon, 6 Nov 2017 15:00:05 -0800 Subject: [PATCH] cpplint: Fix --root for non-subdirectories Using cpplint.py --root with directories at a more outer level than the repository would not work. For example given /a/b/c/.git/filename.cpp Trying to use --root=/a/b would get ignored, and it would ask for a headerguard of FILENAME_H_ instead of C_FILENAME_H_ as expected. Now --root will always use the "full name" and then strip off --root prefix, giving us the desired effect. --- cpplint/cpplint.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/cpplint/cpplint.py b/cpplint/cpplint.py index 52cb7d0ca..73bf16ae6 100755 --- a/cpplint/cpplint.py +++ b/cpplint/cpplint.py @@ -1777,6 +1777,8 @@ def GetHeaderGuardCPPVariable(filename): fileinfo = FileInfo(filename) file_path_from_root = fileinfo.RepositoryName() if _root: + file_path_from_root = fileinfo.FullName() + suffix = os.sep # On Windows using directory separator will leave us with # "bogus escape error" unless we properly escape regex.