Use git-format-patch to generate patch
pre-upload.py feeds patches of commits to checkpatch.pl 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
anyway.
BUG=none
TEST=Run commands below:
cd path/to/kernel
git config --local --add format.pretty oneline
path/to/pre-upload.py
You should see no "ERROR: Missing Signed-off-by: line(s)".
Change-Id: Ica7e2f91ba67a4ba4d4ba1034c9594c67126b06d
Reviewed-on: https://gerrit.chromium.org/gerrit/46347
Tested-by: Che-Liang Chiou <clchiou@chromium.org>
Reviewed-by: Mandeep Singh Baines <msb@chromium.org>
Reviewed-by: Ryan Cui <rcui@chromium.org>
Commit-Queue: Che-Liang Chiou <clchiou@chromium.org>
diff --git a/pre-upload.py b/pre-upload.py
index 1da78d1..5752d16 100755
--- a/pre-upload.py
+++ b/pre-upload.py
@@ -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/checkpatch.pl' % 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('checkpatch.pl errors/warnings\n\n' + output)