Documentation ¶
Index ¶
- Constants
- Variables
- func Apply(c *Client, opts ApplyOptions, patches []File) error
- func Archive(c *Client, opts ArchiveOptions, tree Treeish, paths []File) error
- func ArchiveFormatList() map[string]ArchiveFormat
- func CatFile(c *Client, typ string, s Sha1, opts CatFileOptions) (string, error)
- func CatFileBatch(c *Client, opts CatFileOptions, r io.Reader, w io.Writer) error
- func Checkout(c *Client, opts CheckoutOptions, thing string, files []File) error
- func CheckoutCommit(c *Client, opts CheckoutOptions, commit Commitish) error
- func CheckoutFiles(c *Client, opts CheckoutOptions, tree Treeish, files []File) error
- func CheckoutIndex(c *Client, opts CheckoutIndexOptions, files []File) error
- func CheckoutIndexFromReader(c *Client, opts CheckoutIndexOptions) error
- func CheckoutIndexFromReaderUncommited(c *Client, idx *Index, opts CheckoutIndexOptions) error
- func CheckoutIndexUncommited(c *Client, idx *Index, opts CheckoutIndexOptions, files []File) error
- func Clean(c *Client, opts CleanOptions, files []File) error
- func Clone(opts CloneOptions, rmt Remote, dst File) error
- func Fetch(c *Client, opts FetchOptions, rmt Remote, refs []RefSpec) error
- func ForEachRefCallback(c *Client, prefix string, callback func(*Client, Ref) error) error
- func Fsck(c *Client, stderr io.Writer, opts FsckOptions, objects []string) (errs []error)
- func GeneratePatch(c *Client, options DiffCommonOptions, diffs []HashDiff, dst io.Writer) error
- func Grep(c *Client, opts GrepOptions, pattern string, tree Treeish, pathspec []File) error
- func Merge(c *Client, opts MergeOptions, others []Commitish) error
- func MergeAbort(c *Client, opt MergeOptions) error
- func MergeFile(c *Client, opt MergeFileOptions) (io.Reader, error)
- func MkTreeBatch(c *Client, opts MkTreeOptions, r io.Reader, w io.Writer) error
- func Pull(c *Client, opts PullOptions, repository Remote, remotebranches []string) error
- func Push(c *Client, opts PushOptions, r Remote, refs []Refname) error
- func ReadDeltaOffset(src flate.Reader) (uint64, []byte)
- func ReadVariable(src flate.Reader) uint64
- func ReflogExists(c *Client, r Refname) bool
- func ReflogExpire(c *Client, opts ReflogExpireOptions, refpatterns []string) error
- func RemoteAdd(c *Client, opts RemoteAddOptions, name, url string) error
- func RemoteGetURL(c *Client, opts RemoteGetURLOptions, r Remote) ([]string, error)
- func RemoteShow(c *Client, opts RemoteShowOptions, r Remote, w io.Writer) error
- func Reset(c *Client, opts ResetOptions, files []File) error
- func ResetMode(c *Client, opts ResetOptions, cmt Commitish) error
- func ResetUnstage(c *Client, opts ResetOptions, tree Treeish, files []File) error
- func RevListCallback(c *Client, opt RevListOptions, includes, excludes []Commitish, ...) error
- func Revert(c *Client, opts RevertOptions, commits []Commitish) error
- func Rm(c *Client, opts RmOptions, files []File) error
- func SendPack(c *Client, opts SendPackOptions, r Remote, refs []Refname) error
- func Show(c *Client, opts ShowOptions, objects []string) error
- func Status(c *Client, opts StatusOptions, files []File) (string, error)
- func StatusBranch(c *Client, opts StatusOptions, lineprefix string) (string, error)
- func StatusLong(c *Client, files []File, untracked StatusUntrackedMode, lineprefix string) (string, error)
- func StatusShort(c *Client, files []File, untracked StatusUntrackedMode, ...) (string, error)
- func SymbolicRefDelete(c *Client, opts SymbolicRefOptions, symname SymbolicRef) error
- func SymbolicRefUpdate(c *Client, opts SymbolicRefOptions, symname SymbolicRef, refvalue RefSpec, ...) error
- func TagCommit(c *Client, opts TagOptions, tagname string, cmt Commitish, msg string) error
- func TagDelete(c *Client, opts TagOptions, tagnames []Refname) error
- func TagList(c *Client, opts TagOptions, patterns []string) ([]string, error)
- func UpdateRef(c *Client, opts UpdateRefOptions, ref string, cmt CommitID, reason string) error
- func UpdateRefSpec(c *Client, opts UpdateRefOptions, ref RefSpec, cmt CommitID, reason string) error
- type AddOptions
- type ApplyOptions
- type ArchiveFormat
- type ArchiveOptions
- type BitSetter
- type BlobID
- type Branch
- type BranchOptions
- type ByName
- type ByPath
- type CacheInfo
- type CatFileOptions
- type CheckoutIndexOptions
- type CheckoutOptions
- type CleanOptions
- type Client
- func (c *Client) Close() error
- func (c *Client) CreateBranch(name string, commit Commitish) error
- func (c *Client) ExecEditor(f File) error
- func (c *Client) GetAuthor(t *time.Time) Person
- func (c *Client) GetBranches() ([]Branch, error)
- func (c *Client) GetCachedConfig(varname string) string
- func (c *Client) GetCommitObject(commit CommitID) (GitCommitObject, error)
- func (c *Client) GetCommitter(t *time.Time) (Person, error)
- func (c *Client) GetConfig(varname string) string
- func (c *Client) GetHeadBranch() Branch
- func (c *Client) GetHeadCommit() (CommitID, error)
- func (c *Client) GetObject(sha1 Sha1) (GitObject, error)
- func (c *Client) GetObjectMetadata(sha1 Sha1) (string, uint64, error)
- func (c *Client) GetObjectsDir() File
- func (c *Client) GetRemoteBranches() (branches []Branch, err error)
- func (c *Client) GetTagObject(tag Sha1) (GitTagObject, error)
- func (c *Client) HaveObject(id Sha1) (found bool, packedfile File, err error)
- func (c *Client) IsBare() bool
- func (c *Client) IsInsideGitDir(path File) bool
- func (c *Client) IsInsideWorkTree(path File) bool
- func (c *Client) ResetIndex(tree Treeish, indexname string) error
- func (c *Client) ResetWorkTree() error
- func (c *Client) SetCachedConfig(varname string, value string)
- func (c *Client) WriteObject(objType string, rawdata []byte) (Sha1, error)
- type CloneOptions
- type CommitID
- func Commit(c *Client, opts CommitOptions, message CommitMessage, files []File) (CommitID, error)
- func CommitIDFromString(s string) (CommitID, error)
- func CommitTree(c *Client, opts CommitTreeOptions, tree Treeish, parents []CommitID, ...) (CommitID, error)
- func MergeBase(c *Client, options MergeBaseOptions, commits []Commitish) (CommitID, error)
- func MergeBaseOctopus(c *Client, options MergeBaseOptions, commits []Commitish) (CommitID, error)
- func NearestCommonParent(c *Client, com, other Commitish) (CommitID, error)
- func RevParseCommit(c *Client, opt *RevParseOptions, arg string) (CommitID, error)
- func (s CommitID) AncestorMap(c *Client) (map[CommitID]struct{}, error)
- func (s CommitID) Ancestors(c *Client) ([]CommitID, error)
- func (s CommitID) CommitID(c *Client) (CommitID, error)
- func (c CommitID) Format(cl *Client, format string) (string, error)
- func (c CommitID) FormatMedium(cl *Client) (string, error)
- func (c CommitID) GetAllObjects(cl *Client) ([]Sha1, error)
- func (c CommitID) GetAllObjectsExcept(cl *Client, excludeList map[Sha1]struct{}) ([]Sha1, error)
- func (cmt CommitID) GetAuthor(c *Client) (Person, error)
- func (cmt CommitID) GetCommitMessage(c *Client) (CommitMessage, error)
- func (cmt CommitID) GetCommitter(c *Client) (Person, error)
- func (cmt CommitID) GetCommitterDate(c *Client) (time.Time, error)
- func (cmt CommitID) GetDate(c *Client) (time.Time, error)
- func (child CommitID) IsAncestor(c *Client, parent Commitish) bool
- func (cmt CommitID) Parents(c *Client) ([]CommitID, error)
- func (s CommitID) String() string
- func (c CommitID) TreeID(cl *Client) (TreeID, error)
- type CommitMessage
- type CommitOptions
- type CommitTreeOptions
- type Commitish
- type DiffCommonOptions
- type DiffFilesOptions
- type DiffIndexOptions
- type DiffOptions
- type DiffTreeOptions
- type EntryMode
- type FetchOptions
- type FetchPackOptions
- type File
- func (f File) Append(val string) error
- func (f File) CTime() (uint32, uint32)
- func (f File) Create() (*os.File, error)
- func (f File) Exists() bool
- func (f File) INode() uint32
- func (f File) IndexPath(c *Client) (IndexPath, error)
- func (f File) IsDir() bool
- func (f File) IsInSubmodule(c *Client) (bool, File, error)
- func (f File) IsInsideSymlink() (bool, error)
- func (f File) IsSymlink() bool
- func (f File) Lstat() (os.FileInfo, error)
- func (f File) MTime() (int64, error)
- func (f File) MatchGlob(pattern string) bool
- func (f File) Open() (*os.File, error)
- func (f File) ReadAll() (string, error)
- func (f File) ReadFirstLine() (string, error)
- func (f File) Remove() error
- func (f File) Stat() (os.FileInfo, error)
- func (f File) String() string
- type FixedIndexEntry
- type FormatString
- type FsckOptions
- type GPGKeyId
- type GitBlobObject
- type GitCommitObject
- type GitConfig
- func (g *GitConfig) GetConfig(name string) (string, int)
- func (g *GitConfig) GetConfigList() []string
- func (g *GitConfig) GetConfigSections(name, subsection string) []GitConfigSection
- func (g *GitConfig) SetConfig(name, value string)
- func (g *GitConfig) Unset(name string) int
- func (g GitConfig) WriteConfig() error
- func (g GitConfig) WriteFile(w io.Writer)
- type GitConfigSection
- type GitConfigValues
- type GitDir
- func (gd GitDir) Create(f File) (*os.File, error)
- func (g GitDir) Exists() bool
- func (g GitDir) File(f File) File
- func (gd GitDir) Open(f File) (*os.File, error)
- func (g GitDir) ReadFile(f File) ([]byte, error)
- func (d GitDir) ReadIndex() (*Index, error)
- func (g GitDir) String() string
- func (g GitDir) WriteFile(f File, data []byte, perm os.FileMode) error
- type GitObject
- type GitService
- type GitTagObject
- type GitTreeObject
- type GrepOptions
- type HashDiff
- func Diff(c *Client, opt DiffOptions, paths []File) ([]HashDiff, error)
- func DiffFiles(c *Client, opt DiffFilesOptions, paths []File) ([]HashDiff, error)
- func DiffIndex(c *Client, opt DiffIndexOptions, index *Index, tree Treeish, paths []File) ([]HashDiff, error)
- func DiffTree(c *Client, opt *DiffTreeOptions, tree1, tree2 Treeish, paths []string) ([]HashDiff, error)
- type IgnoreMatch
- type IgnorePattern
- type Index
- func Add(c *Client, opts AddOptions, files []File) (*Index, error)
- func NewIndex() *Index
- func ReadTree(c *Client, opt ReadTreeOptions, tree Treeish) (*Index, error)
- func ReadTreeFastForward(c *Client, opt ReadTreeOptions, parent, dst Treeish) (*Index, error)
- func ReadTreeThreeWay(c *Client, opt ReadTreeOptions, stage1, stage2, stage3 Treeish) (*Index, error)
- func UpdateIndex(c *Client, idx *Index, opts UpdateIndexOptions, files []File) (*Index, error)
- func UpdateIndexCacheInfo(c *Client, idx *Index, opts UpdateIndexOptions) (*Index, error)
- func UpdateIndexFromReader(c *Client, opts UpdateIndexOptions, r io.Reader) (*Index, error)
- func UpdateIndexRefresh(c *Client, idx *Index, opts UpdateIndexOptions) (*Index, error)
- func (g *Index) AddFile(c *Client, file File, opts UpdateIndexOptions) error
- func (g *Index) AddStage(c *Client, path IndexPath, mode EntryMode, s Sha1, stage Stage, size uint32, ...) error
- func (i *Index) GetMap() IndexMap
- func (g Index) GetSha1(path IndexPath) Sha1
- func (i *Index) GetStageMap() map[IndexStageEntry]*IndexEntry
- func (i *Index) GetUnmerged() map[IndexPath]*UnmergedPath
- func (g *Index) RemoveFile(file IndexPath)
- func (g *Index) RemoveUnmergedStages(c *Client, path IndexPath) error
- func (g *Index) ResetIndex(c *Client, tree Treeish) error
- func (g *Index) SetSkipWorktree(c *Client, path IndexPath, value bool) error
- func (g Index) String() string
- func (g Index) WriteIndex(file io.Writer) error
- type IndexEntry
- type IndexMap
- type IndexPackOptions
- type IndexPath
- type IndexStageEntry
- type InitOptions
- type LsFilesOptions
- type LsFilesResult
- type LsRemoteOptions
- type LsTreeOptions
- type MergeBaseOptions
- type MergeFileFile
- type MergeFileOptions
- type MergeOptions
- type MergeStrategy
- type MkTreeOptions
- type ObjectOffset
- type ObjectReference
- type PackEntrySize
- type PackEntryType
- type PackIndexFanout
- type PackObjectsOptions
- type PackProtocolMode
- type PackfileHeader
- type PackfileIndex
- type PackfileIndexV2
- func (idx PackfileIndexV2) GetObject(r io.ReaderAt, s Sha1) (GitObject, error)
- func (idx PackfileIndexV2) GetObjectMetadata(r io.ReaderAt, s Sha1) (GitObject, error)
- func (idx PackfileIndexV2) GetTrailer() (Sha1, Sha1)
- func (idx PackfileIndexV2) HasObject(s Sha1) bool
- func (p *PackfileIndexV2) Len() int
- func (p *PackfileIndexV2) Less(i, j int) bool
- func (p *PackfileIndexV2) Swap(i, j int)
- func (idx PackfileIndexV2) WriteIndex(w io.Writer) error
- type ParsedRevision
- type Pattern
- type Person
- type PktLine
- type PullOptions
- type PushOptions
- type ReadTreeOptions
- type Ref
- func (r Ref) CommitID(c *Client) (CommitID, error)
- func (r Ref) Matches(pattern string) bool
- func (r Ref) MatchesRefSpecSrc(spec RefSpec) (match bool, dst Refname)
- func (r Ref) RefName() string
- func (r Ref) String() string
- func (r Ref) TabString() string
- func (r Ref) TreeID(c *Client) (TreeID, error)
- type RefSpec
- func (r RefSpec) CommitID(c *Client) (CommitID, error)
- func (r RefSpec) Dst() Refname
- func (r RefSpec) File(c *Client) File
- func (r RefSpec) HasPrefix(s string) bool
- func (r RefSpec) Sha1(c *Client) (Sha1, error)
- func (r RefSpec) Src() Refname
- func (r RefSpec) String() string
- func (r RefSpec) TreeID(c *Client) (TreeID, error)
- func (r RefSpec) Value(c *Client) (string, error)
- type ReflogDeleteOptions
- type ReflogExpireOptions
- type Refname
- type Remote
- func (r Remote) FetchURL(c *Client) (string, error)
- func (r Remote) GetLocalRefs(c *Client) ([]Ref, error)
- func (r Remote) IsFile() bool
- func (r Remote) IsStateless(c *Client) (bool, error)
- func (r Remote) Name() string
- func (r Remote) PushURL(c *Client) (string, error)
- func (r Remote) RemoteURL(c *Client) (string, error)
- func (r Remote) String() string
- type RemoteAddOptions
- type RemoteConn
- type RemoteGetURLOptions
- type RemoteOptions
- type RemoteShowOptions
- type ResetOptions
- type RevListOptions
- type RevParseOptions
- type RevertOptions
- type RmOptions
- type SendPackOptions
- type Sha1
- func HashFile(t, filename string) (Sha1, []byte, error)
- func HashReader(t string, r io.Reader) (Sha1, []byte, error)
- func HashReaderWithSize(t string, sz int64, r io.Reader) (Sha1, error)
- func HashSlice(t string, data []byte) (Sha1, []byte, error)
- func Mktag(c *Client, r io.Reader) (Sha1, error)
- func PackObjects(c *Client, opts PackObjectsOptions, w io.Writer, objects []Sha1) (trailer Sha1, err error)
- func RevList(c *Client, opt RevListOptions, w io.Writer, includes, excludes []Commitish) ([]Sha1, error)
- func RevParsePath(c *Client, opt *RevParseOptions, arg string) (Sha1, error)
- func Sha1FromSlice(s []byte) (Sha1, error)
- func Sha1FromString(s string) (Sha1, error)
- func UnpackObjects(c *Client, opts UnpackObjectsOptions, r io.Reader) ([]Sha1, error)
- type ShowOptions
- type ShowRefOptions
- type Stage
- type StatusColumnOptions
- type StatusIgnoreSubmodules
- type StatusOptions
- type StatusUntrackedMode
- type SymbolicRef
- type SymbolicRefOptions
- type TagOptions
- type TreeEntry
- type TreeID
- func (t TreeID) GetAllObjects(cl *Client, prefix IndexPath, recurse, excludeself bool) (map[IndexPath]TreeEntry, error)
- func (t TreeID) GetAllObjectsExcept(cl *Client, excludeList map[Sha1]struct{}, prefix IndexPath, ...) (map[IndexPath]TreeEntry, error)
- func (s TreeID) String() string
- func (t TreeID) TreeID(cl *Client) (TreeID, error)
- type Treeish
- type UnmergedPath
- type UnpackObjectsOptions
- type UpdateIndexOptions
- type UpdateRefOptions
- type V3IndexExtensions
- type VariableLengthInt
- type WorkDir
- type WriteTreeOptions
- Bugs
Constants ¶
const ( ArchiveTar = ArchiveFormat(iota) ArchiveTarGzip ArchiveZip )
const ( ModeBlob = EntryMode(0100644) ModeExec = EntryMode(0100755) ModeSymlink = EntryMode(0120000) ModeCommit = EntryMode(0160000) ModeTree = EntryMode(0040000) )
const ( // Directly pass through read/write requests (used when sending a // packfile) DirectMode = PackProtocolMode(iota) // Decode PktLine format and send the decoded data to the caller. // (used when negotiating pack files) PktLineMode // Like PktLineMode, but also read 1 extra byte for determining which // sideband channel the data is on. Keeps reading from the connection // until something comes in on the main channel, printing any sideband // data to sideband. PktLineSidebandMode )
Valid PackProtocolModes
const ( Stage0 = Stage(iota) Stage1 Stage2 Stage3 )
Valid merge stages.
const ( MergeRecursive = MergeStrategy("recursive") MergeOctopus = MergeStrategy("octopus") )
const ( UploadPackService = GitService(iota) ReceivePackService )
const ( StatusUntrackedNo = StatusUntrackedMode(iota) StatusUntrackedNormal StatusUntrackedAll )
const ( StatusIgnoreSubmodulesNone = StatusIgnoreSubmodules(iota) StatusIgnoreSubmodulesUntracked StatisIgnoreSubmodulesDirty StatusIgnoreSubmodulesAll )
Variables ¶
var AlreadyUpToDate = fmt.Errorf("Already up-to-date.")
var DetachedHead error = errors.New("In Detached HEAD state")
var InvalidBranch error = errors.New("Invalid branch")
var InvalidCommit error = errors.New("Invalid commit")
var InvalidHead error = errors.New("Invalid HEAD")
var InvalidIndex error = errors.New("Invalid index")
var InvalidObject error = errors.New("Invalid object")
var InvalidTree error = errors.New("Invalid tree")
var NoGlobalConfig = fmt.Errorf("No global .gitconfig file exists")
Functions ¶
func ArchiveFormatList ¶
func ArchiveFormatList() map[string]ArchiveFormat
Return the list of supported archive file format
func CatFileBatch ¶
func Checkout ¶
func Checkout(c *Client, opts CheckoutOptions, thing string, files []File) error
Implements the "git checkout" subcommand of git. Variations in the man-page are:
git checkout [-q] [-f] [-m] [<branch>] git checkout [-q] [-f] [-m] --detach [<branch>] git checkout [-q] [-f] [-m] [--detach] <commit> git checkout [-q] [-f] [-m] [[-b|-B|--orphan] <new_branch>] [<start_point>] git checkout [-f|--ours|--theirs|-m|--conflict=<style>] [<tree-ish>] [--] <paths>... git checkout [-p|--patch] [<tree-ish>] [--] [<paths>...]
This will just check the options and call the appropriate variation. You can avoid the overhead by calling the proper variation directly.
"thing" is the thing that the user entered on the command line to be checked out. It might be a branch, a commit, or a treeish, depending on the variation above.
func CheckoutCommit ¶
func CheckoutCommit(c *Client, opts CheckoutOptions, commit Commitish) error
Implements the "git checkout" subcommand of git for variations:
git checkout [-q] [-f] [-m] [<branch>] git checkout [-q] [-f] [-m] --detach [<branch>] git checkout [-q] [-f] [-m] [--detach] <commit> git checkout [-q] [-f] [-m] [[-b|-B|--orphan] <new_branch>] [<start_point>]
func CheckoutFiles ¶
func CheckoutFiles(c *Client, opts CheckoutOptions, tree Treeish, files []File) error
Implements "git checkout" subcommand of git for variations:
git checkout [-f|--ours|--theirs|-m|--conflict=<style>] [<tree-ish>] [--] <paths>... git checkout [-p|--patch] [<tree-ish>] [--] [<paths>...]
func CheckoutIndex ¶
func CheckoutIndex(c *Client, opts CheckoutIndexOptions, files []File) error
CheckoutIndex implements the "git checkout-index" subcommand of git.
func CheckoutIndexFromReader ¶
func CheckoutIndexFromReader(c *Client, opts CheckoutIndexOptions) error
Performs a CheckoutIndex on the files read from opts.Stdin
func CheckoutIndexFromReaderUncommited ¶
func CheckoutIndexFromReaderUncommited(c *Client, idx *Index, opts CheckoutIndexOptions) error
Performs CheckoutIndex on the Stdin io.Reader from opts, with the git index passed as a parameter.
func CheckoutIndexUncommited ¶
func CheckoutIndexUncommited(c *Client, idx *Index, opts CheckoutIndexOptions, files []File) error
Same as "git checkout-index", except the Index is passed as a parameter (and may not have been written to disk yet). You likely want CheckoutIndex instead.
(This is primarily for read-tree to be able to update the filesystem with the -u parameter.)
func Clone ¶
func Clone(opts CloneOptions, rmt Remote, dst File) error
Clones a new repository from rmt into the directory dst, which must not already exist.
func Fetch ¶
func Fetch(c *Client, opts FetchOptions, rmt Remote, refs []RefSpec) error
Fetch implements the "git fetch" command, fetching refs from rmt. If refs is nil, all remote refs will be fetched from the remote.
func ForEachRefCallback ¶
Calls callback for each ref under c's GitDir which has prefix as a prefix.
func Fsck ¶
Fsck implements the "git fsck" subcommand. It prints any error encountered to the stderr argument, and returns an array of said errors.
func GeneratePatch ¶
func Merge ¶
func Merge(c *Client, opts MergeOptions, others []Commitish) error
Implements the "git merge" porcelain command to merge other commits into HEAD and create a new commit.
func MergeAbort ¶
func MergeAbort(c *Client, opt MergeOptions) error
Aborts an in progress merge as "git merge --abort" (Not implemented)
func MergeFile ¶
func MergeFile(c *Client, opt MergeFileOptions) (io.Reader, error)
MergeFile merges changes that lead from opt.Base to opt.Other into opt.Current, flagging conflictsas appropriate.
This will return an io.Reader of the merged state rather than directly Current.
BUG(driusan): this currently invokes an external diff3 tool, which needs to be installed in order to work.
func MkTreeBatch ¶
MkTreeBatch reads trees separated by newlines from r, and writes the TreeID to w.
func Pull ¶
func Pull(c *Client, opts PullOptions, repository Remote, remotebranches []string) error
func ReadDeltaOffset ¶
Reads a delta offset from the io.Reader, and returns both the value and the list of bytes consumed from the reader.
func ReadVariable ¶
func ReflogExists ¶
Returns true if a reflog exists for refname r under client.
func ReflogExpire ¶
func ReflogExpire(c *Client, opts ReflogExpireOptions, refpatterns []string) error
func RemoteGetURL ¶
func RemoteGetURL(c *Client, opts RemoteGetURLOptions, r Remote) ([]string, error)
Implements the "git remote get-url" command.
func RemoteShow ¶
Prints the remote named r in the format of "git remote show r" to destination w.
func Reset ¶
func Reset(c *Client, opts ResetOptions, files []File) error
Reset implementes the "git reset" command and delegates to the appropriate ResetMode or ResetUnstage subcommand.
While the third option is a []File slice, the first argument may instead be a "filename" which parses to a commitish or treeish by rev-parse, in which case it's used as the base to reset to, not a file. In the event that there's both a commitish in git and filename of the same name, it's treated as a commit and you must instead pass "HEAD" as the first file to treat it as a filename.
This behaviour is different than the official git client, which provides an error and a message to disambiguate based on the presence of "--" on the command line. (This is not an option here, because this is a library function, not a command line.)
func ResetMode ¶
func ResetMode(c *Client, opts ResetOptions, cmt Commitish) error
ResetMode implements "git reset [--soft | --mixed | --hard | --merge | --keep]" <commit>
func ResetUnstage ¶
func ResetUnstage(c *Client, opts ResetOptions, tree Treeish, files []File) error
ResetUnstage implements "git reset [<treeish>] -- paths
func RevListCallback ¶
func Revert ¶
func Revert(c *Client, opts RevertOptions, commits []Commitish) error
Reverts the given commits from the HEAD. Revert doesn't actually create the new commit, it returns the new tree and leaves it up to the caller (who has a better chance of knowing the appropriate commit message..)
func Show ¶
func Show(c *Client, opts ShowOptions, objects []string) error
Show implementes the "git show" command.
func StatusBranch ¶
func StatusBranch(c *Client, opts StatusOptions, lineprefix string) (string, error)
func StatusLong ¶
func StatusLong(c *Client, files []File, untracked StatusUntrackedMode, lineprefix string) (string, error)
Return a string of the status
func StatusShort ¶
func StatusShort(c *Client, files []File, untracked StatusUntrackedMode, lineprefix, lineending string) (string, error)
Implements git status --short
func SymbolicRefDelete ¶
func SymbolicRefDelete(c *Client, opts SymbolicRefOptions, symname SymbolicRef) error
func SymbolicRefUpdate ¶
func SymbolicRefUpdate(c *Client, opts SymbolicRefOptions, symname SymbolicRef, refvalue RefSpec, reason string) error
func TagList ¶
func TagList(c *Client, opts TagOptions, patterns []string) ([]string, error)
List tags, if tagnames is specified only list tags which match one of the patterns provided.
func UpdateRef ¶
Handles "git update-ref" command line. ref is what's passed on the command-line it can be either a symbolic ref, or a refspec. We just use a string, because Go doesn't support sum types.
func UpdateRefSpec ¶
func UpdateRefSpec(c *Client, opts UpdateRefOptions, ref RefSpec, cmt CommitID, reason string) error
Safely updates ref to point to cmt under the client c, logging reason in the reflog. If opts.OldValue is set, it will return an error if the current value is not OldValue.
Types ¶
type AddOptions ¶
type ApplyOptions ¶
type ApplyOptions struct {
Stat, NumStat, Summary bool
Check, Index, Cached bool
ThreeWay bool
BuildFakeAncestor string
Reject bool
NullTerminate bool
Strip, Context int
UnidiffZero bool
ForceApply bool
Reverse bool
NoAdd bool
ExcludePattern, IncludePattern string
InaccurateEof bool
Verbose bool
Recount bool
Directory string
UnsafePaths bool
Whitespace string
}
type ArchiveFormat ¶
type ArchiveFormat int
type ArchiveOptions ¶
type BitSetter ¶
type BitSetter struct { // If true, the bit should be modified Modify bool // Value to set the bit to if Modify is true. Value bool }
A BitSetter denotes an option for a flag which sets or unsets a bit. It determines both whether the bit should be set, and the value it should be set to.
type Branch ¶
type Branch RefSpec
A Branch is a type of RefSpec that lives under refs/heads/ or refs/remotes/heads Use GetBranch to get a valid branch from a branchname, don't cast from string
func BranchList ¶
func (Branch) BranchName ¶
Returns the branch name, without the refspec portion.
type BranchOptions ¶
type ByName ¶
type ByName []HashDiff
Implement the sort interface on *GitIndexEntry, so that it's easy to sort by name.
type ByPath ¶
type ByPath []*IndexEntry
Implement the sort interface on *GitIndexEntry, so that it's easy to sort by name.
type CatFileOptions ¶
type CheckoutIndexOptions ¶
type CheckoutIndexOptions struct { UpdateStat bool Quiet bool Force bool All bool NoCreate bool Prefix string // Stage not implemented Stage string // <number>|all Temp bool // Stdin implies checkout-index with the --stdin parameter. // nil implies it wasn't passed. Stdin io.Reader // nil implies no --stdin param passed NullTerminate bool }
CheckoutIndexOptions represents the options that may be passed to "git checkout-index"
type CheckoutOptions ¶
type CheckoutOptions struct { // Not implemented Quiet bool // Not implemented Progress bool // Not implemented Force bool // Check out the named stage for unnamed paths. // Stage2 is equivalent to --ours, Stage3 to --theirs // Not implemented Stage Stage Branch string // -b ForceBranch bool // use branch as -B // Not implemented OrphanBranch bool // use branch as --orphan // Not implemented Track string // Not implemented CreateReflog bool // -l // Not implemented Detach bool IgnoreSkipWorktreeBits bool // Not implemented Merge bool // Not implemented. ConflictStyle string Patch bool // Not implemented IgnoreOtherWorktrees bool }
CheckoutOptions represents the options that may be passed to "git checkout"
type CleanOptions ¶
type CleanOptions struct { Directory bool Force bool DryRun bool Quiet bool // Flags which affect exclusion logic ExcludePatterns []string NoStandardExclude bool OnlyExcluded bool // Not implemented Interactive bool }
Command line options which affect the behaviour of clean.
type Client ¶
type Client struct { GitDir GitDir WorkDir WorkDir ObjectDir string // This is used by the git-read-tree test suite. The description from the // git man page is: // // Currently for internal use only. Set a prefix which gives a path // from above a repository down to its root. One use is to give // submodules context about the superproject that invoked it. // // The reality as far as we're concerned is it changes the output error // message of read-tree slightly. SuperPrefix string // contains filtered or unexported fields }
A Client represents a user of the git command inside of a git repo. It's usually something that is trying to manipulate the repo.
func NewClient ¶
Creates a new client with the given gitDir and workdir. If not specified, NewClient will walk the filesystem until it finds a .git directory to use.
func (*Client) CreateBranch ¶
Create a new branch in the Client's git repository.
func (*Client) ExecEditor ¶
Will invoke the Client's editor to edit the file f.
func (*Client) GetAuthor ¶
Returns the author that should be used for a commit message. If time t is provided,
func (*Client) GetBranches ¶
Return valid branches that a Client knows about.
func (*Client) GetCachedConfig ¶
Gets a cached config variable if it is there. Otherwise, it returns
and empty string.
func (*Client) GetCommitObject ¶
func (c *Client) GetCommitObject(commit CommitID) (GitCommitObject, error)
func (*Client) GetCommitter ¶
Returns the author that should be used for a commit message. If time t is provided, it will return a person with the time part populated to t.
func (*Client) GetConfig ¶
Loads a config variable for the git repo hosted by c. If the local variable exists, it will be used, otherwise it will use the global variable. Non-existent variables will return the empty string.
func (*Client) GetHeadBranch ¶
Returns the branchname of the HEAD branch, or the empty string if the HEAD pointer is invalid or in a detached head state.
func (*Client) GetHeadCommit ¶
Gets the Commit of the current HEAD as a string.
func (*Client) GetObjectMetadata ¶
func (*Client) GetObjectsDir ¶
Returns the .git/objects directory.
func (*Client) GetRemoteBranches ¶
Return valid branches that a Client knows about.
func (*Client) GetTagObject ¶
func (c *Client) GetTagObject(tag Sha1) (GitTagObject, error)
func (*Client) HaveObject ¶
Determine whether or not the object represented by id exists in the Client's object directory. Returns a bool if it was found, and the basename of the packfile pack/idx pair that it was contained in (the zero value if it's stored loosely in the repo), and possibly an error if anything went wrong.
func (*Client) IsInsideGitDir ¶
Returns true if the path is under the client's GitDir.
func (*Client) IsInsideWorkTree ¶
Returns true if path is inside of the client's work tree.
func (*Client) ResetIndex ¶
Resets the index to the Treeish tree and save the results in the file named indexname
func (*Client) ResetWorkTree ¶
ResetWorkTree will replace all objects in c.WorkDir with the content from the index.
func (*Client) SetCachedConfig ¶
Sets a cached config for this session only. None of these configs will be persisted into the local or global configuration. Once the client is closed or is garbage collected the configuration is lost.
type CloneOptions ¶
type CloneOptions struct { InitOptions FetchPackOptions Local bool NoHardLinks bool Reference, ReferenceIfAble bool Dissociate bool Progress bool NoCheckout bool Mirror bool // use name instead of origin as upstream remote. Origin string // Use branch instead of HEAD as default branch to checkout Branch string // Set configs in the newly created repository's config. Configs map[string]string // Only clone a single branch (either HEAD or Branch option) SingleBranch bool NoTags bool RecurseSubmodules bool ShallowSubmodules bool Jobs int }
type CommitID ¶
type CommitID Sha1
func Commit ¶
func Commit(c *Client, opts CommitOptions, message CommitMessage, files []File) (CommitID, error)
Commit implements the command "git commit" in the repository pointed to by c.
func CommitIDFromString ¶
func CommitTree ¶
func MergeBase ¶
func MergeBase(c *Client, options MergeBaseOptions, commits []Commitish) (CommitID, error)
func MergeBaseOctopus ¶
func MergeBaseOctopus(c *Client, options MergeBaseOptions, commits []Commitish) (CommitID, error)
func NearestCommonParent ¶
func RevParseCommit ¶
func RevParseCommit(c *Client, opt *RevParseOptions, arg string) (CommitID, error)
RevParse will parse a single revision into a Commit object.
func (CommitID) AncestorMap ¶
AncestorMap returns a map of empty structs (which can be interpreted as a set) of ancestors of a CommitID.
It's useful if you want to know all the ancestors of s, but don't particularly care about their order. Since commits parents can never be changed, multiple calls to AncestorMap are cached and the cost of calculating the ancestory tree is only incurred the first time.
func (CommitID) GetAllObjectsExcept ¶
returns a list of all objects in c excluding those in excludeList. It also populates excludeList with any objects encountered.
func (CommitID) GetAuthor ¶
Returns the author of the commit (with no time information attached) to the person object.
func (CommitID) GetCommitMessage ¶
func (cmt CommitID) GetCommitMessage(c *Client) (CommitMessage, error)
func (CommitID) GetCommitter ¶
Returns the committer of the commit.
func (CommitID) GetCommitterDate ¶
type CommitMessage ¶
type CommitMessage string
func (CommitMessage) Cleanup ¶
func (cm CommitMessage) Cleanup(mode string, edit bool) (string, error)
func (CommitMessage) String ¶
func (cm CommitMessage) String() string
func (CommitMessage) Subject ¶
func (cm CommitMessage) Subject() string
type CommitOptions ¶
type CommitOptions struct { All bool Patch bool ResetAuthor bool Amend bool Date time.Time Author Person Signoff bool NoVerify bool AllowEmpty bool AllowEmptyMessage bool NoPostRewrite bool Include bool Only bool Quiet bool CleanupMode string NoEdit bool // Things that only affect the output with --dry-run. // Note: Printing the status after --dry-run isn't implemented, // all it does is prevent the call to UpdateRef after CommitTree. // Most of these are a no-op. DryRun bool Short bool Branch bool Porcelain bool Long bool NullTerminate bool UntrackedMode StatusUntrackedMode }
type CommitTreeOptions ¶
type Commitish ¶
func RevParseCommitish ¶
func RevParseCommitish(c *Client, opt *RevParseOptions, arg string) (cmt Commitish, err error)
RevParse will parse a single revision into a Commitish object.
type DiffCommonOptions ¶
type DiffCommonOptions struct { // Print a patch, not just the sha differences Patch bool // The 0 value implies 3. NumContextLines int // Generate the diff in raw format, not a unified diff Raw bool // Exit with a exit code of 1 if there are any diffs ExitCode bool }
Options that are shared between git diff, git diff-files, diff-index, and diff-tree
type DiffFilesOptions ¶
type DiffFilesOptions struct {
DiffCommonOptions
}
Describes the options that may be specified on the command line for "git diff-files". Note that only raw mode is currently supported, even though all the other options are parsed/set in this struct.
type DiffIndexOptions ¶
type DiffIndexOptions struct { DiffCommonOptions // Only compare the index to the tree, not the filesystem. Cached bool }
Describes the options that may be specified on the command line for "git diff-index". Note that only raw mode is currently supported, even though all the other options are parsed/set in this struct.
type DiffOptions ¶
type DiffOptions struct { DiffCommonOptions Staged bool NoIndex bool }
Describes the options that may be specified on the command line for "git diff".
type DiffTreeOptions ¶
type DiffTreeOptions struct { Patch bool // The 0 value implies 3. NumContextLines int Raw bool // Unimplemented. Probably never will be. CompactionHeuristic bool // Can be "default", "myers", "minimal", "patience", or "histogram" DiffAlgorithm string StatWidth, StatNameWidth, StatCount int NumStat bool ShortStat bool DirStat string Summary bool NullTerminate bool NameOnly, NameStatus bool Submodule string // Colour can have three states: "always" (true), "never" (false), or "auto" (nil) Color *bool // "color", "plain", "porcelain", or "none" WordDiff string WordDiffRegex *regexp.Regexp NoRenames bool // Warn if changes introduce conflict markers or whitespace errors. Check bool // Valid options in the []string are "old", "new", or "context" WhitespaceErrorHighlight []string FullIndex, Binary bool // Number of characters to abbreviate the hexadecimal object name to. Abbrev int // Recurse into subtrees. Recurse bool // Diff the initial commit against the empty tree Root bool }
Describes the options that may be specified on the command line for "git diff-index". Note that only raw mode is currently supported, even though all the other options are parsed/set in this struct.
type EntryMode ¶
type EntryMode uint32
An EntryMode is like an os.FileMode, but restricted to the values that are legal in git.
func ModeFromString ¶
type FetchOptions ¶
type FetchOptions struct { Force bool FetchPackOptions }
type FetchPackOptions ¶
type File ¶
type File string
A file represents a file (or directory) relative to os.Getwd()
func (File) IndexPath ¶
Normalizes the file name that's relative to the current working directory to be relative to the workdir root. Ie. convert it from a file system path to an index path.
func (File) IsInSubmodule ¶
Returns true if the file is inside a submodule and the submodule file. FIXME: invert this when submodules are implemented
func (File) IsInsideSymlink ¶
func (File) ReadAll ¶
Reads the entire contents of file and return as a string. Note that this should only be used for very small files (like refspecs)
func (File) ReadFirstLine ¶
Reads the first line of File. (This is primarily to extract commit message lines for reflogs)
type FixedIndexEntry ¶
type FixedIndexEntry struct { Ctime uint32 // 16 Ctimenano uint32 // 20 Mtime int64 // 24 Dev uint32 // 32 Ino uint32 // 36 Mode EntryMode // 40 Uid uint32 // 44 Gid uint32 // 48 Fsize uint32 // 52 Sha1 Sha1 // 72 Flags uint16 // 74 }
func (*FixedIndexEntry) CompareStat ¶
func (i *FixedIndexEntry) CompareStat(f File) error
Refreshes the stat information for this entry in the index against the stat info on the filesystem for things that we know about.
func (FixedIndexEntry) ExtendedFlag ¶
func (i FixedIndexEntry) ExtendedFlag() bool
func (*FixedIndexEntry) RefreshStat ¶
func (i *FixedIndexEntry) RefreshStat(f File) error
Refreshes the stat information for this entry using the file file
func (*FixedIndexEntry) SetExtendedFlag ¶
func (i *FixedIndexEntry) SetExtendedFlag(val bool)
type FormatString ¶
type FormatString string
func (FormatString) FormatCommit ¶
func (f FormatString) FormatCommit(c *Client, cmt CommitID) (string, error)
type FsckOptions ¶
type GitBlobObject ¶
type GitBlobObject struct {
// contains filtered or unexported fields
}
func (GitBlobObject) GetContent ¶
func (b GitBlobObject) GetContent() []byte
func (GitBlobObject) GetSize ¶
func (b GitBlobObject) GetSize() int
func (GitBlobObject) GetType ¶
func (GitBlobObject) GetType() string
func (GitBlobObject) String ¶
func (b GitBlobObject) String() string
type GitCommitObject ¶
type GitCommitObject struct {
// contains filtered or unexported fields
}
func (GitCommitObject) GetContent ¶
func (c GitCommitObject) GetContent() []byte
func (GitCommitObject) GetHeader ¶
func (c GitCommitObject) GetHeader(header string) string
func (GitCommitObject) GetSize ¶
func (c GitCommitObject) GetSize() int
func (GitCommitObject) GetType ¶
func (c GitCommitObject) GetType() string
func (GitCommitObject) String ¶
func (c GitCommitObject) String() string
type GitConfig ¶
type GitConfig struct {
// contains filtered or unexported fields
}
func LoadGlobalConfig ¶
func LoadLocalConfig ¶
func ParseConfig ¶
func (*GitConfig) GetConfigList ¶
func (*GitConfig) GetConfigSections ¶
func (g *GitConfig) GetConfigSections(name, subsection string) []GitConfigSection
Gets all config sections that match name and subsection. The empty string matches all names/subsections.
func (GitConfig) WriteConfig ¶
type GitConfigSection ¶
type GitConfigSection struct {
// contains filtered or unexported fields
}
func (*GitConfigSection) ParseSectionHeader ¶
func (s *GitConfigSection) ParseSectionHeader(headerline string)
func (*GitConfigSection) ParseValues ¶
func (s *GitConfigSection) ParseValues(valueslines string)
type GitConfigValues ¶
This file provides a stupid way of parsing git config files. It's not very efficient, but for now it gets the job done. (There's a lot more low hanging fruit before optimizing this..)
type GitDir ¶
type GitDir File
A GitDir represents the .git/ directory of a repository. It should not have a trailing slash.
type GitService ¶
type GitService uint8
type GitTagObject ¶
type GitTagObject struct {
// contains filtered or unexported fields
}
func (GitTagObject) GetContent ¶
func (b GitTagObject) GetContent() []byte
func (GitTagObject) GetHeader ¶
func (c GitTagObject) GetHeader(header string) string
func (GitTagObject) GetSize ¶
func (b GitTagObject) GetSize() int
func (GitTagObject) GetType ¶
func (GitTagObject) GetType() string
func (GitTagObject) String ¶
func (b GitTagObject) String() string
type GitTreeObject ¶
type GitTreeObject struct {
// contains filtered or unexported fields
}
func (GitTreeObject) GetContent ¶
func (t GitTreeObject) GetContent() []byte
func (GitTreeObject) GetSize ¶
func (t GitTreeObject) GetSize() int
func (GitTreeObject) GetType ¶
func (t GitTreeObject) GetType() string
func (GitTreeObject) String ¶
func (t GitTreeObject) String() string
type GrepOptions ¶
type GrepOptions struct { ShowFilename bool Text bool TextConv bool IgnoreCase bool IgnoreBinary bool Cached bool NoIndex bool Untracked bool NoExcludeStandard bool ExcludeStandard bool RecurseSubmodules bool ParentBaseName string MaxDepth int WordRegex bool InvertMatch bool FullName bool FixedStrings bool LineNumbers bool NameOnly bool OpenFilesInPager string NullTerminate bool Count bool LineBreaks, Heading bool Invert bool ExtendedRegexp bool Colour bool ShowFunction bool FunctionContext bool NumThreads int Quiet bool File File LeadingContext, TrailingContext int // If non-nil, Grep will use opts.Stdout to write results // to instead of os.Stdout. Stdout io.Writer }
type HashDiff ¶
A HashDiff represents a single line in a git diff-index type output.
func Diff ¶
func Diff(c *Client, opt DiffOptions, paths []File) ([]HashDiff, error)
DiffFiles implements the git diff-files command. It compares the file system to the index.
func DiffFiles ¶
func DiffFiles(c *Client, opt DiffFilesOptions, paths []File) ([]HashDiff, error)
DiffFiles implements the git diff-files command. It compares the file system to the index.
func DiffIndex ¶
func DiffIndex(c *Client, opt DiffIndexOptions, index *Index, tree Treeish, paths []File) ([]HashDiff, error)
DiffIndex compares the index against a tree. If the index passed is nil, it reads the index from the .git directory
func (HashDiff) ExternalDiff ¶
func (h HashDiff) ExternalDiff(c *Client, s1, s2 TreeEntry, f File, opts DiffCommonOptions) (string, error)
Returns a diff in the format of the command "diff". Note: this invokes an external diff tool. It should be rewritten in Go to avoid the overhead (and the possibility that diff isn't installed.)
type IgnoreMatch ¶
type IgnoreMatch struct { IgnorePattern // A match has all of the pattern information, or empty pattern if no match was found PathName File // The provided path name that was checked for the ignore }
Represents a match (or non-match) of a particular path name against a set of ignore patterns
func MatchIgnores ¶
func MatchIgnores(c *Client, patterns []IgnorePattern, paths []File) ([]IgnoreMatch, error)
func (IgnoreMatch) LineString ¶
func (im IgnoreMatch) LineString() string
func (IgnoreMatch) String ¶
func (im IgnoreMatch) String() string
Returns the standard representation of an ignore match (or non-match)
type IgnorePattern ¶
type IgnorePattern struct { Pattern string // The pattern to match, relative to the scope Source File // The path to the pattern file where this pattern is found, relative path for work dir resources, otherwise absolute path or blank for one that was provided as input to dgit Scope File // The work directory relative scope that this pattern applies LineNum int // The line number within the source pattern file where this pattern is located }
An ignore pattern declared in a pattern file (e.g. .gitignore) or provided as an input.
func ParseIgnorePatterns ¶
func ParseIgnorePatterns(c *Client, patternFile File, scope File) ([]IgnorePattern, error)
func StandardIgnorePatterns ¶
func StandardIgnorePatterns(c *Client, paths []File) ([]IgnorePattern, error)
Returns the standard ignores (.gitignore files and various global sources) that
should be used to determine whether the provided files are ignored. These patterns can be used with these files with ApplyIgnore() to find whether each file is ignored or not.
func (IgnorePattern) Negates ¶
func (ip IgnorePattern) Negates() bool
type Index ¶
type Index struct { Objects []*IndexEntry // contains filtered or unexported fields }
func Add ¶
func Add(c *Client, opts AddOptions, files []File) (*Index, error)
Add implements the "git add" plumbing command.
func ReadTree ¶
func ReadTree(c *Client, opt ReadTreeOptions, tree Treeish) (*Index, error)
Reads a tree into the index. If DryRun is not false, it will also be written to disk.
func ReadTreeFastForward ¶
func ReadTreeFastForward(c *Client, opt ReadTreeOptions, parent, dst Treeish) (*Index, error)
ReadTreeFastForward will return a new Index with parent fast-forwarded to from parent to dst. Local modifications to the work tree will be preserved. If options.DryRun is not false, it will also be written to the Client's index file.
func ReadTreeThreeWay ¶
func ReadTreeThreeWay(c *Client, opt ReadTreeOptions, stage1, stage2, stage3 Treeish) (*Index, error)
ReadTreeThreeWay will perform a three-way merge on the trees stage1, stage2, and stage3. In a normal merge, stage1 is the common ancestor, stage2 is "our" changes, and stage3 is "their" changes. See git-read-tree(1) for details.
If options.DryRun is not false, it will also be written to the Client's index file.
func UpdateIndex ¶
This implements the git update-index command. It updates the index passed as a parameter, and returns it. It does *not* write it to disk, that's the responsibility of the caller.
func UpdateIndexCacheInfo ¶
func UpdateIndexCacheInfo(c *Client, idx *Index, opts UpdateIndexOptions) (*Index, error)
func UpdateIndexFromReader ¶
func UpdateIndexRefresh ¶
func UpdateIndexRefresh(c *Client, idx *Index, opts UpdateIndexOptions) (*Index, error)
func (*Index) AddFile ¶
func (g *Index) AddFile(c *Client, file File, opts UpdateIndexOptions) error
Adds a file to the index, without writing it to disk. To write it to disk after calling this, use GitIndex.WriteIndex
This will do the following:
- write git object blob of file contents to .git/objects
- normalize os.File name to path relative to gitRoot
- search GitIndex for normalized name if GitIndexEntry found update GitIndexEntry to point to the new object blob else add new GitIndexEntry if not found and createEntry is true, error otherwise
func (*Index) AddStage ¶
func (g *Index) AddStage(c *Client, path IndexPath, mode EntryMode, s Sha1, stage Stage, size uint32, mtime int64, opts UpdateIndexOptions) error
Adds an entry to the index with Sha1 s and stage stage during a merge. If an entry already exists for this pathname/stage, it will be overwritten, otherwise it will be added if createEntry is true, and return an error if not.
As a special case, if something is added as Stage0, then Stage1-3 entries will be removed.
func (Index) GetSha1 ¶
Looks up the Sha1 of path currently stored in the index. Will return the 0 Sha1 if not found.
func (*Index) GetStageMap ¶
func (i *Index) GetStageMap() map[IndexStageEntry]*IndexEntry
func (*Index) GetUnmerged ¶
func (i *Index) GetUnmerged() map[IndexPath]*UnmergedPath
func (*Index) RemoveFile ¶
Remove the first instance of file from the index. (This will usually be stage 0.)
func (*Index) RemoveUnmergedStages ¶
Remove any unmerged (non-stage 0) stage from the index for the given path
func (*Index) ResetIndex ¶
Replaces the index of Client with the the tree from the provided Treeish. if PreserveStatInfo is true, the stat information in the index won't be modified for existing entries.
func (*Index) SetSkipWorktree ¶
func (Index) WriteIndex ¶
This will write a new index file to w by doing the following:
- Sort the objects in g.Index to ascending order based on name and update g.NumberIndexEntries
- Write g.fixedGitIndex to w
- for each entry in g.Objects, write it to w.
- Write the Sha1 of the contents of what was written
type IndexEntry ¶
type IndexEntry struct { FixedIndexEntry *V3IndexExtensions PathName IndexPath }
func LsTree ¶
func LsTree(c *Client, opts LsTreeOptions, tree Treeish, paths []File) ([]*IndexEntry, error)
Implements the git ls-tree subcommand. This will return a list of index entries in tree that match paths
func ReadIndexEntry ¶
func ReadIndexEntry(file *os.File, indexVersion uint32) (*IndexEntry, error)
func (*IndexEntry) RefreshStat ¶
func (ie *IndexEntry) RefreshStat(c *Client) error
Refreshes the stat information for an index entry by comparing it against the path in the index.
func (*IndexEntry) SetSkipWorktree ¶
func (ie *IndexEntry) SetSkipWorktree(value bool)
func (IndexEntry) SkipWorktree ¶
func (ie IndexEntry) SkipWorktree() bool
func (IndexEntry) Stage ¶
func (ie IndexEntry) Stage() Stage
type IndexMap ¶
type IndexMap map[IndexPath]*IndexEntry
func GetIndexMap ¶
Converts the Tree into an IndexEntries, to simplify comparisons between Trees and Indexes
type IndexPackOptions ¶
type IndexPackOptions struct { // Display progress information while indexing pack. Verbose bool // Output index to this writer. If nil, will be based on // the filename. Output io.Writer // Fix a "thin" pack produced by git pack-objects --thin // (not implemented) FixThin bool // A message to store in a .keep file. The string "none" // will be interpreted as an empty file, the empty string // will be interpreted as do not produce a .keep file. Keep string // Not implemented IndexVersion int // Die if the pack contains broken links. (Not implemented) Strict bool // A number of threads to use for resolving deltas. The 0-value // will use GOMAXPROCS. Threads uint // Act as if reading from a non-seekable stream, not a file. Stdin bool }
type IndexPath ¶
type IndexPath string
An IndexPath represents a file in the index. ie. a File path relative to the Git WorkDir, not the current working directory.
func (IndexPath) FilePath ¶
Returns the IndexPath as a filename relative to Getwd, in order to convert from Indexes to Working directory paths.
type IndexStageEntry ¶
type InitOptions ¶
type LsFilesOptions ¶
type LsFilesOptions struct {
// Types of files to show
Cached, Deleted, Modified, Others bool
// Invert exclusion logic
Ignored bool
// Show stage status instead of just file name
Stage bool
// Show files which are unmerged. Implies Stage.
Unmerged bool
// Show files which need to be removed for checkout-index to succeed
Killed bool
// If a directory is classified as "other", show only its name, not
// its contents
Directory bool
// Do not show empty directories with --others
NoEmptyDirectory bool
// Exclude standard patterns (ie. .gitignore and .git/info/exclude)
ExcludeStandard bool
// Exclude using the provided patterns
ExcludePatterns []string
// Exclude using the provided file with the patterns
ExcludeFiles []File
// Exclude using additional patterns from each directory
ExcludePerDirectory []File
ErrorUnmatch bool
// Equivalent to the -t option to git ls-files
Status bool
}
Describes the options that may be specified on the command line for "git diff-index". Note that only raw mode is currently supported, even though all the other options are parsed/set in this struct.
type LsFilesResult ¶
type LsFilesResult struct { *IndexEntry StatusCode rune }
func LsFiles ¶
func LsFiles(c *Client, opt LsFilesOptions, files []File) ([]LsFilesResult, error)
LsFiles implements the git ls-files command. It returns an array of files that match the options passed.
type LsRemoteOptions ¶
type LsTreeOptions ¶
type LsTreeOptions struct { TreeOnly bool Recurse bool ShowTrees bool Long bool NullTerminate bool NameOnly bool Abbrev int FullName bool FullTree bool }
Options for LsTree. (These are almost all presentational and don't affect the behaviour of LsTree itself, but are in this struct to make it easier to use the flags package to parse the command line.
type MergeBaseOptions ¶
type MergeFileFile ¶
type MergeFileOptions ¶
type MergeFileOptions struct {
Current, Base, Other MergeFileFile
Quiet bool
Stdout bool
Diff3 bool
}
type MergeOptions ¶
type MergeOptions struct { // Not implemented NoCommit bool // Not implemented NoEdit bool NoFastForward bool FastForwardOnly bool // Not implemented Log int // Not implemented Stat bool // Not implemented Squash bool // Not implemented Strategy MergeStrategy // Not implemented VerifySignatures bool // Not implemented Quiet bool // Not implemented Verbose bool // Not implemented NoProgress bool // Not implemented Message string }
Merge options represent the options that may be passed on the command line to "git merge"
type MergeStrategy ¶
type MergeStrategy string
type MkTreeOptions ¶
type ObjectOffset ¶
type ObjectOffset int
type ObjectReference ¶
type ObjectReference []byte
type PackEntrySize ¶
type PackEntrySize uint64
type PackEntryType ¶
type PackEntryType uint8
const ( OBJ_COMMIT PackEntryType = 1 OBJ_TREE PackEntryType = 2 OBJ_BLOB PackEntryType = 3 OBJ_TAG PackEntryType = 4 OBJ_OFS_DELTA PackEntryType = 6 OBJ_REF_DELTA PackEntryType = 7 )
func (PackEntryType) String ¶
func (t PackEntryType) String() string
type PackIndexFanout ¶
type PackIndexFanout [256]uint32
type PackObjectsOptions ¶
type PackProtocolMode ¶
type PackProtocolMode uint8
A PackProtocolMode determines how calling Read on a RemoteConn returns data to the caller.
type PackfileHeader ¶
func (PackfileHeader) ReadHeaderSize ¶
func (p PackfileHeader) ReadHeaderSize(r flate.Reader) (PackEntryType, PackEntrySize, Sha1, ObjectOffset, []byte)
Readers a packfile entry header from r, and returns the type of packfile, the size from the header, optionally a reference or file offset (for deltas only), and any data read from the io stream.
type PackfileIndex ¶
type PackfileIndex interface { GetObject(i io.ReaderAt, s Sha1) (GitObject, error) HasObject(s Sha1) bool WriteIndex(w io.Writer) error GetTrailer() (Packfile Sha1, Index Sha1) }
func IndexAndCopyPack ¶
func IndexAndCopyPack(c *Client, opts IndexPackOptions, r io.Reader) (PackfileIndex, error)
Indexes the pack, and stores a copy in Client's .git/objects/pack directory as it's doing so. This is the equivalent of "git index-pack --stdin", but works with any reader.
func IndexPack ¶
func IndexPack(c *Client, opts IndexPackOptions, r io.Reader) (idx PackfileIndex, rerr error)
type PackfileIndexV2 ¶
type PackfileIndexV2 struct { Version uint32 // Must be 2 Fanout PackIndexFanout Sha1Table []Sha1 CRC32 []uint32 // If the MSB is set, it's an index into the next // table, otherwise it's an index into the packfile. FourByteOffsets []uint32 EightByteOffsets []uint64 // The trailer from a V1 checksum Packfile, IdxFile Sha1 // contains filtered or unexported fields }
func (PackfileIndexV2) GetObjectMetadata ¶
Find the object in the table.
func (PackfileIndexV2) GetTrailer ¶
func (idx PackfileIndexV2) GetTrailer() (Sha1, Sha1)
func (PackfileIndexV2) HasObject ¶
func (idx PackfileIndexV2) HasObject(s Sha1) bool
func (*PackfileIndexV2) Len ¶
func (p *PackfileIndexV2) Len() int
Implements the Sorter interface on PackfileIndexV2, in order to sort the Sha1, CRC32, and
func (*PackfileIndexV2) Less ¶
func (p *PackfileIndexV2) Less(i, j int) bool
func (*PackfileIndexV2) Swap ¶
func (p *PackfileIndexV2) Swap(i, j int)
func (PackfileIndexV2) WriteIndex ¶
func (idx PackfileIndexV2) WriteIndex(w io.Writer) error
type ParsedRevision ¶
func RevParse ¶
func RevParse(c *Client, opt RevParseOptions, args []string) (commits []ParsedRevision, err2 error)
Implements "git rev-parse". This should be refactored in terms of RevParseCommit and cleaned up. (clean up a lot.)
func (ParsedRevision) IsAncestor ¶
func (pr ParsedRevision) IsAncestor(c *Client, parent Commitish) bool
type Person ¶
type Person struct {
Name, Email string
// Optional time that this person should be serialized as. Causes
// String() to be returned in commit format if specified
Time *time.Time
}
A Person is usually an Author, but might be a committer. It's someone with an email address.
type PullOptions ¶
type PullOptions struct { FetchOptions MergeOptions }
type PushOptions ¶
type PushOptions struct { SendPackOptions SetUpstream bool }
type ReadTreeOptions ¶
type ReadTreeOptions struct { // Perform a merge Merge bool // Discard changes that are not in stage 0 while doing a merge. Reset bool // Also update the work tree Update bool // -i parameter to ReadTree. Not implemented IgnoreWorktreeCheck bool // Do not write index to disk. DryRun bool // Unused, just for consistency with real git command line. Verbose bool // Not implemented TrivialMerge, AggressiveMerge bool // Read the named tree into the directory prefix/ under the index Prefix string // Used as the name of a .gitignore to look for in each directory ExcludePerDirectory string // Name of the index file to use under c.GitDir IndexOutput string // Discard all the entries in the index instead of updating it to the // named Treeish. Empty bool // Disable sparse checkout. // Note that it's the caller's responsibility to set this option if // core.sparsecheckout is not equal to true. NoSparseCheckout bool }
Options that may be passed in the command line to ReadTree.
type Ref ¶
type Ref struct { // The full name of a ref, starting with refs/ Name string // Value can be either a commit or a tag object Value Sha1 }
func FetchPack ¶
FetchPack fetches a packfile from rmt. It uses wants to retrieve the refnames from the remote, and haves to negotiate the missing objects. FetchPack always makes a single request and declares "done" at the end.
func (Ref) Matches ¶
Matches determines whether a Ref matches a pattern according to the rules of ShowRef
func (Ref) MatchesRefSpecSrc ¶
MatchesRSSrc determines whether the ref matches the src of a refspec. If it matches the src, it also returns the destination
type RefSpec ¶
type RefSpec string
A RefSpec refers to a reference contained under .git/refs
func SymbolicRefGet ¶
func SymbolicRefGet(c *Client, opts SymbolicRefOptions, symname SymbolicRef) (RefSpec, error)
Gets a RefSpec for a symbolic ref. Returns "" if symname is not a valid symbolic ref.
func (RefSpec) Dst ¶
Dst represents the local destination of a remote ref in a refspec. For instance, in the refspec "refs/heads/foo:refs/remotes/origin/foo", Dst refers to "refs/remotes/origin/foo". If the refspec does not have an explicit Dst specified, Dst returns an empty refname.
func (RefSpec) Src ¶
Src represents the ref name of the ref at the remote location for a refspec. for instance, in the refspec "refs/heads/foo:refs/remotes/origin/foo", src refers to refs/heads/foo, the name of the remote reference, while dst refers to refs/remotes/origin/master, the location that we store our cache of what that remote reference is.
type ReflogDeleteOptions ¶
type ReflogDeleteOptions struct{}
type ReflogExpireOptions ¶
type ReflogExpireOptions struct { ReflogDeleteOptions Expire string All bool }
type Refname ¶
type Refname string
func (Refname) LocalName ¶
Returns the local part of a refname when given a ref like refs/heads/foo:refs/heads/bar for send-pack
func (Refname) RemoteName ¶
type Remote ¶
type Remote string
func RemoteList ¶
func RemoteList(c *Client, opts RemoteOptions) ([]Remote, error)
Retrieves a list of remotes set up in the local git repository for Client c.
func (Remote) GetLocalRefs ¶
Gets a list of local references cached for this Remote
type RemoteAddOptions ¶
type RemoteAddOptions struct { RemoteOptions Fetch bool // Import all tags and associated objects when fetching Tags bool // Branch(es) to track (not implemented) Track string // Master branch (not implemented) Master string // Mirror=[push|fetch] // Set up remote as a mirror to push to or fetch from // (not implemented) Mirror string }
type RemoteConn ¶
type RemoteConn interface { // Opens a connection to the remote. This requires at least one round // trip to the service and may mutate the state of this RemoteConn. // // After calling this, the RemoteConn should be in a useable state. OpenConn(GitService) error // Gets a list of references on the remote. If patterns is specified, // restrict to refs which match the pattern. If not, return all // refs GetRefs(opts LsRemoteOptions, patterns []string) ([]Ref, error) // Close the underlying connection to this service. Close() error // Sets the name of git-upload-pack to use for this remote, where // applicable. This must be called before OpenConn. // When called on a transport type that does not support it (such // as the git transport protocol), it will return a nil error. An // error indicates that the protocol *should* support the operation // but was unable to set the variable. SetService(string) error // Gets the protocol version that was negotiated during connection // opening. Only valid after calling OpenConn. ProtocolVersion() uint8 // Returns the capabilities determined during the initial protocol // connection. // // The first index is the capability, the second is the arguments // defined for it. Capabilities() map[string]map[string]struct{} // Tells the connection to print any sideband data to w SetSideband(w io.Writer) // A RemoteConn should act as a writter. When written to, it should // write to the underlying connection in pkt-line format or directly // as per SetWriteMode. io.Writer // Reading from a RemoteConn should return the data after decoding // the line length from a pktline. // The behaviour of the read depends on the PackProtocolMode set // by SetReadMode io.Reader // Determines how reading from the connection returns data to the // caller. SetReadMode(mode PackProtocolMode) // Determines how reading from the connection returns data to the // caller. SetWriteMode(mode PackProtocolMode) // Send a flush packet to the connection Flush() error // Sends a Delimiter packet in protocol V2 Delim() error }
A RemoteConn represends a connection to a remote which communicates with the remote.
func NewRemoteConn ¶
func NewRemoteConn(c *Client, r Remote) (RemoteConn, error)
type RemoteGetURLOptions ¶
type RemoteGetURLOptions struct { RemoteOptions Push bool All bool }
type RemoteOptions ¶
type RemoteOptions struct {
Verbose bool
}
type RemoteShowOptions ¶
type RemoteShowOptions struct { RemoteOptions // Do not query the remote with ls-remote, only show the local cache. NoQuery bool }
type ResetOptions ¶
type RevListOptions ¶
List of command line options that may be passed to RevList
type RevParseOptions ¶
type RevParseOptions struct {
// Operation modes
ParseOpt, SQQuote bool
// Options for --parseopt
KeepDashDash bool
StopAtNonOption bool
StuckLong bool
// Options for Filtering
RevsOnly bool
NoRevs bool
Flags, NoFlags bool
// Options for output. These should probably not be here but be handled
// in the cmd package instead.
Default string
Prefix string
Verify bool
Quiet bool
SQ bool
Not bool
AbbrefRev string //strict|loose
Short uint // The number of characters to abbreviate to. Default should be "4"
Symbolic, SymbolicFullName bool
// Options for Objects
All bool
Branches, Tags, Remotes Pattern
Glob Pattern
Exclude Pattern
Disambiguate string // Prefix
// Options for Files
// BUG(driusan): These should be handled as part of "args", not in RevParseOptions.
// They're included here so that I don't forget about them.
GitCommonDir GitDir
ResolveGitDir File // path
GitPath GitDir
ShowCDup bool
// Other options
After, Before time.Time
}
Options that may be passed to RevParse on the command line. BUG(driusan): None of the RevParse options are implemented
type RevertOptions ¶
type RmOptions ¶
type RmOptions struct { Force bool DryRun bool Recursive bool Cached bool IgnoreUnmatched bool Quiet bool }
RmOptions denotes command line options that may be parsed from "git rm"
type SendPackOptions ¶
type Sha1 ¶
type Sha1 [20]byte
func HashReader ¶
Hashes the data of r with object type t, and returns the hash, and the data that was read from r.
func PackObjects ¶
func PackObjects(c *Client, opts PackObjectsOptions, w io.Writer, objects []Sha1) (trailer Sha1, err error)
Writes a packfile to w of the objects objects from the client's GitDir.
func RevParsePath ¶
func RevParsePath(c *Client, opt *RevParseOptions, arg string) (Sha1, error)
RevParsePath parses a path spec such as `HEAD:README.md` into the value that it represents. The Sha1 returned may be either a tree or a blob, depending on the pathspec.
func Sha1FromSlice ¶
func Sha1FromString ¶
func UnpackObjects ¶
Unpack the objects from r's input stream into the client GitDir's objects directory and returns the list of objects that were unpacked.
func (Sha1) CompressedWriter ¶
Writes the object to w in compressed form
func (Sha1) PackEntryType ¶
func (id Sha1) PackEntryType(c *Client) PackEntryType
func (Sha1) UncompressedSize ¶
type ShowOptions ¶
type ShowOptions struct { DiffOptions Format FormatString }
type ShowRefOptions ¶
type StatusColumnOptions ¶
type StatusColumnOptions string
type StatusIgnoreSubmodules ¶
type StatusIgnoreSubmodules uint8
type StatusOptions ¶
type StatusOptions struct { Short bool Branch bool ShowStash bool Porcelain uint8 Long bool Verbose bool Ignored bool NullTerminate bool UntrackedMode StatusUntrackedMode IgnoreSubmodules StatusIgnoreSubmodules Column StatusColumnOptions }
type StatusUntrackedMode ¶
type StatusUntrackedMode uint8
type SymbolicRef ¶
type SymbolicRef string
A SymbolicRef is generally "HEAD". It's a fake symlink used by git to support operating systems that don't have symlinks
func (SymbolicRef) String ¶
func (s SymbolicRef) String() string
type SymbolicRefOptions ¶
SymbolicRefOptions represents the command line options that may be passed on the command line. (NB. None of these are implemented.)
type TagOptions ¶
type TagOptions struct { // Replace existing tags instead of erroring out. Force bool // Display tags List bool IgnoreCase bool Annotated bool // Delete the given tag Delete bool }
TagOptions is a stub for when more of Tag is implemented
type TreeID ¶
type TreeID Sha1
func MkTree ¶
Mktree reads a tree from r in the same format as ls-tree and returns the TreeID of the converted tree.
func WriteTreeFromIndex ¶
func WriteTreeFromIndex(c *Client, idx *Index, opts WriteTreeOptions) (TreeID, error)
func (TreeID) GetAllObjects ¶
func (t TreeID) GetAllObjects(cl *Client, prefix IndexPath, recurse, excludeself bool) (map[IndexPath]TreeEntry, error)
Returns a map of all paths in the Tree. If recurse is true, it will recurse into subtrees. If excludeself is true, it will *not* include it's own Sha1. (Only really meaningful with recurse)
func (TreeID) GetAllObjectsExcept ¶
func (t TreeID) GetAllObjectsExcept(cl *Client, excludeList map[Sha1]struct{}, prefix IndexPath, recurse, excludeself bool) (map[IndexPath]TreeEntry, error)
GetAllObjectsExcept is like GetAllObjects, except that it excludes those objects in excludeList. It also populates excludeList with any objects encountered.
type Treeish ¶
func RevParseTreeish ¶
func RevParseTreeish(c *Client, opt *RevParseOptions, arg string) (Treeish, error)
RevParseTreeish will parse a single revision into a Treeish structure.
type UnmergedPath ¶
type UnmergedPath struct {
Stage1, Stage2, Stage3 *IndexEntry
}
type UnpackObjectsOptions ¶
type UnpackObjectsOptions struct { // Do not write any objects (not implemented) DryRun bool // Do not print any progress information to os.Stderr Quiet bool // Attempt to recover corrupt pack files (not implemented) Recover bool // Do not write objects with broken content or links (not implemented) Strict bool // Do not attempt to process packfiles larger than this size. // (the value "0" means unlimited.) MaxInputSize uint }
type UpdateIndexOptions ¶
type UpdateIndexOptions struct {
Add, Remove bool
Refresh, ReallyRefresh bool
Quiet bool
IgnoreSubmodules bool
IndexVersion int
// Read the index information from IndexInfo
IndexInfo io.Reader
Unmerged bool
IgnoreMissing bool
Again bool
Unresolve bool
InfoOnly bool
ForceRemove bool
Replace bool
Verbose bool
NullTerminate bool
Chmod BitSetter
SplitIndex BitSetter
UntrackedCache BitSetter
SkipWorktree BitSetter
AssumeUnchanged BitSetter
CacheInfo CacheInfo
Stdin io.Reader
// contains filtered or unexported fields
}
type UpdateRefOptions ¶
type V3IndexExtensions ¶
type V3IndexExtensions struct {
Flags uint16
}
type VariableLengthInt ¶
type VariableLengthInt uint64
func (VariableLengthInt) WriteVariable ¶
func (v VariableLengthInt) WriteVariable(w io.Writer, typ PackEntryType) (int, error)
type WorkDir ¶
type WorkDir File
WorkDir is the top level of the work directory of the current process, or the empty string if the --bare option is provided
type WriteTreeOptions ¶
Notes ¶
Bugs ¶
This should verify that there is a prefix and return an error if it's outside of the tree.
this currently invokes an external diff3 tool, which needs to be installed in order to work.
None of the RevParse options are implemented
These should be handled as part of "args", not in RevParseOptions. They're included here so that I don't forget about them.
Source Files ¶
- add.go
- apply.go
- archive.go
- auth.go
- branch.go
- catfile.go
- checkout.go
- checkoutindex.go
- clean.go
- client.go
- clone.go
- commit.go
- committree.go
- config.go
- consts.go
- diff.go
- difffiles.go
- diffindex.go
- difftree.go
- editor.go
- entrymode.go
- errors.go
- expandtree.go
- fetch.go
- fetchpack.go
- file.go
- file_ctime_unix.go
- file_inode_unix.go
- file_mtime.go
- foreachref.go
- fsck.go
- gitconn.go
- grep.go
- hashdiff.go
- hashobject.go
- httpconn.go
- ignore.go
- index.go
- indexpack.go
- init.go
- interactive.go
- localconn.go
- lsfiles.go
- lsremote.go
- lstree.go
- merge.go
- mergebase.go
- mergefile.go
- mktag.go
- mktree.go
- objects.go
- packfile.go
- packiterator.go
- packobjects.go
- password_other.go
- progressf.go
- protectfs.go
- pull.go
- push.go
- readtree.go
- reflog.go
- refspec.go
- remote.go
- reset.go
- retrieve.go
- revert.go
- revlist.go
- revparse.go
- rm.go
- sendpack.go
- sha1.go
- show.go
- showref.go
- ssh_unix.go
- sshconn.go
- status.go
- symbolicref.go
- tag.go
- unpackobjects.go
- updateindex.go
- updateref.go
- writetree.go