{"modulePath":"github.com/github/git-media","version":"v2.5.2+incompatible","isLatest":true,"isStandardLibrary":false,"goos":"all","goarch":"all","docs":"# package githistory\n\n## Variables\n\n```go\nvar (\n\t// WithFilter is an optional argument given to the NewRewriter\n\t// constructor function to limit invocations of the BlobRewriteFn to\n\t// only pathspecs that match the given *filepathfilter.Filter.\n\tWithFilter = func(filter *filepathfilter.Filter) rewriterOption {\n\t\treturn func(r *Rewriter) {\n\t\t\tr.filter = filter\n\t\t}\n\t}\n\n\t// WithLoggerto logs updates caused by the *git/githistory.Rewriter to\n\t// the given io.Writer \"sink\".\n\tWithLoggerTo = func(sink io.Writer) rewriterOption {\n\t\treturn WithLogger(tasklog.NewLogger(sink))\n\t}\n\n\t// WithLogger logs updates caused by the *git/githistory.Rewriter to the\n\t// be given to the provided logger, \"l\".\n\tWithLogger = func(l *tasklog.Logger) rewriterOption {\n\t\treturn func(r *Rewriter) {\n\t\t\tr.l = l\n\t\t}\n\t}\n)\n```\n\n## Types\n\n```go\ntype BlobRewriteFn func(path string, b *gitobj.Blob) (*gitobj.Blob, error)\n```\nBlobRewriteFn is a mapping function that takes a given blob and returns a new, modified blob. If it returns an error, the new blob will not be written and instead the error will be returned from the Rewrite() function.\n\nInvocations of an instance of BlobRewriteFn are not expected to store the returned blobs in the \\*git/gitobj.ObjectDatabase.\n\nThe path argument is given to be an absolute path to the tree entry being rewritten, where the repository root is the root of the path given. For instance, a file \"b.txt\" in directory \"dir\" would be given as \"/dir/b.txt\", where as a file \"a.txt\" in the root would be given as \"/a.txt\".\n\nAs above, the path separators are OS specific, and equivalent to the result of filepath.Join(...) or os.PathSeparator.\n\n```go\ntype RewriteOptions struct {\n\t// Include is the list of refs of which commits reachable by that ref\n\t// will be included.\n\tInclude []string\n\t// Exclude is the list of refs of which commits reachable by that ref\n\t// will be excluded.\n\tExclude []string\n\n\t// UpdateRefs specifies whether the Rewriter should move refs from the\n\t// original graph onto the migrated one. If true, the refs will be\n\t// moved, and a reflog entry will be created.\n\tUpdateRefs bool\n\n\t// Verbose mode prints migrated objects.\n\tVerbose bool\n\n\t// ObjectMapFilePath is the path to the map of old sha1 to new sha1\n\t// commits\n\tObjectMapFilePath string\n\n\t// BlobFn specifies a function to rewrite blobs.\n\t//\n\t// It is called once per unique, unchanged path. That is to say, if\n\t// /a/foo and /a/bar contain identical contents, the BlobFn will be\n\t// called twice: once for /a/foo and once for /a/bar, but no more on\n\t// each blob for subsequent revisions, so long as each entry remains\n\t// unchanged.\n\tBlobFn BlobRewriteFn\n\t// TreePreCallbackFn specifies a function to be called before opening a\n\t// tree for rewriting. It will be called on all trees throughout history\n\t// in topological ordering through the tree, starting at the root.\n\tTreePreCallbackFn TreePreCallbackFn\n\t// TreeCallbackFn specifies a function to rewrite trees after they have\n\t// been reassembled by calling the above BlobFn on all existing tree\n\t// entries.\n\tTreeCallbackFn TreeCallbackFn\n}\n```\nRewriteOptions is an options type given to the Rewrite() function.\n\n```go\ntype Rewriter struct {\n\t// contains filtered or unexported fields\n}\n```\nRewriter allows rewriting topologically equivalent Git histories between two revisions.\n\n```go\nfunc NewRewriter(db *gitobj.ObjectDatabase, opts ...rewriterOption) *Rewriter\n```\nNewRewriter constructs a \\*Rewriter from the given \\*ObjectDatabase instance.\n\n```go\nfunc (r *Rewriter) Filter() *filepathfilter.Filter\n```\nFilter returns the filter used by this \\*Rewriter to filter subtrees, blobs (see above).\n\n```go\nfunc (r *Rewriter) Rewrite(opt *RewriteOptions) ([]byte, error)\n```\nRewrite rewrites the range of commits given by \\*RewriteOptions.{Left,Right} using the BlobRewriteFn to rewrite the individual blobs.\n\n```go\ntype TreeCallbackFn func(path string, t *gitobj.Tree) (*gitobj.Tree, error)\n```\nTreeCallbackFn specifies a function to call before writing a re-written tree to the object database. The TreeCallbackFn can return a modified tree to be written to the object database instead of one generated from calling BlobFn on all of the tree entries.\n\nTreeCallbackFn can be nil, and will therefore exhibit behavior equivalent to only calling the BlobFn on existing tree entries.\n\nIf the TreeCallbackFn returns an error, it will be returned from the Rewrite() invocation.\n\n```go\ntype TreePreCallbackFn func(path string, t *gitobj.Tree) error\n```\nTreePreCallbackFn specifies a function to call upon opening a new tree for rewriting.\n\nUnlike its sibling TreeCallbackFn, TreePreCallbackFn may not modify the given tree.\n\nTreePreCallbackFn can be nil, and will therefore exhibit behavior equivalent to only calling the BlobFn on existing tree entries.\n\nIf the TreePreCallbackFn returns an error, it will be returned from the Rewrite() invocation.\n\n","path":"github.com/github/git-media/git/githistory","name":"githistory","synopsis":"","isRedistributable":true}
