From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from us-smtp-1.mimecast.com (us-smtp-1.mimecast.com [205.139.110.120]) by mx.groups.io with SMTP id smtpd.web11.11567.1579865077728741496 for ; Fri, 24 Jan 2020 03:24:38 -0800 Authentication-Results: mx.groups.io; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=EvESq+Rl; spf=pass (domain: redhat.com, ip: 205.139.110.120, mailfrom: lersek@redhat.com) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1579865076; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=+qQhhj6Dcc+tBhRh0JVmHSIrWj9bunBvAkOMteWwFKo=; b=EvESq+RlmkZSQH/mrE1+3NAWtUGhXIsWriex3ZJqZUqI2nYUuzbNYaFg1BepWn9zWWiOeJ NmeFb5aW/jwZHw1F65dUHZezR5uRJgVf7tcv1sfYe+4ce767f55xeczcIOpTnACA3+OVqQ yZAvbtyEkEV7zOmKsXwAC0q/eztdtbc= Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-242-m_XHakrfPMmioX9LLUFolg-1; Fri, 24 Jan 2020 06:24:28 -0500 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 5135A1882CC3; Fri, 24 Jan 2020 11:24:27 +0000 (UTC) Received: from lacos-laptop-7.usersys.redhat.com (ovpn-117-77.ams2.redhat.com [10.36.117.77]) by smtp.corp.redhat.com (Postfix) with ESMTP id F128C8578D; Fri, 24 Jan 2020 11:24:25 +0000 (UTC) Subject: Re: [Patch] BaseTools/Scripts/PatchCheck.py: Remove submodule false positives To: Michael D Kinney , devel@edk2.groups.io Cc: Bob Feng , Liming Gao References: <20200123231055.15988-1-michael.d.kinney@intel.com> From: "Laszlo Ersek" Message-ID: <0e907910-f317-2a97-7351-df4620d13b62@redhat.com> Date: Fri, 24 Jan 2020 12:24:24 +0100 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.9.1 MIME-Version: 1.0 In-Reply-To: <20200123231055.15988-1-michael.d.kinney@intel.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 X-MC-Unique: m_XHakrfPMmioX9LLUFolg-1 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Language: en-US Content-Type: text/plain; charset=windows-1252 Content-Transfer-Encoding: 7bit On 01/24/20 00:10, Michael D Kinney wrote: > 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) > https://github.com/git/git/blob/master/Documentation/technical/index-format.txt 32-bit mode, split into (high to low bits) 4-bit object type valid values in binary are 1000 (regular file), 1010 (symbolic link) and 1110 (gitlink) 3-bit unused 9-bit unix permission. Only 0755 and 0644 are valid for regular files. Symbolic links and gitlinks have value 0 in this field. Octal 160000 is E000 hexadecimal. That makes the unused bits and the unix permission bits (12 bits in total) zero, and 0xE is 1110 binary, so the object type is "gitlink". Reviewed-by: Laszlo Ersek Thanks Laszlo