Refactor git command stderr handling (#36402)

And clean up legacy fragile & incorrect logic
This commit is contained in:
wxiaoguang
2026-01-19 07:10:33 +08:00
committed by GitHub
parent fafd1db19e
commit 72be55f7d3
69 changed files with 345 additions and 627 deletions

View File

@@ -64,20 +64,12 @@ func LogNameStatusRepo(ctx context.Context, repository, head, treepath string, p
cmd.AddDashesAndList(files...)
go func() {
stderr := strings.Builder{}
err := cmd.WithDir(repository).
WithStdout(stdoutWriter).
WithStderr(&stderr).
Run(ctx)
if err != nil {
_ = stdoutWriter.CloseWithError(gitcmd.ConcatenateError(err, (&stderr).String()))
return
}
_ = stdoutWriter.Close()
RunWithStderr(ctx)
_ = stdoutWriter.CloseWithError(err)
}()
// For simplicities sake we'll us a buffered reader to read from the cat-file --batch
bufReader := bufio.NewReaderSize(stdoutReader, 32*1024)
return bufReader, cancel