// Alternates returns DotGit(s) based off paths in objects/info/alternates if
// available. This can be used to checks if it's a shared repository.
502536
func (d *DotGit) Alternates() ([]*DotGit, error) {
	altpath := d.fs.Join("objects", "info", "alternates")
	f, err := d.fs.Open(altpath)
	if err != nil {
		return nil, err
	}
	defer f.Close()

	var alternates []*DotGit

	// Read alternate paths line-by-line and create DotGit objects.
	scanner := bufio.NewScanner(f)
	for scanner.Scan() {
		path := scanner.Text()
		if !filepath.IsAbs(path) {
			// For relative paths, we can perform an internal conversion to
			// slash so that they work cross-platform.
			slashPath := filepath.ToSlash(path)
			// If the path is not absolute, it must be relative to object
			// database (.git/objects/info).
			// https://www.kernel.org/pub/software/scm/git/docs/gitrepository-layout.html
			// Hence, derive a path relative to DotGit's root.
			// "../../../reponame/.git/" -> "../../reponame/.git"
			// Remove the first ../
			relpath := filepath.Join(strings.Split(slashPath, "/")[1:]...)
			normalPath := filepath.FromSlash(relpath)
			path = filepath.Join(d.fs.Root(), normalPath)
		}
		fs := osfs.New(filepath.Dir(path))
		alternates = append(alternates, New(fs))
	}

	if err = scanner.Err(); err != nil {
		return nil, err
	}

	return alternates, nil
}
43213
func (e EventBuilder) Alternatives(alts string) EventBuilder {
	e.assertPattern()
	e.fields = append(e.fields, Field{
		valid:   true,
		value:   "[" + alts + "]",
		pattern: patternAlts,
	})
	return e
}
1338713
func DirExists(path string) bool {
	ret, isDir := FileOrDirExists(path)
	return ret && isDir
}
742194
func (c *retryRepository) Manifests(ctx context.Context, options ...distribution.ManifestServiceOption) (distribution.ManifestService, error) {
	s, err := c.Repository.Manifests(ctx, options...)
	if err != nil {
		return nil, err
	}
	return retryManifest{ManifestService: s, repo: c}, nil
}
677075
func (d *DotGit) Objects() ([]plumbing.Hash, error) {
	if d.options.ExclusiveAccess {
		err := d.genObjectList()
		if err != nil {
			return nil, err
		}

		return d.objectList, nil
	}

	var objects []plumbing.Hash
	err := d.ForEachObjectHash(func(hash plumbing.Hash) error {
		objects = append(objects, hash)
		return nil
	})
	if err != nil {
		return nil, err
	}
	return objects, nil
}
94463
func (o *Me) Underlays(info *bambou.FetchingInfo) (UnderlaysList, *bambou.Error) {

	var list UnderlaysList
	err := bambou.CurrentSession().FetchChildren(o, UnderlayIdentity, &list, info)
	return list, err
}
780367
func (g *Geometry) Overlaps(other *Geometry) (bool, error) {
	return g.binaryPred("Overlaps", cGEOSOverlaps, other)
}
163939
func (c *Config) EqualValues(other *Config) bool {
	return c.values.Equal(other.values)
}
1300578
func (r repositoryVerifier) Manifests(ctx context.Context, options ...distribution.ManifestServiceOption) (distribution.ManifestService, error) {
	ms, err := r.Repository.Manifests(ctx, options...)
	if err != nil {
		return nil, err
	}
	return manifestServiceVerifier{ManifestService: ms}, nil
}
993276
func (s *MultiTermvectorService) Offsets(offsets bool) *MultiTermvectorService {
	s.offsets = &offsets
	return s
}
6035
func IsDirExists(path string) bool {
	fi, err := os.Stat(path)

	if err != nil {
		return os.IsExist(err)
	} else {
		return fi.IsDir()
	}

	panic("util isDirExists not reached")
}
1337027
func ensureCloneForRepo(dir string, repo string, alternateRepos []string, out, errOut io.Writer) (*git, error) {
	basePath, err := sourceLocationAsRelativePath(dir, repo)
	if err != nil {
		return nil, err
	}
	klog.V(4).Infof("Ensure repo is cloned at %s pointing to %s", basePath, repo)
	fi, err := os.Stat(basePath)
	if err != nil {
		if !os.IsNotExist(err) {
			return nil, err
		}
		if err := os.MkdirAll(basePath, 0777); err != nil {
			return nil, err
		}
	} else {
		if !fi.IsDir() {
			return nil, fmt.Errorf("repo path %s is not a directory", basePath)
		}
	}
	cloner := &git{}
	extractedRepo, err := cloner.ChangeContext(basePath)
	if err != nil {
		if err != noSuchRepo {
			return nil, err
		}
		klog.V(2).Infof("Cloning %s ...", repo)
		if err := extractedRepo.Clone(repo, out, errOut); err != nil {
			return nil, err
		}
	} else {
		if err := ensureRemoteForRepo(extractedRepo, repo); err != nil {
			return nil, err
		}
	}

	for _, altRepo := range alternateRepos {
		if altRepo == repo {
			continue
		}
		if err := ensureRemoteForRepo(extractedRepo, altRepo); err != nil {
			return nil, err
		}
	}

	return extractedRepo, nil
}
290991
func (d *DotGit) ObjectPacks() ([]plumbing.Hash, error) {
	if !d.options.ExclusiveAccess {
		return d.objectPacks()
	}

	err := d.genPackList()
	if err != nil {
		return nil, err
	}

	return d.packList, nil
}
807083
func Options(pkgs []*packages.Package) ([]interface{}, error) {
	var options []interface{}
	for _, p := range pkgs {
		for _, f := range p.Syntax {
			opts, err := FileOptions(f)
			if err != nil {
				return nil, err
			}
			options = append(options, opts...)
		}
	}
	return options, nil
}
709070
func comparePaths(rawSearchPath, rawConfigPath string) int {
	f := func(c rune) bool {
		return c == '/'
	}
	searchPath := strings.FieldsFunc(rawSearchPath, f)
	configPath := strings.FieldsFunc(rawConfigPath, f)

	if len(searchPath) < len(configPath) {
		return 0
	}

	// Start with a base score of 1, so we return something above 0 for a
	// zero-length path
	score := 1

	for i, element := range configPath {
		searchElement := searchPath[i]

		if element == searchElement {
			score += 2
			continue
		}

		if isDefaultLFSUrl(searchElement, searchPath, i+1) {
			if searchElement[0:len(searchElement)-4] == element {
				// Since we matched without the `.git` prefix, only add one
				// point to the score instead of 2
				score++
				continue
			}
		}

		return 0
	}

	return score
}
636504
func (s checkpointSorter) Swap(i, j int) {
	s[i], s[j] = s[j], s[i]
}
234091
func (repo *LocalRepository) Matches(pathQuery string) bool {
	for _, p := range repo.Subpaths() {
		if p == pathQuery {
			return true
		}
	}

	return false
}