Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
var ( // WithFilter is an optional argument given to the NewRewriter // constructor function to limit invocations of the BlobRewriteFn to // only pathspecs that match the given *filepathfilter.Filter. WithFilter = func(filter *filepathfilter.Filter) rewriterOption { return func(r *Rewriter) { r.filter = filter } } // WithLoggerto logs updates caused by the *git/githistory.Rewriter to // the given io.Writer "sink". WithLoggerTo = func(sink io.Writer) rewriterOption { return WithLogger(tasklog.NewLogger(sink)) } // WithLogger logs updates caused by the *git/githistory.Rewriter to the // be given to the provided logger, "l". WithLogger = func(l *tasklog.Logger) rewriterOption { return func(r *Rewriter) { r.l = l } } )
Functions ¶
This section is empty.
Types ¶
type BlobRewriteFn ¶
BlobRewriteFn 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.
Invocations of an instance of BlobRewriteFn are not expected to store the returned blobs in the *git/gitobj.ObjectDatabase.
The 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".
As above, the path separators are OS specific, and equivalent to the result of filepath.Join(...) or os.PathSeparator.
type RewriteOptions ¶
type RewriteOptions struct { // Include is the list of refs of which commits reachable by that ref // will be included. Include []string // Exclude is the list of refs of which commits reachable by that ref // will be excluded. Exclude []string // UpdateRefs specifies whether the Rewriter should move refs from the // original graph onto the migrated one. If true, the refs will be // moved, and a reflog entry will be created. UpdateRefs bool // Verbose mode prints migrated objects. Verbose bool // ObjectMapFilePath is the path to the map of old sha1 to new sha1 // commits ObjectMapFilePath string // BlobFn specifies a function to rewrite blobs. // // It is called once per unique, unchanged path. That is to say, if // /a/foo and /a/bar contain identical contents, the BlobFn will be // called twice: once for /a/foo and once for /a/bar, but no more on // each blob for subsequent revisions, so long as each entry remains // unchanged. BlobFn BlobRewriteFn // TreePreCallbackFn specifies a function to be called before opening a // tree for rewriting. It will be called on all trees throughout history // in topological ordering through the tree, starting at the root. TreePreCallbackFn TreePreCallbackFn // TreeCallbackFn specifies a function to rewrite trees after they have // been reassembled by calling the above BlobFn on all existing tree // entries. TreeCallbackFn TreeCallbackFn }
RewriteOptions is an options type given to the Rewrite() function.
type Rewriter ¶
type Rewriter struct {
// contains filtered or unexported fields
}
Rewriter allows rewriting topologically equivalent Git histories between two revisions.
func NewRewriter ¶
func NewRewriter(db *gitobj.ObjectDatabase, opts ...rewriterOption) *Rewriter
NewRewriter constructs a *Rewriter from the given *ObjectDatabase instance.
func (*Rewriter) Filter ¶
func (r *Rewriter) Filter() *filepathfilter.Filter
Filter returns the filter used by this *Rewriter to filter subtrees, blobs (see above).
type TreeCallbackFn ¶
TreeCallbackFn 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.
TreeCallbackFn can be nil, and will therefore exhibit behavior equivalent to only calling the BlobFn on existing tree entries.
If the TreeCallbackFn returns an error, it will be returned from the Rewrite() invocation.
type TreePreCallbackFn ¶
TreePreCallbackFn specifies a function to call upon opening a new tree for rewriting.
Unlike its sibling TreeCallbackFn, TreePreCallbackFn may not modify the given tree.
TreePreCallbackFn can be nil, and will therefore exhibit behavior equivalent to only calling the BlobFn on existing tree entries.
If the TreePreCallbackFn returns an error, it will be returned from the Rewrite() invocation.