git

package module
v0.0.0-...-4e0a28b Latest Latest
Warning

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

Go to latest
Published: May 17, 2013 License: MIT Imports: 9 Imported by: 0

README

git2go

Go bindings for libgit2. These bindings are for top-of-the-branch libgit2, and they move fast, things may or may not work. Operator get me Beijing-jing-jing-jing!

Installing

Just go get github.com/libgit2/git2go. You'll need to have top-of-the-branch libgit2 from development installed in your system and available via pkg-config. These bindings are in sync with the top of development.

License

M to the I to the T. See the LICENSE file if you've never seen a MIT license before.

Authors

  • Carlos Martín (@carlosmn)
  • Vicent Martí (@vmg)

Documentation

Index

Constants

View Source
const (
	CHECKOUT_NONE                         CheckoutStrategy = C.GIT_CHECKOUT_NONE                         // Dry run, no actual updates
	CHECKOUT_SAFE                                          = C.GIT_CHECKOUT_SAFE                         // Allow safe updates that cannot overwrite uncommitted data
	CHECKOUT_SAFE_CREATE                                   = C.GIT_CHECKOUT_SAFE_CREATE                  // Allow safe updates plus creation of missing files
	CHECKOUT_FORCE                                         = C.GIT_CHECKOUT_FORCE                        // Allow all updates to force working directory to look like index
	CHECKOUT_ALLOW_CONFLICTS                               = C.GIT_CHECKOUT_ALLOW_CONFLICTS              // Allow checkout to make safe updates even if conflicts are found
	CHECKOUT_REMOVE_UNTRACKED                              = C.GIT_CHECKOUT_REMOVE_UNTRACKED             // Remove untracked files not in index (that are not ignored)
	CHECKOUT_REMOVE_IGNORED                                = C.GIT_CHECKOUT_REMOVE_IGNORED               // Remove ignored files not in index
	CHECKOUT_UPDATE_ONLY                                   = C.GIT_CHECKOUT_UPDATE_ONLY                  // Only update existing files, don't create new ones
	CHECKOUT_DONT_UPDATE_INDEX                             = C.GIT_CHECKOUT_DONT_UPDATE_INDEX            // Normally checkout updates index entries as it goes; this stops that
	CHECKOUT_NO_REFRESH                                    = C.GIT_CHECKOUT_NO_REFRESH                   // Don't refresh index/config/etc before doing checkout
	CHECKOUT_DISABLE_PATHSPEC_MATCH                        = C.GIT_CHECKOUT_DISABLE_PATHSPEC_MATCH       // Treat pathspec as simple list of exact match file paths
	CHECKOUT_SKIP_UNMERGED                                 = C.GIT_CHECKOUT_SKIP_UNMERGED                // Allow checkout to skip unmerged files (NOT IMPLEMENTED)
	CHECKOUT_USE_OURS                                      = C.GIT_CHECKOUT_USE_OURS                     // For unmerged files, checkout stage 2 from index (NOT IMPLEMENTED)
	CHECKOUT_USE_THEIRS                                    = C.GIT_CHECKOUT_USE_THEIRS                   // For unmerged files, checkout stage 3 from index (NOT IMPLEMENTED)
	CHECKOUT_UPDATE_SUBMODULES                             = C.GIT_CHECKOUT_UPDATE_SUBMODULES            // Recursively checkout submodules with same options (NOT IMPLEMENTED)
	CHECKOUT_UPDATE_SUBMODULES_IF_CHANGED                  = C.GIT_CHECKOUT_UPDATE_SUBMODULES_IF_CHANGED // Recursively checkout submodules if HEAD moved in super repo (NOT IMPLEMENTED)
)
View Source
const (
	ITEROVER  = C.GIT_ITEROVER
	EEXISTS   = C.GIT_EEXISTS
	ENOTFOUND = C.GIT_ENOTFOUND
)
View Source
const (
	SubmoduleUpdateDefault  SubmoduleUpdate = C.GIT_SUBMODULE_UPDATE_DEFAULT
	SubmoduleUpdateCheckout                 = C.GIT_SUBMODULE_UPDATE_CHECKOUT
	SubmoduleUpdateRebase                   = C.GIT_SUBMODULE_UPDATE_REBASE
	SubmoduleUpdateMerge                    = C.GIT_SUBMODULE_UPDATE_MERGE
	SubmoduleUpdateNone                     = C.GIT_SUBMODULE_UPDATE_NONE
)
View Source
const (
	SubmoduleIgnoreDefault   SubmoduleIgnore = C.GIT_SUBMODULE_IGNORE_DEFAULT
	SubmoduleIgnoreNone                      = C.GIT_SUBMODULE_IGNORE_NONE
	SubmoduleIgnoreUntracked                 = C.GIT_SUBMODULE_IGNORE_UNTRACKED
	SubmoduleIgnoreDirty                     = C.GIT_SUBMODULE_IGNORE_DIRTY
	SubmoduleIgnoreAll                       = C.GIT_SUBMODULE_IGNORE_ALL
)
View Source
const (
	SubmoduleStatusInHead          SubmoduleStatus = C.GIT_SUBMODULE_STATUS_IN_HEAD
	SubmoduleStatusInIndex                         = C.GIT_SUBMODULE_STATUS_IN_INDEX
	SubmoduleStatusInConfig                        = C.GIT_SUBMODULE_STATUS_IN_CONFIG
	SubmoduleStatusInWd                            = C.GIT_SUBMODULE_STATUS_IN_WD
	SubmoduleStatusIndexAdded                      = C.GIT_SUBMODULE_STATUS_INDEX_ADDED
	SubmoduleStatusIndexDeleted                    = C.GIT_SUBMODULE_STATUS_INDEX_DELETED
	SubmoduleStatusIndexModified                   = C.GIT_SUBMODULE_STATUS_INDEX_MODIFIED
	SubmoduleStatusWdUninitialized                 = C.GIT_SUBMODULE_STATUS_WD_UNINITIALIZED
	SubmoduleStatusWdAdded                         = C.GIT_SUBMODULE_STATUS_WD_ADDED
	SubmoduleStatusWdDeleted                       = C.GIT_SUBMODULE_STATUS_WD_DELETED
	SubmoduleStatusWdModified                      = C.GIT_SUBMODULE_STATUS_WD_MODIFIED
	SubmoduleStatusWdIndexModified                 = C.GIT_SUBMODULE_STATUS_WD_INDEX_MODIFIED
	SubmoduleStatusWdWdModified                    = C.GIT_SUBMODULE_STATUS_WD_WD_MODIFIED
	SubmoduleStatusWdUntracked                     = C.GIT_SUBMODULE_STATUS_WD_UNTRACKED
)
View Source
const (
	SORT_NONE        = C.GIT_SORT_NONE
	SORT_TOPOLOGICAL = C.GIT_SORT_TOPOLOGICAL
	SORT_TIME        = C.GIT_SORT_TIME
	SORT_REVERSE     = C.GIT_SORT_REVERSE
)

Variables

View Source
var (
	OBJ_ANY    = C.GIT_OBJ_ANY
	OBJ_BAD    = C.GIT_OBJ_BAD
	OBJ_COMMIT = C.GIT_OBJ_COMMIT
	OBJ_TREE   = C.GIT_OBJ_TREE
	OBJ_BLOB   = C.GIT_OBJ_BLOB
	OBJ_TAG    = C.GIT_OBJ_TAG
)
View Source
var (
	SYMBOLIC = C.GIT_REF_SYMBOLIC
	OID      = C.GIT_REF_OID
)

Functions

func CallbackGitTreeWalk

func CallbackGitTreeWalk(_root unsafe.Pointer, _entry unsafe.Pointer, ptr unsafe.Pointer) C.int

func Discover

func Discover(start string, across_fs bool, ceiling_dirs []string) (string, error)

func LastError

func LastError() error

func SubmoduleStatusIsUnmodified

func SubmoduleStatusIsUnmodified(status int) bool

func SubmoduleVisitor

func SubmoduleVisitor(csub unsafe.Pointer, name string, cfct unsafe.Pointer) int

Types

type Blob

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

func (*Blob) Contents

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

func (*Blob) Free

func (v *Blob) Free()

func (*Blob) Size

func (v *Blob) Size() int64

type CheckoutOpts

type CheckoutOpts struct {
	Strategy       CheckoutStrategy // Default will be a dry run
	DisableFilters bool             // Don't apply filters like CRLF conversion
	DirMode        os.FileMode      // Default is 0755
	FileMode       os.FileMode      // Default is 0644 or 0755 as dictated by blob
	FileOpenFlags  int              // Default is O_CREAT | O_TRUNC | O_WRONLY
}

type CheckoutStrategy

type CheckoutStrategy uint

type Commit

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

Commit

func (*Commit) Author

func (c *Commit) Author() *Signature

func (*Commit) Committer

func (c *Commit) Committer() *Signature

func (*Commit) Id

func (c *Commit) Id() *Oid

func (*Commit) Message

func (c *Commit) Message() string

func (*Commit) Tree

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

func (*Commit) TreeId

func (c *Commit) TreeId() *Oid

type Config

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

func (*Config) LookupInt32

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

func (*Config) LookupInt64

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

func (*Config) LookupString

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

func (*Config) Set

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

type GitError

type GitError struct {
	Message string
	Code    int
}

func (GitError) Error

func (e GitError) Error() string

type Index

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

func (*Index) AddByPath

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

func (*Index) Free

func (v *Index) Free()

func (*Index) WriteTree

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

type Odb

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

func (*Odb) Exists

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

func (*Odb) Free

func (v *Odb) Free()

func (*Odb) Read

func (v *Odb) Read(oid *Oid) (obj *OdbObject, err error)

func (*Odb) Write

func (v *Odb) Write(data []byte, otype int) (oid *Oid, err error)

type OdbObject

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

func (*OdbObject) Data

func (object *OdbObject) Data() (data []byte)

func (*OdbObject) Free

func (v *OdbObject) Free()

func (*OdbObject) Id

func (object *OdbObject) Id() (oid *Oid)

func (*OdbObject) Len

func (object *OdbObject) Len() (len uint64)

type Oid

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

Oid

func NewOid

func NewOid(b []byte) *Oid

func NewOidFromString

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

func (*Oid) Bytes

func (oid *Oid) Bytes() []byte

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

func (oid *Oid) String() string

type Packbuilder

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

func (*Packbuilder) ForEach

func (pb *Packbuilder) ForEach() chan []byte

func (*Packbuilder) Free

func (pb *Packbuilder) Free()

func (*Packbuilder) Insert

func (pb *Packbuilder) Insert(id *Oid, name string) error

func (*Packbuilder) InsertCommit

func (pb *Packbuilder) InsertCommit(id *Oid) error

func (*Packbuilder) InsertTree

func (pb *Packbuilder) InsertTree(id *Oid) error

func (*Packbuilder) ObjectCount

func (pb *Packbuilder) ObjectCount() uint32

func (*Packbuilder) Write

func (pb *Packbuilder) Write(w io.Writer) error

func (*Packbuilder) WriteToFile

func (pb *Packbuilder) WriteToFile(name string) error

func (*Packbuilder) Written

func (pb *Packbuilder) Written() uint32

type Reference

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

func (*Reference) Delete

func (v *Reference) Delete() error

func (*Reference) Free

func (v *Reference) Free()

func (*Reference) Name

func (v *Reference) Name() string

func (*Reference) Rename

func (v *Reference) Rename(name string, force bool) (*Reference, error)

func (*Reference) Resolve

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

func (*Reference) SetSymbolicTarget

func (v *Reference) SetSymbolicTarget(target string) (*Reference, error)

func (*Reference) SetTarget

func (v *Reference) SetTarget(target *Oid) (*Reference, error)

func (*Reference) SymbolicTarget

func (v *Reference) SymbolicTarget() string

func (*Reference) Target

func (v *Reference) Target() *Oid

func (*Reference) Type

func (v *Reference) Type() int

type Repository

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

Repository

func InitRepository

func InitRepository(path string, isbare bool) (*Repository, error)

func OpenRepository

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

func (*Repository) AddSubmodule

func (repo *Repository) AddSubmodule(url, path string, use_git_link bool) (*Submodule, error)

func (*Repository) Checkout

func (v *Repository) Checkout(opts *CheckoutOpts) error

Updates files in the index and the working tree to match the content of the commit pointed at by HEAD.

func (*Repository) CheckoutIndex

func (v *Repository) CheckoutIndex(index *Index, opts *CheckoutOpts) error

Updates files in the working tree to match the content of the index.

func (*Repository) Config

func (v *Repository) Config() (*Config, error)

func (*Repository) CreateCommit

func (v *Repository) CreateCommit(
	refname string, author, committer *Signature,
	message string, tree *Tree, parents ...*Commit) (*Oid, error)

func (*Repository) CreateReference

func (v *Repository) CreateReference(name string, oid *Oid, force bool) (*Reference, error)

func (*Repository) CreateSymbolicReference

func (v *Repository) CreateSymbolicReference(name, target string, force bool) (*Reference, error)

func (*Repository) ForeachSubmodule

func (repo *Repository) ForeachSubmodule(cbk SubmoduleCbk) error

func (*Repository) Free

func (v *Repository) Free()

func (*Repository) Index

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

func (*Repository) IsBare

func (repo *Repository) IsBare() bool

func (*Repository) LookupBlob

func (v *Repository) LookupBlob(o *Oid) (*Blob, error)

func (*Repository) LookupCommit

func (v *Repository) LookupCommit(o *Oid) (*Commit, error)

func (*Repository) LookupReference

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

func (*Repository) LookupSubmodule

func (repo *Repository) LookupSubmodule(name string) (*Submodule, error)

func (*Repository) LookupTree

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

func (*Repository) NewPackbuilder

func (repo *Repository) NewPackbuilder() (*Packbuilder, error)

func (*Repository) Odb

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

func (*Repository) Path

func (repo *Repository) Path() string

func (*Repository) ReloadAllSubmodules

func (repo *Repository) ReloadAllSubmodules() error

func (*Repository) SetWorkdir

func (repo *Repository) SetWorkdir(workdir string, updateGitlink bool) error

func (*Repository) TreeBuilder

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

func (*Repository) Walk

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

func (*Repository) Workdir

func (repo *Repository) Workdir() string

type RevWalk

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

func (*RevWalk) Iterate

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

func (*RevWalk) Next

func (v *RevWalk) Next(oid *Oid) (err error)

func (*RevWalk) Push

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

func (*RevWalk) PushHead

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

func (*RevWalk) Reset

func (v *RevWalk) Reset()

func (*RevWalk) Sorting

func (v *RevWalk) Sorting(sm uint)

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 Submodule

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

Submodule

func (*Submodule) AddToIndex

func (sub *Submodule) AddToIndex(write_index bool) error

func (*Submodule) FetchRecurseSubmodules

func (sub *Submodule) FetchRecurseSubmodules() bool

func (*Submodule) FinalizeAdd

func (sub *Submodule) FinalizeAdd() error

func (*Submodule) HeadId

func (sub *Submodule) HeadId() *Oid

func (*Submodule) Ignore

func (sub *Submodule) Ignore() SubmoduleIgnore

func (*Submodule) IndexId

func (sub *Submodule) IndexId() *Oid

func (*Submodule) Init

func (sub *Submodule) Init(overwrite bool) error

func (*Submodule) Name

func (sub *Submodule) Name() string

func (*Submodule) Open

func (sub *Submodule) Open() (*Repository, error)

func (*Submodule) Owner

func (sub *Submodule) Owner() *Repository

func (*Submodule) Path

func (sub *Submodule) Path() string

func (*Submodule) Reload

func (sub *Submodule) Reload() error

func (*Submodule) Save

func (sub *Submodule) Save() error

func (*Submodule) SetFetchRecurseSubmodules

func (sub *Submodule) SetFetchRecurseSubmodules(v bool) error

func (*Submodule) SetIgnore

func (sub *Submodule) SetIgnore(ignore SubmoduleIgnore) SubmoduleIgnore

func (*Submodule) SetUpdate

func (sub *Submodule) SetUpdate(update SubmoduleUpdate) SubmoduleUpdate

func (*Submodule) SetUrl

func (sub *Submodule) SetUrl(url string) error

func (*Submodule) Sync

func (sub *Submodule) Sync() error

func (*Submodule) Update

func (sub *Submodule) Update() SubmoduleUpdate

func (*Submodule) Url

func (sub *Submodule) Url() string

func (*Submodule) WdId

func (sub *Submodule) WdId() *Oid

type SubmoduleCbk

type SubmoduleCbk func(sub *Submodule, name string) int

type SubmoduleIgnore

type SubmoduleIgnore int

type SubmoduleStatus

type SubmoduleStatus int

type SubmoduleUpdate

type SubmoduleUpdate int

type Tree

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

func TreeLookup

func TreeLookup(repo *Repository, oid *Oid) (*Tree, error)

func (*Tree) EntryByIndex

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

func (*Tree) EntryByName

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

func (*Tree) EntryCount

func (t *Tree) EntryCount() uint64

func (*Tree) Free

func (t *Tree) Free()

func (*Tree) Walk

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

type TreeBuilder

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

func (*TreeBuilder) Free

func (v *TreeBuilder) Free()

func (*TreeBuilder) Insert

func (v *TreeBuilder) Insert(filename string, id *Oid, filemode int) error

func (*TreeBuilder) Write

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

type TreeEntry

type TreeEntry struct {
	Name string
	Id   *Oid
	Type int
}

type TreeWalkCallback

type TreeWalkCallback func(string, *TreeEntry) int

Jump to

Keyboard shortcuts

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