Suppress stderr of the git rev-parse command

In GetPrimarySolutionPath(), redirect the stderr of the
git rev-parse --show-toplevel command to /dev/null. This avoids the
following error message when running depot_tools' ninja command outside
the Chrome source tree:
fatal: not a git repository (or any of the parent directories): .git

I believe this error message was an unintended side effect of the work
on bug 1340825.

Bug: 1340825
Change-Id: I5679a854d1ff23f581564c54c765e13f8ba8b534
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/tools/depot_tools/+/4392154
Commit-Queue: Wan-Teh Chang <wtc@google.com>
Reviewed-by: Junji Watanabe <jwata@google.com>
Reviewed-by: Gavin Mak <gavinmak@google.com>
changes/54/4392154/2
Wan-Teh Chang 2 years ago committed by LUCI CQ
parent badcbc5268
commit bc5906f6ff

@ -76,8 +76,8 @@ def GetPrimarySolutionPath():
# checkout that contains a 'buildtools' subdir.
top_dir = os.getcwd()
try:
top_dir = subprocess2.check_output(
['git', 'rev-parse', '--show-toplevel'])
top_dir = subprocess2.check_output(['git', 'rev-parse', '--show-toplevel'],
stderr=subprocess2.DEVNULL)
if sys.version_info.major == 3:
top_dir = top_dir.decode('utf-8', 'replace')
top_dir = os.path.normpath(top_dir.strip())

Loading…
Cancel
Save