ggit

package module
v0.0.0-...-7fcb13a Latest Latest
Warning

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

Go to latest
Published: Jun 11, 2014 License: BSD-3-Clause Imports: 16 Imported by: 0

README

This is an implementation of git in Go. It is intended as a learning exercise for both the Go language and git internals and is probably not suitable for any other purpose.

Note: This won't work out of the box against a standard Go, see reader_cache.go for details.

Documentation

Index

Constants

View Source
const (
	OBJ_BAD    = -1
	OBJ_NONE   = 0
	OBJ_COMMIT = 1
	OBJ_TREE   = 2
	OBJ_BLOB   = 3
	OBJ_TAG    = 4
	/* 5 for future expansion */
	OBJ_OFS_DELTA = 6
	OBJ_REF_DELTA = 7
	OBJ_ANY
	OBJ_MAX
)

Variables

View Source
var LookupObject = func(hash string) (Object, error) {
	if len(hash) == 0 {
		return Object{}, fmt.Errorf("invalid hash %s\n", hash)
	}
	o, err := findHash(hashToBytes(hash))
	if err != nil {
		return Object{}, err
	}
	if o != nil {
		return *o, nil
	}
	file, err := openObjectFile(hash)
	if err != nil {
		return Object{}, fmt.Errorf("open %v", err)
	}
	r, err := getZlibReader(file)
	if err != nil {
		_ = file.Close()
		return Object{}, fmt.Errorf("zlib reader %v", err)
	}
	o, err = parseObject(r, r)
	if err != nil {
		_ = file.Close()
		return Object{}, fmt.Errorf("parse %v", err)
	}
	o.file = file
	return *o, nil
}

Functions

func CommitishToHash

func CommitishToHash(committish string) string

func CurrentBranch

func CurrentBranch() (string, error)

func NameToPath

func NameToPath(object string) (string, error)

func PrettyPrintTree

func PrettyPrintTree(tree Object, recurse, dirsOnly bool, dir string) (string, error)

func ReadCommit

func ReadCommit(committish string) (commit, error)

Types

type Branch

type Branch struct {
	Name, Hash string
}

func ReadBranches

func ReadBranches() ([]Branch, error)

type Entry

type Entry struct {
	Ctime, Mtime             time.Time
	Dev, Ino, Mode, Uid, Gid uint32
	Size                     uint32
	Hash                     [sha1.Size]byte
	Flags                    uint16
	ExtendedFlags            uint16
	Path                     []byte
}

func MapIndexFile

func MapIndexFile(filename string) (version uint32, entries []Entry, extensions []extension, data []byte, err error)

func (Entry) String

func (e Entry) String() string

type Object

type Object struct {
	ObjectType string
	Size       uint32

	Reader io.Reader
	// contains filtered or unexported fields
}

func (Object) Close

func (o Object) Close()

Directories

Path Synopsis
cmd

Jump to

Keyboard shortcuts

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