Move head check for a more aggressive use of cache

This commit is contained in:
Fabien Potencier 2024-03-08 08:09:53 +01:00
parent cf9970e7ff
commit ca1a6cef48
No known key found for this signature in database

View file

@ -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)
@ -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