Skip to content

Commit a38fcbb

Browse files
committed
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.
1 parent ec88ff9 commit a38fcbb

File tree

1 file changed

+2
-0
lines changed

1 file changed

+2
-0
lines changed

cpplint/cpplint.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1777,6 +1777,8 @@ def GetHeaderGuardCPPVariable(filename):
17771777
fileinfo = FileInfo(filename)
17781778
file_path_from_root = fileinfo.RepositoryName()
17791779
if _root:
1780+
file_path_from_root = fileinfo.FullName()
1781+
17801782
suffix = os.sep
17811783
# On Windows using directory separator will leave us with
17821784
# "bogus escape error" unless we properly escape regex.

0 commit comments

Comments
 (0)