{"modulePath":"github.com/Keybase/kbfs","version":"v2.11.0+incompatible","isLatest":true,"isStandardLibrary":false,"goos":"all","goarch":"all","docs":"# package libgit\n\n## Constants\n\n```go\nconst (\n\t// AutogitRoot is the subdirectory name within a TLF where autogit\n\t// can be accessed.\n\tAutogitRoot = \".kbfs_autogit\"\n\t// AutogitBranchPrefix is a prefix of a subdirectory name\n\t// containing one element of a git reference name.\n\tAutogitBranchPrefix = \".kbfs_autogit_branch_\"\n)\n```\n\n## Variables\n\n```go\nvar CommitSentinelValue *object.Commit\n```\nCommitSentinelValue marks the end of a list of commits, where there are still commits that haven't been read. Use the zero-value \\`nil\\`.\n\n```go\nvar NullID = ID{}\n```\nNullID is an empty ID\n\n## Functions\n\n```go\nfunc CleanOldDeletedRepos(\n\tctx context.Context, config libkbfs.Config,\n\ttlfHandle *libkbfs.TlfHandle) (err error)\n```\nCleanOldDeletedRepos completely removes any \"deleted\" repos that have been deleted for longer than \\`minDeletedAgeForCleaning\\`.  The caller is responsible for syncing any data to disk, if desired.\n\n```go\nfunc CleanOldDeletedReposTimeLimited(\n\tctx context.Context, config libkbfs.Config,\n\ttlfHandle *libkbfs.TlfHandle) error\n```\nCleanOldDeletedReposTimeLimited is the same as \\`CleanOldDeletedRepos\\`, except it limits the time spent on cleaning, deleting as much data as possible within the given time limit (without returning an error).\n\n```go\nfunc DeleteRepo(\n\tctx context.Context, config libkbfs.Config, tlfHandle *libkbfs.TlfHandle,\n\trepoName string) error\n```\nDeleteRepo \"deletes\" the given repo in the given TLF.  Right now it simply moves the repo out of the way to a special directory, to allow any concurrent writers to finish their pushes without triggering conflict resolution.  The caller is responsible for syncing the FS and flushing the journal, if desired.  It expects the \\`config\\` object to be unique during the lifetime of this call.\n\n```go\nfunc GCRepo(\n\tctx context.Context, config libkbfs.Config, tlfHandle *libkbfs.TlfHandle,\n\trepoName string, options GCOptions) (err error)\n```\nGCRepo runs garbage collection on the specified repo, if it exceeds any of the thresholds provided in \\`options\\`.\n\n```go\nfunc Init(ctx context.Context, gitKBFSParams libkbfs.InitParams,\n\tkbCtx libkbfs.Context, keybaseServiceCn libkbfs.KeybaseServiceCn,\n\tdefaultLogPath string) (context.Context, libkbfs.Config, error)\n```\nInit initializes a context and a libkbfs.Config for git operations. The config should be shutdown when it is done being used.\n\n```go\nfunc LastGCTime(ctx context.Context, fs billy.Filesystem) (\n\ttime.Time, error)\n```\nLastGCTime returns the last time the repo was successfully garbage-collected.\n\n```go\nfunc NeedsGC(storage storage.Storer, options GCOptions) (\n\tdoPackRefs bool, numLooseRefs int, doPruneLoose, doObjectRepack bool,\n\tnumObjectPacks int, err error)\n```\nNeedsGC checks the given repo storage layer against the given options to see what kinds of GC are needed on the repo.\n\n```go\nfunc Params(kbCtx libkbfs.Context,\n\tstorageRoot string, paramsBase *libkbfs.InitParams) (\n\tparams libkbfs.InitParams, tempDir string, err error)\n```\nParams returns a set of default parameters for git-related operations, along with a temp directory that should be cleaned after the git work is complete.\n\n```go\nfunc RenameRepo(\n\tctx context.Context, config libkbfs.Config, tlfHandle *libkbfs.TlfHandle,\n\toldRepoName, newRepoName string) (err error)\n```\nRenameRepo renames the repo from an old name to a new name.  It leaves a symlink behind so that old remotes will continue to work. The caller is responsible for syncing the FS and flushing the journal, if desired.\n\n```go\nfunc Reset(\n\tctx context.Context, repoFS billy.Filesystem, worktreeFS billy.Filesystem,\n\tbranch plumbing.ReferenceName) error\n```\nReset checks out a repo from a billy filesystem, into another billy filesystem.  However, it doesn't make a true git clone, for two reasons.\n\n 1. This will be used to clone KBFS repos, and go-git doesn't natively understand the keybase:// protocol.  There might be a way around this with the \\`InstallProtocol\\` go-git method, but I haven't investigated that yet and it would be some extra work.\n\n 2. These clones are intended for autogit, which will display them as read-only directories.  They do not need to be real git repos, and so there's no need to copy object files or much else in the .git repo.  All we really need is an index, to compute the differences.  Making a full git clone, or even a \"shallow\" git clone, would be wasteful in that it would read and write way more data than we really need.\n\nThe resulting checkout in \\`worktreeFS\\` is therefore not a functional git repo.  The caller should only interact with \\`worktreeFS\\` in a read-only way, and should not attempt any git operations on it.\n\n```go\nfunc StartAutogit(config libkbfs.Config, browserCacheSize int) func()\n```\nStartAutogit launches autogit, and returns a function that should be called on shutdown.\n\n```go\nfunc UpdateRepoMD(ctx context.Context, config libkbfs.Config,\n\ttlfHandle *libkbfs.TlfHandle, fs billy.Filesystem,\n\tpushType keybase1.GitPushType,\n\toldRepoName string, refDataByName RefDataByName) error\n```\nUpdateRepoMD lets the Keybase service know that a repo's MD has been updated.\n\n## Types\n\n```go\ntype AutogitManager struct {\n\t// contains filtered or unexported fields\n}\n```\nAutogitManager can clone and pull source git repos into a destination folder, potentially across different TLFs.  New requests for an operation in a destination repo are blocked by any ongoing requests for the same folder, and multiple outstanding requests for the same destination folder get rolled up into one.\n\n```go\nfunc NewAutogitManager(\n\tconfig libkbfs.Config, browserCacheSize int) *AutogitManager\n```\nNewAutogitManager constructs a new AutogitManager instance.\n\n```go\nfunc (am *AutogitManager) BatchChanges(\n\tctx context.Context, _ []libkbfs.NodeChange,\n\taffectedNodeIDs []libkbfs.NodeID)\n```\nBatchChanges implements the libkbfs.Observer interface for AutogitManager.\n\n```go\nfunc (am *AutogitManager) GetBrowserForRepo(\n\tctx context.Context, gitFS *libfs.FS, repoName string,\n\tbranch plumbing.ReferenceName, subdir string) (*libfs.FS, *Browser, error)\n```\nGetBrowserForRepo returns the root FS for the specified repo and a \\`Browser\\` for the branch and subdir.\n\n```go\nfunc (am *AutogitManager) LocalChange(\n\tctx context.Context, node libkbfs.Node, wr libkbfs.WriteRange)\n```\nLocalChange implements the libkbfs.Observer interface for AutogitManager.\n\n```go\nfunc (am *AutogitManager) Shutdown()\n```\nShutdown shuts down this manager.\n\n```go\nfunc (am *AutogitManager) TlfHandleChange(\n\tctx context.Context, newHandle *libkbfs.TlfHandle)\n```\nTlfHandleChange implements the libkbfs.Observer interface for AutogitManager.\n\n```go\ntype Browser struct {\n\t// contains filtered or unexported fields\n}\n```\nBrowser presents the contents of a git repo as a read-only file system, using only the dotgit directory of the repo.\n\n```go\nfunc NewBrowser(\n\trepoFS *libfs.FS, clock libkbfs.Clock,\n\tgitBranchName plumbing.ReferenceName) (*Browser, error)\n```\nNewBrowser makes a new Browser instance, browsing the given branch of the given repo.  If \\`gitBranchName\\` is empty, \"refs/heads/master\" is used.  If \\`gitBranchName\\` is not empty, but it doesn't begin with \"refs/\", then \"refs/heads/\" is prepended to it.\n\n```go\nfunc (b *Browser) Chroot(p string) (newFS billy.Filesystem, err error)\n```\nChroot implements the billy.Filesystem interface for Browser.\n\n```go\nfunc (b *Browser) Create(_ string) (billy.File, error)\n```\nCreate implements the billy.Filesystem interface for Browser.\n\n```go\nfunc (b *Browser) Join(elem ...string) string\n```\nJoin implements the billy.Filesystem interface for Browser.\n\n```go\nfunc (b *Browser) Lstat(filename string) (fi os.FileInfo, err error)\n```\nLstat implements the billy.Filesystem interface for Browser.\n\n```go\nfunc (b *Browser) MkdirAll(_ string, _ os.FileMode) (err error)\n```\nMkdirAll implements the billy.Filesystem interface for Browser.\n\n```go\nfunc (b *Browser) Open(filename string) (f billy.File, err error)\n```\nOpen implements the billy.Filesystem interface for Browser.\n\n```go\nfunc (b *Browser) OpenFile(filename string, flag int, _ os.FileMode) (\n\tf billy.File, err error)\n```\nOpenFile implements the billy.Filesystem interface for Browser.\n\n```go\nfunc (b *Browser) ReadDir(p string) (fis []os.FileInfo, err error)\n```\nReadDir implements the billy.Filesystem interface for Browser.\n\n```go\nfunc (b *Browser) Readlink(link string) (target string, err error)\n```\nReadlink implements the billy.Filesystem interface for Browser.\n\n```go\nfunc (b *Browser) Remove(_ string) (err error)\n```\nRemove implements the billy.Filesystem interface for Browser.\n\n```go\nfunc (b *Browser) Rename(_, _ string) (err error)\n```\nRename implements the billy.Filesystem interface for Browser.\n\n```go\nfunc (b *Browser) Root() string\n```\nRoot implements the billy.Filesystem interface for Browser.\n\n```go\nfunc (b *Browser) Stat(filename string) (fi os.FileInfo, err error)\n```\nStat implements the billy.Filesystem interface for Browser.\n\n```go\nfunc (b *Browser) Symlink(_, _ string) (err error)\n```\nSymlink implements the billy.Filesystem interface for Browser.\n\n```go\nfunc (b *Browser) TempFile(_, _ string) (billy.File, error)\n```\nTempFile implements the billy.Filesystem interface for Browser.\n\n```go\ntype Config struct {\n\tID         ID\n\tName       string // the original user-supplied format of the name\n\tCreatorUID string\n\tCtime      int64 // create time in unix nanoseconds, by creator's clock\n}\n```\nConfig is a KBFS git repo config file.\n\n```go\ntype GCOptions struct {\n\t// The most loose refs we will tolerate; if there are more loose\n\t// refs, we should pack them.\n\tMaxLooseRefs int\n\t// The minimum number of potentially-expired loose objects we need\n\t// to start the pruning process.  If \u003c 0, pruning will not be done.\n\tPruneMinLooseObjects int\n\t// Any unreachable objects older than this time are subject to\n\t// pruning.\n\tPruneExpireTime time.Time\n\t// The most object packs we will tolerate; if there are more\n\t// object packs, we should re-pack all the objects.  If \u003c 0,\n\t// re-packing will not be done.\n\tMaxObjectPacks int\n}\n```\nGCOptions describe options foe garbage collection.\n\n```go\ntype GitConfigWithoutRemotesStorer struct {\n\t*filesystem.Storage\n\t// contains filtered or unexported fields\n}\n```\nGitConfigWithoutRemotesStorer strips remotes from the config before writing them to disk, to work around a gcfg bug (used by go-git when reading configs from disk) that causes a freakout when it sees backslashes in git file URLs.\n\n```go\nfunc NewGitConfigWithoutRemotesStorer(fs *libfs.FS) (\n\t*GitConfigWithoutRemotesStorer, error)\n```\nNewGitConfigWithoutRemotesStorer creates a new git config implementation that strips remotes from the config before writing them to disk.\n\n```go\nfunc (cwrs *GitConfigWithoutRemotesStorer) Config() (*gogitcfg.Config, error)\n```\nConfig implements the \\`storer.Storer\\` interface.\n\n```go\nfunc (cwrs *GitConfigWithoutRemotesStorer) Init() error\n```\nInit implements the \\`storer.Initializer\\` interface.\n\n```go\nfunc (cwrs *GitConfigWithoutRemotesStorer) SetConfig(c *gogitcfg.Config) (\n\terr error)\n```\nSetConfig implements the \\`storer.Storer\\` interface.\n\n```go\ntype ID struct {\n\t// contains filtered or unexported fields\n}\n```\nID encapsulates a repo ID.\n\n```go\nfunc CreateRepoAndID(\n\tctx context.Context, config libkbfs.Config, tlfHandle *libkbfs.TlfHandle,\n\trepoName string) (ID, error)\n```\nCreateRepoAndID returns a new stable repo ID for the provided repoName in the given TLF.  If the repo has already been created, it returns a \\`RepoAlreadyExistsError\\`.  If \\`repoName\\` already exists, but is a symlink to another renamed directory, the symlink will be removed in favor of the new repo.  The caller is responsible for syncing the FS and flushing the journal, if desired.  It expects the \\`config\\` object to be unique during the lifetime of this call.\n\n```go\nfunc GetOrCreateRepoAndID(\n\tctx context.Context, config libkbfs.Config, tlfHandle *libkbfs.TlfHandle,\n\trepoName string, uniqID string) (*libfs.FS, ID, error)\n```\nGetOrCreateRepoAndID returns a filesystem object rooted at the specified repo, along with the stable repo ID.  If the repo hasn't been created yet, it generates a new ID and creates the repo.  The caller is responsible for syncing the FS and flushing the journal, if desired.\n\n```go\nfunc GetRepoAndID(\n\tctx context.Context, config libkbfs.Config, tlfHandle *libkbfs.TlfHandle,\n\trepoName string, uniqID string) (*libfs.FS, ID, error)\n```\nGetRepoAndID returns a filesystem object rooted at the specified repo, along with the stable repo ID, if it already exists.\n\n```go\nfunc (id ID) Bytes() []byte\n```\nBytes returns the bytes of the ID.\n\n```go\nfunc (id ID) MarshalBinary() (data []byte, err error)\n```\nMarshalBinary implements the encoding.BinaryMarshaler interface for ID.\n\n```go\nfunc (id ID) MarshalText() ([]byte, error)\n```\nMarshalText implements the encoding.TextMarshaler interface for ID.\n\n```go\nfunc (id ID) String() string\n```\nString implements the Stringer interface for ID.\n\n```go\nfunc (id *ID) UnmarshalBinary(data []byte) error\n```\nUnmarshalBinary implements the encoding.BinaryUnmarshaler interface for ID.\n\n```go\nfunc (id *ID) UnmarshalText(buf []byte) error\n```\nUnmarshalText implements the encoding.TextUnmarshaler interface for ID.\n\n```go\ntype InvalidIDError struct {\n\t// contains filtered or unexported fields\n}\n```\nInvalidIDError indicates that a repo ID string is not parseable or invalid.\n\n```go\nfunc (e InvalidIDError) Error() string\n```\n\n```go\ntype OnDemandStorer struct {\n\tstorage.Storer\n\t// contains filtered or unexported fields\n}\n```\nOnDemandStorer is a wrapper around a storage.Storer that reads encoded objects from disk only when the data is needed, to avoid pulling too much data into memory.\n\n```go\nfunc NewOnDemandStorer(s storage.Storer) (*OnDemandStorer, error)\n```\nNewOnDemandStorer constructs an on-demand storage layer on top of an existing \\`Storer\\`.\n\n```go\nfunc (ods *OnDemandStorer) DeltaObject(\n\tot plumbing.ObjectType, hash plumbing.Hash) (\n\tplumbing.EncodedObject, error)\n```\nDeltaObject implements the storer.DeltaObjectStorer interface for OnDemandStorer.\n\n```go\nfunc (ods *OnDemandStorer) EncodedObject(\n\tot plumbing.ObjectType, hash plumbing.Hash) (\n\tplumbing.EncodedObject, error)\n```\nEncodedObject implements the storage.Storer interface for OnDemandStorer.\n\n```go\ntype RPCHandler struct {\n\t// contains filtered or unexported fields\n}\n```\nRPCHandler handles service-\u003eKBFS git RPC calls.\n\n```go\nfunc NewRPCHandlerWithCtx(kbCtx libkbfs.Context, config libkbfs.Config,\n\tkbfsInitParams *libkbfs.InitParams) (*RPCHandler, func())\n```\nNewRPCHandlerWithCtx returns a new instance of a Git RPC handler.\n\n```go\nfunc (rh *RPCHandler) CreateRepo(\n\tctx context.Context, arg keybase1.CreateRepoArg) (\n\tid keybase1.RepoID, err error)\n```\nCreateRepo implements keybase1.KBFSGitInterface for KeybaseServiceBase.\n\n```go\nfunc (rh *RPCHandler) DeleteRepo(\n\tctx context.Context, arg keybase1.DeleteRepoArg) (err error)\n```\nDeleteRepo implements keybase1.KBFSGitInterface for KeybaseServiceBase.\n\n```go\nfunc (rh *RPCHandler) Gc(\n\tctx context.Context, arg keybase1.GcArg) (err error)\n```\nGc implements keybase1.KBFSGitInterface for KeybaseServiceBase.\n\n```go\nfunc (rh *RPCHandler) RenameRepo(ctx context.Context,\n\tfolder keybase1.Folder, oldName, newName string) (err error)\n```\nRenameRepo renames an existing git repository.\n\nTODO: Hook this up to an RPC.\n\n```go\ntype RefData struct {\n\tIsDelete bool\n\tCommits  []*object.Commit\n}\n```\nRefData stores the data for a ref.\n\n```go\ntype RefDataByName map[plumbing.ReferenceName]*RefData\n```\nRefDataByName represents a map of reference names to data about that ref.\n\n","path":"github.com/Keybase/kbfs/libgit","name":"libgit","synopsis":"","isRedistributable":true}
