@@ -114,12 +114,12 @@ func RefBlame(ctx *context.Context) {
114
114
return
115
115
}
116
116
117
- commitNames , previousCommits := processBlameParts (ctx , result .Parts )
117
+ commitNames := processBlameParts (ctx , result .Parts )
118
118
if ctx .Written () {
119
119
return
120
120
}
121
121
122
- renderBlame (ctx , result .Parts , commitNames , previousCommits )
122
+ renderBlame (ctx , result .Parts , commitNames )
123
123
124
124
ctx .HTML (http .StatusOK , tplRepoHome )
125
125
}
@@ -185,12 +185,9 @@ func fillBlameResult(br *git.BlameReader, r *blameResult) error {
185
185
return nil
186
186
}
187
187
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 {
189
189
// store commit data by SHA to look up avatar info etc
190
190
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 )
194
191
// and as blameParts can reference the same commits multiple
195
192
// times, we cache the lookup work locally
196
193
commits := make ([]* git.Commit , 0 , len (blameParts ))
@@ -214,29 +211,11 @@ func processBlameParts(ctx *context.Context, blameParts []git.BlamePart) (map[st
214
211
} else {
215
212
ctx .ServerError ("Repo.GitRepo.GetCommit" , err )
216
213
}
217
- return nil , nil
214
+ return nil
218
215
}
219
216
commitCache [sha ] = commit
220
217
}
221
218
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
-
240
219
commits = append (commits , commit )
241
220
}
242
221
@@ -245,10 +224,10 @@ func processBlameParts(ctx *context.Context, blameParts []git.BlamePart) (map[st
245
224
commitNames [c .ID .String ()] = c
246
225
}
247
226
248
- return commitNames , previousCommits
227
+ return commitNames
249
228
}
250
229
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 ) {
252
231
repoLink := ctx .Repo .RepoLink
253
232
254
233
language := ""
@@ -295,7 +274,6 @@ func renderBlame(ctx *context.Context, blameParts []git.BlamePart, commitNames m
295
274
}
296
275
297
276
commit := commitNames [part .Sha ]
298
- previousSha := previousCommits [part .Sha ]
299
277
if index == 0 {
300
278
// Count commit number
301
279
commitCnt ++
@@ -313,8 +291,8 @@ func renderBlame(ctx *context.Context, blameParts []git.BlamePart, commitNames m
313
291
br .Avatar = gotemplate .HTML (avatar )
314
292
br .RepoLink = repoLink
315
293
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 ))
318
296
br .CommitURL = fmt .Sprintf ("%s/commit/%s" , repoLink , url .PathEscape (part .Sha ))
319
297
br .CommitMessage = commit .CommitMessage
320
298
br .CommitSince = commitSince
0 commit comments