git

package
v0.0.0-...-f39f0c1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 18, 2022 License: MIT Imports: 42 Imported by: 0

Documentation

Index

Constants

View Source
const (
	ArchiveTar = ArchiveFormat(iota)
	ArchiveTarGzip
	ArchiveZip
)
View Source
const (
	ModeBlob    = EntryMode(0100644)
	ModeExec    = EntryMode(0100755)
	ModeSymlink = EntryMode(0120000)
	ModeCommit  = EntryMode(0160000)
	ModeTree    = EntryMode(0040000)
)
View Source
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

View Source
const (
	Stage0 = Stage(iota)
	Stage1
	Stage2
	Stage3
)

Valid merge stages.

View Source
const (
	MergeRecursive = MergeStrategy("recursive")
	MergeOctopus   = MergeStrategy("octopus")
)
View Source
const (
	UploadPackService = GitService(iota)
	ReceivePackService
)
View Source
const (
	StatusUntrackedNo = StatusUntrackedMode(iota)
	StatusUntrackedNormal
	StatusUntrackedAll
)
View Source
const (
	StatusIgnoreSubmodulesNone = StatusIgnoreSubmodules(iota)
	StatusIgnoreSubmodulesUntracked
	StatisIgnoreSubmodulesDirty
	StatusIgnoreSubmodulesAll
)

Variables

View Source
var AlreadyUpToDate = fmt.Errorf("Already up-to-date.")
View Source
var DetachedHead error = errors.New("In Detached HEAD state")
View Source
var InvalidBranch error = errors.New("Invalid branch")
View Source
var InvalidCommit error = errors.New("Invalid commit")
View Source
var InvalidHead error = errors.New("Invalid HEAD")
View Source
var InvalidIndex error = errors.New("Invalid index")
View Source
var InvalidObject error = errors.New("Invalid object")
View Source
var InvalidTree error = errors.New("Invalid tree")
View Source
var NoGlobalConfig = fmt.Errorf("No global .gitconfig file exists")

Functions

func Apply

func Apply(c *Client, opts ApplyOptions, patches []File) error

func Archive

func Archive(c *Client, opts ArchiveOptions, tree Treeish, paths []File) error

func ArchiveFormatList

func ArchiveFormatList() map[string]ArchiveFormat

Return the list of supported archive file format

func CatFile

func CatFile(c *Client, typ string, s Sha1, opts CatFileOptions) (string, error)

func CatFileBatch

func CatFileBatch(c *Client, opts CatFileOptions, r io.Reader, w io.Writer) error

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 Clean

func Clean(c *Client, opts CleanOptions, files []File) error

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

func ForEachRefCallback(c *Client, prefix string, callback func(*Client, Ref) error) error

Calls callback for each ref under c's GitDir which has prefix as a prefix.

func Fsck

func Fsck(c *Client, stderr io.Writer, opts FsckOptions, objects []string) (errs []error)

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 GeneratePatch(c *Client, options DiffCommonOptions, diffs []HashDiff, dst io.Writer) error

func Grep

func Grep(c *Client, opts GrepOptions, pattern string, tree Treeish, pathspec []File) error

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

func MkTreeBatch(c *Client, opts MkTreeOptions, r io.Reader, w io.Writer) error

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 Push

func Push(c *Client, opts PushOptions, r Remote, refs []Refname) error

func ReadDeltaOffset

func ReadDeltaOffset(src flate.Reader) (uint64, []byte)

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 ReadVariable(src flate.Reader) uint64

func ReflogExists

func ReflogExists(c *Client, r Refname) bool

Returns true if a reflog exists for refname r under client.

func ReflogExpire

func ReflogExpire(c *Client, opts ReflogExpireOptions, refpatterns []string) error

func RemoteAdd

func RemoteAdd(c *Client, opts RemoteAddOptions, name, url string) error

func RemoteGetURL

func RemoteGetURL(c *Client, opts RemoteGetURLOptions, r Remote) ([]string, error)

Implements the "git remote get-url" command.

func RemoteShow

func RemoteShow(c *Client, opts RemoteShowOptions, r Remote, w io.Writer) error

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 RevListCallback(c *Client, opt RevListOptions, includes, excludes []Commitish, callback func(Sha1) error) error

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 Rm

func Rm(c *Client, opts RmOptions, files []File) error

func SendPack

func SendPack(c *Client, opts SendPackOptions, r Remote, refs []Refname) error

func Show

func Show(c *Client, opts ShowOptions, objects []string) error

Show implementes the "git show" command.

func Status

func Status(c *Client, opts StatusOptions, files []File) (string, error)

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 TagCommit

func TagCommit(c *Client, opts TagOptions, tagname string, cmt Commitish, msg string) error

func TagDelete

func TagDelete(c *Client, opts TagOptions, tagnames []Refname) 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

func UpdateRef(c *Client, opts UpdateRefOptions, ref string, cmt CommitID, reason string) error

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 AddOptions struct {
	Verbose            bool
	DryRun             bool
	Force              bool
	Interactive        bool
	Patch              bool
	Edit               bool
	Update             bool
	All                bool
	IgnoreRemoval      bool
	IntentToAdd        bool
	Refresh            bool
	IgnoreErrors       bool
	IgnoreMissing      bool
	NoWarnEmbeddedRepo bool
	Chmod              BitSetter
}

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 ArchiveOptions struct {
	Verbose            bool
	List               bool
	WorktreeAttributes bool
	Format             ArchiveFormat
	BasePrefix         string
	OutputFile         *os.File
	CompressionLevel   int
}

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 BlobID

type BlobID Sha1

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 BranchList(c *Client, stdout io.Writer, opts BranchOptions, patterns []string) ([]Branch, error)

func GetBranch

func GetBranch(c *Client, branchname string) (Branch, error)

Returns a valid Branch object for an existing branch.

func (Branch) BranchName

func (b Branch) BranchName() string

Returns the branch name, without the refspec portion.

func (Branch) CommitID

func (b Branch) CommitID(c *Client) (CommitID, error)

Implements Commitish interface on Branch.

func (Branch) DeleteBranch

func (b Branch) DeleteBranch(c *Client) error

Delete a branch

func (Branch) Exists

func (b Branch) Exists(c *Client) bool

Returns true if the branch exists under c's GitDir

func (Branch) String

func (b Branch) String() string

Implements Stringer on Branch

func (Branch) TreeID

func (b Branch) TreeID(c *Client) (TreeID, error)

Implements Treeish on Branch.

type BranchOptions

type BranchOptions struct {
	All    bool
	Quiet  bool
	Move   bool
	Delete bool
	Force  bool
}

type ByName

type ByName []HashDiff

Implement the sort interface on *GitIndexEntry, so that it's easy to sort by name.

func (ByName) Len

func (g ByName) Len() int

func (ByName) Less

func (g ByName) Less(i, j int) bool

func (ByName) Swap

func (g ByName) Swap(i, j int)

type ByPath

type ByPath []*IndexEntry

Implement the sort interface on *GitIndexEntry, so that it's easy to sort by name.

func (ByPath) Len

func (g ByPath) Len() int

func (ByPath) Less

func (g ByPath) Less(i, j int) bool

func (ByPath) Swap

func (g ByPath) Swap(i, j int)

type CacheInfo

type CacheInfo struct {
	Mode EntryMode
	Sha1 Sha1
	Path IndexPath
}

type CatFileOptions

type CatFileOptions struct {
	Type, Size, Pretty bool
	ExitCode           bool
	AllowUnknownType   bool

	Batch, BatchCheck bool
	BatchFmt          string
	FollowSymlinks    bool
}

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 Init

func Init(c *Client, opts InitOptions, dir string) (*Client, error)

func NewClient

func NewClient(gitDir, workDir string) (*Client, error)

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) Close

func (c *Client) Close() error

func (*Client) CreateBranch

func (c *Client) CreateBranch(name string, commit Commitish) error

Create a new branch in the Client's git repository.

func (*Client) ExecEditor

func (c *Client) ExecEditor(f File) error

Will invoke the Client's editor to edit the file f.

func (*Client) GetAuthor

func (c *Client) GetAuthor(t *time.Time) Person

Returns the author that should be used for a commit message. If time t is provided,

func (*Client) GetBranches

func (c *Client) GetBranches() ([]Branch, error)

Return valid branches that a Client knows about.

func (*Client) GetCachedConfig

func (c *Client) GetCachedConfig(varname string) string

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

func (c *Client) GetCommitter(t *time.Time) (Person, error)

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

func (c *Client) GetConfig(varname string) string

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

func (c *Client) GetHeadBranch() Branch

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

func (c *Client) GetHeadCommit() (CommitID, error)

Gets the Commit of the current HEAD as a string.

func (*Client) GetObject

func (c *Client) GetObject(sha1 Sha1) (GitObject, error)

func (*Client) GetObjectMetadata

func (c *Client) GetObjectMetadata(sha1 Sha1) (string, uint64, error)

func (*Client) GetObjectsDir

func (c *Client) GetObjectsDir() File

Returns the .git/objects directory.

func (*Client) GetRemoteBranches

func (c *Client) GetRemoteBranches() (branches []Branch, err error)

Return valid branches that a Client knows about.

func (*Client) GetTagObject

func (c *Client) GetTagObject(tag Sha1) (GitTagObject, error)

func (*Client) HaveObject

func (c *Client) HaveObject(id Sha1) (found bool, packedfile File, err error)

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) IsBare

func (c *Client) IsBare() bool

Returns true if the repo is a bare repo.

func (*Client) IsInsideGitDir

func (c *Client) IsInsideGitDir(path File) bool

Returns true if the path is under the client's GitDir.

func (*Client) IsInsideWorkTree

func (c *Client) IsInsideWorkTree(path File) bool

Returns true if path is inside of the client's work tree.

func (*Client) ResetIndex

func (c *Client) ResetIndex(tree Treeish, indexname string) error

Resets the index to the Treeish tree and save the results in the file named indexname

func (*Client) ResetWorkTree

func (c *Client) ResetWorkTree() error

ResetWorkTree will replace all objects in c.WorkDir with the content from the index.

func (*Client) SetCachedConfig

func (c *Client) SetCachedConfig(varname string, value string)

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.

func (*Client) WriteObject

func (c *Client) WriteObject(objType string, rawdata []byte) (Sha1, error)

Writes an object into the Client's .git/objects/ directory. This will write the object loosely, and not use a packfile.

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 CommitIDFromString(s string) (CommitID, error)

func CommitTree

func CommitTree(c *Client, opts CommitTreeOptions, tree Treeish, parents []CommitID, message string) (CommitID, error)

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 NearestCommonParent(c *Client, com, other Commitish) (CommitID, error)

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

func (s CommitID) AncestorMap(c *Client) (map[CommitID]struct{}, error)

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) Ancestors

func (s CommitID) Ancestors(c *Client) ([]CommitID, error)

func (CommitID) CommitID

func (s CommitID) CommitID(c *Client) (CommitID, error)

func (CommitID) Format

func (c CommitID) Format(cl *Client, format string) (string, error)

func (CommitID) FormatMedium

func (c CommitID) FormatMedium(cl *Client) (string, error)

func (CommitID) GetAllObjects

func (c CommitID) GetAllObjects(cl *Client) ([]Sha1, error)

func (CommitID) GetAllObjectsExcept

func (c CommitID) GetAllObjectsExcept(cl *Client, excludeList map[Sha1]struct{}) ([]Sha1, error)

returns a list of all objects in c excluding those in excludeList. It also populates excludeList with any objects encountered.

func (CommitID) GetAuthor

func (cmt CommitID) GetAuthor(c *Client) (Person, error)

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

func (cmt CommitID) GetCommitter(c *Client) (Person, error)

Returns the committer of the commit.

func (CommitID) GetCommitterDate

func (cmt CommitID) GetCommitterDate(c *Client) (time.Time, error)

func (CommitID) GetDate

func (cmt CommitID) GetDate(c *Client) (time.Time, error)

func (CommitID) IsAncestor

func (child CommitID) IsAncestor(c *Client, parent Commitish) bool

func (CommitID) Parents

func (cmt CommitID) Parents(c *Client) ([]CommitID, error)

Returns all direct parents of commit c.

func (CommitID) String

func (s CommitID) String() string

func (CommitID) TreeID

func (c CommitID) TreeID(cl *Client) (TreeID, error)

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 CommitTreeOptions struct {
	GPGKey GPGKeyId

	NoGPGSign bool
}

type Commitish

type Commitish interface {
	CommitID(c *Client) (CommitID, error)
}

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

func ModeFromString(s string) (EntryMode, error)

func (EntryMode) TreeType

func (e EntryMode) TreeType() string

TreeType prints the entry mode as the type that shows up in the "git ls-tree" command.

type FetchOptions

type FetchOptions struct {
	Force bool
	FetchPackOptions
}

type FetchPackOptions

type FetchPackOptions struct {
	All                            bool
	Stdin                          io.Reader
	StatelessRPC                   bool
	Quiet                          bool
	Keep                           bool
	Thin                           bool
	IncludeTag                     bool
	UploadPack                     string
	Depth                          int32
	DeepenRelative                 bool
	NoProgress                     bool
	CheckSelfContainedAndConnected bool
	Verbose                        bool
}

type File

type File string

A file represents a file (or directory) relative to os.Getwd()

func (File) Append

func (f File) Append(val string) error

Appends the value val to the end of the file f. Not that f must already exist.

func (File) CTime

func (f File) CTime() (uint32, uint32)

func (File) Create

func (f File) Create() (*os.File, error)

func (File) Exists

func (f File) Exists() bool

Determines if the file exists on the filesystem.

func (File) INode

func (f File) INode() uint32

func (File) IndexPath

func (f File) IndexPath(c *Client) (IndexPath, error)

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) IsDir

func (f File) IsDir() bool

func (File) IsInSubmodule

func (f File) IsInSubmodule(c *Client) (bool, File, error)

Returns true if the file is inside a submodule and the submodule file. FIXME: invert this when submodules are implemented

func (f File) IsInsideSymlink() (bool, error)
func (f File) IsSymlink() bool

func (File) Lstat

func (f File) Lstat() (os.FileInfo, error)

Returns lstat information for the given file.

func (File) MTime

func (f File) MTime() (int64, error)

func (File) MatchGlob

func (f File) MatchGlob(pattern string) bool

Returns true if f matches the filesystem glob pattern pattern.

func (File) Open

func (f File) Open() (*os.File, error)

func (File) ReadAll

func (f File) ReadAll() (string, error)

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

func (f File) ReadFirstLine() (string, error)

Reads the first line of File. (This is primarily to extract commit message lines for reflogs)

func (File) Remove

func (f File) Remove() error

func (File) Stat

func (f File) Stat() (os.FileInfo, error)

Returns stat information for the given file.

func (File) String

func (f File) String() string

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 FsckOptions struct {
	Unreachable      bool
	NoDangling       bool
	Root             bool
	Tags             bool
	Cache            bool
	NoReflogs        bool
	NoFull           bool
	ConnectivityOnly bool
	Strict           bool
	Verbose          bool
	LostFound        bool
	NameObjects      bool
	NoProgress       bool
}

type GPGKeyId

type GPGKeyId string

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 LoadGlobalConfig() (GitConfig, error)

func LoadLocalConfig

func LoadLocalConfig(c *Client) (GitConfig, error)

func ParseConfig

func ParseConfig(configFile io.Reader) GitConfig

func (*GitConfig) GetConfig

func (g *GitConfig) GetConfig(name string) (string, int)

func (*GitConfig) GetConfigList

func (g *GitConfig) GetConfigList() []string

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) SetConfig

func (g *GitConfig) SetConfig(name, value string)

func (*GitConfig) Unset

func (g *GitConfig) Unset(name string) int

func (GitConfig) WriteConfig

func (g GitConfig) WriteConfig() error

func (GitConfig) WriteFile

func (g GitConfig) WriteFile(w io.Writer)

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

type GitConfigValues map[string]string

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.

func (GitDir) Create

func (gd GitDir) Create(f File) (*os.File, error)

Creates a file relative to GitDir. There should not be a leading slash.

func (GitDir) Exists

func (g GitDir) Exists() bool

func (GitDir) File

func (g GitDir) File(f File) File

Returns a file named f, relative to GitDir

func (GitDir) Open

func (gd GitDir) Open(f File) (*os.File, error)

Opens a file relative to GitDir. There should not be a leading slash.

func (GitDir) ReadFile

func (g GitDir) ReadFile(f File) ([]byte, error)

ReadFile reads a file under the GitDir and returns the contents.

func (GitDir) ReadIndex

func (d GitDir) ReadIndex() (*Index, error)

Reads the index file from the GitDir and returns a Index object. If the index file does not exist, it will return a new empty Index.

func (GitDir) String

func (g GitDir) String() string

func (GitDir) WriteFile

func (g GitDir) WriteFile(f File, data []byte, perm os.FileMode) error

WriteFile writes data to the file f, using permission perm for the file if it does not already exist.

WriteFile will overwrite existing file contents.

type GitObject

type GitObject interface {
	GetType() string
	GetContent() []byte
	GetSize() int

	// Print the object in human readable format.
	String() string
}

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

type HashDiff struct {
	Name             IndexPath
	Src, Dst         TreeEntry
	SrcSize, DstSize uint
}

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 DiffTree

func DiffTree(c *Client, opt *DiffTreeOptions, tree1, tree2 Treeish, paths []string) ([]HashDiff, error)

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.)

func (HashDiff) String

func (h HashDiff) String() string

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) Matches

func (ip IgnorePattern) Matches(ignorePath string, isDir bool) bool

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 NewIndex

func NewIndex() *Index

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

func UpdateIndex(c *Client, idx *Index, opts UpdateIndexOptions, files []File) (*Index, error)

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 UpdateIndexFromReader(c *Client, opts UpdateIndexOptions, r io.Reader) (*Index, error)

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:

  1. write git object blob of file contents to .git/objects
  2. normalize os.File name to path relative to gitRoot
  3. 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) GetMap

func (i *Index) GetMap() IndexMap

func (Index) GetSha1

func (g Index) GetSha1(path IndexPath) Sha1

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

func (g *Index) RemoveFile(file IndexPath)

Remove the first instance of file from the index. (This will usually be stage 0.)

func (*Index) RemoveUnmergedStages

func (g *Index) RemoveUnmergedStages(c *Client, path IndexPath) error

Remove any unmerged (non-stage 0) stage from the index for the given path

func (*Index) ResetIndex

func (g *Index) ResetIndex(c *Client, tree Treeish) error

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 (g *Index) SetSkipWorktree(c *Client, path IndexPath, value bool) error

func (Index) String

func (g Index) String() string

func (Index) WriteIndex

func (g Index) WriteIndex(file io.Writer) error

This will write a new index file to w by doing the following:

  1. Sort the objects in g.Index to ascending order based on name and update g.NumberIndexEntries
  2. Write g.fixedGitIndex to w
  3. for each entry in g.Objects, write it to w.
  4. 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

func GetIndexMap(c *Client, t Treeish) (IndexMap, error)

Converts the Tree into an IndexEntries, to simplify comparisons between Trees and Indexes

func (IndexMap) Contains

func (im IndexMap) Contains(path IndexPath) bool

func (IndexMap) HasDir

func (im IndexMap) HasDir(path IndexPath) bool

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

func (f IndexPath) FilePath(c *Client) (File, error)

Returns the IndexPath as a filename relative to Getwd, in order to convert from Indexes to Working directory paths.

func (IndexPath) IsClean

func (f IndexPath) IsClean(c *Client, s Sha1) bool

Returns true if the file on the filesystem hashes to Sha1, (which is usually the hash from the index) to determine if the file is clean.

func (IndexPath) String

func (f IndexPath) String() string

type IndexStageEntry

type IndexStageEntry struct {
	IndexPath
	Stage
}

type InitOptions

type InitOptions struct {
	Quiet bool
	Bare  bool

	Template File

	// Not implemented
	SeparateGitDir File

	// Not implemented
	Shared os.FileMode
}

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 LsRemoteOptions struct {
	Heads, Tags   bool
	RefsOnly      bool
	Quiet         bool
	UploadPack    string
	ExitCode      bool
	GetURL        bool
	SymRef        bool
	Sort          string
	ServerOptions []string
}

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 MergeBaseOptions struct {
	IsAncestor bool
	Octopus    bool
}

type MergeFileFile

type MergeFileFile struct {
	Filename File
	Label    string
}

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 MkTreeOptions struct {
	NilTerminate bool
	AllowMissing bool
	Batch        bool
}

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 PackObjectsOptions struct {
	// The number of entries to use for the sliding window for delta
	// calculations
	Window int

	// Use offset deltas instead of refdeltas when calculating delta
	DeltaBaseOffset bool
}

type PackProtocolMode

type PackProtocolMode uint8

A PackProtocolMode determines how calling Read on a RemoteConn returns data to the caller.

type PackfileHeader

type PackfileHeader struct {
	Signature [4]byte
	Version   uint32
	Size      uint32
}

func (PackfileHeader) ReadHeaderSize

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) GetObject

func (idx PackfileIndexV2) GetObject(r io.ReaderAt, s Sha1) (GitObject, error)

func (PackfileIndexV2) GetObjectMetadata

func (idx PackfileIndexV2) GetObjectMetadata(r io.ReaderAt, s Sha1) (GitObject, error)

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

type ParsedRevision struct {
	Id       Sha1
	Excluded bool
}

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) Ancestors

func (pr ParsedRevision) Ancestors(c *Client) ([]CommitID, error)

func (ParsedRevision) CommitID

func (pr ParsedRevision) CommitID(c *Client) (CommitID, error)

func (ParsedRevision) IsAncestor

func (pr ParsedRevision) IsAncestor(c *Client, parent Commitish) bool

func (ParsedRevision) TreeID

func (pr ParsedRevision) TreeID(c *Client) (TreeID, error)

type Pattern

type Pattern string

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.

func (Person) String

func (p Person) String() string

type PktLine

type PktLine string

func PktLineEncode

func PktLineEncode(line []byte) (PktLine, error)

func PktLineEncodeNoNl

func PktLineEncodeNoNl(line []byte) (PktLine, error)

func (PktLine) String

func (p PktLine) String() string

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

func FetchPack(c *Client, opts FetchPackOptions, rm Remote, wants []Refname) ([]Ref, error)

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 LsRemote

func LsRemote(c *Client, opts LsRemoteOptions, r Remote, patterns []string) ([]Ref, error)

func ShowRef

func ShowRef(c *Client, opts ShowRefOptions, patterns []string) ([]Ref, error)

func (Ref) CommitID

func (r Ref) CommitID(c *Client) (CommitID, error)

func (Ref) Matches

func (r Ref) Matches(pattern string) bool

Matches determines whether a Ref matches a pattern according to the rules of ShowRef

func (Ref) MatchesRefSpecSrc

func (r Ref) MatchesRefSpecSrc(spec RefSpec) (match bool, dst Refname)

MatchesRSSrc determines whether the ref matches the src of a refspec. If it matches the src, it also returns the destination

func (Ref) RefName

func (r Ref) RefName() string

Gets the "ref name" of the ref suitable for showing in places

like git log and git rev-list.

func (Ref) String

func (r Ref) String() string

func (Ref) TabString

func (r Ref) TabString() string

func (Ref) TreeID

func (r Ref) TreeID(c *Client) (TreeID, error)

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) CommitID

func (r RefSpec) CommitID(c *Client) (CommitID, error)

func (RefSpec) Dst

func (r RefSpec) Dst() Refname

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) File

func (r RefSpec) File(c *Client) File

Returns the file that holds r.

func (RefSpec) HasPrefix

func (r RefSpec) HasPrefix(s string) bool

func (RefSpec) Sha1

func (r RefSpec) Sha1(c *Client) (Sha1, error)

func (RefSpec) Src

func (r RefSpec) Src() Refname

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.

func (RefSpec) String

func (r RefSpec) String() string

func (RefSpec) TreeID

func (r RefSpec) TreeID(c *Client) (TreeID, error)

func (RefSpec) Value

func (r RefSpec) Value(c *Client) (string, error)

Returns the value of RefSpec in Client's GitDir, or the empty string if it doesn't exist.

type ReflogDeleteOptions

type ReflogDeleteOptions struct{}

type ReflogExpireOptions

type ReflogExpireOptions struct {
	ReflogDeleteOptions

	Expire string
	All    bool
}

type Refname

type Refname string

func (Refname) CommitID

func (rn Refname) CommitID(c *Client) (CommitID, error)

func (Refname) Exists

func (rn Refname) Exists(c *Client) bool

returns true if the reference name exists under the client's GitDir.

func (Refname) LocalName

func (rn Refname) LocalName() Refname

Returns the local part of a refname when given a ref like refs/heads/foo:refs/heads/bar for send-pack

func (Refname) RemoteName

func (rn Refname) RemoteName() Refname

func (Refname) String

func (rn Refname) String() string

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) FetchURL

func (r Remote) FetchURL(c *Client) (string, error)

Returns the URL used to fetch from remote.

func (Remote) GetLocalRefs

func (r Remote) GetLocalRefs(c *Client) ([]Ref, error)

Gets a list of local references cached for this Remote

func (Remote) IsFile

func (r Remote) IsFile() bool

Returns true if the remote points to a local filesystem path.

func (Remote) IsStateless

func (r Remote) IsStateless(c *Client) (bool, error)

func (Remote) Name

func (r Remote) Name() string

func (Remote) PushURL

func (r Remote) PushURL(c *Client) (string, error)

Returns the URL used to push to a remote.

func (Remote) RemoteURL

func (r Remote) RemoteURL(c *Client) (string, error)

func (Remote) String

func (r Remote) String() string

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 ResetOptions struct {
	Quiet bool

	Soft, Mixed, Hard, Merge, Keep bool
}

type RevListOptions

type RevListOptions struct {
	Quiet, Objects bool
	MaxCount       *uint
	VerifyObjects  bool
	All            bool
}

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
	SharedIndexPath 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 RevertOptions struct {
	Edit bool

	MergeParent int

	NoCommit bool
	SignOff  bool

	MergeStrategy       string
	MergeStrategyOption string

	Continue, Quit, Abort bool
}

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 SendPackOptions struct {
	All    bool
	DryRun bool
	Force  bool

	Verbose bool
	Thin    bool
	Atomic  bool

	Signed      bool
	ReceivePack string
}

type Sha1

type Sha1 [20]byte

func HashFile

func HashFile(t, filename string) (Sha1, []byte, error)

func HashReader

func HashReader(t string, r io.Reader) (Sha1, []byte, error)

Hashes the data of r with object type t, and returns the hash, and the data that was read from r.

func HashReaderWithSize

func HashReaderWithSize(t string, sz int64, r io.Reader) (Sha1, error)

func HashSlice

func HashSlice(t string, data []byte) (Sha1, []byte, error)

func Mktag

func Mktag(c *Client, r io.Reader) (Sha1, error)

Implements mktag by reading the input from r in the format described in git-mktag(1).

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 RevList

func RevList(c *Client, opt RevListOptions, w io.Writer, includes, excludes []Commitish) ([]Sha1, error)

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 Sha1FromSlice(s []byte) (Sha1, error)

func Sha1FromString

func Sha1FromString(s string) (Sha1, error)

func UnpackObjects

func UnpackObjects(c *Client, opts UnpackObjectsOptions, r io.Reader) ([]Sha1, error)

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

func (s Sha1) CompressedWriter(c *Client, w io.Writer) error

Writes the object to w in compressed form

func (Sha1) PackEntryType

func (id Sha1) PackEntryType(c *Client) PackEntryType

func (Sha1) String

func (s Sha1) String() string

func (Sha1) Type

func (id Sha1) Type(c *Client) string

Returns the git type of the object this Sha1 represents

func (Sha1) UncompressedSize

func (s Sha1) UncompressedSize(c *Client) uint64

type ShowOptions

type ShowOptions struct {
	DiffOptions
	Format FormatString
}

type ShowRefOptions

type ShowRefOptions struct {
	IncludeHead bool

	Tags, Heads bool

	Dereference bool

	Sha1Only bool

	Verify bool

	Abbrev int

	Quiet bool

	ExcludeExisting string
}

type Stage

type Stage uint8

A Stage represents a git merge stage in the index.

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) CommitID

func (s SymbolicRef) CommitID(c *Client) (CommitID, error)

func (SymbolicRef) String

func (s SymbolicRef) String() string

type SymbolicRefOptions

type SymbolicRefOptions struct {
	Quiet  bool
	Delete bool
	Short  bool
}

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 TreeEntry

type TreeEntry struct {
	Sha1     Sha1
	FileMode EntryMode
}

A TreeEntry represents an entry inside of a Treeish.

type TreeID

type TreeID Sha1

func MkTree

func MkTree(c *Client, opts MkTreeOptions, r io.Reader) (TreeID, error)

Mktree reads a tree from r in the same format as ls-tree and returns the TreeID of the converted tree.

func WriteTree

func WriteTree(c *Client, opts WriteTreeOptions) (TreeID, error)

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.

func (TreeID) String

func (s TreeID) String() string

func (TreeID) TreeID

func (t TreeID) TreeID(cl *Client) (TreeID, error)

Ensures the Tree implements Treeish

type Treeish

type Treeish interface {
	TreeID(c *Client) (TreeID, error)
}

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 UpdateRefOptions struct {
	Delete bool

	NoDeref      bool
	CreateReflog bool
	OldValue     Commitish

	// Not implemented
	Stdin         io.Reader
	NullTerminate bool
}

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

func (WorkDir) String

func (f WorkDir) String() string

type WriteTreeOptions

type WriteTreeOptions struct {
	MissingOk bool
	Prefix    string
}

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.

Directories

Path Synopsis
Delta provides functions for reading and calculating git styles deltas.
Delta provides functions for reading and calculating git styles deltas.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL