index

package
v4.0.0-rc4+incompatible Latest Latest
Warning

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

Go to latest
Published: Nov 14, 2016 License: MIT Imports: 11 Imported by: 0

Documentation

Overview

Package index implements a encoder/decoder of index format files

Index

Constants

This section is empty.

Variables

View Source
var (
	// DecodeVersionSupported is the range of supported index versions
	DecodeVersionSupported = struct{ Min, Max uint32 }{Min: 2, Max: 4}

	// ErrMalformedSignature is returned by Decode when the index header file is
	// malformed
	ErrMalformedSignature = errors.New("malformed index signature file")
	// ErrInvalidChecksum is returned by Decode if the SHA1 hash missmatch with
	// the read content
	ErrInvalidChecksum = errors.New("invalid checksum")
)
View Source
var (
	// EncodeVersionSupported is the range of supported index versions
	EncodeVersionSupported uint32 = 2

	// ErrInvalidTimestamp is returned by Encode if a Index with a Entry with
	// negative timestamp values
	ErrInvalidTimestamp = errors.New("negative timestamps are not allowed")
)
View Source
var (
	// ErrUnsupportedVersion is returned by Decode when the idxindex file
	// version is not supported.
	ErrUnsupportedVersion = errors.New("Unsuported version")
)

Functions

This section is empty.

Types

type Decoder

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

A Decoder reads and decodes idx files from an input stream.

func NewDecoder

func NewDecoder(r io.Reader) *Decoder

NewDecoder returns a new decoder that reads from r.

func (*Decoder) Decode

func (d *Decoder) Decode(idx *Index) error

Decode reads the whole index object from its input and stores it in the value pointed to by idx.

type Encoder

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

An Encoder writes an Index to an output stream.

func NewEncoder

func NewEncoder(w io.Writer) *Encoder

NewEncoder returns a new encoder that writes to w.

func (*Encoder) Encode

func (e *Encoder) Encode(idx *Index) error

Encode writes the Index to the stream of the encoder.

type Entry

type Entry struct {
	// Hash is the SHA1 of the represented file
	Hash plumbing.Hash
	// Name is the  Entry path name relative to top level directory
	Name string
	// CreatedAt time when the tracked path was created
	CreatedAt time.Time
	// ModifiedAt time when the tracked path was changed
	ModifiedAt time.Time
	// Dev and Inode of the tracked path
	Dev, Inode uint32
	// Mode of the path
	Mode os.FileMode
	// UID and GID, userid and group id of the owner
	UID, GID uint32
	// Size is the length in bytes for regular files
	Size uint32
	// Stage on a merge is defines what stage is representing this entry
	// https://git-scm.com/book/en/v2/Git-Tools-Advanced-Merging
	Stage Stage
	// SkipWorktree used in sparse checkouts
	// https://git-scm.com/docs/git-read-tree#_sparse_checkout
	SkipWorktree bool
	// IntentToAdd record only the fact that the path will be added later
	// https://git-scm.com/docs/git-add ("git add -N")
	IntentToAdd bool
}

Entry represents a single file (or stage of a file) in the cache. An entry represents exactly one stage of a file. If a file path is unmerged then multiple Entry instances may appear for the same path name.

type Index

type Index struct {
	Version     uint32
	Entries     []Entry
	Cache       *Tree
	ResolveUndo *ResolveUndo
}

Index contains the information about which objects are currently checked out in the worktree, having information about the working files. Changes in worktree are detected using this Index. The Index is also used during merges

type ResolveUndo

type ResolveUndo struct {
	Entries []ResolveUndoEntry
}

ResolveUndo when a conflict is resolved (e.g. with "git add path"), these higher stage entries will be removed and a stage-0 entry with proper resolution is added. When these higher stage entries are removed, they are saved in the resolve undo extension

type ResolveUndoEntry

type ResolveUndoEntry struct {
	Path   string
	Stages map[Stage]plumbing.Hash
}

ResolveUndoEntry contains the information about a conflict when is resolved

type Stage

type Stage int

Stage during merge

const (
	// Merged is the default stage, fully merged
	Merged Stage = 1
	// AncestorMode is the base revision
	AncestorMode Stage = 1
	// OurMode is the first tree revision, ours
	OurMode Stage = 2
	// TheirMode is the second tree revision, theirs
	TheirMode Stage = 3
)

type Tree

type Tree struct {
	Entries []TreeEntry
}

Tree contains pre-computed hashes for trees that can be derived from the index. It helps speed up tree object generation from index for a new commit.

type TreeEntry

type TreeEntry struct {
	// Path component (relative to its parent directory)
	Path string
	// Entries is the number of entries in the index that is covered by the tree
	// this entry represents
	Entries int
	// Trees is the number that represents the number of subtrees this tree has
	Trees int
	// Hash object name for the object that would result from writing this span
	// of index as a tree.
	Hash plumbing.Hash
}

TreeEntry entry of a cached Tree

Jump to

Keyboard shortcuts

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