Use git-format-patch to generate patch feeds patches of commits to for style check.
However it generates patches using git-show instead of git-format-patch.
The problem with git-show is that its output format is configurable
through git-config, and so it might generate a illegitimate formatted
patch.  Besides, git-format-patch should be used to generate patches

TEST=Run commands below:
       cd path/to/kernel
       git config --local --add format.pretty oneline
     You should see no "ERROR: Missing Signed-off-by: line(s)".

Change-Id: Ica7e2f91ba67a4ba4d4ba1034c9594c67126b06d
Tested-by: Che-Liang Chiou <>
Reviewed-by: Mandeep Singh Baines <>
Reviewed-by: Ryan Cui <>
Commit-Queue: Che-Liang Chiou <>
diff --git a/ b/
index 1da78d1..5752d16 100755
--- a/
+++ b/
@@ -186,9 +186,9 @@
   return full_upstream.replace('heads', 'remotes/' + remote)
-def _get_diff(commit):
-  """Returns the diff for this commit."""
-  return _run_command(['git', 'show', commit])
+def _get_patch(commit):
+  """Returns the patch for this commit."""
+  return _run_command(['git', 'format-patch', '--stdout', '-1', commit])
 def _try_utf8_decode(data):
@@ -383,7 +383,7 @@
   hooks_dir = _get_hooks_dir()
   cmd = ['%s/' % hooks_dir] + options + ['-']
   p = subprocess.Popen(cmd, stdin=subprocess.PIPE, stdout=subprocess.PIPE)
-  output = p.communicate(_get_diff(commit))[0]
+  output = p.communicate(_get_patch(commit))[0]
   if p.returncode:
     return HookFailure(' errors/warnings\n\n' + output)