@@ -66,6 +66,7 @@ type GetCommitsOptions struct {
66
66
// If non-empty, show divergence from this ref (left-right log)
67
67
RefToShowDivergenceFrom string
68
68
MainBranches * MainBranches
69
+ HashPool * utils.StringPool
69
70
}
70
71
71
72
// GetCommits obtains the commits of the current branch
@@ -74,7 +75,7 @@ func (self *CommitLoader) GetCommits(opts GetCommitsOptions) ([]*models.Commit,
74
75
75
76
if opts .IncludeRebaseCommits && opts .FilterPath == "" {
76
77
var err error
77
- commits , err = self .MergeRebasingCommits (commits )
78
+ commits , err = self .MergeRebasingCommits (opts . HashPool , commits )
78
79
if err != nil {
79
80
return nil , err
80
81
}
@@ -89,7 +90,7 @@ func (self *CommitLoader) GetCommits(opts GetCommitsOptions) ([]*models.Commit,
89
90
defer wg .Done ()
90
91
91
92
logErr = self .getLogCmd (opts ).RunAndProcessLines (func (line string ) (bool , error ) {
92
- commit := self .extractCommitFromLine (line , opts .RefToShowDivergenceFrom != "" )
93
+ commit := self .extractCommitFromLine (opts . HashPool , line , opts .RefToShowDivergenceFrom != "" )
93
94
commits = append (commits , commit )
94
95
return false , nil
95
96
})
@@ -159,7 +160,7 @@ func (self *CommitLoader) GetCommits(opts GetCommitsOptions) ([]*models.Commit,
159
160
return commits , nil
160
161
}
161
162
162
- func (self * CommitLoader ) MergeRebasingCommits (commits []* models.Commit ) ([]* models.Commit , error ) {
163
+ func (self * CommitLoader ) MergeRebasingCommits (hashPool * utils. StringPool , commits []* models.Commit ) ([]* models.Commit , error ) {
163
164
// chances are we have as many commits as last time so we'll set the capacity to be the old length
164
165
result := make ([]* models.Commit , 0 , len (commits ))
165
166
for i , commit := range commits {
@@ -172,7 +173,7 @@ func (self *CommitLoader) MergeRebasingCommits(commits []*models.Commit) ([]*mod
172
173
workingTreeState := self .getWorkingTreeState ()
173
174
addConflictedRebasingCommit := true
174
175
if workingTreeState .CherryPicking || workingTreeState .Reverting {
175
- sequencerCommits , err := self .getHydratedSequencerCommits (workingTreeState )
176
+ sequencerCommits , err := self .getHydratedSequencerCommits (hashPool , workingTreeState )
176
177
if err != nil {
177
178
return nil , err
178
179
}
@@ -181,7 +182,7 @@ func (self *CommitLoader) MergeRebasingCommits(commits []*models.Commit) ([]*mod
181
182
}
182
183
183
184
if workingTreeState .Rebasing {
184
- rebasingCommits , err := self .getHydratedRebasingCommits (addConflictedRebasingCommit )
185
+ rebasingCommits , err := self .getHydratedRebasingCommits (hashPool , addConflictedRebasingCommit )
185
186
if err != nil {
186
187
return nil , err
187
188
}
@@ -196,7 +197,7 @@ func (self *CommitLoader) MergeRebasingCommits(commits []*models.Commit) ([]*mod
196
197
// then puts them into a commit object
197
198
// example input:
198
199
// 8ad01fe32fcc20f07bc6693f87aa4977c327f1e1|10 hours ago|Jesse Duffield| (HEAD -> master, tag: v0.15.2)|refresh commits when adding a tag
199
- func (self * CommitLoader ) extractCommitFromLine (line string , showDivergence bool ) * models.Commit {
200
+ func (self * CommitLoader ) extractCommitFromLine (hashPool * utils. StringPool , line string , showDivergence bool ) * models.Commit {
200
201
split := strings .SplitN (line , "\x00 " , 8 )
201
202
202
203
hash := split [0 ]
@@ -234,7 +235,7 @@ func (self *CommitLoader) extractCommitFromLine(line string, showDivergence bool
234
235
parents = strings .Split (parentHashes , " " )
235
236
}
236
237
237
- return models .NewCommit (models.NewCommitOpts {
238
+ return models .NewCommit (hashPool , models.NewCommitOpts {
238
239
Hash : hash ,
239
240
Name : message ,
240
241
Tags : tags ,
@@ -247,13 +248,13 @@ func (self *CommitLoader) extractCommitFromLine(line string, showDivergence bool
247
248
})
248
249
}
249
250
250
- func (self * CommitLoader ) getHydratedRebasingCommits (addConflictingCommit bool ) ([]* models.Commit , error ) {
251
+ func (self * CommitLoader ) getHydratedRebasingCommits (hashPool * utils. StringPool , addConflictingCommit bool ) ([]* models.Commit , error ) {
251
252
todoFileHasShortHashes := self .version .IsOlderThan (2 , 25 , 2 )
252
- return self .getHydratedTodoCommits (self .getRebasingCommits (addConflictingCommit ), todoFileHasShortHashes )
253
+ return self .getHydratedTodoCommits (hashPool , self .getRebasingCommits (hashPool , addConflictingCommit ), todoFileHasShortHashes )
253
254
}
254
255
255
- func (self * CommitLoader ) getHydratedSequencerCommits (workingTreeState models.WorkingTreeState ) ([]* models.Commit , error ) {
256
- commits := self .getSequencerCommits ()
256
+ func (self * CommitLoader ) getHydratedSequencerCommits (hashPool * utils. StringPool , workingTreeState models.WorkingTreeState ) ([]* models.Commit , error ) {
257
+ commits := self .getSequencerCommits (hashPool )
257
258
if len (commits ) > 0 {
258
259
// If we have any commits in .git/sequencer/todo, then the last one of
259
260
// those is the conflicting one.
@@ -262,16 +263,16 @@ func (self *CommitLoader) getHydratedSequencerCommits(workingTreeState models.Wo
262
263
// For single-commit cherry-picks and reverts, git apparently doesn't
263
264
// use the sequencer; in that case, CHERRY_PICK_HEAD or REVERT_HEAD is
264
265
// our conflicting commit, so synthesize it here.
265
- conflicedCommit := self .getConflictedSequencerCommit (workingTreeState )
266
+ conflicedCommit := self .getConflictedSequencerCommit (hashPool , workingTreeState )
266
267
if conflicedCommit != nil {
267
268
commits = append (commits , conflicedCommit )
268
269
}
269
270
}
270
271
271
- return self .getHydratedTodoCommits (commits , true )
272
+ return self .getHydratedTodoCommits (hashPool , commits , true )
272
273
}
273
274
274
- func (self * CommitLoader ) getHydratedTodoCommits (todoCommits []* models.Commit , todoFileHasShortHashes bool ) ([]* models.Commit , error ) {
275
+ func (self * CommitLoader ) getHydratedTodoCommits (hashPool * utils. StringPool , todoCommits []* models.Commit , todoFileHasShortHashes bool ) ([]* models.Commit , error ) {
275
276
if len (todoCommits ) == 0 {
276
277
return nil , nil
277
278
}
@@ -292,7 +293,7 @@ func (self *CommitLoader) getHydratedTodoCommits(todoCommits []*models.Commit, t
292
293
293
294
fullCommits := map [string ]* models.Commit {}
294
295
err := cmdObj .RunAndProcessLines (func (line string ) (bool , error ) {
295
- commit := self .extractCommitFromLine (line , false )
296
+ commit := self .extractCommitFromLine (hashPool , line , false )
296
297
fullCommits [commit .Hash ()] = commit
297
298
return false , nil
298
299
})
@@ -331,7 +332,7 @@ func (self *CommitLoader) getHydratedTodoCommits(todoCommits []*models.Commit, t
331
332
// git-rebase-todo example:
332
333
// pick ac446ae94ee560bdb8d1d057278657b251aaef17 ac446ae
333
334
// pick afb893148791a2fbd8091aeb81deba4930c73031 afb8931
334
- func (self * CommitLoader ) getRebasingCommits (addConflictingCommit bool ) []* models.Commit {
335
+ func (self * CommitLoader ) getRebasingCommits (hashPool * utils. StringPool , addConflictingCommit bool ) []* models.Commit {
335
336
bytesContent , err := self .readFile (filepath .Join (self .repoPaths .WorktreeGitDirPath (), "rebase-merge/git-rebase-todo" ))
336
337
if err != nil {
337
338
self .Log .Error (fmt .Sprintf ("error occurred reading git-rebase-todo: %s" , err .Error ()))
@@ -350,7 +351,7 @@ func (self *CommitLoader) getRebasingCommits(addConflictingCommit bool) []*model
350
351
// See if the current commit couldn't be applied because it conflicted; if
351
352
// so, add a fake entry for it
352
353
if addConflictingCommit {
353
- if conflictedCommit := self .getConflictedCommit (todos ); conflictedCommit != nil {
354
+ if conflictedCommit := self .getConflictedCommit (hashPool , todos ); conflictedCommit != nil {
354
355
commits = append (commits , conflictedCommit )
355
356
}
356
357
}
@@ -364,7 +365,7 @@ func (self *CommitLoader) getRebasingCommits(addConflictingCommit bool) []*model
364
365
// Command does not have a commit associated, skip
365
366
continue
366
367
}
367
- commits = utils .Prepend (commits , models .NewCommit (models.NewCommitOpts {
368
+ commits = utils .Prepend (commits , models .NewCommit (hashPool , models.NewCommitOpts {
368
369
Hash : t .Commit ,
369
370
Name : t .Msg ,
370
371
Status : models .StatusRebasing ,
@@ -375,7 +376,7 @@ func (self *CommitLoader) getRebasingCommits(addConflictingCommit bool) []*model
375
376
return commits
376
377
}
377
378
378
- func (self * CommitLoader ) getConflictedCommit (todos []todo.Todo ) * models.Commit {
379
+ func (self * CommitLoader ) getConflictedCommit (hashPool * utils. StringPool , todos []todo.Todo ) * models.Commit {
379
380
bytesContent , err := self .readFile (filepath .Join (self .repoPaths .WorktreeGitDirPath (), "rebase-merge/done" ))
380
381
if err != nil {
381
382
self .Log .Error (fmt .Sprintf ("error occurred reading rebase-merge/done: %s" , err .Error ()))
@@ -391,10 +392,10 @@ func (self *CommitLoader) getConflictedCommit(todos []todo.Todo) *models.Commit
391
392
amendFileExists , _ := self .os .FileExists (filepath .Join (self .repoPaths .WorktreeGitDirPath (), "rebase-merge/amend" ))
392
393
messageFileExists , _ := self .os .FileExists (filepath .Join (self .repoPaths .WorktreeGitDirPath (), "rebase-merge/message" ))
393
394
394
- return self .getConflictedCommitImpl (todos , doneTodos , amendFileExists , messageFileExists )
395
+ return self .getConflictedCommitImpl (hashPool , todos , doneTodos , amendFileExists , messageFileExists )
395
396
}
396
397
397
- func (self * CommitLoader ) getConflictedCommitImpl (todos []todo.Todo , doneTodos []todo.Todo , amendFileExists bool , messageFileExists bool ) * models.Commit {
398
+ func (self * CommitLoader ) getConflictedCommitImpl (hashPool * utils. StringPool , todos []todo.Todo , doneTodos []todo.Todo , amendFileExists bool , messageFileExists bool ) * models.Commit {
398
399
// Should never be possible, but just to be safe:
399
400
if len (doneTodos ) == 0 {
400
401
self .Log .Error ("no done entries in rebase-merge/done file" )
@@ -465,14 +466,14 @@ func (self *CommitLoader) getConflictedCommitImpl(todos []todo.Todo, doneTodos [
465
466
466
467
// Any other todo that has a commit associated with it must have failed with
467
468
// a conflict, otherwise we wouldn't have stopped the rebase:
468
- return models .NewCommit (models.NewCommitOpts {
469
+ return models .NewCommit (hashPool , models.NewCommitOpts {
469
470
Hash : lastTodo .Commit ,
470
471
Action : lastTodo .Command ,
471
472
Status : models .StatusConflicted ,
472
473
})
473
474
}
474
475
475
- func (self * CommitLoader ) getSequencerCommits () []* models.Commit {
476
+ func (self * CommitLoader ) getSequencerCommits (hashPool * utils. StringPool ) []* models.Commit {
476
477
bytesContent , err := self .readFile (filepath .Join (self .repoPaths .WorktreeGitDirPath (), "sequencer/todo" ))
477
478
if err != nil {
478
479
self .Log .Error (fmt .Sprintf ("error occurred reading sequencer/todo: %s" , err .Error ()))
@@ -493,7 +494,7 @@ func (self *CommitLoader) getSequencerCommits() []*models.Commit {
493
494
// Command does not have a commit associated, skip
494
495
continue
495
496
}
496
- commits = utils .Prepend (commits , models .NewCommit (models.NewCommitOpts {
497
+ commits = utils .Prepend (commits , models .NewCommit (hashPool , models.NewCommitOpts {
497
498
Hash : t .Commit ,
498
499
Name : t .Msg ,
499
500
Status : models .StatusCherryPickingOrReverting ,
@@ -504,7 +505,7 @@ func (self *CommitLoader) getSequencerCommits() []*models.Commit {
504
505
return commits
505
506
}
506
507
507
- func (self * CommitLoader ) getConflictedSequencerCommit (workingTreeState models.WorkingTreeState ) * models.Commit {
508
+ func (self * CommitLoader ) getConflictedSequencerCommit (hashPool * utils. StringPool , workingTreeState models.WorkingTreeState ) * models.Commit {
508
509
var shaFile string
509
510
var action todo.TodoCommand
510
511
if workingTreeState .CherryPicking {
@@ -526,7 +527,7 @@ func (self *CommitLoader) getConflictedSequencerCommit(workingTreeState models.W
526
527
if len (lines ) == 0 {
527
528
return nil
528
529
}
529
- return models .NewCommit (models.NewCommitOpts {
530
+ return models .NewCommit (hashPool , models.NewCommitOpts {
530
531
Hash : lines [0 ],
531
532
Status : models .StatusConflicted ,
532
533
Action : action ,
0 commit comments