diff options
author | Josip Sokcevic <sokcevic@chromium.org> | 2024-09-26 21:55:10 +0000 |
---|---|---|
committer | LUCI <gerrit-scoped@luci-project-accounts.iam.gserviceaccount.com> | 2024-09-26 22:10:36 +0000 |
commit | 621de7ed127f2adb39ed1f0747383ac2afc4d075 (patch) | |
tree | d5bdd5a66932a3aa93193d01291e5ae580c3a873 /git_command.py | |
parent | d7ebdf56be6095338ea37bd4b52533c5bd7774e7 (diff) | |
download | git-repo-621de7ed127f2adb39ed1f0747383ac2afc4d075.tar.gz |
Disable git terminal prompt during fetch/clone
git fetch operation may prompt user to enter username and password.
This won't be visible to user when repo sync operation since stdout and
stderr are redirected. If that happens, user may think repo is doing
work and likely won't realize it's stuck on user's input.
This patch disables prompt for clone and fetch operations, and repo will
fail fast.
R=gavinmak@google.com
Bug: b/368644181
Change-Id: I2efa88ae66067587a00678eda155d861034b9127
Reviewed-on: https://gerrit-review.googlesource.com/c/git-repo/+/438001
Reviewed-by: Nasser Grainawi <nasser.grainawi@linaro.org>
Tested-by: Josip Sokcevic <sokcevic@google.com>
Commit-Queue: Josip Sokcevic <sokcevic@google.com>
Reviewed-by: Gavin Mak <gavinmak@google.com>
Diffstat (limited to 'git_command.py')
-rw-r--r-- | git_command.py | 15 |
1 files changed, 9 insertions, 6 deletions
diff --git a/git_command.py b/git_command.py index 1ec7c3ed..55216b1c 100644 --- a/git_command.py +++ b/git_command.py | |||
@@ -313,12 +313,15 @@ class GitCommand: | |||
313 | cwd = None | 313 | cwd = None |
314 | command_name = cmdv[0] | 314 | command_name = cmdv[0] |
315 | command.append(command_name) | 315 | command.append(command_name) |
316 | # Need to use the --progress flag for fetch/clone so output will be | 316 | |
317 | # displayed as by default git only does progress output if stderr is a | 317 | if command_name in ("fetch", "clone"): |
318 | # TTY. | 318 | env["GIT_TERMINAL_PROMPT"] = "0" |
319 | if sys.stderr.isatty() and command_name in ("fetch", "clone"): | 319 | # Need to use the --progress flag for fetch/clone so output will be |
320 | if "--progress" not in cmdv and "--quiet" not in cmdv: | 320 | # displayed as by default git only does progress output if stderr is |
321 | command.append("--progress") | 321 | # a TTY. |
322 | if sys.stderr.isatty(): | ||
323 | if "--progress" not in cmdv and "--quiet" not in cmdv: | ||
324 | command.append("--progress") | ||
322 | command.extend(cmdv[1:]) | 325 | command.extend(cmdv[1:]) |
323 | 326 | ||
324 | event_log = ( | 327 | event_log = ( |