{"modulePath":"github.com/Github/git-lfs","version":"v1.5.6","isLatest":true,"isStandardLibrary":false,"goos":"all","goarch":"all","docs":"# package git\n\nPackage git contains various commands that shell out to git NOTE: Subject to change, do not rely on this package from outside git-lfs source\n\nPackage git contains various commands that shell out to git NOTE: Subject to change, do not rely on this package from outside git-lfs source\n\n## Constants\n\n```go\nconst (\n\tRefTypeLocalBranch  = RefType(iota)\n\tRefTypeRemoteBranch = RefType(iota)\n\tRefTypeLocalTag     = RefType(iota)\n\tRefTypeRemoteTag    = RefType(iota)\n\tRefTypeHEAD         = RefType(iota) // current checkout\n\tRefTypeOther        = RefType(iota) // stash or unknown\n\n\t// A ref which can be used as a placeholder for before the first commit\n\t// Equivalent to git mktree \u003c /dev/null, useful for diffing before first commit\n\tRefBeforeFirstCommit = \"4b825dc642cb6eb9a060e54bf8d69288fbee4904\"\n)\n```\n\n```go\nconst (\n\t// MaxPacketLength is the maximum total (header+payload) length\n\t// encode-able within one packet using Git's pkt-line protocol.\n\tMaxPacketLength = 65516\n)\n```\n\n## Variables\n\n```go\nvar Config = \u0026gitConfig{}\n```\n\n## Functions\n\n```go\nfunc CloneWithoutFilters(flags CloneFlags, args []string) error\n```\nCloneWithoutFilters clones a git repo but without the smudge filter enabled so that files in the working copy will be pointers and not real LFS data\n\n```go\nfunc DefaultRemote() (string, error)\n```\nDefaultRemote returns the default remote based on: 1. The currently tracked remote branch, if present 2. \"origin\", if defined 3. Any other SINGLE remote defined in .git/config Returns an error if all of these fail, i.e. no tracked remote branch, no \"origin\", and either no remotes defined or 2+ non-\"origin\" remotes\n\n```go\nfunc FormatGitDate(tm time.Time) string\n```\nFormatGitDate converts a Go date into a git command line format date\n\n```go\nfunc GetTrackedFiles(pattern string) ([]string, error)\n```\nGetTrackedFiles returns a list of files which are tracked in Git which match the pattern specified (standard wildcard form) Both pattern and the results are relative to the current working directory, not the root of the repository\n\n```go\nfunc GitAndRootDirs() (string, string, error)\n```\n\n```go\nfunc GitDir() (string, error)\n```\n\n```go\nfunc IsVersionAtLeast(actualVersion, desiredVersion string) bool\n```\nIsVersionAtLeast compares 2 version strings (ok to be prefixed with 'git version', ignores)\n\n```go\nfunc LsRemote(remote, remoteRef string) (string, error)\n```\n\n```go\nfunc ParseGitDate(str string) (time.Time, error)\n```\nParse a Git date formatted in ISO 8601 format (%ci/%ai)\n\n```go\nfunc RemoteBranchForLocalBranch(localBranch string) string\n```\nRemoteBranchForLocalBranch returns the name (only) of the remote branch that the local branch is tracking If no specific branch is configured, returns local branch name\n\n```go\nfunc RemoteForBranch(localBranch string) string\n```\nRemoteForBranch returns the remote name that a given local branch is tracking (blank if none)\n\n```go\nfunc RemoteForCurrentBranch() (string, error)\n```\nRemoteForCurrentBranch returns the name of the remote that the current branch is tracking\n\n```go\nfunc RemoteList() ([]string, error)\n```\n\n```go\nfunc RemoteRefNameForCurrentBranch() (string, error)\n```\nRemoteRefForCurrentBranch returns the full remote ref (refs/remotes/{remote}/{remotebranch}) that the current branch is tracking.\n\n```go\nfunc RootDir() (string, error)\n```\n\n```go\nfunc UpdateIndex(file string) error\n```\n\n```go\nfunc ValidateRemote(remote string) error\n```\nValidateRemote checks that a named remote is valid for use Mainly to check user-supplied remotes \u0026 fail more nicely\n\n```go\nfunc ValidateRemoteURL(remote string) error\n```\nValidateRemoteURL checks that a string is a valid Git remote URL\n\n## Types\n\n```go\ntype CloneFlags struct {\n\t// --template \u003ctemplate_directory\u003e\n\tTemplateDirectory string\n\t// -l --local\n\tLocal bool\n\t// -s --shared\n\tShared bool\n\t// --no-hardlinks\n\tNoHardlinks bool\n\t// -q --quiet\n\tQuiet bool\n\t// -n --no-checkout\n\tNoCheckout bool\n\t// --progress\n\tProgress bool\n\t// --bare\n\tBare bool\n\t// --mirror\n\tMirror bool\n\t// -o \u003cname\u003e --origin \u003cname\u003e\n\tOrigin string\n\t// -b \u003cname\u003e --branch \u003cname\u003e\n\tBranch string\n\t// -u \u003cupload-pack\u003e --upload-pack \u003cpack\u003e\n\tUpload string\n\t// --reference \u003crepository\u003e\n\tReference string\n\t// --dissociate\n\tDissociate bool\n\t// --separate-git-dir \u003cgit dir\u003e\n\tSeparateGit string\n\t// --depth \u003cdepth\u003e\n\tDepth string\n\t// --recursive\n\tRecursive bool\n\t// --recurse-submodules\n\tRecurseSubmodules bool\n\t// -c \u003cvalue\u003e --config \u003cvalue\u003e\n\tConfig string\n\t// --single-branch\n\tSingleBranch bool\n\t// --no-single-branch\n\tNoSingleBranch bool\n\t// --verbose\n\tVerbose bool\n\t// --ipv4\n\tIpv4 bool\n\t// --ipv6\n\tIpv6 bool\n}\n```\nFor compatibility with git clone we must mirror all flags in CloneWithoutFilters\n\n```go\ntype CommitSummary struct {\n\tSha            string\n\tShortSha       string\n\tParents        []string\n\tCommitDate     time.Time\n\tAuthorDate     time.Time\n\tAuthorName     string\n\tAuthorEmail    string\n\tCommitterName  string\n\tCommitterEmail string\n\tSubject        string\n}\n```\nSome top level information about a commit (only first line of message)\n\n```go\nfunc GetCommitSummary(commit string) (*CommitSummary, error)\n```\nGet summary information about a commit\n\n```go\ntype FilterProcessScanner struct {\n\t// contains filtered or unexported fields\n}\n```\nFilterProcessScanner provides a scanner-like interface capable of initializing the filter process with the Git parent, and scanning for requests across the protocol.\n\nReading a request (and errors) is as follows:\n\n\ts := NewFilterProcessScanner(os.Stdin, os.Stderr)\n\tfor s.Scan() {\n\t        req := s.Request()\n\t\t       // ...\n\t}\n\n\tif err := s.Err(); err != nil {\n\t        // ...\n\t}\n\n```go\nfunc NewFilterProcessScanner(r io.Reader, w io.Writer) *FilterProcessScanner\n```\nNewFilterProcessScanner constructs a new instance of the \\`\\*FilterProcessScanner\\` type which reads packets from the \\`io.Reader\\` \"r\", and writes packets to the \\`io.Writer\\`, \"w\".\n\nBoth reader and writers SHOULD NOT be \\`\\*git.PacketReader\\` or \\`\\*git.PacketWriter\\`s, they will be transparently treated as such. In other words, it is safe (and recommended) to pass \\`os.Stdin\\` and \\`os.Stdout\\` directly.\n\n```go\nfunc (o *FilterProcessScanner) Err() error\n```\nErr returns any error encountered from the last call to Scan(). It is available only after a call to \\`Scan()\\` has completed, and is re-initialized to nil at the beginning of the subsequent \\`Scan()\\` call.\n\n```go\nfunc (o *FilterProcessScanner) Init() error\n```\nInit initializes the filter and ACKs back and forth between the Git LFS subprocess and the Git parent process that each is a git-filter-server and client respectively.\n\nIf either side wrote an invalid sequence of data, or did not meet expectations, an error will be returned. If the filter type is not supported, an error will be returned. If the pkt-line welcome message was invalid, an error will be returned.\n\nIf there was an error reading or writing any of the packets below, an error will be returned.\n\n```go\nfunc (o *FilterProcessScanner) NegotiateCapabilities() error\n```\nNegotiateCapabilities executes the process of negotiating capabilities between the filter client and server. If we don't support any of the capabilities given to LFS by the parent, an error will be returned. If there was an error reading or writing capabilities between the two, an error will be returned.\n\n```go\nfunc (o *FilterProcessScanner) Request() *Request\n```\nRequest returns the request read from a call to Scan(). It is available only after a call to \\`Scan()\\` has completed, and is re-initialized to nil at the beginning of the subsequent \\`Scan()\\` call.\n\n```go\nfunc (o *FilterProcessScanner) Scan() bool\n```\nScan scans for the next request, or error and returns whether or not the scan was successful, indicating the presence of a valid request. If the Scan failed, there was either an error reading the next request (and the results of calling \\`Err()\\` should be inspected), or the pipe was closed and no more requests are present.\n\nClosing the pipe is Git's way to communicate that no more files will be filtered. Git expects that the LFS process exits after this event.\n\n```go\nfunc (o *FilterProcessScanner) WriteStatus(status string) error\n```\n\n```go\ntype PktlineWriter struct {\n\t// contains filtered or unexported fields\n}\n```\nPktlineWriter is an implementation of \\`io.Writer\\` which writes data buffers \"p\" to an underlying pkt-line stream for use with the Git pkt-line format.\n\n```go\nfunc NewPktlineWriter(w io.Writer, c int) *PktlineWriter\n```\nNewPktlineWriter returns a new \\*PktlineWriter, which will write to the underlying data stream \"w\". The internal buffer is initialized with the given capacity, \"c\".\n\nIf \"w\" is already a \\`\\*PktlineWriter\\`, it will be returned as-is.\n\n```go\nfunc (w *PktlineWriter) Flush() error\n```\nFlush empties the internal buffer used to store data temporarily and then writes the pkt-line's FLUSH packet, to signal that it is done writing this chunk of data.\n\n```go\nfunc (w *PktlineWriter) Write(p []byte) (int, error)\n```\nWrite implements the io.Writer interface's \\`Write\\` method by providing a packet-based backend to the given buffer \"p\".\n\nAs many bytes are removed from \"p\" as possible and stored in an internal buffer until the amount of data in the internal buffer is enough to write a single packet. Once the internal buffer is full, a packet is written to the underlying stream of data, and the process repeats.\n\nWhen the caller has no more data to write in the given chunk of packets, a subsequent call to \\`Flush()\\` SHOULD be made in order to signify that the current pkt sequence has terminated, and a new one can begin.\n\nWrite returns the number of bytes in \"p\" accepted into the writer, which \\_MAY\\_ be written to the underlying protocol stream, or may be written into the internal buffer.\n\nIf any error was encountered while either buffering or writing, that error is returned, along with the number of bytes written to the underlying protocol stream, as described above.\n\n```go\ntype Ref struct {\n\tName string\n\tType RefType\n\tSha  string\n}\n```\nA git reference (branch, tag etc)\n\n```go\nfunc CachedRemoteRefs(remoteName string) ([]*Ref, error)\n```\nCachedRemoteRefs returns the list of branches \u0026 tags for a remote which are currently cached locally. No remote request is made to verify them.\n\n```go\nfunc CurrentRef() (*Ref, error)\n```\n\n```go\nfunc CurrentRemoteRef() (*Ref, error)\n```\n\n```go\nfunc GetAllWorkTreeHEADs(storageDir string) ([]*Ref, error)\n```\nGetAllWorkTreeHEADs returns the refs that all worktrees are using as HEADs This returns all worktrees plus the master working copy, and works even if working dir is actually in a worktree right now Pass in the git storage dir (parent of 'objects') to work from\n\n```go\nfunc LocalRefs() ([]*Ref, error)\n```\nRefs returns all of the local and remote branches and tags for the current repository. Other refs (HEAD, refs/stash, git notes) are ignored.\n\n```go\nfunc RecentBranches(since time.Time, includeRemoteBranches bool, onlyRemote string) ([]*Ref, error)\n```\nRecentBranches returns branches with commit dates on or after the given date/time Return full Ref type for easier detection of duplicate SHAs etc since: refs with commits on or after this date will be included includeRemoteBranches: true to include refs on remote branches onlyRemote: set to non-blank to only include remote branches on a single remote\n\n```go\nfunc RemoteRefs(remoteName string) ([]*Ref, error)\n```\nRemoteRefs returns a list of branches \u0026 tags for a remote by actually accessing the remote vir git ls-remote\n\n```go\nfunc ResolveRef(ref string) (*Ref, error)\n```\n\n```go\nfunc ResolveRefs(refnames []string) ([]*Ref, error)\n```\n\n```go\ntype RefType int\n```\n\n```go\nfunc ParseRefToTypeAndName(fullref string) (t RefType, name string)\n```\nGet the type \u0026 name of a git reference\n\n```go\ntype Request struct {\n\t// Header maps header strings to values, and is encoded as the first\n\t// part of the packet.\n\tHeader map[string]string\n\t// Payload represents the body of the packet, and contains the contents\n\t// of the file in the index.\n\tPayload io.Reader\n}\n```\nRequest represents a single command sent to LFS from the parent Git process.\n\n","path":"github.com/Github/git-lfs/git","name":"git","synopsis":"Package git contains various commands that shell out to git NOTE: Subject to change, do not rely on this package from outside git-lfs source","isRedistributable":true}
