git4go

package module
v0.0.0-...-2308fe3 Latest Latest
Warning

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

Go to latest
Published: Sep 20, 2017 License: GPL-2.0, ISC, LGPL-2.1, + 1 more Imports: 26 Imported by: 1

README

git4go
==========

Pure Golang implementation of git repository operation library. It has as same API as [git2go](https://github.com/libgit2/git2go) - ([libgit2](https://libgit2.github.com) wrapper for Golang).

License
============

``git4go`` is under GPL2 **with linking exception**. This is a translation of libgit2 and it uses same license.

This means you can link to and use the library from any program, proprietary or open source; paid or
gratis.  However, you cannot modify git4go and distribute it without supplying the source.

See the COPYING file for the full license text.

GPLv2 specifies "translation to other language" means "modification", so I have to use GPLv2 in my understanding (if not, I want to move LGPLv3 or something).

Documentation

Index

Constants

View Source
const (
	GitPackedRefsFile        = "packed-refs"
	GitSymbolReference       = "ref: "
	PackPeelingNone     byte = 0
	PackPeelingStandard byte = 1
	PackPeelingFull     byte = 2
	PackRefHasPeel      byte = 1
	PackRefWasLoose     byte = 2
	PackRefCannotPeel   byte = 4
	PackRefShadowed     byte = 8
)
View Source
const (
	ConfigFileNameSystem string = "gitconfig"
	ConfigFileNameGlobal string = ".gitconfig"
	ConfigFileNameXDG    string = "config"
	ConfigFileNameInrepo string = "config"

	ConfigLevelSystem  ConfigLevel = 1
	ConfigLevelXDG     ConfigLevel = 2
	ConfigLevelGlobal  ConfigLevel = 3
	ConfigLevelLocal   ConfigLevel = 4
	ConfigLevelApp     ConfigLevel = 5
	ConfigLevelHighest ConfigLevel = -1
)
View Source
const (
	FNMNoEscape   FnMatchFlag = 1 << iota
	FNMPathName   FnMatchFlag = 1 << iota
	FNMPeriod     FnMatchFlag = 1 << iota
	FNMLeadingDir FnMatchFlag = 1 << iota
	FNMCaseFold   FnMatchFlag = 1 << iota

	RangeMatch   RangeMatchResult = 1
	RangeNoMatch RangeMatchResult = 0
	RangeError   RangeMatchResult = -1
)
View Source
const (
	GitOidRawSize                    = 20
	GitOidHexSize                    = 40
	GitOidMinimumPrefixLength        = 4
	GitObjectDirMode          uint32 = 0777
	GitObjectFileMode         uint32 = 0444
)
View Source
const (
	GitIndexFile     = "index"
	GitIndexFileMode = 0666

	IndexAddDefault              IndexAddOpts = 0
	IndexAddForce                IndexAddOpts = 1
	IndexAddDisablePathspecMatch IndexAddOpts = 2
	IndexAddCheckPathspec        IndexAddOpts = 4

	IndexEntryNameMask   IndexEntryFlag = 0x0fff
	IndexEntryStageMask  IndexEntryFlag = 0x3000
	IndexEntryStageShift int            = 12
	IndexEntryExtended   uint16         = 0x4000

	IndexEntryIntentToAdd     IndexEntryExtendedFlag = 1 << 13
	IndexEntrySkipWorkTree    IndexEntryExtendedFlag = 1 << 14
	IndexEntryExtended2       IndexEntryExtendedFlag = 1 << 15
	IndexEntryExtendedFlags   IndexEntryExtendedFlag = IndexEntryIntentToAdd + IndexEntrySkipWorkTree
	IndexEntryUpdate          IndexEntryExtendedFlag = 1 << 0
	IndexEntryRemove          IndexEntryExtendedFlag = 1 << 1
	IndexEntryUpToDate        IndexEntryExtendedFlag = 1 << 2
	IndexEntryAdded           IndexEntryExtendedFlag = 1 << 3
	IndexEntryHashed          IndexEntryExtendedFlag = 1 << 4
	IndexEntryUnHashed        IndexEntryExtendedFlag = 1 << 5
	IndexEntryWTRemove        IndexEntryExtendedFlag = 1 << 6 /**< remove in work directory */
	IndexEntryConflicted      IndexEntryExtendedFlag = 1 << 7
	IndexEntryUnpacked        IndexEntryExtendedFlag = 1 << 8
	IndexEntryNewSkipWorkTree IndexEntryExtendedFlag = 1 << 9

	IndexHeaderSize = 12
	IndexFooterSize = 20

	IndexVersionNumber    = 2
	IndexVersionNumberExt = 3

	IndexHeaderSig uint32 = 0x44495243

	IndexMinimumEntrySize = 62

	IndexCapIgnoreCase IndexCapFlag = 1
	IndexCapNoFilemode IndexCapFlag = 2
	IndexCapNoSimlinks IndexCapFlag = 4
	IndexCapFromOwner  IndexCapFlag = -1

	IndexApplyFile IndexMatchResult = 0
	IndexSkipFile  IndexMatchResult = 1
	IndexAbort     IndexMatchResult = -1

	StageAncestor IndexStage = 1
	StageOurs     IndexStage = 2
	StageTheirs   IndexStage = 3
)
View Source
const (
	GitLoosePriority      = 1
	GitPackedPriority     = 2
	GitAlternatesMaxDepth = 5
	GitAlternatesFile     = "info/alternates"
)
View Source
const (
	ReferenceOid        ReferenceType = 1
	ReferenceSymbolic   ReferenceType = 2
	DefaultNestingLevel               = 5
	MaxNestingLevel                   = 10
	GitRefNameMax                     = 1024
)
View Source
const (
	GIT_REPOSITORY_OPEN_NO_FLAG   uint32 = 0
	GIT_REPOSITORY_OPEN_NO_SEARCH uint32 = (1 << 0)
	GIT_REPOSITORY_OPEN_CROSS_FS  uint32 = (1 << 1)
	GIT_REPOSITORY_OPEN_BARE      uint32 = (1 << 2)
	GitObjectsDir                 string = "objects/"
	GitHeadFile                   string = "HEAD"
	GitRefsDir                    string = "refs/"
	GitRefsTagsDir                string = "refs/tags"
)
View Source
const (
	DELTA_SIZE_MIN = 4
)

Variables

View Source
var IndexExtConflictNameSig []byte = []byte("NAME")
View Source
var IndexExtTreeCacheSig []byte = []byte("TREE")
View Source
var IndexExtUnmergedSig []byte = []byte("REUC")

Functions

func ApplyDelta

func ApplyDelta(base, delta []byte) ([]byte, error)

func ConfigFindGlobal

func ConfigFindGlobal() (string, error)

func ConfigFindSystem

func ConfigFindSystem() (string, error)

func ConfigFindXDG

func ConfigFindXDG() (string, error)

func CreateDelta

func CreateDelta(source, target []byte, maxDeltaSize uint64) ([]byte, error)

func Discover

func Discover(start string, acrossFs bool, ceilingDirs []string) (string, error)

func Is64bit

func Is64bit() bool

func IsErrorCode

func IsErrorCode(err error, c ErrorCode) bool

func MSB

func MSB(x uint64, bit uint) bool

func MakeGitError

func MakeGitError(message string, errorCode ErrorCode) error

func PutPack

func PutPack(pack *PackFile) error

func SelectByArch

func SelectByArch(for32, for64 uint64) uint64

Types

type Blob

type Blob struct {
	// contains filtered or unexported fields
}

func (*Blob) Contents

func (b *Blob) Contents() []byte

func (*Blob) Id

func (o *Blob) Id() *Oid

func (*Blob) Owner

func (o *Blob) Owner() *Repository

func (*Blob) Peel

func (b *Blob) Peel(targetType ObjectType) (Object, error)

func (*Blob) Size

func (b *Blob) Size() int64

func (*Blob) Type

func (b *Blob) Type() ObjectType

type BlobChunkCallback

type BlobChunkCallback func(maxLen int) ([]byte, error)

type Blocks

type Blocks struct {
	// contains filtered or unexported fields
}

func NewBlocks

func NewBlocks(n int) *Blocks

type Bucket

type Bucket struct {
	// contains filtered or unexported fields
}

type Commit

type Commit struct {
	Parents []*Oid
	// contains filtered or unexported fields
}

func (*Commit) Amend

func (c *Commit) Amend(refname string, author, committer *Signature, message string, tree *Tree) (*Oid, error)

func (Commit) Author

func (c Commit) Author() *Signature

func (Commit) Committer

func (c Commit) Committer() *Signature

func (*Commit) Id

func (o *Commit) Id() *Oid

func (*Commit) Message

func (c *Commit) Message() string

func (*Commit) NthGenAncestor

func (c *Commit) NthGenAncestor(n uint) (*Commit, error)

func (*Commit) Owner

func (o *Commit) Owner() *Repository

func (*Commit) Parent

func (c *Commit) Parent(n int) *Commit

func (*Commit) ParentCount

func (c *Commit) ParentCount() int

func (*Commit) ParentId

func (c *Commit) ParentId(n int) *Oid

func (*Commit) Peel

func (c *Commit) Peel(targetType ObjectType) (Object, error)

func (*Commit) Summary

func (c *Commit) Summary() string

func (Commit) Tree

func (c Commit) Tree() (*Tree, error)

func (Commit) TreeId

func (c Commit) TreeId() *Oid

func (*Commit) Type

func (t *Commit) Type() ObjectType

type CommitListFlag

type CommitListFlag uint
const (
	Parent1 CommitListFlag = 1 << iota
	Parent2 CommitListFlag = 1 << iota
	Result  CommitListFlag = 1 << iota
	Stale   CommitListFlag = 1 << iota
)

type Config

type Config struct {
	// contains filtered or unexported fields
}

func NewConfig

func NewConfig() (*Config, error)

func (*Config) AddFile

func (c *Config) AddFile(path string, level ConfigLevel, force bool) error

func (*Config) LookupBool

func (c *Config) LookupBool(name string) (bool, error)

func (*Config) LookupBooleanWithDefaultValue

func (c *Config) LookupBooleanWithDefaultValue(name string) (bool, error)

func (*Config) LookupInt32

func (c *Config) LookupInt32(name string) (int32, error)

func (*Config) LookupInt64

func (c *Config) LookupInt64(name string) (int64, error)

func (*Config) LookupString

func (c *Config) LookupString(name string) (string, error)

func (*Config) LookupStringWithDefaultValue

func (c *Config) LookupStringWithDefaultValue(name string) (string, error)

func (*Config) SetBool

func (c *Config) SetBool(name string, value bool) (err error)

func (*Config) SetInt32

func (c *Config) SetInt32(name string, value int32) (err error)

func (*Config) SetInt64

func (c *Config) SetInt64(name string, value int64) (err error)

func (*Config) SetString

func (c *Config) SetString(name, value string) (err error)

type ConfigLevel

type ConfigLevel int

type DeltaIndex

type DeltaIndex struct {
	MemSize  uint64
	Source   []byte
	HashMask uint32
	Hash     []*DeltaIndexEntry
}

type DeltaIndexEntry

type DeltaIndexEntry struct {
	Ptr  int
	Val  uint
	Next *DeltaIndexEntry
}

type ErrorCode

type ErrorCode int
const (
	// Requested object could not be found
	ErrNotFound ErrorCode = -3
	// Operation not allowed on bare repository
	ErrBareRepository ErrorCode = -8
	// The operation is not valid for a directory
	ErrDirectory ErrorCode = -23
	// Signals end of iteration with iterator
	ErrIterOver ErrorCode = -31
)

type Filemode

type Filemode uint32
const (
	FilemodeTree           Filemode = 0040000
	FilemodeBlob           Filemode = 0100644
	FilemodeBlobExecutable Filemode = 0100755
	FilemodeLink           Filemode = 0120000
	FilemodeCommit         Filemode = 0160000
)

type FnMatchFlag

type FnMatchFlag int

type ForEachReferenceCallback

type ForEachReferenceCallback func(*Reference) error

type ForEachReferenceNameCallback

type ForEachReferenceNameCallback func(string) error

type GitError

type GitError struct {
	Message string
	Code    ErrorCode
}

func (GitError) Error

func (e GitError) Error() string

type Index

type Index struct {
	Entries []*IndexEntry
	// contains filtered or unexported fields
}

func NewIndex

func NewIndex() (*Index, error)

NewIndex allocates a new index. It won't be associated with any file on the filesystem or repository

func OpenIndex

func OpenIndex(path string) (*Index, error)

OpenIndex creates a new index at the given path. If the file does not exist it will be created when Write() is called.

func (*Index) Add

func (v *Index) Add(entry *IndexEntry) error

Add adds or replaces the given entry to the index, making a copy of the data

func (*Index) AddAll

func (v *Index) AddAll(pathSpecs []string, flags IndexAddOpts, callback IndexMatchedPathCallback) error

todo

func (*Index) AddByPath

func (v *Index) AddByPath(path string) error

func (*Index) AddConflict

func (v *Index) AddConflict(ancestor *IndexEntry, our *IndexEntry, their *IndexEntry) error

todo: not implemented yet

func (*Index) AddFromBuffer

func (v *Index) AddFromBuffer(sourceEntry *IndexEntry, buffer []byte) error

todo: not implemented yet

func (*Index) Caps

func (v *Index) Caps() IndexCapFlag

func (*Index) CleanupConflicts

func (v *Index) CleanupConflicts()

FIXME: this might return an error

func (*Index) Clear

func (v *Index) Clear() error

func (*Index) ConflictIterator

func (v *Index) ConflictIterator() (*IndexConflictIterator, error)

func (*Index) EntryByIndex

func (v *Index) EntryByIndex(index int) (*IndexEntry, error)

func (*Index) EntryCount

func (v *Index) EntryCount() uint

func (*Index) Find

func (v *Index) Find(path string) int

func (*Index) GetConflict

func (v *Index) GetConflict(path string) (IndexConflict, error)

func (*Index) HasConflicts

func (v *Index) HasConflicts() bool

func (Index) Owner

func (v Index) Owner() *Repository

func (*Index) Path

func (v *Index) Path() string

Path returns the index' path on disk or an empty string if it exists only in memory.

func (*Index) Read

func (v *Index) Read(force bool) error

func (*Index) ReadTree

func (v *Index) ReadTree(tree *Tree) error

ReadTree replaces the contents of the index with those of the given tree

func (*Index) Remove

func (v *Index) Remove(path string, stage IndexStage) error

func (*Index) RemoveAll

func (v *Index) RemoveAll(pathSpecs []string, callback IndexMatchedPathCallback) error

todo

func (*Index) RemoveByPath

func (v *Index) RemoveByPath(path string) error

func (*Index) RemoveConflict

func (v *Index) RemoveConflict(path string) error

todo: not implemented yet

func (*Index) SetCaps

func (v *Index) SetCaps(caps IndexCapFlag) error

func (*Index) UpdateAll

func (v *Index) UpdateAll(pathSpecs []string, callback IndexMatchedPathCallback) error

todo

func (*Index) Write

func (v *Index) Write() error

todo

func (*Index) WriteTree

func (v *Index) WriteTree() (*Oid, error)

todo

func (*Index) WriteTreeTo

func (v *Index) WriteTreeTo(repo *Repository) (*Oid, error)

todo

type IndexAddOpts

type IndexAddOpts uint

type IndexCapFlag

type IndexCapFlag int

type IndexCompareFunc

type IndexCompareFunc func(string, string) bool

type IndexConflict

type IndexConflict struct {
	Ancestor *IndexEntry
	Our      *IndexEntry
	Their    *IndexEntry
}

type IndexConflictIterator

type IndexConflictIterator struct {
	// contains filtered or unexported fields
}

func (*IndexConflictIterator) Index

func (v *IndexConflictIterator) Index() *Index

func (*IndexConflictIterator) Next

type IndexEntry

type IndexEntry struct {
	Ctime time.Time
	Mtime time.Time
	Mode  Filemode
	Uid   uint32
	Gid   uint32
	Size  uint32
	Id    *Oid
	Path  string
	// contains filtered or unexported fields
}

func (IndexEntry) IsConflict

func (v IndexEntry) IsConflict() bool

func (*IndexEntry) SetStage

func (v *IndexEntry) SetStage(flag IndexStage)

func (IndexEntry) Stage

func (v IndexEntry) Stage() IndexStage

type IndexEntryExtendedFlag

type IndexEntryExtendedFlag uint16

type IndexEntryFlag

type IndexEntryFlag uint16

type IndexMatchResult

type IndexMatchResult int

type IndexMatchedPathCallback

type IndexMatchedPathCallback func(string, string) IndexMatchResult

type IndexNameEntry

type IndexNameEntry struct {
	// contains filtered or unexported fields
}

type IndexReucEntry

type IndexReucEntry struct {
	// contains filtered or unexported fields
}

type IndexStage

type IndexStage int

type MWindow

type MWindow struct {
	// contains filtered or unexported fields
}

type MWindowCtl

type MWindowCtl struct {
	// contains filtered or unexported fields
}

type MWindowFile

type MWindowFile struct {
	// contains filtered or unexported fields
}

func (*MWindowFile) Open

func (mwf *MWindowFile) Open(offset, extra uint64) ([]byte, error)

type Match

type Match struct {
	// contains filtered or unexported fields
}

type Object

type Object interface {
	Id() *Oid
	Type() ObjectType
	Owner() *Repository
	Peel(targetType ObjectType) (Object, error)
}

type ObjectType

type ObjectType int
const (
	ObjectAny      ObjectType = -2
	ObjectBad      ObjectType = -2
	ObjectCommit   ObjectType = 1
	ObjectTree     ObjectType = 2
	ObjectBlob     ObjectType = 3
	ObjectTag      ObjectType = 4
	ObjectOfsDelta ObjectType = 6
	ObjectRefDelta ObjectType = 7
)

func TypeString2Type

func TypeString2Type(typeString string) ObjectType

func (ObjectType) String

func (o ObjectType) String() string

type Odb

type Odb struct {
	// contains filtered or unexported fields
}

func OdbOpen

func OdbOpen(objectsDir string) (*Odb, error)

func (*Odb) AddDefaultBackends

func (o *Odb) AddDefaultBackends(objectsDir string, asAlternates bool, alternateDepth int) error

func (*Odb) Exists

func (o *Odb) Exists(oid *Oid) bool

func (*Odb) ExistsPrefix

func (o *Odb) ExistsPrefix(oid *Oid, length int) (*Oid, error)

func (*Odb) ForEach

func (o *Odb) ForEach(callback OdbForEachCallback) error

func (*Odb) GetAllObjects

func (o *Odb) GetAllObjects() ([]*Oid, error)

func (*Odb) Hash

func (v *Odb) Hash(data []byte, objType ObjectType) (*Oid, error)

func (*Odb) Read

func (o *Odb) Read(oid *Oid) (*OdbObject, error)

func (*Odb) ReadHeader

func (o *Odb) ReadHeader(oid *Oid) (ObjectType, uint64, error)

func (*Odb) ReadPrefix

func (o *Odb) ReadPrefix(oid *Oid, length int) (*Oid, *OdbObject, error)

func (*Odb) Write

func (o *Odb) Write(data []byte, objType ObjectType) (*Oid, error)

type OdbBackend

type OdbBackend interface {
	InitBackend(priority int, isAlternate bool, fileInfo os.FileInfo)
	Priority() int
	IsAlternate() bool
	SameDirectory(info os.FileInfo) bool
	Read(oid *Oid) (*OdbObject, error)
	ReadPrefix(oid *Oid, length int) (*Oid, *OdbObject, error)
	ReadHeader(oid *Oid) (ObjectType, uint64, error)
	Write(data []byte, objectType ObjectType) (*Oid, error)
	Exists(oid *Oid) bool
	ExistsPrefix(oid *Oid, length int) (*Oid, error)
	Refresh() error
	ForEach(callback OdbForEachCallback) error
}

type OdbBackendBase

type OdbBackendBase struct {
	// contains filtered or unexported fields
}

func (*OdbBackendBase) InitBackend

func (b *OdbBackendBase) InitBackend(priority int, isAlternate bool, fileInfo os.FileInfo)

func (*OdbBackendBase) IsAlternate

func (b *OdbBackendBase) IsAlternate() bool

func (*OdbBackendBase) Priority

func (b *OdbBackendBase) Priority() int

func (*OdbBackendBase) SameDirectory

func (b *OdbBackendBase) SameDirectory(info os.FileInfo) bool

type OdbBackendLoose

type OdbBackendLoose struct {
	OdbBackendBase
	// contains filtered or unexported fields
}

func NewOdbBackendLoose

func NewOdbBackendLoose(objectsDir string, compressionLevel int, doFileSync bool, dirMode, fileMode uint32) *OdbBackendLoose

func (*OdbBackendLoose) Exists

func (o *OdbBackendLoose) Exists(oid *Oid) bool

func (*OdbBackendLoose) ExistsPrefix

func (o *OdbBackendLoose) ExistsPrefix(oid *Oid, length int) (*Oid, error)

func (*OdbBackendLoose) ForEach

func (o *OdbBackendLoose) ForEach(callback OdbForEachCallback) error

func (*OdbBackendLoose) Read

func (o *OdbBackendLoose) Read(oid *Oid) (*OdbObject, error)

func (*OdbBackendLoose) ReadHeader

func (o *OdbBackendLoose) ReadHeader(oid *Oid) (ObjectType, uint64, error)

func (*OdbBackendLoose) ReadPrefix

func (o *OdbBackendLoose) ReadPrefix(oid *Oid, length int) (*Oid, *OdbObject, error)

func (*OdbBackendLoose) Refresh

func (o *OdbBackendLoose) Refresh() error

func (*OdbBackendLoose) Write

func (o *OdbBackendLoose) Write(data []byte, objType ObjectType) (*Oid, error)

type OdbBackendPacked

type OdbBackendPacked struct {
	OdbBackendBase
	// contains filtered or unexported fields
}

func NewOdbBackendPacked

func NewOdbBackendPacked(objectsDir string) *OdbBackendPacked

func (*OdbBackendPacked) Exists

func (o *OdbBackendPacked) Exists(oid *Oid) bool

func (*OdbBackendPacked) ExistsPrefix

func (o *OdbBackendPacked) ExistsPrefix(shortOid *Oid, length int) (*Oid, error)

func (*OdbBackendPacked) ForEach

func (o *OdbBackendPacked) ForEach(callback OdbForEachCallback) error

func (*OdbBackendPacked) Read

func (o *OdbBackendPacked) Read(oid *Oid) (*OdbObject, error)

func (*OdbBackendPacked) ReadHeader

func (o *OdbBackendPacked) ReadHeader(oid *Oid) (ObjectType, uint64, error)

func (*OdbBackendPacked) ReadPrefix

func (o *OdbBackendPacked) ReadPrefix(shortOid *Oid, length int) (*Oid, *OdbObject, error)

func (*OdbBackendPacked) Refresh

func (o *OdbBackendPacked) Refresh() error

func (*OdbBackendPacked) Write

func (o *OdbBackendPacked) Write(data []byte, objType ObjectType) (*Oid, error)

type OdbBackends

type OdbBackends []OdbBackend

func (OdbBackends) Len

func (a OdbBackends) Len() int

func (OdbBackends) Less

func (a OdbBackends) Less(i, j int) bool

func (OdbBackends) Swap

func (a OdbBackends) Swap(i, j int)

type OdbForEachCallback

type OdbForEachCallback func(id *Oid) error

type OdbObject

type OdbObject struct {
	Type ObjectType
	Data []byte
}

type Oid

type Oid [GitOidRawSize]byte

func NewOid

func NewOid(s string) (*Oid, error)

func NewOidFromBytes

func NewOidFromBytes(b []byte) *Oid

func NewOidFromPrefix

func NewOidFromPrefix(s string) (*Oid, error)

func (*Oid) Cmp

func (oid *Oid) Cmp(oid2 *Oid) int

func (*Oid) Copy

func (oid *Oid) Copy() *Oid

func (*Oid) Equal

func (oid *Oid) Equal(oid2 *Oid) bool

func (*Oid) IsZero

func (oid *Oid) IsZero() bool

func (*Oid) NCmp

func (oid *Oid) NCmp(oid2 *Oid, n uint) int

func (*Oid) PathFormat

func (oid *Oid) PathFormat() (string, string)

func (*Oid) String

func (oid *Oid) String() string

type PackChainElem

type PackChainElem struct {
	// contains filtered or unexported fields
}

type PackEntry

type PackEntry struct {
	Offset   uint64
	Sha1     *Oid
	PackFile *PackFile
}

type PackFile

type PackFile struct {
	// contains filtered or unexported fields
}

func GetPack

func GetPack(path string) (*PackFile, error)

func NewPackFile

func NewPackFile(path string) (*PackFile, error)

type PackRef

type PackRef struct {
	// contains filtered or unexported fields
}

type PackRefSortedCache

type PackRefSortedCache struct {
	// contains filtered or unexported fields
}

func (*PackRefSortedCache) Lookup

func (c *PackRefSortedCache) Lookup(key string) *PackRef

func (*PackRefSortedCache) Upsert

func (c *PackRefSortedCache) Upsert(key string) *PackRef

type RangeMatchResult

type RangeMatchResult int

type RefDb

type RefDb struct {
	// contains filtered or unexported fields
}

func (*RefDb) GetPackedReferences

func (r *RefDb) GetPackedReferences() ([]*Reference, error)

func (*RefDb) Lookup

func (r *RefDb) Lookup(name string) (*Reference, error)

type Reference

type Reference struct {
	// contains filtered or unexported fields
}

Reference type and its methods

func (*Reference) Cmp

func (v *Reference) Cmp(ref2 *Reference) int

func (*Reference) IsBranch

func (r *Reference) IsBranch() bool

func (*Reference) IsRemote

func (r *Reference) IsRemote() bool

func (*Reference) IsTag

func (r *Reference) IsTag() bool

func (*Reference) Name

func (r *Reference) Name() string

func (*Reference) Owner

func (r *Reference) Owner() *Repository

func (*Reference) Resolve

func (r *Reference) Resolve() (*Reference, error)

func (*Reference) SymbolicTarget

func (r *Reference) SymbolicTarget() string

func (*Reference) Target

func (r *Reference) Target() *Oid

func (*Reference) Type

func (r *Reference) Type() ReferenceType

type ReferenceType

type ReferenceType int

type Repository

type Repository struct {
	// contains filtered or unexported fields
}

func OpenRepository

func OpenRepository(path string) (*Repository, error)

func OpenRepositoryExtended

func OpenRepositoryExtended(path string) (*Repository, error)

func (*Repository) Config

func (repo *Repository) Config() *Config

func (*Repository) CreateBlobFromBuffer

func (r *Repository) CreateBlobFromBuffer(data []byte) (*Oid, error)

func (*Repository) CreateBlobFromChunks

func (r *Repository) CreateBlobFromChunks(hintPath string, callback BlobChunkCallback) (*Oid, error)

todo

func (*Repository) CreateBlobFromWorkdir

func (r *Repository) CreateBlobFromWorkdir(path string) (*Oid, error)

func (*Repository) DefaultSignature

func (repo *Repository) DefaultSignature() (*Signature, error)

func (*Repository) DwimReference

func (r *Repository) DwimReference(name string) (*Reference, error)

func (*Repository) ForEachGlobReference

func (r *Repository) ForEachGlobReference(pattern string, callback ForEachReferenceCallback) error

func (*Repository) ForEachGlobReferenceName

func (r *Repository) ForEachGlobReferenceName(pattern string, callback ForEachReferenceNameCallback) error

func (*Repository) ForEachReference

func (r *Repository) ForEachReference(callback ForEachReferenceCallback) error

func (*Repository) ForEachReferenceName

func (r *Repository) ForEachReferenceName(callback ForEachReferenceNameCallback) error

func (*Repository) Head

func (r *Repository) Head() (*Reference, error)

func (*Repository) Index

func (r *Repository) Index() (*Index, error)

func (*Repository) IsBare

func (r *Repository) IsBare() bool

func (*Repository) IsPathValid

func (r *Repository) IsPathValid(name string) bool

todo: not implemented yet

func (*Repository) ListTag

func (r *Repository) ListTag() ([]string, error)

func (*Repository) Lookup

func (r *Repository) Lookup(oid *Oid) (Object, error)

func (*Repository) LookupBlob

func (r *Repository) LookupBlob(oid *Oid) (*Blob, error)

func (*Repository) LookupCommit

func (r *Repository) LookupCommit(oid *Oid) (*Commit, error)

func (*Repository) LookupPrefix

func (r *Repository) LookupPrefix(oid *Oid, length int) (Object, error)

func (*Repository) LookupPrefixBlob

func (r *Repository) LookupPrefixBlob(oid *Oid, length int) (*Blob, error)

func (*Repository) LookupPrefixCommit

func (r *Repository) LookupPrefixCommit(oid *Oid, length int) (*Commit, error)

func (*Repository) LookupPrefixTag

func (r *Repository) LookupPrefixTag(oid *Oid, length int) (*Tag, error)

func (*Repository) LookupPrefixTree

func (r *Repository) LookupPrefixTree(oid *Oid, length int) (*Tree, error)

func (*Repository) LookupReference

func (r *Repository) LookupReference(name string) (*Reference, error)

func (*Repository) LookupTag

func (r *Repository) LookupTag(oid *Oid) (*Tag, error)

func (*Repository) LookupTree

func (r *Repository) LookupTree(oid *Oid) (*Tree, error)

func (*Repository) NewRefDb

func (r *Repository) NewRefDb() *RefDb

func (*Repository) Odb

func (r *Repository) Odb() (odb *Odb, err error)

func (*Repository) Path

func (r *Repository) Path() string

func (*Repository) SetIndex

func (r *Repository) SetIndex(index *Index)

func (*Repository) TreeBuilder

func (r *Repository) TreeBuilder() (*TreeBuilder, error)

func (*Repository) Walk

func (v *Repository) Walk() (*RevWalk, error)

func (*Repository) Workdir

func (r *Repository) Workdir() string

type RevWalk

type RevWalk struct {
	// contains filtered or unexported fields
}

func (*RevWalk) Hide

func (v *RevWalk) Hide(id *Oid) error

func (*RevWalk) HideGlob

func (v *RevWalk) HideGlob(glob string) error

func (*RevWalk) HideHead

func (v *RevWalk) HideHead() (err error)

func (*RevWalk) HideRange

func (v *RevWalk) HideRange(r string) error

func (*RevWalk) HideRef

func (v *RevWalk) HideRef(r string) error

func (*RevWalk) Iterate

func (v *RevWalk) Iterate(fun RevWalkIterator) (err error)

func (*RevWalk) Next

func (v *RevWalk) Next(id *Oid) error

func (*RevWalk) Push

func (v *RevWalk) Push(id *Oid) error

func (*RevWalk) PushGlob

func (v *RevWalk) PushGlob(glob string) error

func (*RevWalk) PushHead

func (v *RevWalk) PushHead() (err error)

func (*RevWalk) PushRange

func (v *RevWalk) PushRange(r string) error

func (*RevWalk) PushRef

func (v *RevWalk) PushRef(r string) error

func (*RevWalk) Reset

func (v *RevWalk) Reset()

func (*RevWalk) Sorting

func (v *RevWalk) Sorting(sm SortType)

type RevWalkIterator

type RevWalkIterator func(commit *Commit) bool

type Signature

type Signature struct {
	Name  string
	Email string
	When  time.Time
}

func (*Signature) Offset

func (v *Signature) Offset() int

the offset in mintes, which is what git wants

type SortType

type SortType uint
const (
	SortNone        SortType = 1 << iota
	SortTopological SortType = 1 << iota
	SortTime        SortType = 1 << iota
	SortReverse     SortType = 1 << iota
)

type Tag

type Tag struct {
	// contains filtered or unexported fields
}

func (*Tag) Id

func (o *Tag) Id() *Oid

func (*Tag) Message

func (t *Tag) Message() string

func (*Tag) Name

func (t *Tag) Name() string

func (*Tag) Owner

func (o *Tag) Owner() *Repository

func (*Tag) Peel

func (t *Tag) Peel(targetType ObjectType) (Object, error)

func (*Tag) Tagger

func (t *Tag) Tagger() *Signature

func (*Tag) Target

func (t *Tag) Target() Object

func (*Tag) TargetId

func (t *Tag) TargetId() *Oid

func (*Tag) TargetType

func (t *Tag) TargetType() ObjectType

func (*Tag) Type

func (t *Tag) Type() ObjectType

type Tree

type Tree struct {
	Entries []*TreeEntry
	// contains filtered or unexported fields
}

func (*Tree) EntryByIndex

func (t *Tree) EntryByIndex(index int) *TreeEntry

func (*Tree) EntryByName

func (t *Tree) EntryByName(filename string) *TreeEntry

func (*Tree) EntryByPath

func (t *Tree) EntryByPath(path string) (*TreeEntry, error)

func (*Tree) EntryCount

func (t *Tree) EntryCount() uint64

func (*Tree) Id

func (o *Tree) Id() *Oid

func (*Tree) Owner

func (o *Tree) Owner() *Repository

func (*Tree) Peel

func (t *Tree) Peel(targetType ObjectType) (Object, error)

func (*Tree) Type

func (t *Tree) Type() ObjectType

func (*Tree) Walk

func (t *Tree) Walk(callback TreeWalkCallback) error

func (*Tree) WalkPost

func (t *Tree) WalkPost(callback TreeWalkCallback) error

type TreeBuilder

type TreeBuilder struct {
	Entries map[string]*TreeEntry
	// contains filtered or unexported fields
}

func (*TreeBuilder) Insert

func (b *TreeBuilder) Insert(filename string, oid *Oid, filemode Filemode) error

func (*TreeBuilder) Remove

func (b *TreeBuilder) Remove(filename string) error

func (*TreeBuilder) Write

func (b *TreeBuilder) Write() (*Oid, error)

type TreeCache

type TreeCache struct {
	// contains filtered or unexported fields
}

type TreeEntries

type TreeEntries []*TreeEntry

func (TreeEntries) Len

func (p TreeEntries) Len() int

func (TreeEntries) Less

func (p TreeEntries) Less(i, j int) bool

func (TreeEntries) Swap

func (p TreeEntries) Swap(i, j int)

type TreeEntry

type TreeEntry struct {
	Name     string
	Id       *Oid
	Type     ObjectType
	Filemode Filemode
}

type TreeWalkCallback

type TreeWalkCallback func(root string, entry *TreeEntry) int

Directories

Path Synopsis
cmd
got

Jump to

Keyboard shortcuts

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