Fine tune diff highlighting (#36592)

This commit is contained in:
wxiaoguang
2026-02-12 15:01:36 +08:00
committed by GitHub
parent 47b387921a
commit 2876800cb2
6 changed files with 139 additions and 75 deletions
+12 -1
View File
@@ -12,11 +12,15 @@ import (
"math"
"strconv"
"strings"
"sync/atomic"
"time"
"code.gitea.io/gitea/modules/git/gitcmd"
"code.gitea.io/gitea/modules/log"
)
var catFileBatchDebugWaitClose atomic.Int64
type catFileBatchCommunicator struct {
cancel context.CancelFunc
reqWriter io.Writer
@@ -36,7 +40,14 @@ func newCatFileBatch(ctx context.Context, repoPath string, cmdCatFile *gitcmd.Co
ctx, ctxCancel := context.WithCancelCause(ctx)
// We often want to feed the commits in order into cat-file --batch, followed by their trees and subtrees as necessary.
stdinWriter, stdoutReader, pipeClose := cmdCatFile.MakeStdinStdoutPipe()
stdinWriter, stdoutReader, stdPipeClose := cmdCatFile.MakeStdinStdoutPipe()
pipeClose := func() {
if delay := catFileBatchDebugWaitClose.Load(); delay > 0 {
time.Sleep(time.Duration(delay)) // for testing purpose only
}
stdPipeClose()
}
ret = &catFileBatchCommunicator{
debugGitCmd: cmdCatFile,
cancel: func() { ctxCancel(nil) },