# README
Git Module
This module is merged from https://github.com/go-gitea/git which is a Go module to access Git through shell commands. Now it's a part of gitea's main repository for easier pull request.
# Functions
AddChanges marks local changes to be ready for commit.
AddChangesWithArgs marks local changes to be ready for commit.
AllCommitsCount returns count of all commits in repository.
AllowLFSFiltersArgs return globalCommandArgs with lfs filter, it should only be used for tests.
true if "set"/"true", false if "unset"/"false", none otherwise.
BinToHexHeash converts a binary Hash into a hex encoded one.
Clone clones original repository to target path.
CloneWithArgs original repository to target path.
CommitChanges commits local changes with given committer, author and message.
CommitChangesWithArgs commits local changes with given committer, author and message.
CommitFromReader will generate a Commit from a provided reader We need this to interpret commits from cat-file or cat-file --batch
If used as part of a cat-file --batch stream you need to limit the reader to the correct size.
CommitsCount returns number of total commits of until given revision.
CommonCmdServEnvs is like CommonGitCmdEnvs, but it only returns minimal required environment variables for the "gitea serv" command.
CommonGitCmdEnvs returns the common environment variables for a "git" command.
ComputeBlobHash compute the hash for a given blob content.
ConcatenateError concatenats an error with stderr string.
CreateBlameReader creates reader for given repository, commit and file.
CutDiffAroundLine cuts a diff of a file in way that only the given line + numberOfLine above it will be shown it also recalculates hunks and adds the appropriate headers to the new diff.
Fsck verifies the connectivity and validity of the objects in the database.
GetAffectedFiles returns the affected files between two commits.
GetCommitFileStatus returns file status of commit in given repository.
GetDiffShortStat counts number of changed files, number of additions and deletions.
GetDivergingCommits returns the number of commits a targetBranch is ahead or behind a baseBranch.
GetFullCommitID returns full length (40) of commit ID by given short SHA in a repository.
GetHook returns a Git hook by given name and repository.
GetLastCommitForPaths returns last commit information.
GetLatestCommitTime returns time for latest commit in repository (across all branches).
GetNote retrieves the git-notes data for a given commit.
GetRawDiff dumps diff results of repository in given commit ID to io.Writer.
GetRemoteAddress returns remote url of git repository in the repoPath with special remote name.
GetRemoteURL returns the url of a specific remote of the repository.
GetRepoRawDiffForFile dumps diff results of file in given commit ID to io.Writer according given repository.
GetReverseRawDiff dumps the reverse diff results of repository in given commit ID to io.Writer.
HomeDir is the home dir for git to store the global config file used by Gitea internally.
InitFull initializes git module with version check and change global variables, sync gitconfig.
InitRepository initializes a new Git repository.
InitSimple initializes git module with a very simple step, no config changes, no global command arguments.
IsBranchExist returns true if given branch exists in the repository.
IsErrBadLink if some error is ErrBadLink.
IsErrBranchNotExist checks if an error is a ErrBranchNotExist.
IsErrMoreThanOne checks if an error is a ErrMoreThanOne.
IsErrNotExist if some error is ErrNotExist.
IsErrPushOutOfDate checks if an error is a ErrPushOutOfDate.
IsErrPushRejected checks if an error is a ErrPushRejected.
IsReferenceExist returns true if given reference exists in the repository.
IsRepoURLAccessible checks if given repository URL is accessible.
IsTagExist returns true if given tag exists in the repository.
IsValidHookName returns true if given name is a valid Git hook.
IsValidRefPattern ensures that the provided string could be a valid reference.
ListHooks returns a list of Git hooks of given repository.
LogNameStatusRepo opens git log --raw in the provided repo and returns a stdin pipe, a stdout reader and cancel function.
NewCommand creates and returns a new Git Command based on given command and arguments.
NewCommandContextNoGlobals creates and returns a new Git Command based on given command and arguments only with the specify args and don't care global command args Each argument should be safe to be trusted.
NewCommitFileStatus creates a CommitFileStatus.
NewCommitSubModuleFile create a new submodule file.
NewLastCommitCache creates a new last commit cache for repo.
NewLogNameStatusRepoParser returns a new parser for a git log raw output.
NewSearchCommitsOptions construct a SearchCommitsOption from a space-delimited search string.
NewTree create a new tree according the repository and tree id.
OpenRepository opens the repository at the given path with the provided context.
ParseBool returns the boolean value represented by the string as per git's git_config_bool true will be returned for the result if the string is empty, but valid will be false.
ParseDiffHunkString parse the diffhunk content and return.
ParseTreeEntries parses the output of a `git ls-tree -l` command.
ParseTreeLine reads an entry from a tree in a cat-file --batch stream This carefully avoids allocations - except where fnameBuf is too small.
Push pushs local commits to given remote branch.
ReadBatchLine reads the header line from cat-file --batch We expect: <oid> SP <type> SP <size> LF then leaving the rest of the stream "<contents> LF" to be read.
ReadTagObjectID reads a tag object ID hash from a cat-file --batch stream, throwing away the rest of the stream.
ReadTreeID reads a tree ID from a cat-file --batch stream, throwing away the rest of the stream.
RefURL returns the absolute URL for a ref in a repository.
SetExecutablePath changes the path of git executable and checks the file permission and version.
SetUpdateHook writes given content to update hook of the repository.
ToEntryMode converts a string to an EntryMode.
ToTrustedCmdArgs converts a list of strings (trusted as argument) to TrustedCmdArgs In most cases, it shouldn't be used.
WalkGitLog walks the git log --name-status for the head commit in the provided treepath and files.
WriteCommitGraph write commit graph to speed up repo access this requires git v2.18 to be installed.
# Constants
BranchPrefix base dir of the branch information file store on git.
BUNDLE bundle archive type.
DefaultLocale is the default LC_ALL to run git commands in.
EntryModeBlob.
EntryModeCommit.
EntryModeExec.
EntryModeSymlink.
EntryModeTree.
ForPrefix special ref to create a pull request: refs/for/<target-branch>/<topic-branch> or refs/for/<targe-branch> -o topic='<topic-branch>'.
HookPathUpdate hook update path.
NotesRef is the git ref where Gitea will look for git-notes data.
ObjectBlob blob object type.
ObjectBranch branch object type.
ObjectCommit commit object type.
ObjectTag tag object type.
ObjectTree tree object type.
PullPrefix is the base directory of the pull information of git.
RawDiffType possible values.
RawDiffType possible values.
RemotePrefix is the base directory of the remotes information of git.
the minimum Git version required.
TagPrefix tags prefix path on the repository.
TARGZ tar gz archive type.
ZIP zip archive type.
# Variables
the default context to run git commands in, must be initialized by git.InitXxx.
ErrNotValidHook error when a git hook is not valid.
the command name of git, will be updated to an absolute path during initialization.
# Structs
BlamePart represents block of blame - continuous lines with one sha.
BlameReader returns part of file blame one by one.
Blob represents a Git object.
Branch represents a Git branch.
CheckAttributeOpts represents the possible options to CheckAttribute.
CheckAttributeReader provides a reader for check-attribute content that can be long running.
CloneRepoOptions options when clone a repository.
CodeActivityAuthor represents git statistics data for commit authors.
CodeActivityStats represents git statistics data.
Command represents a command with its subcommands or arguments.
Commit represents a git commit.
CommitChangesOptions the options when a commit created.
CommitFileStatus represents status of files in a commit.
CommitInfo describes the first commit with the provided entry.
CommitsCountOptions the options when counting commits.
CommitSignature represents a git commit signature part.
CommitSubModuleFile represents a file with submodule type.
CommitTreeOpts represents the possible options to CommitTree.
CompareInfo represents needed information for comparing references.
DeleteBranchOptions Option(s) for delete branch.
DivergeObject represents commit count diverging commits.
ErrBadLink entry.FollowLink error.
ErrBranchNotExist represents a "BranchNotExist" kind of error.
ErrMoreThanOne represents an error if pull request fails when there are more than one sources (branch, tag) with the same name.
ErrNotExist commit not exist error.
ErrPushOutOfDate represents an error if merging fails due to the base branch being updated.
ErrPushRejected represents an error if merging fails due to rejection from a hook.
GPGSettings represents the default GPG settings for this repository.
Hook represents a Git hook.
LastCommitCache represents a cache to store last commit.
LimitedReaderCloser is a limited reader closer.
LogNameStatusCommitData represents a commit artefact from git log raw.
LogNameStatusRepoParser parses a git log raw output from LogRawRepo.
Note stores information about a note created using git-notes.
ObjectCache provides thread-safe cache operations.
PushOptions options when push to remote.
Reference represents a Git ref.
Repository represents a Git repository.
RunOpts represents parameters to run the command.
SearchCommitsOptions specify the parameters for SearchCommits.
Signature represents the Author, Committer or Tagger information.
SubModule is a reference on git repository.
Tag represents a Git tag.
Tree represents a flat directory listing.
TreeEntry the leaf in the git tree.
# Interfaces
WriteCloserError wraps an io.WriteCloser with an additional CloseWithError function.
# Type aliases
ArchiveType archive types.
Entries a list of entry.
EntryMode the type of the object in the git tree.
ObjectType git object type.
RawDiffType type of a raw diff.
RefName represents a full git reference name.
TrustedCmdArgs returns the trusted arguments for git command.