Documentation
¶
Index ¶
- Constants
- Variables
- func ArgsIncomplete() error
- func CheckCRC(data []byte) bool
- func Init(ctx context.Context, name string) error
- func IsGit() (bool, error)
- type Blob
- type Comm
- type Config
- type Got
- func (got *Got) Add(ctx context.Context, all bool, args ...string) error
- func (got *Got) Branches() (io.Reader, error)
- func (got *Got) CatFile(ctx context.Context, prefix string, mode int) (io.Reader, error)
- func (got *Got) Checkout(ctx context.Context, name string) error
- func (got *Got) Commit(ctx context.Context, msg string, all bool) (string, error)
- func (g *Got) Delete(path []string, where int) error
- func (got *Got) DeleteBranch(ctx context.Context, name string) error
- func (g *Got) Diff(cached bool, output, arg string) error
- func (git *Got) FatalErr(err error)
- func (g *Got) Fetch(ctx context.Context, remote string) error
- func (got *Got) FindObject(prefix string) (string, error)
- func (got *Got) GotErr(err error)
- func (got *Got) HashObject(data []byte, ty string, w bool) ([]byte, error)
- func (g *Got) Log(rdr io.Reader) error
- func (got *Got) LsFiles(ctx context.Context, stage, cached, deleted, modified, others bool) error
- func (got *Got) LsRemote()
- func (got *Got) LsTree(ctx context.Context, path string) (io.Reader, error)
- func (got *Got) Merge(ctx context.Context, comm string) error
- func (got *Got) NewBranch(ctx context.Context, name string) error
- func (got *Got) Object(sha string, ty ObjectType) (GotObject, error)
- func (g *Got) OpenRead(id string) (io.Reader, error)
- func (g *Got) OpenWrite() error
- func (got *Got) Pull(ctx context.Context, remote string, rebase bool) error
- func (got *Got) Push(ctx context.Context, url string) (string, error)
- func (got *Got) ReadObject(prefix string) (string, string, []byte, error)
- func (got *Got) ReadObjectStream(prefix string) (string, string, io.Reader, error)
- func (got *Got) ReadTree(treeish string) error
- func (got *Got) RemoteAdd(ctx context.Context, name string) error
- func (got *Got) RemoteRm(ctx context.Context, name string) error
- func (g *Got) Rm(ctx context.Context, cached bool, args []string) error
- func (g *Got) ShowConf(path []string, where int) (io.Reader, error)
- func (got *Got) Status(ctx context.Context) io.Reader
- func (git *Got) UpErr(err error) error
- func (got *Got) UpIndexEntries(entries []*IdxEntry) error
- func (g *Got) UpdateConf(path []string, value string, where int) error
- func (got *Got) UpdateIndex(ctx context.Context, all, remove bool) error
- func (got *Got) VerifyPack(ctx context.Context, idx string) error
- func (got *Got) WkDir() string
- func (got *Got) WriteTree(ctx context.Context) (string, error)
- type GotObject
- type Hasher
- type Idx
- type IdxEntry
- type InlineCmt
- type KV
- type Line
- type LineType
- type ObjectErr
- type ObjectType
- type OpErr
- type Pack
- type PackErr
- type Ref
- type RefType
- type Section
- type Sha1
- type Sign
- type Tag
- type Tree
- type User
Constants ¶
const ( FetchRefSpec = "+refs/heads/*:refs/remotes/%s/*" PushRefSpec = "refs/heads/*:refs/heads/*" )
default RefSpecs
const ( Sep byte = 0 Space byte = ' ' )
const ( OBJ_COMMIT pkObjectType OBJ_TREE OBJ_BLOB OBJ_TAG OBJ_OFS_DELTA OBJ_REF_DELTA )
const RFC2822 = "Mon Jan 2 15:04:05 2006 -0700"
const TIME_FORMAT = "Mon Jan 2 15:04:05 2006 -0700"
Time format used in formatting commit time
Variables ¶
var ( IOWriteErr = &OpErr{Context: "Could not write to the specified writer: "} PermissionErr = &OpErr{Context: "Permission denied: "} FormatErr = &OpErr{Context: "Bad Formatting: "} CopyErr = &OpErr{Context: "Could not copy data: "} NotDefinedErr = &OpErr{Context: "Value not defined"} IOCreateErr = &OpErr{Context: "Could not create file/ directory:"} IoReadErr = &OpErr{Context: "Could not read file:"} Incomplete = &OpErr{Context: "Object Incomplete"} )
var (
GenericNetErr = &PackErr{Context: "Pack File Error"}
)
var HeadNotINitErr = fmt.Errorf("Head not yet initialized")
Functions ¶
func ArgsIncomplete ¶
func ArgsIncomplete() error
func CheckCRC ¶
the crc32IEEE polynomial: X^32+X^26+X^23+X^22+X^16+X^12+X^11+X^10+X^8+X^7+X^5+X^4+X^2+X^1+X^0
func Init ¶
#####PORCELAINS##### Porcelains are generally small and neat methods that rely heavily on plumbers to do the dirty work, and sometimes helprs too. Its an unfair world, but it is what it is Check: https://stackoverflow.com/questions/35894613/how-to-disallow-access-to-a-file-for-one-user/35895436#35895436 on file permissions Init creates a directory for your repo and initializes the hidden .git directory
Types ¶
type Got ¶
type Got struct {
// contains filtered or unexported fields
}
func (*Got) Add ¶
Add updates the index using the current content found in the working tree, to prepare the content staged for the next commit. provide full paths please comebck: move parsing problems to cmd
func (*Got) CatFile ¶
CatFile displays the file info using the git logger (set as os.Stdout). It uses flags to determine what it displays
func (*Got) Commit ¶
https://github.com/git/git/blob/master/Documentation/technical/http-protocol.txt https://github.com/git/git/blob/master/Documentation/technical/pack-protocol.txt Commit first writes the tree from the set of staged objects we have no commit-tree method comeback to fix the method. we need a way to writ the committed changes to stdout comeback `all` determines whether all known files (already in index) is automatically committed
func (*Got) FatalErr ¶
comback remove os.Exit(). program should only exit at main.main. here, I want to return an error value that directly causes the program to exit at the main function with a non-zero code / |||The Got panic error handler |||| /// FatalErr is a convenience function for errors that will cause the program to exit
func (*Got) FindObject ¶
FindObject takes a sha1 prefix. It returns the path to the object file. It doesn't care t open it another method does that we want to have findObject such that even though we do not have a full 20 byte string, we can still find the path to the file it is unlikely to find two blobs with the same sha1 prefix, but if such happens, we return an error and expect the user to provide a longer string
func (*Got) LsFiles ¶
LsFiles prints to stdOut the state of staged files, i.e. the index files After a Commit, it is clean comeback
func (*Got) LsRemote ¶
func (got *Got) LsRemote()
after refs and capabilities discovery, client may send the flush packet to tell the server it has ended
func (*Got) Push ¶
discover references available in the remote repo first the remote repo has no workspace. It basically contains what is in the .git directory.
func (*Got) ReadObject ¶
ReadObject bulds on findObject. First, it finds the object, but it does more, it attempts to read it and assert that it contains valid git object files apart from that, it tries to understand what kind of git object it is
func (*Got) ReadObjectStream ¶
func (*Got) Rm ¶
Rm remove files matching pathspec from the index, or from the working tree and the index It will not remove a file from just your working directory provide full paths please
func (*Got) UpIndexEntries ¶
write the index file, given a slice of index this is the function that stages files IndexEntry file integers in git are written in NE.
func (*Got) UpdateConf ¶
comeback
func (*Got) UpdateIndex ¶
comeback
type Idx ¶
type Idx struct {
// contains filtered or unexported fields
}
we work only with version 2 https://github.com/git/git/blob/master/Documentation/technical/index-format.txt
type InlineCmt ¶
type InlineCmt struct {
// contains filtered or unexported fields
}
stands for comment lines and empty lines
type Line ¶
type Line struct {
// contains filtered or unexported fields
}
if comment, k is empty. if sect, k is sect, v is subsect if it exists.
type ObjectErr ¶
type ObjectErr struct {
ErrSTring string
// contains filtered or unexported fields
}
type ObjectType ¶
type ObjectType int
type OpErr ¶
type OpErr struct {
Context string
// contains filtered or unexported fields
}
TODO: In doing this work, I have tried to do my best with error handling / Errors that do not belong directly to the Git struct Preference is to return these errors early after adding a context. the caller then decides what to do. Because this app is not robust, we mostly just panic
func (OpErr) AddContext ¶
type Pack ¶
TODO: TRY USING SOMETHING LIKE THE ENCODER INTERFACE TO DESCRIBE THE FUNCTIONALITY OF THE PACK. CHECK HEX ENCODER
type Ref ¶
type Ref struct {
// contains filtered or unexported fields
}
type Tree ¶
type Tree struct {
// contains filtered or unexported fields
}
tree [content size]\0[Entries having references to other trees and blobs] [mode] [file/folder name]\0[SHA-1 of referencing blob or tree]