[gclient] Fix an issue with gclient hanging.

gclient hangs when I try to update my infra checkout,
running pstree reveals that we're waiting for less to
complete, which it can't do because of how gclient
invokes less.

In the absence of a more robust mechanism for making
git non-interactive, I vote we just set the pager to
cat and the editor to false and call it a day.

Change-Id: Icc66c0a91d45426bb5f65f2ffb325c4f6b6e532d
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/tools/depot_tools/+/7008969
Commit-Queue: Gregory Nisbet <gregorynisbet@google.com>
Reviewed-by: Gavin Mak <gavinmak@google.com>
This commit is contained in:
Greg NISBET
2025-10-07 11:52:14 -07:00
committed by LUCI CQ
parent 9e2bef892d
commit d04b267a2d

View File

@@ -4657,6 +4657,22 @@ def can_run_gclient_and_helpers():
def main(argv): def main(argv):
"""Doesn't parse the arguments here, just find the right subcommand to """Doesn't parse the arguments here, just find the right subcommand to
execute.""" execute."""
# gclient will sometimes hang when trying to `gclient sync` an infra checkout.
# Running pstree reveals what's happening:
#
# | |-tmux: server-+-bash-+-python3---git---less
# | | | `-vim---{vim}
# | | |-bash
# | | `-bash-+-pstree
# | | `-vim
#
# `less` in this case is the git pager. So, let's set the pager to something harmless.
# For good measure, let's also set the editor to false so that we don't even try to
# get the user to edit something.
os.environ["GIT_PAGER"] = "cat"
os.environ["GIT_EDITOR"] = "false"
if not can_run_gclient_and_helpers(): if not can_run_gclient_and_helpers():
return 2 return 2
disable_buffering() disable_buffering()