patman: Deal with git safe-directory warning
When running tests where the .git directory is not owned by the current
user, various warnings are produced and the tests fail. This happens in
CI.
For patman itself, modify the gitutil.get_top_level() function to return
None in this case. Ensure that the warning is not shown, since it creates
about 1000 lines of output.
For checkpatch, the same warning is produced even though --no-tree is
given. Suppress that as well.
Signed-off-by: Simon Glass <sjg@chromium.org>
diff --git a/tools/patman/checkpatch.py b/tools/patman/checkpatch.py
index 5df06b1..f9204a9 100644
--- a/tools/patman/checkpatch.py
+++ b/tools/patman/checkpatch.py
@@ -22,7 +22,7 @@
def find_check_patch():
- top_level = gitutil.get_top_level()
+ top_level = gitutil.get_top_level() or ''
try_list = [
os.getcwd(),
os.path.join(os.getcwd(), '..', '..'),
@@ -219,8 +219,9 @@
args.append('--no-tree')
if show_types:
args.append('--show-types')
- output = command.output(*args, os.path.join(cwd or '', fname),
- raise_on_error=False)
+ output = command.output(
+ *args, os.path.join(cwd or '', fname), raise_on_error=False,
+ capture_stderr=not use_tree)
return check_patch_parse(output, verbose)