From 155b74f87ec453c2baf031bf1912048f8e413a9c Mon Sep 17 00:00:00 2001 From: charles <30816317+charles7668@users.noreply.github.com> Date: Thu, 27 Mar 2025 17:25:31 +0800 Subject: [PATCH] Fix the issue with error message logging for the `check-attr` command on Windows OS. (#34035) Close #34022 , #33550 This error message always appears when using the `check-attr` command, even though it works correctly. The issue occurs when the stdin writer is closed, so I added a special case to handle and check the error message when the exit code is 1. --- modules/git/command.go | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/modules/git/command.go b/modules/git/command.go index fd781ffef4fd9..dc75adfacefca 100644 --- a/modules/git/command.go +++ b/modules/git/command.go @@ -350,9 +350,10 @@ func (c *Command) Run(opts *RunOpts) error { // We need to check if the context is canceled by the program on Windows. // This is because Windows does not have signal checking when terminating the process. // It always returns exit code 1, unlike Linux, which has many exit codes for signals. + // `err.Error()` returns "exit status 1" when using the `git check-attr` command after the context is canceled. if runtime.GOOS == "windows" && err != nil && - err.Error() == "" && + (err.Error() == "" || err.Error() == "exit status 1") && cmd.ProcessState.ExitCode() == 1 && ctx.Err() == context.Canceled { return ctx.Err()