// Checkout switchs branches or restore working tree files.
// Arg can be a commit hash, a branch or a tag.
334064
func (g *Git) Checkout(arg string) *command.Model {
	return g.command("checkout", arg)
}
893689
func (h *HookPayload) Branch() string {
	ref := h.Ref
	if h.ObjectAttributes != nil && len(h.ObjectAttributes.Ref) > 0 {
		ref = h.ObjectAttributes.Ref
	}

	return strings.TrimPrefix(ref, "refs/heads/")
}
1005280
func (p *ExclusivePool) CheckOut(identity string) {
	p.lock.Lock()
	defer p.lock.Unlock()

	p.pool[identity].Unlock()
	if p.count[identity] == 1 {
		delete(p.pool, identity)
		delete(p.count, identity)
	} else {
		p.count[identity]--
	}
}
268445
func NewCheckout(commits notifypb.GitilesCommits) Checkout {
	results := make(Checkout, len(commits.GetCommits()))
	for _, gitilesCommit := range commits.GetCommits() {
		results[protoutil.GitilesRepoURL(gitilesCommit)] = gitilesCommit.Id
	}
	return results
}
114249
func checkMatch(f *ast.File, pos token.Pos) (match, error) {
	path, _ := astutil.PathEnclosingInterval(f, pos, pos)
	result := match{}
	if path == nil {
		return result, fmt.Errorf("can't find node enclosing position")
	}
	switch node := path[0].(type) {
	case *ast.Ident:
		result.ident = node
	case *ast.SelectorExpr:
		result.ident = node.Sel
	case *ast.BasicLit:
		// if there was a literal import path, we build a special ident of
		// the same value, which we eventually use to print the path
		if len(path) > 1 {
			if spec, ok := path[1].(*ast.ImportSpec); ok {
				if p, err := strconv.Unquote(spec.Path.Value); err == nil {
					result.ident = ast.NewIdent(p)
				}
			}
		}
	}
	if result.ident != nil {
		for _, n := range path[1:] {
			if field, ok := n.(*ast.Field); ok {
				result.wasEmbeddedField = len(field.Names) == 0
			}
		}
	}
	return result, nil
}
251188
func (hc healthCheckHandler) Checker() (string, error) {
	if err := hc.annotationsService.Check(); err != nil {
		return "Error connecting to neo4j", err
	}
	return "Connectivity to neo4j is ok", nil
}
1356563
func (c *agentConf) CheckArgs(args []string) error {
	if c.dataDir == "" {
		return util.RequiredError("data-dir")
	}
	return cmd.CheckEmpty(args)
}
743361
func (c Checkout) Filter(whiteset stringset.Set) Checkout {
	newCheckout := make(Checkout)
	for repo, commit := range c {
		if whiteset.Has(repo) {
			newCheckout[repo] = commit
		}
	}
	return newCheckout
}
724006
func (c *Checkout) CommitAndPush(ctx context.Context, commitAction CommitAction, note interface{}) error {
	if !check(ctx, c.dir, c.config.Paths) {
		return ErrNoChanges
	}

	commitAction.Message += c.config.SkipMessage
	if commitAction.SigningKey == "" {
		commitAction.SigningKey = c.config.SigningKey
	}

	if err := commit(ctx, c.dir, commitAction); err != nil {
		return err
	}

	if note != nil {
		rev, err := c.HeadRevision(ctx)
		if err != nil {
			return err
		}
		if err := addNote(ctx, c.dir, rev, c.config.NotesRef, note); err != nil {
			return err
		}
	}

	refs := []string{c.config.Branch}
	ok, err := refExists(ctx, c.dir, c.realNotesRef)
	if ok {
		refs = append(refs, c.realNotesRef)
	} else if err != nil {
		return err
	}

	if err := push(ctx, c.dir, c.upstream.URL, refs); err != nil {
		return PushError(c.upstream.URL, err)
	}
	return nil
}
135446
func (v *Validator) CheckAll() error {
	var errs *multierror.Error
	errs = multierror.Append(errs, v.CheckJSONSchema())
	errs = multierror.Append(errs, v.CheckPlatform())
	errs = multierror.Append(errs, v.CheckRoot())
	errs = multierror.Append(errs, v.CheckMandatoryFields())
	errs = multierror.Append(errs, v.CheckSemVer())
	errs = multierror.Append(errs, v.CheckMounts())
	errs = multierror.Append(errs, v.CheckProcess())
	errs = multierror.Append(errs, v.CheckLinux())
	errs = multierror.Append(errs, v.CheckAnnotations())
	if v.platform == "linux" || v.platform == "solaris" {
		errs = multierror.Append(errs, v.CheckHooks())
	}

	return errs.ErrorOrNil()
}
790160
func (r *Store) Tree(ctx context.Context) (tree.Tree, error) {
	root := simple.New("gopass")
	addFileFunc := func(in ...string) {
		for _, f := range in {
			var ct string
			switch {
			case strings.HasSuffix(f, ".b64"):
				ct = "application/octet-stream"
			case strings.HasSuffix(f, ".yml"):
				ct = "text/yaml"
			case strings.HasSuffix(f, ".yaml"):
				ct = "text/yaml"
			default:
				ct = "text/plain"
			}
			if err := root.AddFile(f, ct); err != nil {
				out.Error(ctx, "Failed to add file %s to tree: %s", f, err)
				continue
			}
		}
	}
	addTplFunc := func(in ...string) {
		for _, f := range in {
			if err := root.AddTemplate(f); err != nil {
				out.Error(ctx, "Failed to add template %s to tree: %s", f, err)
				continue
			}
		}
	}

	sf, err := r.store.List(ctx, "")
	if err != nil {
		return nil, err
	}
	addFileFunc(sf...)
	addTplFunc(r.store.ListTemplates(ctx, "")...)

	mps := r.MountPoints()
	sort.Sort(store.ByPathLen(mps))
	for _, alias := range mps {
		substore := r.mounts[alias]
		if substore == nil {
			continue
		}
		if err := root.AddMount(alias, substore.Path()); err != nil {
			return nil, errors.Errorf("failed to add mount: %s", err)
		}
		sf, err := substore.List(ctx, "")
		if err != nil {
			return nil, errors.Errorf("failed to add file: %s", err)
		}
		addFileFunc(sf...)
		addTplFunc(substore.ListTemplates(ctx, alias)...)
	}

	return root, nil
}
966792
func (c *Checker) Check(rel string, recurse bool, beforeRev, afterRev string) ([]Change, error) {
	// If revision is unset use VCS's default revision
	dBefore, dAfter := c.vcs.DefaultRevision()
	if beforeRev == "" {
		beforeRev = dBefore
	}
	if afterRev == "" {
		afterRev = dAfter
	}
	c.recurse = recurse

	var err error
	c.path, err = importPathTo(rel)
	if err != nil {
		return nil, err
	}

	c.logf("import path: %q before: %q after: %q recursive: %v\n", c.path, beforeRev, afterRev, c.recurse)

	// Parse revisions from VCS into go/ast
	start := time.Now()
	if c.b, err = c.parse(beforeRev); err != nil {
		return nil, err
	}
	if c.a, err = c.parse(afterRev); err != nil {
		return nil, err
	}
	parse := time.Since(start)

	start = time.Now()
	changes, err := c.compareDecls()
	if err != nil {
		var buf bytes.Buffer
		fmt.Fprintf(&buf, "error comparing declarations: %s\n", err)
		if derr, ok := err.(*diffError); ok {
			_ = ast.Fprint(&buf, c.b[derr.pkg].fset, derr.bdecl, ast.NotNilFilter)
			_ = ast.Fprint(&buf, c.a[derr.pkg].fset, derr.adecl, ast.NotNilFilter)
		}
		return nil, errors.New(buf.String())
	}
	diff := time.Since(start)

	start = time.Now()
	sort.Sort(byID(changes))
	sort := time.Since(start)

	c.logf("Timing: parse: %v, diff: %v, sort: %v, total: %v\n", parse, diff, sort, parse+diff+sort)
	c.logf("Changes detected: %v\n", len(changes))

	return changes, nil
}
970797
func (f *File) Check() {
	// TODO
	typs := make(map[ast.Expr]types.TypeAndValue)
	defs := make(map[*ast.Ident]types.Object)
	uses := make(map[*ast.Ident]types.Object)
	config := types.Config{FakeImportC: true}
	config.Importer = importer.Default()
	info := &types.Info{Types: typs, Defs: defs, Uses: uses}
	astFiles := []*ast.File{f.ast}
	typesPkg, err := config.Check(fileDir(f), f.fs, astFiles, info)
	if err != nil {
		log.Fatalf("checking package: %s", err)
	}
	f.Info = info
	f.Pkg = typesPkg
}
1360322
func (p *Parser) Args(dot bool) (bool, error) {

	if p.PeekByte() != '(' {
		return false, nil
	}
	p.Byte()

	i := p.ev.Level()

	if dot {
		p.ev.Add(TypeGroup)
	} else {
		p.ev.Add(TypeArguments)
	}
	p.ev.Inc()

	p.WhiteSpace()
	p.ArgList()
	p.WhiteSpace()

	if p.PeekByte() != ')' {
		return false, errors.New("missing )")
	}
	p.Byte()

	// Level before and after is the same
	p.ev.SetLevel(i)
	return true, nil
}
350716
func (w *Worktree) Checkout(opts *CheckoutOptions) error {
	if err := opts.Validate(); err != nil {
		return err
	}

	if opts.Create {
		if err := w.createBranch(opts); err != nil {
			return err
		}
	}

	c, err := w.getCommitFromCheckoutOptions(opts)
	if err != nil {
		return err
	}

	ro := &ResetOptions{Commit: c, Mode: MergeReset}
	if opts.Force {
		ro.Mode = HardReset
	}

	if !opts.Hash.IsZero() && !opts.Create {
		err = w.setHEADToCommit(opts.Hash)
	} else {
		err = w.setHEADToBranch(opts.Branch, c)
	}

	if err != nil {
		return err
	}

	return w.Reset(ro)
}
1149902
func (_m *Client) Checkout(revision string) error {
	ret := _m.Called(revision)

	var r0 error
	if rf, ok := ret.Get(0).(func(string) error); ok {
		r0 = rf(revision)
	} else {
		r0 = ret.Error(0)
	}

	return r0
}
924377
func (ctx *Context) Check() []*Conflict {
	// Find duplicate packages that have been marked for moving.
	findDups := make(map[string][]*Operation, 3) // map[canonical][]local
	for _, op := range ctx.Operation {
		if op.State != OpReady {
			continue
		}
		findDups[op.Pkg.Path] = append(findDups[op.Pkg.Path], op)
	}

	var ret []*Conflict
	for canonical, lop := range findDups {
		if len(lop) == 1 {
			continue
		}
		destDir := path.Join(ctx.RootImportPath, ctx.VendorFolder, canonical)
		ret = append(ret, &Conflict{
			Canonical: canonical,
			Local:     destDir,
			Operation: lop,
		})
	}
	return ret
}