From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mga03.intel.com (mga03.intel.com [134.134.136.65]) by mx.groups.io with SMTP id smtpd.web12.4585.1579821066152530976 for ; Thu, 23 Jan 2020 15:11:06 -0800 Authentication-Results: mx.groups.io; dkim=missing; spf=pass (domain: intel.com, ip: 134.134.136.65, mailfrom: michael.d.kinney@intel.com) X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga001.fm.intel.com ([10.253.24.23]) by orsmga103.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 23 Jan 2020 15:10:56 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.70,355,1574150400"; d="scan'208";a="290036900" Received: from unknown (HELO mdkinney-MOBL2.amr.corp.intel.com) ([10.241.98.74]) by fmsmga001.fm.intel.com with ESMTP; 23 Jan 2020 15:10:56 -0800 From: "Michael D Kinney" To: devel@edk2.groups.io Cc: Bob Feng , Liming Gao , Laszlo Ersek Subject: [Patch] BaseTools/Scripts/PatchCheck.py: Remove submodule false positives Date: Thu, 23 Jan 2020 15:10:55 -0800 Message-Id: <20200123231055.15988-1-michael.d.kinney@intel.com> X-Mailer: git-send-email 2.21.0.windows.1 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit https://bugzilla.tianocore.org/show_bug.cgi?id=2484 https://bugzilla.tianocore.org/show_bug.cgi?id=2485 Update PatchCheck to not enforce no tabs and not enforce CR/LF line endings for .gitmodules files. These files are updated by git when a git submodule command is used and the updates by git use tab characters and LF line endings. Also update patch check to not enforce CR/LF line endings for patch lines that create a submodule directory. These patch lines use LF line endings. The git submodule directory is added as a new file with attributes 160000 that can be detected by looking for the pattern "new file mode 160000". Cc: Bob Feng Cc: Liming Gao Cc: Laszlo Ersek Signed-off-by: Michael D Kinney --- BaseTools/Scripts/PatchCheck.py | 23 +++++++++++++++++++++-- 1 file changed, 21 insertions(+), 2 deletions(-) diff --git a/BaseTools/Scripts/PatchCheck.py b/BaseTools/Scripts/PatchCheck.py index 173d4517e0..6823cc69bb 100755 --- a/BaseTools/Scripts/PatchCheck.py +++ b/BaseTools/Scripts/PatchCheck.py @@ -341,7 +341,21 @@ class GitDiffCheck: self.state = PRE_PATCH self.filename = line[13:].split(' ', 1)[0] self.is_newfile = False - self.force_crlf = not self.filename.endswith('.sh') + self.force_crlf = True + self.force_notabs = True + if self.filename.endswith('.sh'): + # + # Do not enforce CR/LF line endings for linux shell scripts. + # + self.force_crlf = False + if self.filename == '.gitmodules': + # + # .gitmodules is updated by git and uses tabs and LF line + # endings. Do not enforce no tabs and do not enforce + # CR/LF line endings. + # + self.force_crlf = False + self.force_notabs = False elif len(line.rstrip()) != 0: self.format_error("didn't find diff command") self.line_num += 1 @@ -355,6 +369,11 @@ class GitDiffCheck: self.binary = True if self.is_newfile: self.new_bin.append(self.filename) + elif line.startswith('new file mode 160000'): + # + # New submodule. Do not enforce CR/LF line endings + # + self.force_crlf = False else: ok = False self.is_newfile = self.newfile_prefix_re.match(line) @@ -429,7 +448,7 @@ class GitDiffCheck: if self.force_crlf and eol != '\r\n': self.added_line_error('Line ending (%s) is not CRLF' % repr(eol), line) - if '\t' in line: + if self.force_notabs and '\t' in line: self.added_line_error('Tab character used', line) if len(stripped) < len(line): self.added_line_error('Trailing whitespace found', line) -- 2.21.0.windows.1