@@ -200,22 +200,13 @@ func GetPullDiffStats(ctx *context.Context) {
200200		return 
201201	}
202202
203- 	diffOptions  :=  & gitdiff.DiffOptions {
204- 		BeforeCommitID :     mergeBaseCommitID ,
205- 		AfterCommitID :      headCommitID ,
206- 		MaxLines :           setting .Git .MaxGitDiffLines ,
207- 		MaxLineCharacters :  setting .Git .MaxGitDiffLineCharacters ,
208- 		MaxFiles :           setting .Git .MaxGitDiffFiles ,
209- 		WhitespaceBehavior : gitdiff .GetWhitespaceFlag (ctx .Data ["WhitespaceBehavior" ].(string )),
210- 	}
211- 
212- 	diff , err  :=  gitdiff .GetPullDiffStats (ctx .Repo .GitRepo , diffOptions )
203+ 	diffShortStat , err  :=  gitdiff .GetDiffShortStat (ctx .Repo .GitRepo , mergeBaseCommitID , headCommitID )
213204	if  err  !=  nil  {
214- 		ctx .ServerError ("GetPullDiffStats " , err )
205+ 		ctx .ServerError ("GetDiffShortStat " , err )
215206		return 
216207	}
217208
218- 	ctx .Data ["Diff " ] =  diff 
209+ 	ctx .Data ["DiffShortStat " ] =  diffShortStat 
219210}
220211
221212func  GetMergedBaseCommitID (ctx  * context.Context , issue  * issues_model.Issue ) string  {
@@ -752,36 +743,43 @@ func viewPullFiles(ctx *context.Context, specifiedStartCommit, specifiedEndCommi
752743		MaxLineCharacters :  setting .Git .MaxGitDiffLineCharacters ,
753744		MaxFiles :           maxFiles ,
754745		WhitespaceBehavior : gitdiff .GetWhitespaceFlag (ctx .Data ["WhitespaceBehavior" ].(string )),
755- 		FileOnly :           fileOnly ,
756746	}
757747
758748	if  ! willShowSpecifiedCommit  {
759749		diffOptions .BeforeCommitID  =  startCommitID 
760750	}
761751
762- 	var  methodWithError  string 
763- 	var  diff  * gitdiff.Diff 
764- 	shouldGetUserSpecificDiff  :=  false 
752+ 	diff , err  :=  gitdiff .GetDiff (ctx , gitRepo , diffOptions , files ... )
753+ 	if  err  !=  nil  {
754+ 		ctx .ServerError ("GetDiff" , err )
755+ 		return 
756+ 	}
765757
766758	// if we're not logged in or only a single commit (or commit range) is shown we 
767759	// have to load only the diff and not get the viewed information 
768760	// as the viewed information is designed to be loaded only on latest PR 
769761	// diff and if you're signed in. 
762+ 	shouldGetUserSpecificDiff  :=  false 
770763	if  ! ctx .IsSigned  ||  willShowSpecifiedCommit  ||  willShowSpecifiedCommitRange  {
771- 		diff , err  =  gitdiff .GetDiff (ctx , gitRepo , diffOptions , files ... )
772- 		methodWithError  =  "GetDiff" 
764+ 		// do nothing 
773765	} else  {
774- 		diff , err  =  gitdiff .SyncAndGetUserSpecificDiff (ctx , ctx .Doer .ID , pull , gitRepo , diffOptions , files ... )
775- 		methodWithError  =  "SyncAndGetUserSpecificDiff" 
776766		shouldGetUserSpecificDiff  =  true 
767+ 		err  =  gitdiff .SyncUserSpecificDiff (ctx , ctx .Doer .ID , pull , gitRepo , diff , diffOptions , files ... )
768+ 		if  err  !=  nil  {
769+ 			ctx .ServerError ("SyncUserSpecificDiff" , err )
770+ 			return 
771+ 		}
777772	}
773+ 
774+ 	diffShortStat , err  :=  gitdiff .GetDiffShortStat (ctx .Repo .GitRepo , startCommitID , endCommitID )
778775	if  err  !=  nil  {
779- 		ctx .ServerError (methodWithError , err )
776+ 		ctx .ServerError ("GetDiffShortStat" , err )
780777		return 
781778	}
779+ 	ctx .Data ["DiffShortStat" ] =  diffShortStat 
782780
783781	ctx .PageData ["prReview" ] =  map [string ]any {
784- 		"numberOfFiles" :       diff .NumFiles ,
782+ 		"numberOfFiles" :       diffShortStat .NumFiles ,
785783		"numberOfViewedFiles" : diff .NumViewedFiles ,
786784	}
787785
@@ -840,7 +838,7 @@ func viewPullFiles(ctx *context.Context, specifiedStartCommit, specifiedEndCommi
840838	}
841839
842840	ctx .Data ["Diff" ] =  diff 
843- 	ctx .Data ["DiffNotAvailable" ] =  diff .NumFiles  ==  0 
841+ 	ctx .Data ["DiffNotAvailable" ] =  diffShortStat .NumFiles  ==  0 
844842
845843	baseCommit , err  :=  ctx .Repo .GitRepo .GetCommit (startCommitID )
846844	if  err  !=  nil  {
0 commit comments