Convenience wrapper that fetches from a remote instance and calls repo.unpack with the resulting packfile stream for you.
Read the current active branch.
Load a git object from the database. You can pass in either a hash or a symbolic name like HEAD or refs/tags/v3.1.4.
The object will be of the form: { type: "commit", // Or "tag", "tree", or "blob" body: { ... } // Or an array for tree and a binary value for blob. }
This convenience wrapper will call repo.load for you and then check if the type is what you expected. If it is, it will return the body directly. If it's not, it will error.
var commit = yield repo.loadAs("commit", "HEAD"); var tree = yield repo.loadAs("tree", commit.tree);
I'm using yield syntax because it's simpler, you can use callbacks instead if you prefer.
This convenience wrapper creates a readable stream of the history sorted by author date. If you want full history, pass in HEAD for the hash.
Remove an object.
Resolve a ref, branch, or tag to a real hash.
Save an object to the database. This will give you back the hash of the cotent by which you can retrieve the value back.
Another convenience wrapper, this time to save objects as a specefic type. The body must be in the right format.
var blobHash = yield repo.saveAs("blob", binaryData); var treeHash = yield repo.saveAs("tree", [ { mode: 0100644, name: "file.dat", hash: blobHash } ]); var commitHash = yield repo.saveAs("commit", { tree: treeHash, author: { name: "Tim Caswell", email: "tim@creationix.com", date: new Date }, message: "Save the blob" });
Set the current active branch.
This helper will return a stream of files suitable for traversing a file tree as a linear stream. The hash can be a ref to a commit, a commit hash or a tree hash directly.
Import a packfile stream (simple-stream format) into the current database. This is used mostly for clone and fetch operations where the stream comes from a remote repo.
opts is a hash of optional configs.
opts.onProgress(progress) - listen to the git progress channel by passing in a event listener. opts.onError(error) - same thing, but for the error channel. opts.deline - If this is truthy, the progress and error messages will be rechunked to be whole lines. They usually come jumbled in the internal sidechannel.
Update whatever branch HEAD is pointing to so that it points to hash. You'll usually want to do this after creating a new commint in the HEAD branch.
This is the generic helper that logWalk and treeWalk use. See js-git.js source for usage.
any