Skip to content

Commit a759496

Browse files
authored
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.
1 parent 96e7369 commit a759496

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

modules/git/command.go

+2-1
Original file line numberDiff line numberDiff line change
@@ -350,9 +350,10 @@ func (c *Command) run(ctx context.Context, skip int, opts *RunOpts) error {
350350
// We need to check if the context is canceled by the program on Windows.
351351
// This is because Windows does not have signal checking when terminating the process.
352352
// It always returns exit code 1, unlike Linux, which has many exit codes for signals.
353+
// `err.Error()` returns "exit status 1" when using the `git check-attr` command after the context is canceled.
353354
if runtime.GOOS == "windows" &&
354355
err != nil &&
355-
err.Error() == "" &&
356+
(err.Error() == "" || err.Error() == "exit status 1") &&
356357
cmd.ProcessState.ExitCode() == 1 &&
357358
ctx.Err() == context.Canceled {
358359
return ctx.Err()

0 commit comments

Comments
 (0)