refactor: GetDiffShortStat and fix panic caused by inconsistent "changed file number" (#39248)

This commit is contained in:
wxiaoguang
2026-09-06 05:20:42 +00:00
committed by GitHub
parent e5e7b2e76e
commit 3bd7ea4c9f
13 changed files with 143 additions and 146 deletions
+11 -10
View File
@@ -409,23 +409,24 @@ func (cpi *comparePageInfoType) prepareCompareDiff(ctx *context.Context, whitesp
}
fileOnly := ctx.FormBool("file-only")
diffCommonOptions := gitdiff.DiffCommonOptions{
BeforeCommitID: beforeCommitID,
AfterCommitID: headCommitID,
WhitespaceBehavior: whitespaceBehavior,
}
diff, err := gitdiff.GetDiffForRender(ctx, ci.HeadRepo.Link(), ci.HeadGitRepo,
&gitdiff.DiffOptions{
BeforeCommitID: beforeCommitID,
AfterCommitID: headCommitID,
SkipTo: ctx.FormString("skip-to"),
MaxLines: maxLines,
MaxLineCharacters: setting.Git.MaxGitDiffLineCharacters,
MaxFiles: maxFiles,
WhitespaceBehavior: whitespaceBehavior,
DirectComparison: ci.DirectComparison(),
DiffCommonOptions: diffCommonOptions,
SkipTo: ctx.FormString("skip-to"),
MaxLines: maxLines,
MaxLineCharacters: setting.Git.MaxGitDiffLineCharacters,
MaxFiles: maxFiles,
}, ctx.FormStrings("files")...)
if err != nil {
ctx.ServerError("GetDiff", err)
return
}
diffShortStat, err := gitdiff.GetDiffShortStat(ctx, ci.HeadGitRepo, beforeCommitID, headCommitID)
diffShortStat, err := gitdiff.GetDiffShortStat(ctx, ci.HeadGitRepo, &diffCommonOptions)
if err != nil {
ctx.ServerError("GetDiffShortStat", err)
return