// Owner returns a weak reference to the repository which owns this
// object. This won't keep the underlying repository alive.
499808
func (o *Object) Owner() *Repository {
	ret := &Repository{
		ptr: C.git_object_owner(o.ptr),
	}
	runtime.KeepAlive(o)
	return ret
}
547051
func getOwner(login string, lookupUser LookupUser, lookupGroup LookupGroup) (int, int, os.FileMode, error) {
	var err error
	var uid int
	var gid int
	var mode os.FileMode

	// Lookup the Unix login for the UID and fallback GID.
	u, err := lookupUser(login)
	if err != nil {
		return 0, 0, 0, trace.Wrap(err)
	}
	uid, err = strconv.Atoi(u.Uid)
	if err != nil {
		return 0, 0, 0, trace.Wrap(err)
	}

	// If the tty group exists, use that as the gid of the TTY and set mode to
	// be u+rw. Otherwise use the group of the user with mode u+rw g+w.
	group, err := lookupGroup("tty")
	if err != nil {
		gid, err = strconv.Atoi(u.Gid)
		if err != nil {
			return 0, 0, 0, trace.Wrap(err)
		}
		mode = 0620
	} else {
		gid, err = strconv.Atoi(group.Gid)
		if err != nil {
			return 0, 0, 0, trace.Wrap(err)
		}
		mode = 0600
	}

	return uid, gid, mode, nil
}
476416
func (r *Repository) Object(t plumbing.ObjectType, h plumbing.Hash) (object.Object, error) {
	obj, err := r.Storer.EncodedObject(t, h)
	if err != nil {
		return nil, err
	}

	return object.DecodeObject(r.Storer, obj)
}
396631
func (s *SnapshotVerifyRepositoryService) Repository(repository string) *SnapshotVerifyRepositoryService {
	s.repository = repository
	return s
}
403548
func (_ENSRegistry *ENSRegistryCaller) Owner(opts *bind.CallOpts, node [32]byte) (common.Address, error) {
	var (
		ret0 = new(common.Address)
	)
	out := ret0
	err := _ENSRegistry.contract.Call(opts, out, "owner", node)
	return *ret0, err
}
440383
func (s *GitHubCodeDestination) SetOwner(v string) *GitHubCodeDestination {
	s.Owner = &v
	return s
}
319934
func (s *Session) SetOwner(v string) *Session {
	s.Owner = &v
	return s
}
353145
func (s *ActionTypeId) SetOwner(v string) *ActionTypeId {
	s.Owner = &v
	return s
}
477810
func (_ENS *ENSSession) Owner(node [32]byte) (common.Address, error) {
	return _ENS.Contract.Owner(&_ENS.CallOpts, node)
}
568737
func (s *ProductViewSummary) SetOwner(v string) *ProductViewSummary {
	s.Owner = &v
	return s
}
215656
func ForkRepository(doer, owner *User, baseRepo *Repository, name, desc string) (_ *Repository, err error) {
	if !owner.CanCreateRepo() {
		return nil, errors.ReachLimitOfRepo{owner.RepoCreationNum()}
	}

	repo := &Repository{
		OwnerID:       owner.ID,
		Owner:         owner,
		Name:          name,
		LowerName:     strings.ToLower(name),
		Description:   desc,
		DefaultBranch: baseRepo.DefaultBranch,
		IsPrivate:     baseRepo.IsPrivate,
		IsFork:        true,
		ForkID:        baseRepo.ID,
	}

	sess := x.NewSession()
	defer sess.Close()
	if err = sess.Begin(); err != nil {
		return nil, err
	}

	if err = createRepository(sess, doer, owner, repo); err != nil {
		return nil, err
	} else if _, err = sess.Exec("UPDATE `repository` SET num_forks=num_forks+1 WHERE id=?", baseRepo.ID); err != nil {
		return nil, err
	}

	repoPath := repo.repoPath(sess)
	RemoveAllWithNotice("Repository path erase before creation", repoPath)

	_, stderr, err := process.ExecTimeout(10*time.Minute,
		fmt.Sprintf("ForkRepository 'git clone': %s/%s", owner.Name, repo.Name),
		"git", "clone", "--bare", baseRepo.RepoPath(), repoPath)
	if err != nil {
		return nil, fmt.Errorf("git clone: %v", stderr)
	}

	_, stderr, err = process.ExecDir(-1,
		repoPath, fmt.Sprintf("ForkRepository 'git update-server-info': %s", repoPath),
		"git", "update-server-info")
	if err != nil {
		return nil, fmt.Errorf("git update-server-info: %v", err)
	}

	if err = createDelegateHooks(repoPath); err != nil {
		return nil, fmt.Errorf("createDelegateHooks: %v", err)
	}

	if err = sess.Commit(); err != nil {
		return nil, fmt.Errorf("Commit: %v", err)
	}

	if err = repo.UpdateSize(); err != nil {
		log.Error(2, "UpdateSize [repo_id: %d]: %v", repo.ID, err)
	}
	if err = PrepareWebhooks(baseRepo, HOOK_EVENT_FORK, &api.ForkPayload{
		Forkee: repo.APIFormat(nil),
		Repo:   baseRepo.APIFormat(nil),
		Sender: doer.APIFormat(),
	}); err != nil {
		log.Error(2, "PrepareWebhooks [repo_id: %d]: %v", baseRepo.ID, err)
	}
	return repo, nil
}
48135
func NewOwner(keyID string, ref blob.Ref) *Owner {
	return &Owner{
		keyID:       []string{keyID},
		blobByKeyID: map[string]SignerRefSet{keyID: SignerRefSet{ref.String()}},
	}
}
474936
func (s *ScanKeys) KeyOwner(keyID uint64) *libkb.User {
	s.Lock()
	defer s.Unlock()

	return s.keyOwners[keyID]
}
1362416
func (s *SnapshotDeleteRepositoryService) Repository(repositories ...string) *SnapshotDeleteRepositoryService {
	s.repository = append(s.repository, repositories...)
	return s
}
206129
func (b *lowBuilder) searchOwner() (owner *serverconfig.Owner, err error) {
	if b.high.Identity == "" {
		return nil, errNoOwner
	}
	if b.high.IdentitySecretRing == "" {
		return nil, errNoOwner
	}
	return &serverconfig.Owner{
		Identity:    b.high.Identity,
		SecringFile: b.high.IdentitySecretRing,
	}, nil
}
1335443
func (s *GitServer) GetRepoByOwner(owner, name string) (provider.Repo, error) {
	r := &Repo{}
	repo, _, err := s.client.Repositories.Get(s.ctx, owner, name)
	if err != nil {
		local.Printf("Unable to find repo [%s/%s]", owner, name)
		return r, err
	}
	if repo == nil {
		return r, nil
	}
	r.impl = repo
	r.assumedOwner = owner
	if *repo.Fork && repo.Parent.Owner != nil {
		r.forkedFrom = &Repo{impl: repo.Parent}
	}
	return r, nil

}
1141592
func (i *DocumentIndex) AddDocumentOwner(id influxdb.ID, ownerType string, ownerID influxdb.ID) error {
	if err := i.ownerExists(ownerType, ownerID); err != nil {
		return err
	}

	// TODO(desa): support users owning resources.

	m := &influxdb.UserResourceMapping{
		UserID:   ownerID,
		UserType: influxdb.Owner,
		// In this case UserID refers to an organization rather than a user.
		MappingType:  influxdb.OrgMappingType,
		ResourceType: influxdb.DocumentsResourceType,
		ResourceID:   id,
	}
	return i.service.createUserResourceMapping(i.ctx, i.tx, m)
}