Versions in this module Expand all Collapse all v1 v1.28.0-dev Jun 29, 2026 v1.27.0 Jul 13, 2026 Changes in this version + const BranchPrefix + const CmdSubVerbLfsDownload + const CmdSubVerbLfsUpload + const CmdVerbLfsAuthenticate + const CmdVerbLfsTransfer + const CmdVerbReceivePack + const CmdVerbUploadArchive + const CmdVerbUploadPack + const CoAuthoredByTrailer + const ForPrefix + const NotesRef + const PullPrefix + const RefNameHead + const RemotePrefix + const RequiredVersion + const SigningKeyFormatOpenPGP + const SigningKeyFormatSSH + const TagPrefix + var ErrNotValidHook = errors.New("not a valid Git hook") + func AddTemplateSubmoduleIndexes(ctx context.Context, repoPath string, submodules []TemplateSubmoduleCommit) error + func Clone(ctx context.Context, from, to string, opts CloneRepoOptions) error + func CommitMessageSplitTrailer(s string) (content, sep, trailer string) + func CutDiffAroundLine(originalDiff io.Reader, line int64, old bool, numbersOfLine int) (string, error) + func DiscardFull(rd BufferedReader, discard int64) error + func GetAffectedFiles(repo *Repository, branchName, oldCommitID, newCommitID string, env []string) ([]string, error) + func GetFileDiffCutAroundLine(repo *Repository, startCommit, endCommit, treePath string, line int64, ...) (ret string, retErr error) + func GetFullCommitID(ctx context.Context, repoPath, shortID string) (string, error) + func GetLastCommitForPaths(ctx context.Context, commit *Commit, treePath string, paths []string) (map[string]*Commit, error) + func GetNote(ctx context.Context, repo *Repository, commitID string, note *Note) error + func GetRawDiff(repo *Repository, commitID string, diffType RawDiffType, writer io.Writer) (retErr error) + func GetRemoteAddress(ctx context.Context, repoPath, remoteName string) (string, error) + func GetSigningKey(ctx context.Context) (*SigningKey, *Signature) + func HashFilePathForWebUI(s string) string + func InitFull() (err error) + func InitRepository(ctx context.Context, repoPath string, bare bool, objectFormatName string) error + func InitSimple() error + func IsAllowedVerbForServe(verb string) bool + func IsAllowedVerbForServeLfs(verb string) bool + func IsEmptyCommitID(commitID string) bool + func IsErrBranchNotExist(err error) bool + func IsErrInvalidCloneAddr(err error) bool + func IsErrMoreThanOne(err error) bool + func IsErrNotExist(err error) bool + func IsErrPushOutOfDate(err error) bool + func IsErrPushRejected(err error) bool + func IsRemoteNotExistError(err error) bool + func IsRepoURLAccessible(ctx context.Context, url string) bool + func IsStringLikelyCommitID(objFmt ObjectFormat, s string, minLength ...int) bool + func IsValidHookName(name string) bool + func IsValidObjectFormat(name string) bool + func IsValidRefPattern(name string) bool + func ParseBool(value string) (result, valid bool) + func ParseCatFileTreeLine(objectFormat ObjectFormat, rd BufferedReader) (mode EntryMode, name string, objID ObjectID, n int, err error) + func ParseDiffHunkString(diffHunk string) (leftLine, leftHunk, rightLine, rightHunk int) + func ParseRefSuffix(ref string) (refName, refSuffix string) + func ParseRemoteAddr(remoteAddr, authUsername, authPassword string) (string, error) + func Push(ctx context.Context, repoPath string, opts PushOptions) error + func ReadTagObjectID(rd BufferedReader, size int64) (string, error) + func ReadTreeID(rd BufferedReader, size int64) (string, error) + func RunGitTests(m interface{ ... }) + func SanitizeRefPattern(name string) string + func SplitCommitTitleBody(commitMessage string, titleRuneLimit int) (title, body string) + func WalkShowRef(ctx context.Context, repoPath string, extraArgs gitcmd.TrustedCmdArgs, ...) (countAll int, err error) + func WriteCommitGraph(ctx context.Context, repoPath string) error + type Blob struct + ID ObjectID + func (b *Blob) DataAsync() (_ io.ReadCloser, retErr error) + func (b *Blob) GetBlobBytes(limit int64) ([]byte, error) + func (b *Blob) GetBlobContent(limit int64) (string, error) + func (b *Blob) GetBlobContentBase64(originContent *strings.Builder) (string, error) + func (b *Blob) GetBlobLineCount(w io.Writer) (int, error) + func (b *Blob) GuessContentType() (typesniffer.SniffedType, error) + func (b *Blob) Name() string + func (b *Blob) Size() int64 + type BufferedReader interface + Buffered func() int + Discard func(n int) (int, error) + Peek func(n int) ([]byte, error) + ReadBytes func(sep byte) ([]byte, error) + ReadSlice func(sep byte) ([]byte, error) + ReadString func(sep byte) (string, error) + type CatFileBatch interface + QueryContent func(obj string) (*CatFileObject, BufferedReader, error) + QueryInfo func(obj string) (*CatFileObject, error) + type CatFileBatchCloser interface + Close func() + func NewBatch(ctx context.Context, repoPath string) (CatFileBatchCloser, error) + type CatFileObject struct + ID string + Size int64 + Type string + type CloneRepoOptions struct + Bare bool + Branch string + Depth int + Env []string + Filter string + Mirror bool + NoCheckout bool + Quiet bool + Shared bool + SingleBranch bool + SkipTLSVerify bool + Timeout time.Duration + type CodeActivityAuthor struct + Commits int64 + Email string + Name string + type CodeActivityStats struct + Additions int64 + AuthorCount int64 + Authors []*CodeActivityAuthor + ChangedFiles int64 + CommitCount int64 + CommitCountInAllBranches int64 + Deletions int64 + type Commit struct + Author *Signature + Committer *Signature + ID ObjectID + Parents []ObjectID + Signature *CommitSignature + func CommitFromReader(gitRepo *Repository, objectID ObjectID, reader io.Reader) (*Commit, error) + func (c *Commit) AllParticipantIdentities() []*CommitIdentity + func (c *Commit) CacheCommit(ctx context.Context) error + func (c *Commit) CoAuthorIdentities() (coAuthors []*CommitIdentity) + func (c *Commit) CommitsBefore() ([]*Commit, error) + func (c *Commit) CommitsBeforeLimit(num int) ([]*Commit, error) + func (c *Commit) CommitsBeforeUntil(ref RefName) ([]*Commit, error) + func (c *Commit) CommitsByRange(page, pageSize int, not, since, until string) ([]*Commit, error) + func (c *Commit) FileChangedSinceCommit(filename, pastCommit string) (bool, error) + func (c *Commit) GetCommitByPath(relpath string) (*Commit, error) + func (c *Commit) GetFileContent(filename string, limit int) (string, error) + func (c *Commit) GetFilesChangedSinceCommit(pastCommit string) ([]string, error) + func (c *Commit) GetSubModule(entryName string) (*SubModule, error) + func (c *Commit) GetSubModules() (*ObjectCache[*SubModule], error) + func (c *Commit) HasFile(filename string) (bool, error) + func (c *Commit) HasPreviousCommit(objectID ObjectID) (bool, error) + func (c *Commit) IsForcePush(oldCommitID string) (bool, error) + func (c *Commit) Parent(n int) (*Commit, error) + func (c *Commit) ParentCount() int + func (c *Commit) ParentID(n int) (ObjectID, error) + func (c *Commit) SearchCommits(opts SearchCommitsOptions) ([]*Commit, error) + type CommitIdentity struct + Email string + Name string + type CommitInfo struct + Commit *Commit + Entry *TreeEntry + SubmoduleFile *CommitSubmoduleFile + type CommitMessage struct + MessageRaw string + func (c *CommitMessage) MessageBody() string + func (c *CommitMessage) MessageTitle() string + func (c *CommitMessage) MessageTrailer() CommitMessageTrailerValues + func (c *CommitMessage) MessageUTF8() string + type CommitMessageTrailerValues map[string][]string + func CommitMessageParseTrailer(s string) CommitMessageTrailerValues + type CommitSignature struct + Payload string + Signature string + type CommitSubmoduleFile struct + func GetCommitInfoSubmoduleFile(repoLink, fullPath string, commit *Commit, refCommitID ObjectID) (*CommitSubmoduleFile, error) + func NewCommitSubmoduleFile(repoLink, fullPath, refURL, refID string) *CommitSubmoduleFile + func (sf *CommitSubmoduleFile) RefID() string + func (sf *CommitSubmoduleFile) SubmoduleWebLinkCompare(ctx context.Context, commitID1, commitID2 string) *SubmoduleWebLink + func (sf *CommitSubmoduleFile) SubmoduleWebLinkTree(ctx context.Context, optCommitID ...string) *SubmoduleWebLink + type CommitTreeOpts struct + AlwaysSign bool + Key *SigningKey + Message string + NoGPGSign bool + Parents []string + type CommitsByFileAndRangeOptions struct + File string + FollowRename bool + Not string + Page int + Revision string + Since string + Until string + type Entries []*TreeEntry + func (tes Entries) CustomSort(cmp func(s1, s2 string) int) + func (tes Entries) GetCommitsInfo(ctx context.Context, repoLink string, commit *Commit, treePath string) ([]CommitInfo, *Commit, error) + type EntryFollowResult struct + SymlinkContent string + TargetEntry *TreeEntry + TargetFullPath string + func EntryFollowLink(commit *Commit, fullPath string, te *TreeEntry) (*EntryFollowResult, error) + func EntryFollowLinks(commit *Commit, firstFullPath string, firstTreeEntry *TreeEntry, ...) (res *EntryFollowResult, err error) + type EntryMode int + const EntryModeBlob + const EntryModeCommit + const EntryModeExec + const EntryModeNoEntry + const EntryModeSymlink + const EntryModeTree + func ParseEntryMode(mode string) EntryMode + func (e EntryMode) IsDir() bool + func (e EntryMode) IsExecutable() bool + func (e EntryMode) IsLink() bool + func (e EntryMode) IsRegular() bool + func (e EntryMode) IsSubModule() bool + func (e EntryMode) String() string + type ErrBranchNotExist struct + Name string + func (err ErrBranchNotExist) Error() string + func (err ErrBranchNotExist) Unwrap() error + type ErrInvalidCloneAddr struct + Host string + IsInvalidPath bool + IsPermissionDenied bool + IsProtocolInvalid bool + IsURLError bool + LocalPath bool + func (err *ErrInvalidCloneAddr) Error() string + func (err *ErrInvalidCloneAddr) Unwrap() error + type ErrMoreThanOne struct + Err error + StdErr string + StdOut string + func (err *ErrMoreThanOne) Error() string + type ErrNotExist struct + ID string + RelPath string + func (err ErrNotExist) Error() string + func (err ErrNotExist) Unwrap() error + type ErrPushOutOfDate struct + Err error + StdErr string + StdOut string + func (err *ErrPushOutOfDate) Error() string + func (err *ErrPushOutOfDate) Unwrap() error + type ErrPushRejected struct + Err error + Message string + StdErr string + StdOut string + func (err *ErrPushRejected) Error() string + func (err *ErrPushRejected) GenerateMessage() + func (err *ErrPushRejected) Unwrap() error + type Features struct + SupportCatFileBatchCommand bool + SupportCheckAttrOnBare bool + SupportGitMergeTree bool + SupportHashSha256 bool + SupportProcReceive bool + SupportedObjectFormats []ObjectFormat + UsingGogit bool + func DefaultFeatures() *Features + func (f *Features) CheckVersionAtLeast(atLeast string) bool + func (f *Features) VersionInfo() string + type GPGSettings struct + Email string + Format string + KeyID string + Name string + PublicKeyContent string + Sign bool + func GetDefaultPublicGPGKey(ctx context.Context, forceUpdate bool) (*GPGSettings, error) + func (gpgSettings *GPGSettings) LoadPublicKeyContent() error + type GrepModeType string + const GrepModeExact + const GrepModeRegexp + const GrepModeWords + type GrepOptions struct + ContextLineNumber int + GrepMode GrepModeType + MaxLineLength int + MaxResultLimit int + PathspecList []string + RefName string + type GrepResult struct + Filename string + LineCodes []string + LineNumbers []int + func GrepSearch(ctx context.Context, repo *Repository, search string, opts GrepOptions) ([]*GrepResult, error) + type Hook struct + Content string + IsActive bool + Sample string + func GetHook(repoPath, name string) (*Hook, error) + func ListHooks(repoPath string) (_ []*Hook, err error) + func (h *Hook) Name() string + func (h *Hook) Update() error + type IndexObjectInfo struct + Filename string + Mode string + Object ObjectID + type LastCommitCache struct + func NewLastCommitCache(count int64, repoPath string, gitRepo *Repository, cache cache.StringCache) *LastCommitCache + func (c *LastCommitCache) Get(ref, entryPath string) (*Commit, error) + func (c *LastCommitCache) GetCommitByPath(commitID, entryPath string) (*Commit, error) + func (c *LastCommitCache) Put(ref, entryPath, commitID string) error + type LsTreeEntry struct + EntryMode EntryMode + ID ObjectID + Name string + Size optional.Option[int64] + type Note struct + Commit *Commit + Message []byte + type ObjectCache struct + func (oc *ObjectCache[T]) Get(id string) (T, bool) + func (oc *ObjectCache[T]) Set(id string, obj T) + type ObjectFormat interface + ComputeHash func(t ObjectType, content []byte) ObjectID + EmptyObjectID func() ObjectID + EmptyTree func() ObjectID + FullLength func() int + IsValid func(input string) bool + MustID func(b []byte) ObjectID + Name func() string + var Sha1ObjectFormat ObjectFormat = Sha1ObjectFormatImpl{} + var Sha256ObjectFormat ObjectFormat = Sha256ObjectFormatImpl{} + func ObjectFormatFromName(name string) ObjectFormat + type ObjectID interface + IsZero func() bool + RawValue func() []byte + RefName func() RefName + String func() string + Type func() ObjectFormat + func ComputeBlobHash(hashType ObjectFormat, content []byte) ObjectID + func MustIDFromString(hexHash string) ObjectID + func NewIDFromString(hexHash string) (ObjectID, error) + type ObjectType string + const ObjectBlob + const ObjectBranch + const ObjectCommit + const ObjectTag + const ObjectTree + func (o ObjectType) Bytes() []byte + type PushOptions struct + Branch string + Env []string + Force bool + ForceWithLease string + LocalRefName string + Mirror bool + Remote string + Timeout time.Duration + type RawDiffType string + const RawDiffNormal + const RawDiffPatch + type RefName string + func RefNameFromBranch(shortName string) RefName + func RefNameFromCommit(shortName string) RefName + func RefNameFromTag(shortName string) RefName + func (ref RefName) BranchName() string + func (ref RefName) ForBranchName() string + func (ref RefName) IsBranch() bool + func (ref RefName) IsFor() bool + func (ref RefName) IsPull() bool + func (ref RefName) IsRemote() bool + func (ref RefName) IsTag() bool + func (ref RefName) PullName() string + func (ref RefName) RefGroup() string + func (ref RefName) RefType() RefType + func (ref RefName) RefWebLinkPath() string + func (ref RefName) RemoteName() string + func (ref RefName) ShortName() string + func (ref RefName) String() string + func (ref RefName) TagName() string + type RefType string + const RefTypeBranch + const RefTypeCommit + const RefTypeTag + type Reference struct + Name string + Object ObjectID + Type string + func (ref *Reference) Commit() (*Commit, error) + func (ref *Reference) RefGroup() string + func (ref *Reference) ShortName() string + type Repository struct + Ctx context.Context + LastCommitCache *LastCommitCache + Path string + func OpenRepository(ctx context.Context, repoPath string) (*Repository, error) + func (repo *Repository) AddObjectToIndex(mode string, object ObjectID, filename string) error + func (repo *Repository) AddObjectsToIndex(objects ...IndexObjectInfo) error + func (repo *Repository) AddRemote(name, url string, fetch bool) error + func (repo *Repository) CatFileBatch(ctx context.Context) (_ CatFileBatch, closeFunc func(), err error) + func (repo *Repository) Close() error + func (repo *Repository) CommitTree(author, committer *Signature, tree *Tree, opts CommitTreeOpts) (ObjectID, error) + func (repo *Repository) CommitsBetween(afterRef, beforeRef RefName, limit int, optSkip ...int) ([]*Commit, error) + func (repo *Repository) CommitsByFileAndRange(opts CommitsByFileAndRangeOptions) (commits []*Commit, hasMore bool, _ error) + func (repo *Repository) ConvertToGitID(ref string) (ObjectID, error) + func (repo *Repository) CreateAnnotatedTag(name, message, revision string) error + func (repo *Repository) CreateTag(name, revision string) error + func (repo *Repository) EmptyIndex() error + func (repo *Repository) FileChangedBetweenCommits(filename, id1, id2 string) (bool, error) + func (repo *Repository) GetAnnotatedTag(sha string) (*Tag, error) + func (repo *Repository) GetBlob(idStr string) (*Blob, error) + func (repo *Repository) GetBranchCommit(name string) (*Commit, error) + func (repo *Repository) GetBranchCommitID(name string) (string, error) + func (repo *Repository) GetBranchNames(skip, limit int) ([]string, int, error) + func (repo *Repository) GetCodeActivityStats(fromTime time.Time, branch string) (*CodeActivityStats, error) + func (repo *Repository) GetCommit(ref string) (*Commit, error) + func (repo *Repository) GetCommitBranchStart(env []string, branch, endCommitID string) (string, error) + func (repo *Repository) GetCommitByPath(relpath string) (*Commit, error) + func (repo *Repository) GetCommitsFromIDs(commitIDs []string) []*Commit + func (repo *Repository) GetDiff(compareArg string, w io.Writer) error + func (repo *Repository) GetDiffBinary(compareArg string, w io.Writer) error + func (repo *Repository) GetDiffNumChangedFiles(base, head string, directComparison bool) (int, error) + func (repo *Repository) GetFilesChangedBetween(base, head string) ([]string, error) + func (repo *Repository) GetHook(name string) (*Hook, error) + func (repo *Repository) GetObjectFormat() (ObjectFormat, error) + func (repo *Repository) GetPatch(compareArg string, w io.Writer) error + func (repo *Repository) GetRefCommitID(name string) (string, error) + func (repo *Repository) GetRefs() ([]*Reference, error) + func (repo *Repository) GetRefsBySha(sha, prefix string) ([]string, error) + func (repo *Repository) GetRefsFiltered(pattern string) ([]*Reference, error) + func (repo *Repository) GetTag(name string) (*Tag, error) + func (repo *Repository) GetTagCommit(name string) (*Commit, error) + func (repo *Repository) GetTagCommitID(name string) (string, error) + func (repo *Repository) GetTagID(name string) (string, error) + func (repo *Repository) GetTagInfos(page, pageSize int) ([]*Tag, int, error) + func (repo *Repository) GetTagNameBySHA(sha string) (string, error) + func (repo *Repository) GetTagType(id ObjectID) (string, error) + func (repo *Repository) GetTagWithID(idStr, name string) (*Tag, error) + func (repo *Repository) GetTree(idStr string) (*Tree, error) + func (repo *Repository) GetTreePathLatestCommit(refName, treePath string) (*Commit, error) + func (repo *Repository) HashObjectBytes(buf []byte) (ObjectID, error) + func (repo *Repository) Hooks() ([]*Hook, error) + func (repo *Repository) IsBranchExist(name string) bool + func (repo *Repository) IsCommitInBranch(commitID, branch string) (r bool, err error) + func (repo *Repository) IsEmpty() (bool, error) + func (repo *Repository) IsObjectExist(name string) bool + func (repo *Repository) IsReferenceExist(name string) bool + func (repo *Repository) IsTagExist(name string) bool + func (repo *Repository) ListOccurrences(ctx context.Context, refType, commitSHA string) ([]string, error) + func (repo *Repository) LsFiles(filenames ...string) ([]string, error) + func (repo *Repository) LsTree(ref string, filenames ...string) ([]string, error) + func (repo *Repository) ReadPatchCommit(prID int64) (commitSHA string, err error) + func (repo *Repository) ReadTreeToIndex(treeish string, indexFilename ...string) error + func (repo *Repository) ReadTreeToTemporaryIndex(treeish string) (tmpIndexFilename, tmpDir string, cancel context.CancelFunc, err error) + func (repo *Repository) RemoveFilesFromIndex(filenames ...string) error + func (repo *Repository) ResolveReference(name string) (string, error) + func (repo *Repository) ShowPrettyFormatLogToList(ctx context.Context, revisionRange string) ([]*Commit, error) + func (repo *Repository) UnstableGuessRefByShortName(shortName string) RefName + func (repo *Repository) WalkReferences(refType ObjectType, skip, limit int, walkfn func(sha1, refname string) error) (int, error) + func (repo *Repository) WriteTree() (*Tree, error) + type SearchCommitsOptions struct + After string + All bool + Authors []string + Before string + Committers []string + Keywords []string + func NewSearchCommitsOptions(searchString string, forAllRefs bool) SearchCommitsOptions + type Sha1Hash [20]byte + func (*Sha1Hash) Type() ObjectFormat + func (h *Sha1Hash) IsZero() bool + func (h *Sha1Hash) RawValue() []byte + func (h *Sha1Hash) RefName() RefName + func (h *Sha1Hash) String() string + type Sha1ObjectFormatImpl struct + func (Sha1ObjectFormatImpl) EmptyObjectID() ObjectID + func (Sha1ObjectFormatImpl) EmptyTree() ObjectID + func (Sha1ObjectFormatImpl) FullLength() int + func (Sha1ObjectFormatImpl) IsValid(input string) bool + func (Sha1ObjectFormatImpl) MustID(b []byte) ObjectID + func (Sha1ObjectFormatImpl) Name() string + func (h Sha1ObjectFormatImpl) ComputeHash(t ObjectType, content []byte) ObjectID + type Sha256Hash [32]byte + func (*Sha256Hash) Type() ObjectFormat + func (h *Sha256Hash) IsZero() bool + func (h *Sha256Hash) RawValue() []byte + func (h *Sha256Hash) RefName() RefName + func (h *Sha256Hash) String() string + type Sha256ObjectFormatImpl struct + func (Sha256ObjectFormatImpl) EmptyObjectID() ObjectID + func (Sha256ObjectFormatImpl) EmptyTree() ObjectID + func (Sha256ObjectFormatImpl) FullLength() int + func (Sha256ObjectFormatImpl) IsValid(input string) bool + func (Sha256ObjectFormatImpl) MustID(b []byte) ObjectID + func (Sha256ObjectFormatImpl) Name() string + func (h Sha256ObjectFormatImpl) ComputeHash(t ObjectType, content []byte) ObjectID + type Signature struct + Email string + Name string + When time.Time + func (s *Signature) Decode(b []byte) + func (s *Signature) String() string + type SigningKey struct + Format string + KeyID string + func (s *SigningKey) String() string + type SubModule struct + Branch string + Path string + URL string + type SubmoduleWebLink struct + CommitWebLink string + RepoWebLink string + type Tag struct + ID ObjectID + Name string + Object ObjectID + Signature *CommitSignature + Tagger *Signature + Type string + type TemplateSubmoduleCommit struct + Commit string + Path string + func GetTemplateSubmoduleCommits(ctx context.Context, repoPath string) (submoduleCommits []TemplateSubmoduleCommit, _ error) + type Tree struct + func NewTree(repo *Repository, id ObjectID) *Tree + func (t *Tree) GetBlobByPath(relpath string) (*Blob, error) + func (t *Tree) GetTreeEntryByPath(relpath string) (_ *TreeEntry, err error) + func (t *Tree) ListEntries() (Entries, error) + func (t *Tree) ListEntriesRecursiveFast() (Entries, error) + func (t *Tree) ListEntriesRecursiveWithSize() (Entries, error) + func (t *Tree) SubTree(rpath string) (*Tree, error) + type TreeCommon struct + ID ObjectID + ResolvedID ObjectID + type TreeEntry struct + ID ObjectID + func ParseTreeEntries(data []byte) ([]*TreeEntry, error) + func (te *TreeEntry) Blob() *Blob + func (te *TreeEntry) GetSubJumpablePathName() string + func (te *TreeEntry) IsDir() bool + func (te *TreeEntry) IsExecutable() bool + func (te *TreeEntry) IsLink() bool + func (te *TreeEntry) IsRegular() bool + func (te *TreeEntry) IsSubModule() bool + func (te *TreeEntry) Mode() EntryMode + func (te *TreeEntry) Name() string + func (te *TreeEntry) Size() int64 + func (te *TreeEntry) Tree() *Tree + func (te *TreeEntry) Type() string v1.27.0-rc0 Jun 29, 2026