Refactor git command stderr handling (#36402)

And clean up legacy fragile & incorrect logic
This commit is contained in:
wxiaoguang authored and GitHub committed 2026-01-18 15:10:33 -08:00
1 parent fafd1db19e
commit 72be55f7d3
69 files changed
+345 -627

No files matched your search

+2 -4
View File
@@ -1271,13 +1271,11 @@ func getDiffBasic(ctx context.Context, gitRepo *git.Repository, opts *DiffOption
}()
go func() {
stderr := &bytes.Buffer{}
if err := cmdDiff.WithTimeout(time.Duration(setting.Git.Timeout.Default) * time.Second).
WithDir(repoPath).
WithStdout(writer).
WithStderr(stderr).
Run(cmdCtx); err != nil && !git.IsErrCanceledOrKilled(err) {
log.Error("error during GetDiff(git diff dir: %s): %v, stderr: %s", repoPath, err, stderr.String())
RunWithStderr(cmdCtx); err != nil && !git.IsErrCanceledOrKilled(err) {
log.Error("error during GetDiff(git diff dir: %s): %v", repoPath, err)
}
_ = writer.Close()