Skip to content

Commit

Permalink
Merge pull request #79 from splitsh/aggressive-cache
Browse files Browse the repository at this point in the history
Move head check for a more aggressive use of cache
  • Loading branch information
fabpot committed Mar 8, 2024
2 parents cf9970e + ca1a6ce commit eaede0b
Showing 1 changed file with 8 additions and 9 deletions.
17 changes: 8 additions & 9 deletions splitter/state.go
Expand Up @@ -522,12 +522,18 @@ func (s *state) legacyMessage(rev *git.Commit) string {

// pushRevs sets the range to split
func (s *state) pushRevs(revWalk *git.RevWalk) error {
// this is needed as origin might be in the process of being updated by git.FetchOrigin()
s.repoMu.Lock()
defer s.repoMu.Unlock()

// find the latest split sha1 if any on origin
var start *git.Oid
start = s.cache.getHead()
if start != nil {
s.result.moveHead(s.cache.get(start))
// FIXME: CHECK that this is an ancestor of the branch?
return revWalk.PushRange(fmt.Sprintf("%s..%s", start, s.originBranch))
}

// find the latest split sha1 if any on origin
var err error
if s.config.Commit != "" {
start, err = git.NewOid(s.config.Commit)
Expand All @@ -538,13 +544,6 @@ func (s *state) pushRevs(revWalk *git.RevWalk) error {
return revWalk.PushRange(fmt.Sprintf("%s^..%s", start, s.originBranch))
}

start = s.cache.getHead()
if start != nil {
s.result.moveHead(s.cache.get(start))
// FIXME: CHECK that this is an ancestor of the branch?
return revWalk.PushRange(fmt.Sprintf("%s..%s", start, s.originBranch))
}

branch, err := s.repo.RevparseSingle(s.originBranch)
if err != nil {
return err
Expand Down

0 comments on commit eaede0b

Please sign in to comment.