]> git.proxmox.com Git - mirror_edk2.git/commitdiff
BaseTools/PatchCheck.py: Fix misreport for binary changes in patch
authorHao Wu <hao.a.wu@intel.com>
Thu, 8 Jun 2017 02:58:22 +0000 (10:58 +0800)
committerHao Wu <hao.a.wu@intel.com>
Mon, 26 Jun 2017 01:26:56 +0000 (09:26 +0800)
For a patch file that:
1. Contains a binary change
2. Contains any other changes after the binary change

PatchCheck.py will complains with the following error:
* Patch format error: diff found after end of patch
   Line: literal XXXX

This commit resolves this misreport.

Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Hao Wu <hao.a.wu@intel.com>
Reviewed-by: Liming Gao <liming.gao@intel.com>
BaseTools/Scripts/PatchCheck.py

index 7c3008233c24f07d540e37326f48f79ae8050540..4bc697b1af1623ca247d87de187dc319ec7fe947 100755 (executable)
@@ -1,7 +1,7 @@
 ## @file\r
 #  Check a patch for various format issues\r
 #\r
-#  Copyright (c) 2015 - 2016, Intel Corporation. All rights reserved.<BR>\r
+#  Copyright (c) 2015 - 2017, Intel Corporation. All rights reserved.<BR>\r
 #\r
 #  This program and the accompanying materials are licensed and made\r
 #  available under the terms and conditions of the BSD License which\r
@@ -265,7 +265,7 @@ class GitDiffCheck:
             if line.startswith('@@ '):\r
                 self.state = PRE_PATCH\r
             elif len(line) >= 1 and line[0] not in ' -+' and \\r
-                 not line.startswith(r'\ No newline '):\r
+                 not line.startswith(r'\ No newline ') and not self.binary:\r
                 for line in self.lines[self.line_num + 1:]:\r
                     if line.startswith('diff --git'):\r
                         self.format_error('diff found after end of patch')\r
@@ -300,7 +300,7 @@ class GitDiffCheck:
         elif self.state == PATCH:\r
             if self.binary:\r
                 pass\r
-            if line.startswith('-'):\r
+            elif line.startswith('-'):\r
                 pass\r
             elif line.startswith('+'):\r
                 self.check_added_line(line[1:])\r