Documentation ¶
Overview ¶
https://github.com/git/git/blob/master/Documentation/gitrepository-layout.txt
Index ¶
- Variables
- type DotGit
- func (d *DotGit) AddAlternate(remote string) error
- func (d *DotGit) Alternates() ([]*DotGit, error)
- func (d *DotGit) Close() error
- func (d *DotGit) Config() (billy.File, error)
- func (d *DotGit) ConfigWriter() (billy.File, error)
- func (d *DotGit) CountLooseRefs() (int, error)
- func (d *DotGit) DeleteOldObjectPackAndIndex(hash plumbing.Hash, t time.Time) error
- func (d *DotGit) ForEachObjectHash(fun func(plumbing.Hash) error) error
- func (d *DotGit) Fs() billy.Filesystem
- func (d *DotGit) Index() (billy.File, error)
- func (d *DotGit) IndexWriter() (billy.File, error)
- func (d *DotGit) Initialize() error
- func (d *DotGit) Module(name string) (billy.Filesystem, error)
- func (d *DotGit) NewObject() (*ObjectWriter, error)
- func (d *DotGit) NewObjectPack() (*PackWriter, error)
- func (d *DotGit) Object(h plumbing.Hash) (billy.File, error)
- func (d *DotGit) ObjectDelete(h plumbing.Hash) error
- func (d *DotGit) ObjectPack(hash plumbing.Hash) (billy.File, error)
- func (d *DotGit) ObjectPackIdx(hash plumbing.Hash) (billy.File, error)
- func (d *DotGit) ObjectPacks() ([]plumbing.Hash, error)
- func (d *DotGit) ObjectStat(h plumbing.Hash) (os.FileInfo, error)
- func (d *DotGit) Objects() ([]plumbing.Hash, error)
- func (d *DotGit) ObjectsWithPrefix(prefix []byte) ([]plumbing.Hash, error)
- func (d *DotGit) PackRefs() (err error)
- func (d *DotGit) Ref(name plumbing.ReferenceName) (*plumbing.Reference, error)
- func (d *DotGit) Refs() ([]*plumbing.Reference, error)
- func (d *DotGit) RemoveRef(name plumbing.ReferenceName) error
- func (d *DotGit) SetRef(r, old *plumbing.Reference) error
- func (d *DotGit) Shallow() (billy.File, error)
- func (d *DotGit) ShallowWriter() (billy.File, error)
- type EncodedObject
- func (e *EncodedObject) Hash() plumbing.Hash
- func (e *EncodedObject) Reader() (io.ReadCloser, error)
- func (e *EncodedObject) SetSize(int64)
- func (e *EncodedObject) SetType(plumbing.ObjectType)
- func (e *EncodedObject) Size() int64
- func (e *EncodedObject) Type() plumbing.ObjectType
- func (e *EncodedObject) Writer() (io.WriteCloser, error)
- type ObjectWriter
- type Options
- type PackWriter
- type RepositoryFilesystem
- func (fs *RepositoryFilesystem) Chroot(path string) (billy.Filesystem, error)
- func (fs *RepositoryFilesystem) Create(filename string) (billy.File, error)
- func (fs *RepositoryFilesystem) Join(elem ...string) string
- func (fs *RepositoryFilesystem) Lstat(filename string) (os.FileInfo, error)
- func (fs *RepositoryFilesystem) MkdirAll(filename string, perm os.FileMode) error
- func (fs *RepositoryFilesystem) Open(filename string) (billy.File, error)
- func (fs *RepositoryFilesystem) OpenFile(filename string, flag int, perm os.FileMode) (billy.File, error)
- func (fs *RepositoryFilesystem) ReadDir(path string) ([]os.FileInfo, error)
- func (fs *RepositoryFilesystem) Readlink(link string) (string, error)
- func (fs *RepositoryFilesystem) Remove(filename string) error
- func (fs *RepositoryFilesystem) Rename(oldpath, newpath string) error
- func (fs *RepositoryFilesystem) Root() string
- func (fs *RepositoryFilesystem) Stat(filename string) (os.FileInfo, error)
- func (fs *RepositoryFilesystem) Symlink(target, link string) error
- func (fs *RepositoryFilesystem) TempFile(dir, prefix string) (billy.File, error)
Constants ¶
This section is empty.
Variables ¶
var ( // ErrNotFound is returned by New when the path is not found. ErrNotFound = errors.New("path not found") // ErrIdxNotFound is returned by Idxfile when the idx file is not found ErrIdxNotFound = errors.New("idx file not found") // ErrPackfileNotFound is returned by Packfile when the packfile is not found ErrPackfileNotFound = errors.New("packfile not found") // ErrConfigNotFound is returned by Config when the config is not found ErrConfigNotFound = errors.New("config file not found") // ErrPackedRefsDuplicatedRef is returned when a duplicated reference is // found in the packed-ref file. This is usually the case for corrupted git // repositories. ErrPackedRefsDuplicatedRef = errors.New("duplicated ref found in packed-ref file") // ErrPackedRefsBadFormat is returned when the packed-ref file corrupt. ErrPackedRefsBadFormat = errors.New("malformed packed-ref") // ErrSymRefTargetNotFound is returned when a symbolic reference is // targeting a non-existing object. This usually means the repository // is corrupt. ErrSymRefTargetNotFound = errors.New("symbolic reference target not found") // ErrIsDir is returned when a reference file is attempting to be read, // but the path specified is a directory. ErrIsDir = errors.New("reference path is a directory") )
Functions ¶
This section is empty.
Types ¶
type DotGit ¶
type DotGit struct {
// contains filtered or unexported fields
}
The DotGit type represents a local git repository on disk. This type is not zero-value-safe, use the New function to initialize it.
func New ¶
func New(fs billy.Filesystem) *DotGit
New returns a DotGit value ready to be used. The path argument must be the absolute path of a git repository directory (e.g. "/foo/bar/.git").
func NewWithOptions ¶
NewWithOptions sets non default configuration options. See New for complete help.
func (*DotGit) AddAlternate ¶
func (*DotGit) Alternates ¶
Alternates returns DotGit(s) based off paths in objects/info/alternates if available. This can be used to checks if it's a shared repository.
func (*DotGit) ConfigWriter ¶
ConfigWriter returns a file pointer for write to the config file
func (*DotGit) CountLooseRefs ¶
func (*DotGit) DeleteOldObjectPackAndIndex ¶
func (*DotGit) ForEachObjectHash ¶
ForEachObjectHash iterates over the hashes of objects found under the .git/objects/ directory and executes the provided function.
func (*DotGit) Fs ¶
func (d *DotGit) Fs() billy.Filesystem
Fs returns the underlying filesystem of the DotGit folder.
func (*DotGit) IndexWriter ¶
IndexWriter returns a file pointer for write to the index file
func (*DotGit) Initialize ¶
Initialize creates all the folder scaffolding.
func (*DotGit) NewObject ¶
func (d *DotGit) NewObject() (*ObjectWriter, error)
NewObject return a writer for a new object file.
func (*DotGit) NewObjectPack ¶
func (d *DotGit) NewObjectPack() (*PackWriter, error)
NewObjectPack return a writer for a new packfile, it saves the packfile to disk and also generates and save the index for the given packfile.
func (*DotGit) ObjectDelete ¶
ObjectDelete removes the object file, if exists
func (*DotGit) ObjectPack ¶
ObjectPack returns a fs.File of the given packfile
func (*DotGit) ObjectPackIdx ¶
ObjectPackIdx returns a fs.File of the index file for a given packfile
func (*DotGit) ObjectPacks ¶
ObjectPacks returns the list of availables packfiles
func (*DotGit) ObjectStat ¶
ObjectStat returns a os.FileInfo pointing the object file, if exists
func (*DotGit) Objects ¶
Objects returns a slice with the hashes of objects found under the .git/objects/ directory.
func (*DotGit) ObjectsWithPrefix ¶
ObjectsWithPrefix returns the hashes of objects that have the given prefix.
func (*DotGit) PackRefs ¶
PackRefs packs all loose refs into the packed-refs file.
This implementation only works under the assumption that the view of the file system won't be updated during this operation. This strategy would not work on a general file system though, without locking each loose reference and checking it again before deleting the file, because otherwise an updated reference could sneak in and then be deleted by the packed-refs process. Alternatively, every ref update could also lock packed-refs, so only one lock is required during ref-packing. But that would worsen performance in the common case.
TODO: add an "all" boolean like the `git pack-refs --all` flag. When `all` is false, it would only pack refs that have already been packed, plus all tags.
func (*DotGit) Refs ¶
Refs scans the git directory collecting references, which it returns. Symbolic references are resolved and included in the output.
func (*DotGit) RemoveRef ¶
func (d *DotGit) RemoveRef(name plumbing.ReferenceName) error
RemoveRef removes a reference by name.
func (*DotGit) ShallowWriter ¶
ShallowWriter returns a file pointer for write to the shallow file
type EncodedObject ¶
type EncodedObject struct {
// contains filtered or unexported fields
}
func NewEncodedObject ¶
func NewEncodedObject(dir *DotGit, h plumbing.Hash, t plumbing.ObjectType, size int64) *EncodedObject
func (*EncodedObject) Hash ¶
func (e *EncodedObject) Hash() plumbing.Hash
func (*EncodedObject) Reader ¶
func (e *EncodedObject) Reader() (io.ReadCloser, error)
func (*EncodedObject) SetSize ¶
func (e *EncodedObject) SetSize(int64)
func (*EncodedObject) SetType ¶
func (e *EncodedObject) SetType(plumbing.ObjectType)
func (*EncodedObject) Size ¶
func (e *EncodedObject) Size() int64
func (*EncodedObject) Type ¶
func (e *EncodedObject) Type() plumbing.ObjectType
func (*EncodedObject) Writer ¶
func (e *EncodedObject) Writer() (io.WriteCloser, error)
type ObjectWriter ¶
func (*ObjectWriter) Close ¶
func (w *ObjectWriter) Close() error
type Options ¶
type Options struct { // ExclusiveAccess means that the filesystem is not modified externally // while the repo is open. ExclusiveAccess bool // KeepDescriptors makes the file descriptors to be reused but they will // need to be manually closed calling Close(). KeepDescriptors bool // AlternatesFS provides the billy filesystem to be used for Git Alternates. // If none is provided, it falls back to using the underlying instance used for // DotGit. AlternatesFS billy.Filesystem }
Options holds configuration for the storage.
type PackWriter ¶
type PackWriter struct { Notify func(plumbing.Hash, *idxfile.Writer) // contains filtered or unexported fields }
PackWriter is a io.Writer that generates the packfile index simultaneously, a packfile.Decoder is used with a file reader to read the file being written this operation is synchronized with the write operations. The packfile is written in a temp file, when Close is called this file is renamed/moved (depends on the Filesystem implementation) to the final location, if the PackWriter is not used, nothing is written
func (*PackWriter) Close ¶
func (w *PackWriter) Close() error
Close closes all the file descriptors and save the final packfile, if nothing was written, the tempfiles are deleted without writing a packfile.
type RepositoryFilesystem ¶
type RepositoryFilesystem struct {
// contains filtered or unexported fields
}
RepositoryFilesystem is a billy.Filesystem compatible object wrapper which handles dot-git filesystem operations and supports commondir according to git scm layout: https://github.com/git/git/blob/master/Documentation/gitrepository-layout.txt
func NewRepositoryFilesystem ¶
func NewRepositoryFilesystem(dotGitFs, commonDotGitFs billy.Filesystem) *RepositoryFilesystem
func (*RepositoryFilesystem) Chroot ¶
func (fs *RepositoryFilesystem) Chroot(path string) (billy.Filesystem, error)
func (*RepositoryFilesystem) Create ¶
func (fs *RepositoryFilesystem) Create(filename string) (billy.File, error)
func (*RepositoryFilesystem) Join ¶
func (fs *RepositoryFilesystem) Join(elem ...string) string
func (*RepositoryFilesystem) Lstat ¶
func (fs *RepositoryFilesystem) Lstat(filename string) (os.FileInfo, error)
func (*RepositoryFilesystem) MkdirAll ¶
func (fs *RepositoryFilesystem) MkdirAll(filename string, perm os.FileMode) error
func (*RepositoryFilesystem) Open ¶
func (fs *RepositoryFilesystem) Open(filename string) (billy.File, error)
func (*RepositoryFilesystem) ReadDir ¶
func (fs *RepositoryFilesystem) ReadDir(path string) ([]os.FileInfo, error)
func (*RepositoryFilesystem) Readlink ¶
func (fs *RepositoryFilesystem) Readlink(link string) (string, error)
func (*RepositoryFilesystem) Remove ¶
func (fs *RepositoryFilesystem) Remove(filename string) error
func (*RepositoryFilesystem) Rename ¶
func (fs *RepositoryFilesystem) Rename(oldpath, newpath string) error
func (*RepositoryFilesystem) Root ¶
func (fs *RepositoryFilesystem) Root() string
func (*RepositoryFilesystem) Stat ¶
func (fs *RepositoryFilesystem) Stat(filename string) (os.FileInfo, error)
func (*RepositoryFilesystem) Symlink ¶
func (fs *RepositoryFilesystem) Symlink(target, link string) error
func (*RepositoryFilesystem) TempFile ¶
func (fs *RepositoryFilesystem) TempFile(dir, prefix string) (billy.File, error)