summaryrefslogtreecommitdiff
path: root/tools/u_boot_pylib/gitutil.py
diff options
context:
space:
mode:
authorSimon Glass <sjg@chromium.org>2025-05-10 13:04:55 +0200
committerSimon Glass <sjg@chromium.org>2025-05-27 10:07:42 +0100
commit212ed6bdb73d7999c8a25ad0c55a5358c0b44f03 (patch)
tree74b6fc80496b1d2c12ec3316623ba83891c91ce7 /tools/u_boot_pylib/gitutil.py
parent45f239afa1f85fdc6700d8e088e179024c6c21b0 (diff)
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>
Diffstat (limited to 'tools/u_boot_pylib/gitutil.py')
-rw-r--r--tools/u_boot_pylib/gitutil.py11
1 files changed, 8 insertions, 3 deletions
diff --git a/tools/u_boot_pylib/gitutil.py b/tools/u_boot_pylib/gitutil.py
index cfcfeffe2f4..7d001d03bed 100644
--- a/tools/u_boot_pylib/gitutil.py
+++ b/tools/u_boot_pylib/gitutil.py
@@ -644,7 +644,7 @@ def get_top_level():
"""Return name of top-level directory for this git repo.
Returns:
- str: Full path to git top-level directory
+ str: Full path to git top-level directory, or None if not found
This test makes sure that we are running tests in the right subdir
@@ -652,7 +652,12 @@ def get_top_level():
os.path.join(get_top_level(), 'tools', 'patman')
True
"""
- return command.output_one_line('git', 'rev-parse', '--show-toplevel')
+ result = command.run_one(
+ 'git', 'rev-parse', '--show-toplevel', oneline=True, capture=True,
+ capture_stderr=True, raise_on_error=False)
+ if result.return_code:
+ return None
+ return result.stdout.strip()
def get_alias_file():
@@ -670,7 +675,7 @@ def get_alias_file():
if os.path.isabs(fname):
return fname
- return os.path.join(get_top_level(), fname)
+ return os.path.join(get_top_level() or '', fname)
def get_default_user_name():