@@ -114,12 +114,12 @@ func RefBlame(ctx *context.Context) {
114114 return
115115 }
116116
117- commitNames , previousCommits := processBlameParts (ctx , result .Parts )
117+ commitNames := processBlameParts (ctx , result .Parts )
118118 if ctx .Written () {
119119 return
120120 }
121121
122- renderBlame (ctx , result .Parts , commitNames , previousCommits )
122+ renderBlame (ctx , result .Parts , commitNames )
123123
124124 ctx .HTML (http .StatusOK , tplRepoHome )
125125}
@@ -185,12 +185,9 @@ func fillBlameResult(br *git.BlameReader, r *blameResult) error {
185185 return nil
186186}
187187
188- func processBlameParts (ctx * context.Context , blameParts []git.BlamePart ) ( map [string ]* user_model.UserCommit , map [ string ] string ) {
188+ func processBlameParts (ctx * context.Context , blameParts []git.BlamePart ) map [string ]* user_model.UserCommit {
189189 // store commit data by SHA to look up avatar info etc
190190 commitNames := make (map [string ]* user_model.UserCommit )
191- // previousCommits contains links from SHA to parent SHA,
192- // if parent also contains the current TreePath.
193- previousCommits := make (map [string ]string )
194191 // and as blameParts can reference the same commits multiple
195192 // times, we cache the lookup work locally
196193 commits := make ([]* git.Commit , 0 , len (blameParts ))
@@ -214,29 +211,11 @@ func processBlameParts(ctx *context.Context, blameParts []git.BlamePart) (map[st
214211 } else {
215212 ctx .ServerError ("Repo.GitRepo.GetCommit" , err )
216213 }
217- return nil , nil
214+ return nil
218215 }
219216 commitCache [sha ] = commit
220217 }
221218
222- // find parent commit
223- if commit .ParentCount () > 0 {
224- psha := commit .Parents [0 ]
225- previousCommit , ok := commitCache [psha .String ()]
226- if ! ok {
227- previousCommit , _ = commit .Parent (0 )
228- if previousCommit != nil {
229- commitCache [psha .String ()] = previousCommit
230- }
231- }
232- // only store parent commit ONCE, if it has the file
233- if previousCommit != nil {
234- if haz1 , _ := previousCommit .HasFile (ctx .Repo .TreePath ); haz1 {
235- previousCommits [commit .ID .String ()] = previousCommit .ID .String ()
236- }
237- }
238- }
239-
240219 commits = append (commits , commit )
241220 }
242221
@@ -245,10 +224,10 @@ func processBlameParts(ctx *context.Context, blameParts []git.BlamePart) (map[st
245224 commitNames [c .ID .String ()] = c
246225 }
247226
248- return commitNames , previousCommits
227+ return commitNames
249228}
250229
251- func renderBlame (ctx * context.Context , blameParts []git.BlamePart , commitNames map [string ]* user_model.UserCommit , previousCommits map [ string ] string ) {
230+ func renderBlame (ctx * context.Context , blameParts []git.BlamePart , commitNames map [string ]* user_model.UserCommit ) {
252231 repoLink := ctx .Repo .RepoLink
253232
254233 language := ""
@@ -295,7 +274,6 @@ func renderBlame(ctx *context.Context, blameParts []git.BlamePart, commitNames m
295274 }
296275
297276 commit := commitNames [part .Sha ]
298- previousSha := previousCommits [part .Sha ]
299277 if index == 0 {
300278 // Count commit number
301279 commitCnt ++
@@ -313,8 +291,8 @@ func renderBlame(ctx *context.Context, blameParts []git.BlamePart, commitNames m
313291 br .Avatar = gotemplate .HTML (avatar )
314292 br .RepoLink = repoLink
315293 br .PartSha = part .Sha
316- br .PreviousSha = previousSha
317- br .PreviousShaURL = fmt .Sprintf ("%s/blame/commit/%s/%s" , repoLink , url .PathEscape (previousSha ), util .PathEscapeSegments (ctx . Repo . TreePath ))
294+ br .PreviousSha = part . PreviousSha
295+ br .PreviousShaURL = fmt .Sprintf ("%s/blame/commit/%s/%s" , repoLink , url .PathEscape (part . PreviousSha ), util .PathEscapeSegments (part . PreviousPath ))
318296 br .CommitURL = fmt .Sprintf ("%s/commit/%s" , repoLink , url .PathEscape (part .Sha ))
319297 br .CommitMessage = commit .CommitMessage
320298 br .CommitSince = commitSince
0 commit comments