Snap for 6671412 from c2fc52cc787edef0ef1818726b9bf656b894b894 to rvc-d1-release

Change-Id: I47dbb4f81bbb8d09a66e46895c887f9b59739816
diff --git a/checkstyle.py b/checkstyle.py
index 9733848..85a5d90 100755
--- a/checkstyle.py
+++ b/checkstyle.py
@@ -182,9 +182,12 @@
                              stdout=subprocess.PIPE, env=checkstyle_env,
                              universal_newlines=True)
     stdout, _ = check.communicate()
+    stdout_lines = stdout.splitlines()
     # A work-around for Checkstyle printing error count to stdio.
-    if '</checkstyle>' in stdout.splitlines()[-2]:
-      stdout = '\n'.join(stdout.splitlines()[:-1])
+    if len(stdout_lines) < 2:
+      stdout = stdout_lines[0]
+    elif len(stdout_lines) >= 2 and '</checkstyle>' in stdout_lines[-2]:
+      stdout = '\n'.join(stdout_lines[:-1])
     return stdout
   except OSError as e:
     if e.errno == errno.ENOENT:
diff --git a/gitlint/git.py b/gitlint/git.py
index 9d796f6..e55aa06 100644
--- a/gitlint/git.py
+++ b/gitlint/git.py
@@ -126,7 +126,7 @@
 
     # Split as bytes, as the output may have some non unicode characters.
     blame_lines = subprocess.check_output(
-        ['git', 'blame', commit, '--porcelain', '--', filename]).split(
+        ['git', 'blame', (commit + '^!'), '--porcelain', '--', filename]).split(
             os.linesep.encode('utf-8'))
     modified_line_numbers = utils.filter_lines(
         blame_lines,