@@ -66,6 +66,7 @@ type GetCommitsOptions struct {
6666 // If non-empty, show divergence from this ref (left-right log)
6767 RefToShowDivergenceFrom string
6868 MainBranches * MainBranches
69+ HashPool * utils.StringPool
6970}
7071
7172// GetCommits obtains the commits of the current branch
@@ -74,7 +75,7 @@ func (self *CommitLoader) GetCommits(opts GetCommitsOptions) ([]*models.Commit,
7475
7576 if opts .IncludeRebaseCommits && opts .FilterPath == "" {
7677 var err error
77- commits , err = self .MergeRebasingCommits (commits )
78+ commits , err = self .MergeRebasingCommits (opts . HashPool , commits )
7879 if err != nil {
7980 return nil , err
8081 }
@@ -89,7 +90,7 @@ func (self *CommitLoader) GetCommits(opts GetCommitsOptions) ([]*models.Commit,
8990 defer wg .Done ()
9091
9192 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 != "" )
9394 commits = append (commits , commit )
9495 return false , nil
9596 })
@@ -159,7 +160,7 @@ func (self *CommitLoader) GetCommits(opts GetCommitsOptions) ([]*models.Commit,
159160 return commits , nil
160161}
161162
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 ) {
163164 // chances are we have as many commits as last time so we'll set the capacity to be the old length
164165 result := make ([]* models.Commit , 0 , len (commits ))
165166 for i , commit := range commits {
@@ -172,7 +173,7 @@ func (self *CommitLoader) MergeRebasingCommits(commits []*models.Commit) ([]*mod
172173 workingTreeState := self .getWorkingTreeState ()
173174 addConflictedRebasingCommit := true
174175 if workingTreeState .CherryPicking || workingTreeState .Reverting {
175- sequencerCommits , err := self .getHydratedSequencerCommits (workingTreeState )
176+ sequencerCommits , err := self .getHydratedSequencerCommits (hashPool , workingTreeState )
176177 if err != nil {
177178 return nil , err
178179 }
@@ -181,7 +182,7 @@ func (self *CommitLoader) MergeRebasingCommits(commits []*models.Commit) ([]*mod
181182 }
182183
183184 if workingTreeState .Rebasing {
184- rebasingCommits , err := self .getHydratedRebasingCommits (addConflictedRebasingCommit )
185+ rebasingCommits , err := self .getHydratedRebasingCommits (hashPool , addConflictedRebasingCommit )
185186 if err != nil {
186187 return nil , err
187188 }
@@ -196,7 +197,7 @@ func (self *CommitLoader) MergeRebasingCommits(commits []*models.Commit) ([]*mod
196197// then puts them into a commit object
197198// example input:
198199// 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 {
200201 split := strings .SplitN (line , "\x00 " , 8 )
201202
202203 hash := split [0 ]
@@ -234,7 +235,7 @@ func (self *CommitLoader) extractCommitFromLine(line string, showDivergence bool
234235 parents = strings .Split (parentHashes , " " )
235236 }
236237
237- return models .NewCommit (models.NewCommitOpts {
238+ return models .NewCommit (hashPool , models.NewCommitOpts {
238239 Hash : hash ,
239240 Name : message ,
240241 Tags : tags ,
@@ -247,13 +248,13 @@ func (self *CommitLoader) extractCommitFromLine(line string, showDivergence bool
247248 })
248249}
249250
250- func (self * CommitLoader ) getHydratedRebasingCommits (addConflictingCommit bool ) ([]* models.Commit , error ) {
251+ func (self * CommitLoader ) getHydratedRebasingCommits (hashPool * utils. StringPool , addConflictingCommit bool ) ([]* models.Commit , error ) {
251252 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 )
253254}
254255
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 )
257258 if len (commits ) > 0 {
258259 // If we have any commits in .git/sequencer/todo, then the last one of
259260 // those is the conflicting one.
@@ -262,16 +263,16 @@ func (self *CommitLoader) getHydratedSequencerCommits(workingTreeState models.Wo
262263 // For single-commit cherry-picks and reverts, git apparently doesn't
263264 // use the sequencer; in that case, CHERRY_PICK_HEAD or REVERT_HEAD is
264265 // our conflicting commit, so synthesize it here.
265- conflicedCommit := self .getConflictedSequencerCommit (workingTreeState )
266+ conflicedCommit := self .getConflictedSequencerCommit (hashPool , workingTreeState )
266267 if conflicedCommit != nil {
267268 commits = append (commits , conflicedCommit )
268269 }
269270 }
270271
271- return self .getHydratedTodoCommits (commits , true )
272+ return self .getHydratedTodoCommits (hashPool , commits , true )
272273}
273274
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 ) {
275276 if len (todoCommits ) == 0 {
276277 return nil , nil
277278 }
@@ -292,7 +293,7 @@ func (self *CommitLoader) getHydratedTodoCommits(todoCommits []*models.Commit, t
292293
293294 fullCommits := map [string ]* models.Commit {}
294295 err := cmdObj .RunAndProcessLines (func (line string ) (bool , error ) {
295- commit := self .extractCommitFromLine (line , false )
296+ commit := self .extractCommitFromLine (hashPool , line , false )
296297 fullCommits [commit .Hash ()] = commit
297298 return false , nil
298299 })
@@ -331,7 +332,7 @@ func (self *CommitLoader) getHydratedTodoCommits(todoCommits []*models.Commit, t
331332// git-rebase-todo example:
332333// pick ac446ae94ee560bdb8d1d057278657b251aaef17 ac446ae
333334// pick afb893148791a2fbd8091aeb81deba4930c73031 afb8931
334- func (self * CommitLoader ) getRebasingCommits (addConflictingCommit bool ) []* models.Commit {
335+ func (self * CommitLoader ) getRebasingCommits (hashPool * utils. StringPool , addConflictingCommit bool ) []* models.Commit {
335336 bytesContent , err := self .readFile (filepath .Join (self .repoPaths .WorktreeGitDirPath (), "rebase-merge/git-rebase-todo" ))
336337 if err != nil {
337338 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
350351 // See if the current commit couldn't be applied because it conflicted; if
351352 // so, add a fake entry for it
352353 if addConflictingCommit {
353- if conflictedCommit := self .getConflictedCommit (todos ); conflictedCommit != nil {
354+ if conflictedCommit := self .getConflictedCommit (hashPool , todos ); conflictedCommit != nil {
354355 commits = append (commits , conflictedCommit )
355356 }
356357 }
@@ -364,7 +365,7 @@ func (self *CommitLoader) getRebasingCommits(addConflictingCommit bool) []*model
364365 // Command does not have a commit associated, skip
365366 continue
366367 }
367- commits = utils .Prepend (commits , models .NewCommit (models.NewCommitOpts {
368+ commits = utils .Prepend (commits , models .NewCommit (hashPool , models.NewCommitOpts {
368369 Hash : t .Commit ,
369370 Name : t .Msg ,
370371 Status : models .StatusRebasing ,
@@ -375,7 +376,7 @@ func (self *CommitLoader) getRebasingCommits(addConflictingCommit bool) []*model
375376 return commits
376377}
377378
378- func (self * CommitLoader ) getConflictedCommit (todos []todo.Todo ) * models.Commit {
379+ func (self * CommitLoader ) getConflictedCommit (hashPool * utils. StringPool , todos []todo.Todo ) * models.Commit {
379380 bytesContent , err := self .readFile (filepath .Join (self .repoPaths .WorktreeGitDirPath (), "rebase-merge/done" ))
380381 if err != nil {
381382 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
391392 amendFileExists , _ := self .os .FileExists (filepath .Join (self .repoPaths .WorktreeGitDirPath (), "rebase-merge/amend" ))
392393 messageFileExists , _ := self .os .FileExists (filepath .Join (self .repoPaths .WorktreeGitDirPath (), "rebase-merge/message" ))
393394
394- return self .getConflictedCommitImpl (todos , doneTodos , amendFileExists , messageFileExists )
395+ return self .getConflictedCommitImpl (hashPool , todos , doneTodos , amendFileExists , messageFileExists )
395396}
396397
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 {
398399 // Should never be possible, but just to be safe:
399400 if len (doneTodos ) == 0 {
400401 self .Log .Error ("no done entries in rebase-merge/done file" )
@@ -465,14 +466,14 @@ func (self *CommitLoader) getConflictedCommitImpl(todos []todo.Todo, doneTodos [
465466
466467 // Any other todo that has a commit associated with it must have failed with
467468 // a conflict, otherwise we wouldn't have stopped the rebase:
468- return models .NewCommit (models.NewCommitOpts {
469+ return models .NewCommit (hashPool , models.NewCommitOpts {
469470 Hash : lastTodo .Commit ,
470471 Action : lastTodo .Command ,
471472 Status : models .StatusConflicted ,
472473 })
473474}
474475
475- func (self * CommitLoader ) getSequencerCommits () []* models.Commit {
476+ func (self * CommitLoader ) getSequencerCommits (hashPool * utils. StringPool ) []* models.Commit {
476477 bytesContent , err := self .readFile (filepath .Join (self .repoPaths .WorktreeGitDirPath (), "sequencer/todo" ))
477478 if err != nil {
478479 self .Log .Error (fmt .Sprintf ("error occurred reading sequencer/todo: %s" , err .Error ()))
@@ -493,7 +494,7 @@ func (self *CommitLoader) getSequencerCommits() []*models.Commit {
493494 // Command does not have a commit associated, skip
494495 continue
495496 }
496- commits = utils .Prepend (commits , models .NewCommit (models.NewCommitOpts {
497+ commits = utils .Prepend (commits , models .NewCommit (hashPool , models.NewCommitOpts {
497498 Hash : t .Commit ,
498499 Name : t .Msg ,
499500 Status : models .StatusCherryPickingOrReverting ,
@@ -504,7 +505,7 @@ func (self *CommitLoader) getSequencerCommits() []*models.Commit {
504505 return commits
505506}
506507
507- func (self * CommitLoader ) getConflictedSequencerCommit (workingTreeState models.WorkingTreeState ) * models.Commit {
508+ func (self * CommitLoader ) getConflictedSequencerCommit (hashPool * utils. StringPool , workingTreeState models.WorkingTreeState ) * models.Commit {
508509 var shaFile string
509510 var action todo.TodoCommand
510511 if workingTreeState .CherryPicking {
@@ -526,7 +527,7 @@ func (self *CommitLoader) getConflictedSequencerCommit(workingTreeState models.W
526527 if len (lines ) == 0 {
527528 return nil
528529 }
529- return models .NewCommit (models.NewCommitOpts {
530+ return models .NewCommit (hashPool , models.NewCommitOpts {
530531 Hash : lines [0 ],
531532 Status : models .StatusConflicted ,
532533 Action : action ,
0 commit comments