Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
advice: refuse to output if stderr not TTY
The advice system is intended to help end users around corner cases or other difficult spots when using the Git tool. As such, they are added without considering the possibility that they could break scripts or external tools that execute Git processes and then parse the output. I will not debate the merit of tools parsing stderr, but instead attempt to be helpful to tool authors by avoiding these behavior changes across Git versions. In b79deeb (advice: add --no-advice global option, 2024-05-03), the --no-advice option was presented as a way to help tool authors specify that they do not want any advice messages. As part of this implementation, the GIT_ADVICE environment variable is given as a way to communicate the desire for advice (=1) or no advice (=0) and pass that along to all child processes. However, both the --no-advice option and the GIT_ADVICE environment variable require the tool author to change how they interact with Git to gain this protection. If Git instead disables the advice system when stderr is not a terminal, then tool authors benefit immediately. It is important, though, to let interested users force advice to be enabled, even when redirecting stderr to a non-terminal file. Be sure to test this by ensuring GIT_ADVICE=1 forces advice to be written to non-terminals. The changes leading up to this already set GIT_ADVICE=1 in all other test scripts that care about the advice being output (or not). Signed-off-by: Derrick Stolee <derrickstolee@github.com>
- Loading branch information