diff --git a/LICENSE b/LICENSE index 4782c6003..80bc57cb1 100644 --- a/LICENSE +++ b/LICENSE @@ -1,24 +1,19 @@ Copyright (c) 2013 Tim Branyen -This file is free software; you can redistribute it and/or modify -it under the terms of the GNU General Public License, version 2, -as published by the Free Software Foundation. +Permission is hereby granted, free of charge, to any person obtaining a copy of +this software and associated documentation files (the "Software"), to deal in +the Software without restriction, including without limitation the rights to +use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies +of the Software, and to permit persons to whom the Software is furnished to do +so, subject to the following conditions: -In addition to the permissions in the GNU General Public License, -the authors give you unlimited permission to link the compiled -version of this file into combinations with other programs, -and to distribute those combinations without any restriction -coming from the use of this file. (The General Public License -restrictions do apply in other respects; for example, they cover -modification of the file, and distribution when not linked into -a combined executable.) +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. -This file is distributed in the hope that it will be useful, but -WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -General Public License for more details. - -You should have received a copy of the GNU General Public License -along with this program; see the file COPYING. If not, write to -the Free Software Foundation, 51 Franklin Street, Fifth Floor, -Boston, MA 02110-1301, USA. +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. diff --git a/README.md b/README.md index 383e938c9..462e22e18 100644 --- a/README.md +++ b/README.md @@ -3,44 +3,31 @@ nodegit > Node.js libgit2 bindings -**v0.0.78** [![Build +**v0.1.0** [![Build Status](https://travis-ci.org/tbranyen/nodegit.png)](https://travis-ci.org/tbranyen/nodegit) -Maintained by Tim Branyen [@tbranyen](http://twitter.com/tbranyen) and Michael -Robinson [@codeofinterest](http://twitter.com/codeofinterest), with help from +Maintained by Tim Branyen [@tbranyen](http://twitter.com/tbranyen), Michael +Robinson [@codeofinterest](http://twitter.com/codeofinterest), and Nick Kallen [@nk](http://twitter.com/nk), with help from [awesome contributors](https://github.com/tbranyen/nodegit/contributors)! API Documentation ------------------------ -Documentation may be found here: [`nodegit` documentation](http://tbranyen.github.com/nodegit/). - -Contributing ------------- - -Nodegit aims to eventually provide native asynchronous bindings for as much of -libgit2 as possible, but we can't do it alone! - -We welcome pull requests, but please pay attention to the following: whether -your lovely code fixes a bug or adds a new feature, please include unit tests -that either prove the bug is fixed, or that your new feature works as expected. -See [running tests](#running-tests) - -Unit tests are what makes the Node event loop go around. +Documentation may be found here: [`nodegit` documentation](http://www.nodegit.org/nodegit/). Building and installing ----------------------- ### Dependencies ### -To install `nodegit` you need `Node.js`, `python` and `cmake`. To run unit tests you will need to have -`git` installed and accessible from your `PATH` to fetch any `vendor/` addons. + +To install `nodegit` you need `Node.js`, `python` and `cmake`. ### Easy install (Recommended) ### This will install and configure everything you need to use `nodegit`. ```` bash -$ npm install nodegit +$ npm run-script gen && npm install && npm test ```` ### Mac OS X/Linux/Unix ### @@ -50,14 +37,7 @@ $ npm install nodegit ```` bash $ git clone git://github.com/tbranyen/nodegit.git $ cd nodegit -$ node install -```` - -\*Updating to a new version\* - -```` bash -$ git pull -$ node install +$ npm run-script gen && npm install ```` ### Windows via Cygwin ### @@ -70,129 +50,62 @@ Instructions on compiling `Node.js` on a Windows platform can be found here: API Example Usage ----------------- +Below are two examples. [There are several more](https://github.com/nodegit/nodegit/tree/master/example). + ### Git Log Emulation ### -#### Convenience API #### +```JavaScript +var git = require('../'), + path = require('path'); + +git.Repo.open(path.resolve(__dirname, '/tmp/repo/.git'), function(error, repo) { + if (error) throw error; + + repo.getMaster(function(error, branch) { + if (error) throw error; + + // History returns an event. + var history = branch.history(); + + // History emits 'commit' event for each commit in the branch's history + history.on('commit', function(commit) { + console.log('commit ' + commit.sha()); + console.log('Author:', commit.author().name() + ' <' + commit.author().email() + '>'); + console.log('Date:', commit.date()); + console.log('\n ' + commit.message()); + }); + + // Don't forget to call `start()`! + history.start(); + }); +}); + +``` + +### Clone a repo and read a file ### ```JavaScript -// Load in the module. -var git = require('nodegit'), - async = require('async'); - -// Open the repository in the current directory. -git.repo('.git', function(error, repository) { - if (error) { - throw error; - } - - // Use the master branch. - repository.branch('master', function(error, branch) { - if (error) { - throw error; - } - - // Iterate over the revision history. - branch.history().on('commit', function(error, commit) { - - // Print out `git log` emulation. - async.series([ - function(callback) { - commit.sha(callback); - }, - function(callback) { - commit.time(callback); - }, - function(callback) { - commit.author(function(error, author) { - author.name(callback); - }); - }, - function(callback) { - commit.author(function(error, author) { - author.email(callback); - }); - }, - function(callback) { - commit.message(callback); - } - ], function printCommit(error, results) { - console.log('SHA ' + results[0]); - console.log(new Date(results[1] * 1000)); - console.log(results[2] + ' <' + results[3] + '>'); - console.log(results[4]); - }); +git.Repo.clone("https://github.com/nodegit/nodegit.git", path, null, function(error, repo) { + if (error) throw error; + + repo.getCommit('59b20b8d5c6ff8d09518454d4dd8b7b30f095ab5', function(error, commit) { + if (error) throw error; + + commit.getEntry('README.md', function(error, entry) { + if (error) throw error; + + entry.getBlob(function(error, blob) { + if (error) throw error; + + console.log(entry.name(), entry.sha(), blob.size() + 'b'); + console.log('========================================================\n\n'); + var firstTenLines = blob.toString().split('\n').slice(0, 10).join('\n'); + console.log(firstTenLines); + console.log('...'); + }); }); }); }); ``` -Running tests -------------- - -__`nodegit` library code is written adhering to a modified `JSHint`. Run these checks with `make lint` in the project root.__ - -__To run unit tests ensure to update the submodules with `git submodule update --init` and install the development dependencies nodeunit and rimraf with `npm install`.__ - -Then simply run `npm test` in the project root. - -Release information -------------------- - -__Can keep track of current method coverage at: [http://bit.ly/tb_methods](http://bit.ly/tb_methods)__ - -### v0.0.7: ### - * Updated to work with Node ~0.8. - * More unit tests - * Added convenience build script - * Locked libgit2 to version 0.15.0 - -### v0.0.6: ### - * Updated to work with Node ~0.6. - -### v0.0.5: ### - * Added in fast Buffer support. - * Blob raw write supported added, no convenience methods yet... - * Updated libgit2 to version 0.12.0 - -### v0.0.4: ### - * Many fixes! - * Blob raw write supported added, no convenience methods yet... - * Updated libgit2 to version 0.12.0 - -### v0.0.3: ### - * More documented native source code - * Updated convenience api code - * More unit tests - * Updated libgit2 to version 0.11.0 - * Windows Cygwin support! *albeit hacky* - -### v0.0.2: ### - * More methods implemented - * More unit tests - * More API development - * Tree and Blob support - * Updated libgit2 to version 0.8.0 - -### v0.0.1: ### - * Some useful methods implemented - * Some unit tests - * Some documented source code - * Useable build/code quality check tools - * Node.js application that can be configured/built/installed via source and NPM - * An API that can be easily extended with convenience methods in JS - * An API that offers a familiar clean syntax that will make adoption and use much more likely - * Open for public testing - * GitHub landing page - * Repo, Oid, Commit, Error, Ref, and RevWalk support - * Built on libgit2 version 0.3.0 - -Getting involved ----------------- - -If you find this project of interest, please document all issues and fork if -you feel you can provide a patch. Testing is of huge importance; by simply -running the unit tests on your system and reporting issues you can contribute! - -__Before submitting a pull request, please ensure both that you've added unit -tests to cover your shiny new code, and that all unit tests and lint checks -pass.__ +[![githalytics.com alpha](https://cruel-carlota.pagodabox.com/a81b20d9f61dbcdc7c68002c6a564b5b "githalytics.com")](http://githalytics.com/tbranyen/nodegit) diff --git a/TODO b/TODO new file mode 100644 index 000000000..34afdf82b --- /dev/null +++ b/TODO @@ -0,0 +1 @@ +- codegen documentation diff --git a/binding.gyp b/binding.gyp index b683da9ea..bbc232773 100644 --- a/binding.gyp +++ b/binding.gyp @@ -6,18 +6,37 @@ 'src/base.cc', 'src/blob.cc', 'src/commit.cc', - 'src/error.cc', 'src/oid.cc', 'src/reference.cc', + 'src/object.cc', 'src/repo.cc', + 'src/index.cc', + 'src/index_entry.cc', + 'src/index_time.cc', + 'src/tag.cc', 'src/revwalk.cc', 'src/signature.cc', + 'src/time.cc', 'src/tree.cc', + 'src/tree_builder.cc', 'src/tree_entry.cc', + 'src/diff_find_options.cc', + 'src/diff_options.cc', 'src/diff_list.cc', + 'src/patch.cc', + 'src/delta.cc', + 'src/diff_file.cc', + 'src/diff_range.cc', 'src/threads.cc', - 'src/functions/string.cc', - 'src/functions/utilities.cc' + 'src/wrapper.cc', + 'src/refdb.cc', + 'src/odb_object.cc', + 'src/odb.cc', + 'src/submodule.cc', + 'src/remote.cc', + 'src/clone_options.cc', + 'src/functions/copy.cc', + ], 'include_dirs': [ diff --git a/example/apps/git_profanity_check.js b/example/apps/git_profanity_check.js index 3031f4186..09f0e09db 100644 --- a/example/apps/git_profanity_check.js +++ b/example/apps/git_profanity_check.js @@ -5,50 +5,36 @@ // Script to detect cursewords in commit messages and provide the // offending commit sha's. // vim: ft=javascript -var git = require( 'nodegit' ); +var git = require('../../'); -var curses = [ 'add', 'swears', 'here' ] - , path = './.git' - , branch = 'master' - , reCurse = new RegExp('\\b(?:' + curses.join('|') + ')\\b', 'gi'); +var curses = ['add', 'swears', 'here'], + path = './.git', + branchName = 'master', + reCurse = new RegExp('\\b(?:' + curses.join('|') + ')\\b', 'gi'); -// Set git path -if ( process.argv.length < 3 ) { - console.log( 'No path passed as argument, defaulting to ./.git' ); -} -else { +if (process.argv.length < 3) { + console.log('No git path passed as argument, defaulting to ./.git'); +} else { path = process.argv[2]; - // Set repo branch - if ( process.argv.length < 4 ) { - console.log( 'No branch passed as argument, defaulting to master' ); - } - else { - branch = process.argv[3]; + if (process.argv.length < 4) { + console.log('No repo branchName passed as argument, defaulting to master'); + } else { + branchName = process.argv[3]; } } -// Open repository -git.repo( path, function( err, repo ) { - if ( err ) { - throw new Error( err ); - } +git.Repo.open(path, function(error, repo) { + if (error) throw error; - // Open branch - repo.branch( branch, function( err, branch ) { - if ( err ) { - throw new Error( err ); - } + repo.getBranch(branchName, function(error, branch) { + if (error) throw error; - // Iterate history var history = branch.history(); - history.on( 'commit', function( idx, commit ) { - // Check commit messages first - if ( reCurse.test(commit.message) ) { - console.log( 'Curse detected in commit', commit.sha, 'message' ); - return; - } - }); + history.on('commit', function(commit) { + if (reCurse.test(commit.message())) + console.log('Curse detected in commit', commit.sha(), 'message', commit.message()); + }).start(); }); }); diff --git a/example/clone.js b/example/clone.js new file mode 100644 index 000000000..75f8b3603 --- /dev/null +++ b/example/clone.js @@ -0,0 +1,27 @@ +var git = require('../'), + rimraf = require('rimraf'), + path = "/tmp/nodegit-clone-demo"; + +rimraf(path, function() { + git.Repo.clone("https://github.com/nodegit/nodegit.git", path, null, function(error, repo) { + if (error) throw error; + + repo.getCommit('59b20b8d5c6ff8d09518454d4dd8b7b30f095ab5', function(error, commit) { + if (error) throw error; + + commit.getEntry('README.md', function(error, entry) { + if (error) throw error; + + entry.getBlob(function(error, blob) { + if (error) throw error; + + console.log(entry.name(), entry.sha(), blob.size() + 'b'); + console.log('========================================================\n\n'); + var firstTenLines = blob.toString().split('\n').slice(0, 10).join('\n'); + console.log(firstTenLines); + console.log('...'); + }); + }); + }); + }); +}); \ No newline at end of file diff --git a/example/convenience-commit.js b/example/convenience-commit.js deleted file mode 100644 index 1e2320a85..000000000 --- a/example/convenience-commit.js +++ /dev/null @@ -1,48 +0,0 @@ -// Load in the module. -var git = require('nodegit'), - async = require('async'); - -// Open the repository in the current directory. -git.repo('.git', function(error, repository) { - if (error) throw error; - - // Use the master branch (a branch is the HEAD commit) - repository.branch('master', function(error, branch) { - if (error) throw error; - - // History returns an event, and begins walking the history - var history = branch.history(); - - // History emits 'commit' event for each commit in the branch's history - history.on('commit', function(error, commit) { - // Print out `git log` emulation. - async.series([ - function(callback) { - commit.sha(callback); - }, - function(callback) { - commit.date(callback); - }, - function(callback) { - commit.author(function(error, author) { - author.name(callback); - }); - }, - function(callback) { - commit.author(function(error, author) { - author.email(callback); - }); - }, - function(callback) { - commit.message(callback); - } - ], function printCommit(error, results) { - if (error) throw error; - console.log('SHA ' + results[0]); - console.log(results[1] * 1000); - console.log(results[2] + ' <' + results[3] + '>'); - console.log(results[4]); - }); - }); - }); -}); diff --git a/example/convenience-repo.js b/example/convenience-repo.js deleted file mode 100644 index e641fe880..000000000 --- a/example/convenience-repo.js +++ /dev/null @@ -1,19 +0,0 @@ -// Load in the module -var git = require( '../' ); -// Open a repository for reading -git.repo( '../.git', function( err, repo ) { - // Success is always 0, failure is always an error string - if( err ) { throw err; } - // Use the master branch - repo.branch( 'master', function( err, branch ) { - if( err ) { throw err; } - // Iterate over the revision history - branch.history().on( 'commit', function( err, commit ) { - // Print out `git log` emulation - console.log( 'commit ' + commit.sha ); - console.log( commit.author.name + ' <' + commit.author.email + '>' ); - console.log( commit.time ); - console.log( commit.message ); - }); - }); -}); diff --git a/example/convenience-tree.js b/example/convenience-tree.js deleted file mode 100644 index efe4cb928..000000000 --- a/example/convenience-tree.js +++ /dev/null @@ -1,23 +0,0 @@ -// Load in the module. -var git = require('nodegit'); - -// Open the repository in the current directory. -git.repo('.git', function(error, repository) { - if (error) throw error; - - // Use the master branch. - repository.branch('master', function(error, branch) { - if (error) throw error; - - // Iterate over the revision history. - branch.tree(function(error, tree) { - console.log(tree); - if (error) throw error; - tree.walk().on('entry', function(error, entry) { - entry.name(function(error, name) { - console.log(name); - }); - }); - }); - }); -}); diff --git a/example/diff-commits.js b/example/diff-commits.js new file mode 100644 index 000000000..edd05b3eb --- /dev/null +++ b/example/diff-commits.js @@ -0,0 +1,35 @@ +var git = require('../'), + path = require('path'); + +// This code examines the diffs between a particular commit and all of its +// parents. Since this commit is not a merge, it only has one parent. This is +// similar to doing `git show`. + +git.Repo.open(path.resolve(__dirname, '../.git'), function(error, repo) { + if (error) throw error; + + repo.getCommit('59b20b8d5c6ff8d09518454d4dd8b7b30f095ab5', function(error, commit) { + if (error) throw error; + + console.log('commit ' + commit.sha()); + console.log('Author:', commit.author().name() + ' <' + commit.author().email() + '>'); + console.log('Date:', commit.date()); + console.log('\n ' + commit.message()); + + commit.getDiff(function(error, diffList) { + if (error) throw error; + + diffList.forEach(function(diff) { + diff.patches().forEach(function(patch) { + console.log("diff", patch.oldFile().path(), patch.newFile().path()); + patch.hunks().forEach(function(hunk) { + console.log(hunk.header().trim()); + hunk.lines().forEach(function(line) { + console.log(String.fromCharCode(line.lineOrigin) + line.content.trim()); + }); + }); + }); + }); + }); + }); +}); diff --git a/example/fetch.js b/example/fetch.js new file mode 100644 index 000000000..2eeffe327 --- /dev/null +++ b/example/fetch.js @@ -0,0 +1,17 @@ +var git = require('../'), + path = require('path'); + +git.Repo.open(path.resolve(__dirname, '../.git'), function(error, repo) { + if (error) throw error; + + var remote = repo.getRemote("origin"); + remote.connect(0, function(error) { + if (error) throw error; + + remote.download(null, function(error) { + if (error) throw error; + + console.log("It worked!"); + }) + }); +}); diff --git a/example/general.js b/example/general.js new file mode 100644 index 000000000..2a7baea94 --- /dev/null +++ b/example/general.js @@ -0,0 +1,328 @@ +var git = require('../'), + path = require('path'); + +// **nodegit** is a javascript library for node.js that wraps libgit2, a +// pure C implementation of the Git core. It provides an asynchronous +// interface around any functions that do I/O, and a sychronous interface +// around the rest. +// +// This file is an example of using that API in a real, JS file. +// +// **libgit2** (for the most part) only implements the core plumbing +// functions, not really the higher level porcelain stuff. For a primer on +// Git Internals that you will need to know to work with Git at this level, +// check out [Chapter 9][pg] of the Pro Git book. + +// Nearly, all git operations in the context of a repository. +// To open a repository, + +git.Repo.open(path.resolve(__dirname, '../.git'), function(error, repo) { + // For all of the following examples, error-handling will be performed in + // this naive way: + if (error) throw error; + console.log("Opened repository."); + + // ### SHA-1 Value Conversions + + // Objects in git (commits, blobs, etc.) are referred to by their SHA value + // **nodegit** uses a simple wrapper around hash values called an `Oid`. + // The oid validates that the SHA is well-formed. + + var oid = git.Oid.fromString('fd373a561d63bfc0a5665608fe057f2131d81fee'); + + // Most functions in in **nodegit** that take an oid will also take a + // string, so for example, you can look up a commit by a string SHA or + // an Oid, but but any functions that create new SHAs will always return + // an Oid. + + // If you have a oid, you can easily get the hex value of the SHA again. + console.log("Sha hex string:", oid.sha()); + + // ### Working with the Object Database + + // **libgit2** provides [direct access][odb] to the object database. The + // object database is where the actual objects are stored in Git. For + // working with raw objects, we'll need to get this structure from the + // repository. + var odb = repo.odb(); + + // We can read raw objects directly from the object database if we have + // the oid (SHA) of the object. This allows us to access objects without + // knowing thier type and inspect the raw bytes unparsed. + + odb.read(oid, function(error, object) { + if (error) throw error; + + // A raw object only has three properties - the type (commit, blob, tree + // or tag), the size of the raw data and the raw, unparsed data itself. + // For a commit or tag, that raw data is human readable plain ASCII + // text. For a blob it is just file contents, so it could be text or + // binary data. For a tree it is a special binary format, so it's unlikely + // to be hugely helpful as a raw object. + var data = object.data(), + type = object.type(); + + console.log("Object size and type:", object.size(), object.type()); + }); + + // You can also write raw object data to Git. This is pretty cool because + // it gives you direct access to the key/value properties of Git. Here + // we'll write a new blob object that just contains a simple string. + // Notice that we have to specify the object type. + odb.write("test data", "test data".length, git.Object.Type.Blob, function(error, oid) { + if (error) throw error; + + // Now that we've written the object, we can check out what SHA1 was + // generated when the object was written to our database. + console.log("Written Object: ", oid.sha()); + }); + + // ### Object Parsing + + // libgit2 has methods to parse every object type in Git so you don't have + // to work directly with the raw data. This is much faster and simpler + // than trying to deal with the raw data yourself. + + // #### Commit Parsing + + // [Parsing commit objects][pco] is simple and gives you access to all the + // data in the commit - the author (name, email, datetime), committer + // (same), tree, message, encoding and parent(s). + + oid = git.Oid.fromString("698c74e817243efe441a5d1f3cbaf3998282ca86"); + + // Many methods in **nodegit** are asynchronous, because they do file + // or network I/O. By convention, all asynchronous methods are named + // imperatively, like `getCommit`, `open`, `read`, `write`, etc., whereas + // synchronous methods are named nominatively, like `type`, `size`, `name`. + + repo.getCommit(oid, function(error, commit) { + if (error) throw error; + + // Each of the properties of the commit object are accessible via methods, + // including commonly needed variations, such as `git_commit_time` which + // returns the author time and `git_commit_message` which gives you the + // commit message. + console.log("Commit:", commit.message(), commit.author().name(), commit.date()); + + // Commits can have zero or more parents. The first (root) commit will + // have no parents, most commits will have one (i.e. the commit it was + // based on) and merge commits will have two or more. Commits can + // technically have any number, though it's rare to have more than two. + commit.getParents(function(error, parents) { + parents.forEach(function(parent) { + console.log("Parent:", parent.oid().sha()); + }); + }); + }); + + // #### Writing Commits + + // nodegit provides a couple of methods to create commit objects easily as + // well. + + var author = git.Signature.create("Scott Chacon", "schacon@gmail.com", 123456789, 60); + var committer = git.Signature.create("Scott A Chacon", "scott@github.com", 987654321, 90); + + // Commit objects need a tree to point to and optionally one or more + // parents. Here we're creating oid objects to create the commit with, + // but you can also use existing ones: + + var treeId = git.Oid.fromString("4170d10f19600b9cb086504e8e05fe7d863358a2"); + var parentId = git.Oid.fromString("eebd0ead15d62eaf0ba276da53af43bbc3ce43ab"); + + repo.getTree(treeId, function(error, tree) { + if (error) throw error; + + repo.getCommit(parentId, function(error, parent) { + if (error) throw error; + // Here we actually create the commit object with a single call with all + // the values we need to create the commit. The SHA key is written to the + // `commit_id` variable here. + repo.createCommit( + null /* do not update the HEAD */, + author, + committer, + "example commit", + tree, + [parent], + function (error, oid) { + console.log("New Commit:", oid.sha()); + }); + }); + }); + + // #### Tag Parsing + + // You can parse and create tags with the [tag management API][tm], which + // functions very similarly to the commit lookup, parsing and creation + // methods, since the objects themselves are very similar. + + oid = git.Oid.fromString("97f6d755647aca272e7c8003323472cefca772fc"); + repo.getTag(oid, function(error, tag) { + if (error) throw error; + + // Now that we have the tag object, we can extract the information it + // generally contains: the target (usually a commit object), the type of + // the target object (usually 'commit'), the name ('v1.0'), the tagger (a + // git_signature - name, email, timestamp), and the tag message. + console.log(tag.name(), tag.targetType(), tag.message()); + + tag.getTarget(function (error, target) { + if (error) throw error; + + console.log("Target is commit:", target.isCommit()); + }); + }); + + // #### Tree Parsing + + // A Tree is how Git represents the state of the filesystem + // at a given revision. In general, a tree corresponds to a directory, + // and files in that directory are either files (blobs) or directories. + + // [Tree parsing][tp] is a bit different than the other objects, in that + // we have a subtype which is the tree entry. This is not an actual + // object type in Git, but a useful structure for parsing and traversing + // tree entries. + + oid = git.Oid.fromString("e1b0c7ea57bfc5e30ec279402a98168a27838ac9"); + repo.getTree(oid, function(error, tree) { + if (error) throw error; + + console.log("Tree Size:", tree.size()); + function dfs(error, tree) { + tree.entries().forEach(function(entry) { + if (entry.isDirectory()) { + entry.getTree(dfs); + } else if (entry.isFile()) { + console.log("Tree Entry:", entry.name()); + } + }); + } + dfs(null, tree); + + // You can also access tree entries by path if you know the path of the + // entry you're looking for. + tree.getEntry("example/general.js", function(error, entry) { + if (error) throw error; + + // Entries which are files have blobs associated with them: + entry.getBlob(function(error, blob) { + console.log("Blob size:", blob.size()); + }); + }); + }); + + // #### Blob Parsing + + // The last object type is the simplest and requires the least parsing + // help. Blobs are just file contents and can contain anything, there is + // no structure to it. The main advantage to using the [simple blob + // api][ba] is that when you're creating blobs you don't have to calculate + // the size of the content. There is also a helper for reading a file + // from disk and writing it to the db and getting the oid back so you + // don't have to do all those steps yourself. + + oid = git.Oid.fromString("991c06b7b1ec6f939488427e4b41a4fa3e1edd5f"); + repo.getBlob(oid, function(error, blob) { + if (error) throw error; + + // You can access a node.js Buffer with the raw contents of the blob directly. + // Note that this buffer may not be contain ASCII data for certain blobs + // (e.g. binary files). + var buffer = blob.content(); + + // If you know that the blob is UTF-8, however, + console.log("Blob contents:", blob.toString().slice(0, 38)); + }); + + // ### Revwalking + + // The libgit2 [revision walking api][rw] provides methods to traverse the + // directed graph created by the parent pointers of the commit objects. + // Since all commits point back to the commit that came directly before + // them, you can walk this parentage as a graph and find all the commits + // that were ancestors of (reachable from) a given starting point. This + // can allow you to create `git log` type functionality. + + oid = git.Oid.fromString("698c74e817243efe441a5d1f3cbaf3998282ca86"); + + // To use the revwalker, create a new walker, tell it how you want to sort + // the output and then push one or more starting points onto the walker. + // If you want to emulate the output of `git log` you would push the SHA + // of the commit that HEAD points to into the walker and then start + // traversing them. You can also 'hide' commits that you want to stop at + // or not see any of their ancestors. So if you want to emulate `git log + // branch1..branch2`, you would push the oid of `branch2` and hide the oid + // of `branch1`. + var revWalk = repo.createRevWalk(); + revWalk.sorting(git.RevWalk.Sort.Topological, git.RevWalk.Sort.Reverse); + revWalk.push(oid, function(error) { + if (error) throw error; + + // Now that we have the starting point pushed onto the walker, we start + // asking for ancestors. It will return them in the sorting order we asked + // for as commit oids. We can then lookup and parse the commited pointed + // at by the returned OID; note that this operation is specially fast + // since the raw contents of the commit object will be cached in memory + + function walk() { + revWalk.next(function(error, oid) { + if (error) throw error; + if (!oid) return; + + repo.getCommit(oid, function(error, commit) { + if (error) throw error; + + console.log("Commit:", commit.sha()); + walk(); + }); + }); + } + walk(); + }); + + // ### Index File Manipulation + + // The [index file API][gi] allows you to read, traverse, update and write + // the Git index file (sometimes thought of as the staging area). + repo.openIndex(function(error, index) { + if (error) throw error; + + // For each entry in the index, you can get a bunch of information + // including the SHA (oid), path and mode which map to the tree objects + // that are written out. It also has filesystem properties to help + // determine what to inspect for changes (ctime, mtime, dev, ino, uid, + // gid, file_size and flags) All these properties are exported publicly in + // the `IndexEntry` class + + index.entries().forEach(function(entry) { + console.log("Index Entry:", entry.path(), entry.mtime().seconds()); + }); + }); + + // ### References + + // The [reference API][ref] allows you to list, resolve, create and update + // references such as branches, tags and remote references (everything in + // the .git/refs directory). + + repo.getReferences(git.Reference.Type.All, function(error, referenceNames) { + if (error) throw error; + + referenceNames.forEach(function(referenceName) { + repo.getReference(referenceName, function(error, reference) { + if (error) throw error; + + if (reference.isOid()) { + console.log("Reference:", referenceName, reference.oid()); + } else if (reference.isSymbolic()) { + console.log("Reference:", referenceName, reference.symbolicTarget()); + } + }); + }); + }); +}); + + diff --git a/example/new-commit.js b/example/new-commit.js new file mode 100755 index 000000000..7fd130931 --- /dev/null +++ b/example/new-commit.js @@ -0,0 +1,32 @@ +var git = require('../'), + path = require('path'); + +// This example opens a certain file, `README.md`, at a particular commit, +// and prints the first 10 lines as well as some metadata. + +git.Repo.open(path.resolve(__dirname, '../.git'), function(error, repo) { + if (error) throw error; + + repo.getCommit('0a70ef1237bc1ea50dbccd395e1a114201b75a68', function(error, commit) { + if (error) throw error; + + commit.getTree(function(error, tree) { + if (error) throw error; + + var builder = tree.builder(), + buffer = new Buffer("this is a file\n"); + + builder.insertBlob("/lib/baz.txt", buffer, false) + builder.write(function(error, treeId) { + if (error) throw error; + + var author = git.Signature.create("Scott Chacon", "schacon@gmail.com", 123456789, 60); + var committer = git.Signature.create("Scott A Chacon", "scott@github.com", 987654321, 90); + + repo.createCommit(null, author, committer, "message", treeId, [commit], function(error, commitId) { + console.log("New Commit:", commitId.sha()); + }); + }); + }); + }); +}); diff --git a/example/raw-blob.js b/example/raw-blob.js deleted file mode 100644 index cee4b70a2..000000000 --- a/example/raw-blob.js +++ /dev/null @@ -1,24 +0,0 @@ -var git = require( '../' ).raw - , path = require( 'path' ); - -var repo = new git.Repo(); -repo.open( path.resolve( '../.git' ), function() { - var oid = new git.Oid(); - oid.mkstr( '59b20b8d5c6ff8d09518454d4dd8b7b30f095ab5' ); - - var commit = new git.Commit(); - commit.lookup( repo, oid, function( err ) { - var tree = new git.Tree( repo ), - entry = new git.TreeEntry(), - blob = new git.Blob( repo ); - - if( !commit.tree( tree ) && tree.entryCount() > 1 ) { - tree.entryByIndex( entry, 1 ); - entry.toObject( repo, blob ); - - console.log( entry.name() + ':' ); - console.log( blob.rawSize() ); - console.log( typeof blob.rawContent() ); - } - }); -}); diff --git a/example/raw-commit.js b/example/raw-commit.js deleted file mode 100644 index 07212061d..000000000 --- a/example/raw-commit.js +++ /dev/null @@ -1,13 +0,0 @@ -var git = require( '../' ).raw, - path = require( 'path' ); - -var repo = new git.Repo(); -repo.open( path.resolve( '../.git' ), function() { - var oid = new git.Oid(); - oid.mkstr( '59b20b8d5c6ff8d09518454d4dd8b7b30f095ab5' ); - - var commit = new git.Commit(); - commit.lookup( repo, oid, function( err ) { - console.log( new git.Error().strError( err ) ); - }); -}); diff --git a/example/raw-error.js b/example/raw-error.js deleted file mode 100644 index ab20568aa..000000000 --- a/example/raw-error.js +++ /dev/null @@ -1,7 +0,0 @@ -var git2 = require( '../' ).raw; - -var error = new git2.Error(); -// Valid -console.log( error.strError(0) ); -// Invalid -console.log( error.strError(-2) ); diff --git a/example/raw-oid.js b/example/raw-oid.js deleted file mode 100644 index 5b57a1234..000000000 --- a/example/raw-oid.js +++ /dev/null @@ -1,9 +0,0 @@ -var git = require( '../' ).raw; - -var oid = new git.Oid(); -oid.mkstr('1810DFF58D8A660512D4832E740F692884338CCD'); -console.log( oid.toString(40) ); - -//// Test formatting -//console.log( oid.mkstr('5f2aa9407f7b3aeb531c621c3358953841ccfc98') ); -//console.log( oid.toString(40) ); diff --git a/example/raw-repo.js b/example/raw-repo.js deleted file mode 100644 index bda7da00e..000000000 --- a/example/raw-repo.js +++ /dev/null @@ -1,17 +0,0 @@ -var git = require( '../' ).raw, - path = require( 'path' ); - - -var repo = new git.Repo(), - error = new git.Error(); - -// Access existing repository -repo.open( path.resolve( '../.git' ), function( err ) { - var master = new git.Ref(repo); - repo.lookupRef( master, 'refs/heads/master', function( err, ref ) { - console.log(err, master); - var oid = new git.Oid(); - master.oid(oid); - console.log( oid.toString(40) ); - }); -}); diff --git a/example/raw-revwalk.js b/example/raw-revwalk.js deleted file mode 100644 index 4a07747d6..000000000 --- a/example/raw-revwalk.js +++ /dev/null @@ -1,34 +0,0 @@ -var git = require( '../' ).raw, - path = require( 'path' ); - -var repo = new git.Repo(); - -// Access existing repository -repo.open( path.resolve( '../.git' ), function( err ) { - var revwalk = new git.RevWalk( repo ), - oid = new git.Oid(), - error = new git.Error(), - master = new git.Ref( repo ), - commit = new git.Commit( repo ); - - if( err ) { console.log( error.strError( err ) ); return; } - - oid.mkstr( '2a900f56b6dc6cc285b4d25b2407d9a3dfe76002' ); - - commit.lookup( repo, oid, function( err ) { - if( err ) { console.log('Error', error.strError(err)); return; } - revwalk.push( commit ); - - var _commit = new git.Commit(repo); - - function walk() { - revwalk.next(_commit, function( err ) { - if( err ) { return; } - console.log( _commit.messageShort() ); - walk(); - }); - } - - walk(); - }); -}); diff --git a/example/read-file.js b/example/read-file.js new file mode 100644 index 000000000..fc698b03d --- /dev/null +++ b/example/read-file.js @@ -0,0 +1,27 @@ +var git = require('../'), + path = require('path'); + +// This example opens a certain file, `README.md`, at a particular commit, +// and prints the first 10 lines as well as some metadata. + +git.Repo.open(path.resolve(__dirname, '../.git'), function(error, repo) { + if (error) throw error; + + repo.getCommit('59b20b8d5c6ff8d09518454d4dd8b7b30f095ab5', function(error, commit) { + if (error) throw error; + + commit.getEntry('README.md', function(error, entry) { + if (error) throw error; + + entry.getBlob(function(error, blob) { + if (error) throw error; + + console.log(entry.name(), entry.sha(), blob.size() + 'b'); + console.log('========================================================\n\n'); + var firstTenLines = blob.toString().split('\n').slice(0, 10).join('\n'); + console.log(firstTenLines); + console.log('...'); + }); + }); + }); +}); diff --git a/example/readme-example.js b/example/readme-example.js deleted file mode 100644 index 6ca62d8ca..000000000 --- a/example/readme-example.js +++ /dev/null @@ -1,14 +0,0 @@ -var git = require( 'nodegit' ); - -git.repo( 'jquery/.git', function() { - console.log( 'Repo opened' ); - - this.branch( 'master', function() { - console.log( 'Branch opened' ); - - this.history().on( 'commit', function( i, commit ) { - console.log( commit.id.toString(40) ); - }); - - }); -}); diff --git a/example/walk-history.js b/example/walk-history.js new file mode 100644 index 000000000..4a31f806b --- /dev/null +++ b/example/walk-history.js @@ -0,0 +1,28 @@ +var git = require('../'), + path = require('path'), + sort = git.RevWalk.Sort; + +// This code walks the history of the master branch and prints results +// that look very similar to calling `git log` from the command line + +git.Repo.open(path.resolve(__dirname, '../.git'), function(error, repo) { + if (error) throw error; + + repo.getMaster(function(error, branch) { + if (error) throw error; + + // History returns an event. + var history = branch.history(sort.Time); + + // History emits 'commit' event for each commit in the branch's history + history.on('commit', function(commit) { + console.log('commit ' + commit.sha()); + console.log('Author:', commit.author().name() + ' <' + commit.author().email() + '>'); + console.log('Date:', commit.date()); + console.log('\n ' + commit.message()); + }); + + // Don't forget to call `start()`! + history.start(); + }); +}); diff --git a/example/walk-tree.js b/example/walk-tree.js new file mode 100644 index 000000000..c5c5f98a8 --- /dev/null +++ b/example/walk-tree.js @@ -0,0 +1,27 @@ +var git = require('../'), + path = require('path'); + +// A `tree` in git is typically a representation of the filesystem at +// a revision. A tree has a set of entries, each entry being either a +// tree (directory), or a file. + +git.Repo.open(path.resolve(__dirname, '../.git'), function(error, repo) { + if (error) throw error; + + repo.getMaster(function(error, branch) { + if (error) throw error; + + branch.getTree(function(error, tree) { + if (error) throw error; + + // `walk()` returns an event. + var walker = tree.walk(); + walker.on('entry', function(entry) { + console.log(entry.path()); + }); + + // Don't forget to call `start()`! + walker.start(); + }); + }); +}); diff --git a/gen.js b/gen.js new file mode 100644 index 000000000..d05c6d7ad --- /dev/null +++ b/gen.js @@ -0,0 +1,17 @@ +var fs = require('fs'), + ejs = require('ejs'), + path = require('path'); + +var idefs = JSON.parse(fs.readFileSync('v0.18.0.json')), + classTemplate = ejs.compile(fs.readFileSync(path.resolve("./templates/class.cc.ejs")).toString(), {filename: 'class.cc'}), + headerTemplate = ejs.compile(fs.readFileSync(path.resolve("./templates/header.h.ejs")).toString(), {filename: 'header.h'}); + +for (var i in idefs) { + var idef = idefs[i]; + if (idef.ignore) continue; + + fs.writeFileSync( + path.resolve("./include/" + idef.filename), headerTemplate(idef)); + fs.writeFileSync( + path.resolve("./src/" + path.basename(idef.filename, '.h') + '.cc'), classTemplate(idef)); +} diff --git a/include/blob.h b/include/blob.h index f857d23e1..561338354 100755 --- a/include/blob.h +++ b/include/blob.h @@ -1,112 +1,41 @@ /** - * Copyright (c) 2011, Tim Branyen @tbranyen - * @author Michael Robinson @codeofinterest - * - * Dual licensed under the MIT and GPL licenses. - */ + * This code is auto-generated; unless you know what you're doing, do not modify! + **/ -#ifndef BLOB_H -#define BLOB_H +#ifndef GITBLOB_H +#define GITBLOB_H #include #include -#include +#include #include "git2.h" -#include "repo.h" -#include "oid.h" - -using namespace v8; using namespace node; +using namespace v8; -/** - * Wrapper for libgit2 git_blob. - */ class GitBlob : public ObjectWrap { public: static Persistent constructor_template; + static void Initialize (Handle target); - static void Initialize(Handle target); - - git_blob* GetValue(); - void SetValue(git_blob* blob); - - protected: - GitBlob() {}; - ~GitBlob() {}; - - static Handle New(const Arguments& args); - static Handle Free(const Arguments& args); - - static Handle Lookup(const Arguments& args); - static void LookupWork(uv_work_t* req); - static void LookupAfterWork(uv_work_t* req); - - static Handle RawContent(const Arguments& args); - static void RawContentWork(uv_work_t* req); - static void RawContentAfterWork(uv_work_t* req); - - static Handle CreateFromFile(const Arguments& args); - static void CreateFromFileWork(uv_work_t* req); - static void CreateFromFileAfterWork(uv_work_t* req); + git_blob *GetValue(); - static Handle CreateFromBuffer(const Arguments& args); - static void CreateFromBufferWork(uv_work_t* req); - static void CreateFromBufferAfterWork(uv_work_t* req); + static Handle New(void *raw); private: + GitBlob(git_blob *raw); + ~GitBlob(); - git_blob* blob; - - struct LookupBaton { - uv_work_t request; - const git_error* error; - - GitBlob* blob; - git_blob* rawBlob; - git_repository* rawRepo; - git_oid rawOid; - - Persistent callback; - }; - - struct RawContentBaton { - uv_work_t request; - - GitBlob* blob; - git_blob* rawBlob; - std::string rawContent; - int rawSize; - - Persistent callback; - }; - - struct CreateFromFileBaton { - uv_work_t request; - const git_error* error; - - GitBlob* blob; - git_blob* rawBlob; - git_repository* rawRepo; - std::string path; - - Persistent callback; - }; - - struct CreateFromBufferBaton { - uv_work_t request; - const git_error* error; + static Handle New(const Arguments& args); - GitBlob* blob; - git_blob* rawBlob; - git_repository* rawRepo; - const void* data; - size_t dataLength; - Persistent callback; - }; + static Handle Oid(const Arguments& args); + static Handle Content(const Arguments& args); + static Handle Size(const Arguments& args); + static Handle IsBinary(const Arguments& args); + git_blob *raw; }; #endif diff --git a/include/branch.h b/include/branch.h new file mode 100644 index 000000000..bfbf9bcdb --- /dev/null +++ b/include/branch.h @@ -0,0 +1,48 @@ +/** + * This code is auto-generated; unless you know what you're doing, do not modify! + **/ + +#ifndef BRANCH_H +#define BRANCH_H + +#include +#include +#include + +#include "git2.h" + +using namespace node; +using namespace v8; + +class Branch : public ObjectWrap { + public: + + static Persistent constructor_template; + static void Initialize (Handle target); + + git_branch *GetValue(); + + static Handle New(void *raw); + + private: + Branch(git_branch *raw); + ~Branch(); + + static Handle New(const Arguments& args); + + + static Handle Create(const Arguments& args); + static Handle Delete(const Arguments& args); + static Handle Foreach(const Arguments& args); + static Handle Move(const Arguments& args); + static Handle Lookup(const Arguments& args); + static Handle Name(const Arguments& args); + static Handle Upstream(const Arguments& args); + static Handle SetUpstream(const Arguments& args); + static Handle UpstreamName(const Arguments& args); + static Handle IsHead(const Arguments& args); + static Handle RemoteName(const Arguments& args); + git_branch *raw; +}; + +#endif diff --git a/include/clone_options.h b/include/clone_options.h new file mode 100644 index 000000000..14da5daad --- /dev/null +++ b/include/clone_options.h @@ -0,0 +1,37 @@ +/** + * This code is auto-generated; unless you know what you're doing, do not modify! + **/ + +#ifndef GITCLONEOPTIONS_H +#define GITCLONEOPTIONS_H + +#include +#include +#include + +#include "git2.h" + +using namespace node; +using namespace v8; + +class GitCloneOptions : public ObjectWrap { + public: + + static Persistent constructor_template; + static void Initialize (Handle target); + + git_clone_options *GetValue(); + + static Handle New(void *raw); + + private: + GitCloneOptions(git_clone_options *raw); + ~GitCloneOptions(); + + static Handle New(const Arguments& args); + + + git_clone_options *raw; +}; + +#endif diff --git a/include/commit.h b/include/commit.h index 961d2ed82..6f69f5889 100755 --- a/include/commit.h +++ b/include/commit.h @@ -1,162 +1,48 @@ -/* - * Copyright 2011, Tim Branyen @tbranyen - * @author Michael Robinson @codeofinterest - * - * Dual licensed under the MIT and GPL licenses. - */ +/** + * This code is auto-generated; unless you know what you're doing, do not modify! + **/ + +#ifndef GITCOMMIT_H +#define GITCOMMIT_H #include #include -#include +#include #include "git2.h" -#include "reference.h" -#include "repo.h" -#include "oid.h" -#include "tree.h" - using namespace node; using namespace v8; -/** - * Class wrapper for libgit2 git_commit - */ class GitCommit : public ObjectWrap { public: - /** - * v8::FunctionTemplate used to create Node.js constructor - */ - static Persistent constructor_template; - /** - * Used to intialize the EventEmitter from Node.js - * - * @param target v8::Object the Node.js module object - */ + static Persistent constructor_template; static void Initialize (Handle target); - git_commit* GetValue(); - void SetValue(git_commit* commit); - void SetOid(git_oid* oid); + git_commit *GetValue(); - protected: - GitCommit() {} - ~GitCommit() {} + static Handle New(void *raw); + + private: + GitCommit(git_commit *raw); + ~GitCommit(); static Handle New(const Arguments& args); - static Handle Free(const Arguments& args); - static Handle Lookup(const Arguments& args); - static void LookupWork(uv_work_t *req); - static void LookupAfterWork(uv_work_t *req); static Handle Oid(const Arguments& args); - + static Handle MessageEncoding(const Arguments& args); static Handle Message(const Arguments& args); - static void MessageWork(uv_work_t* req); - static void MessageAfterWork(uv_work_t* req); - static Handle Time(const Arguments& args); - static void TimeWork(uv_work_t* req); - static void TimeAfterWork(uv_work_t* req); - static Handle Offset(const Arguments& args); - static void OffsetWork(uv_work_t* req); - static void OffsetAfterWork(uv_work_t* req); - - static Handle Author(const Arguments& args); - static void AuthorWork(uv_work_t* req); - static void AuthorAfterWork(uv_work_t* req); - static Handle Committer(const Arguments& args); - static void CommitterWork(uv_work_t* req); - static void CommitterAfterWork(uv_work_t* req); - - static Handle Tree(const Arguments& args); - static void TreeWork(uv_work_t* req); - static void TreeAfterWork(uv_work_t* req); - - static Handle Parents(const Arguments& args); - static void ParentsWork(uv_work_t* req); - static void ParentsAfterWork(uv_work_t* req); - - private: - git_commit* commit; - git_oid* oid; - - struct LookupBaton { - uv_work_t request; - const git_error* error; - - git_repository* repo; - git_oid rawOid; - std::string sha; - git_commit* rawCommit; - - Persistent callback; - }; - - struct MessageBaton { - uv_work_t request; - - git_commit* rawCommit; - std::string message; - - Persistent callback; - }; - - struct TimeBaton { - uv_work_t request; - - git_commit* rawCommit; - git_time_t time; - - Persistent callback; - }; - - struct SignatureBaton { - uv_work_t request; - - git_commit* rawCommit; - const git_signature* rawSignature; - - Persistent callback; - }; - - struct OffsetBaton { - uv_work_t request; - - git_commit* rawCommit; - int offset; - - Persistent callback; - }; - - - struct TreeBaton { - uv_work_t request; - const git_error* error; - - git_commit* rawCommit; - git_tree* rawTree; - - Persistent callback; - }; - - struct Parent { - const git_oid* rawOid; - git_commit* rawCommit; - }; - - struct ParentsBaton { - uv_work_t request; - const git_error* error; - - int index; - git_commit* rawCommit; - std::vector parents; - - Persistent callback; - }; + static Handle Author(const Arguments& args); + static Handle TreeId(const Arguments& args); + static Handle ParentCount(const Arguments& args); + static Handle ParentId(const Arguments& args); + static Handle NthGenAncestor(const Arguments& args); + git_commit *raw; }; + +#endif diff --git a/include/delta.h b/include/delta.h new file mode 100644 index 000000000..e06f6283c --- /dev/null +++ b/include/delta.h @@ -0,0 +1,42 @@ +/** + * This code is auto-generated; unless you know what you're doing, do not modify! + **/ + +#ifndef GITDELTA_H +#define GITDELTA_H + +#include +#include +#include + +#include "git2.h" + +using namespace node; +using namespace v8; + +class GitDelta : public ObjectWrap { + public: + + static Persistent constructor_template; + static void Initialize (Handle target); + + git_diff_delta *GetValue(); + + static Handle New(void *raw); + + private: + GitDelta(git_diff_delta *raw); + ~GitDelta(); + + static Handle New(const Arguments& args); + + static Handle OldFile(const Arguments& args); + static Handle NewFile(const Arguments& args); + static Handle Status(const Arguments& args); + static Handle Similarity(const Arguments& args); + static Handle Flags(const Arguments& args); + + git_diff_delta *raw; +}; + +#endif diff --git a/include/diff.h b/include/diff.h new file mode 100644 index 000000000..677f22b50 --- /dev/null +++ b/include/diff.h @@ -0,0 +1,109 @@ +/** + * This code is auto-generated; unless you know what you're doing, do not modify! + **/ + +#ifndef GITDIFF_H +#define GITDIFF_H + +#include +#include +#include + +#include "git2.h" + +using namespace node; +using namespace v8; + +class GitDiff : public ObjectWrap { + public: + + static Persistent constructor_template; + static void Initialize (Handle target); + + git_diff_list *GetValue(); + + private: + GitDiff(git_diff_list *raw); + ~GitDiff(); + + static Handle New(const Arguments& args); + + + static Handle TreeToTree(const Arguments& args); + static void TreeToTreeWork(uv_work_t* req); + static void TreeToTreeAfterWork(uv_work_t* req); + + struct TreeToTreeBaton { + uv_work_t request; + const git_error* error; + git_diff_list * diff; + Persistent repoReference; + git_repository * repo; + Persistent old_treeReference; + git_tree * old_tree; + Persistent new_treeReference; + git_tree * new_tree; + Persistent optsReference; + const git_diff_options * opts; + Persistent callback; + }; + static Handle TreeToIndex(const Arguments& args); + static void TreeToIndexWork(uv_work_t* req); + static void TreeToIndexAfterWork(uv_work_t* req); + + struct TreeToIndexBaton { + uv_work_t request; + const git_error* error; + git_diff_list * diff; + Persistent repoReference; + git_repository * repo; + Persistent old_treeReference; + git_tree * old_tree; + Persistent indexReference; + git_index * index; + Persistent optsReference; + const git_diff_options * opts; + Persistent callback; + }; + static Handle IndexToWorkdir(const Arguments& args); + static void IndexToWorkdirWork(uv_work_t* req); + static void IndexToWorkdirAfterWork(uv_work_t* req); + + struct IndexToWorkdirBaton { + uv_work_t request; + const git_error* error; + git_diff_list * diff; + Persistent repoReference; + git_repository * repo; + Persistent indexReference; + git_index * index; + Persistent optsReference; + const git_diff_options * opts; + Persistent callback; + }; + static Handle TreeToWorkdir(const Arguments& args); + static void TreeToWorkdirWork(uv_work_t* req); + static void TreeToWorkdirAfterWork(uv_work_t* req); + + struct TreeToWorkdirBaton { + uv_work_t request; + const git_error* error; + git_diff_list * diff; + Persistent repoReference; + git_repository * repo; + Persistent old_treeReference; + git_tree * old_tree; + Persistent optsReference; + const git_diff_options * opts; + Persistent callback; + }; + static Handle Merge(const Arguments& args); + static Handle FindSimilar(const Arguments& args); + static Handle StatusChar(const Arguments& args); + static Handle NumDeltas(const Arguments& args); + static Handle NumDeltasOfType(const Arguments& args); + static Handle GetPatch(const Arguments& args); + git_diff_list *raw; +}; + +#endif diff --git a/include/diff_file.h b/include/diff_file.h new file mode 100644 index 000000000..f7f8210d0 --- /dev/null +++ b/include/diff_file.h @@ -0,0 +1,42 @@ +/** + * This code is auto-generated; unless you know what you're doing, do not modify! + **/ + +#ifndef GITDIFFFILE_H +#define GITDIFFFILE_H + +#include +#include +#include + +#include "git2.h" + +using namespace node; +using namespace v8; + +class GitDiffFile : public ObjectWrap { + public: + + static Persistent constructor_template; + static void Initialize (Handle target); + + git_diff_file *GetValue(); + + static Handle New(void *raw); + + private: + GitDiffFile(git_diff_file *raw); + ~GitDiffFile(); + + static Handle New(const Arguments& args); + + static Handle Oid(const Arguments& args); + static Handle Path(const Arguments& args); + static Handle Size(const Arguments& args); + static Handle Flags(const Arguments& args); + static Handle Mode(const Arguments& args); + + git_diff_file *raw; +}; + +#endif diff --git a/include/diff_find_options.h b/include/diff_find_options.h new file mode 100644 index 000000000..3500d1b23 --- /dev/null +++ b/include/diff_find_options.h @@ -0,0 +1,37 @@ +/** + * This code is auto-generated; unless you know what you're doing, do not modify! + **/ + +#ifndef GITDIFFFINDOPTIONS_H +#define GITDIFFFINDOPTIONS_H + +#include +#include +#include + +#include "git2.h" + +using namespace node; +using namespace v8; + +class GitDiffFindOptions : public ObjectWrap { + public: + + static Persistent constructor_template; + static void Initialize (Handle target); + + git_diff_find_options *GetValue(); + + static Handle New(void *raw); + + private: + GitDiffFindOptions(git_diff_find_options *raw); + ~GitDiffFindOptions(); + + static Handle New(const Arguments& args); + + + git_diff_find_options *raw; +}; + +#endif diff --git a/include/diff_list.h b/include/diff_list.h index 58913866e..185a00e56 100644 --- a/include/diff_list.h +++ b/include/diff_list.h @@ -1,123 +1,42 @@ -/* - * Copyright 2011, Tim Branyen @tbranyen - * @author Michael Robinson @codeofinterest - * - * Dual licensed under the MIT and GPL licenses. - */ +/** + * This code is auto-generated; unless you know what you're doing, do not modify! + **/ + +#ifndef GITDIFFLIST_H +#define GITDIFFLIST_H #include #include -#include #include -#include #include "git2.h" -#include "repo.h" -#include "oid.h" - using namespace node; using namespace v8; -/** - * Class wrapper for libgit2 git_diff_list - */ class GitDiffList : public ObjectWrap { public: static Persistent constructor_template; - - static const int WALK_DELTA_SEND_THRESHHOLD = 10; - static void Initialize (Handle target); - git_diff_list* GetValue(); - void SetValue(git_diff_list* diffList); - - protected: - GitDiffList() {} - ~GitDiffList() {} - - static Handle New(const Arguments& args); - static Handle Free(const Arguments& args); - - static Handle TreeToTree(const Arguments& args); - static void TreeToTreeWork(uv_work_t *req); - static void TreeToTreeAfterWork(uv_work_t *req); + git_diff_list *GetValue(); - /** - * Walk the current git_diff_list - */ - static Handle Walk(const Arguments& args); - static void WalkWork(void *payload); - static int WalkWorkFile(const git_diff_delta *delta, float progress, - void *payload); - static int WalkWorkHunk(const git_diff_delta *delta, const git_diff_range *range, - const char *header, size_t header_len, void *payload); - static int WalkWorkData(const git_diff_delta *delta, /** delta that contains this data */ - const git_diff_range *range, /** range of lines containing this data */ - char line_origin, /** git_diff_list_t value from above */ - const char *content, /** diff data - not NUL terminated */ - size_t content_len, /** number of bytes of diff data */ - void *payload); /** user reference data */ - /** - * Called when WalkWorkFile reaches its cache - * thresholds. Passes data back to main thread - * - * @param payload The WalkBaton - */ - static void WalkWorkSendFile(uv_async_t *handle, int status /*UNUSED*/); - static void WalkWorkSendHunk(uv_async_t *handle, int status /*UNUSED*/); - static void WalkWorkSendData(uv_async_t *handle, int status /*UNUSED*/); - static void WalkWorkSendEnd(uv_async_t *handle, int status /*UNUSED*/); + static Handle New(void *raw); private: - git_diff_list* diffList; + GitDiffList(git_diff_list *raw); + ~GitDiffList(); - struct TreeToTreeBaton { - uv_work_t request; - const git_error* error; - - GitDiffList *diffList; - git_repository* repo; - git_oid oldOid; - std::string oldSha; - git_oid newOid; - std::string newSha; - - git_diff_list* rawDiffList; - - Persistent callback; - }; - - struct DeltaContent { - git_diff_range *range; - char lineOrigin; - size_t contentLength; - std::string content; - }; - - struct Delta { - git_diff_delta *raw; - std::vector contents; - }; - - struct WalkBaton { - uv_thread_t threadId; - uv_mutex_t mutex; - uv_async_t asyncFile; - uv_async_t asyncHunk; - uv_async_t asyncData; - uv_async_t asyncEnd; - - const git_error* error; + static Handle New(const Arguments& args); - std::map fileDeltas; - git_diff_list* rawDiffList; - Persistent fileCallback; - Persistent hunkCallback; - Persistent lineCallback; - Persistent endCallback; - }; + static Handle Merge(const Arguments& args); + static Handle FindSimilar(const Arguments& args); + static Handle Size(const Arguments& args); + static Handle NumDeltasOfType(const Arguments& args); + static Handle Patch(const Arguments& args); + git_diff_list *raw; }; + +#endif diff --git a/include/diff_options.h b/include/diff_options.h new file mode 100644 index 000000000..6dd93a0b8 --- /dev/null +++ b/include/diff_options.h @@ -0,0 +1,37 @@ +/** + * This code is auto-generated; unless you know what you're doing, do not modify! + **/ + +#ifndef GITDIFFOPTIONS_H +#define GITDIFFOPTIONS_H + +#include +#include +#include + +#include "git2.h" + +using namespace node; +using namespace v8; + +class GitDiffOptions : public ObjectWrap { + public: + + static Persistent constructor_template; + static void Initialize (Handle target); + + git_diff_options *GetValue(); + + static Handle New(void *raw); + + private: + GitDiffOptions(git_diff_options *raw); + ~GitDiffOptions(); + + static Handle New(const Arguments& args); + + + git_diff_options *raw; +}; + +#endif diff --git a/include/diff_range.h b/include/diff_range.h new file mode 100644 index 000000000..bb44337b4 --- /dev/null +++ b/include/diff_range.h @@ -0,0 +1,41 @@ +/** + * This code is auto-generated; unless you know what you're doing, do not modify! + **/ + +#ifndef GITDIFFRANGE_H +#define GITDIFFRANGE_H + +#include +#include +#include + +#include "git2.h" + +using namespace node; +using namespace v8; + +class GitDiffRange : public ObjectWrap { + public: + + static Persistent constructor_template; + static void Initialize (Handle target); + + git_diff_range *GetValue(); + + static Handle New(void *raw); + + private: + GitDiffRange(git_diff_range *raw); + ~GitDiffRange(); + + static Handle New(const Arguments& args); + + static Handle OldStart(const Arguments& args); + static Handle OldLines(const Arguments& args); + static Handle NewStart(const Arguments& args); + static Handle NewLines(const Arguments& args); + + git_diff_range *raw; +}; + +#endif diff --git a/include/error.h b/include/error.h deleted file mode 100755 index 101a51122..000000000 --- a/include/error.h +++ /dev/null @@ -1,39 +0,0 @@ -/** - * Copyright (c) 2011, Tim Branyen @tbranyen - * @author Michael Robinson @codeofinterest - * - * Dual licensed under the MIT and GPL licenses. - */ - -#ifndef ERROR_H -#define ERROR_H - -#include - -#include "git2.h" - -using namespace v8; -using namespace node; - -/** - * Wrapper for libgit2 git_error. - */ -class GitError : public ObjectWrap { - public: - - static Persistent constructor_template; - - static void Initialize(Handle target); - - static Local WrapError(const git_error* error); - - protected: - GitError() {}; - ~GitError() {}; - - const git_error* error; - - static Handle New(const Arguments& args); -}; - -#endif diff --git a/include/functions/copy.h b/include/functions/copy.h new file mode 100644 index 000000000..fe2408740 --- /dev/null +++ b/include/functions/copy.h @@ -0,0 +1,16 @@ +#include + +#include "git2.h" + +#ifndef COPY_FUNCTIONS +#define COPY_FUNCTIONS + +const git_oid *git_oid_dup(const git_oid *arg); +const git_index_entry *git_index_entry_dup(const git_index_entry *arg); +const git_index_time *git_index_time_dup(const git_index_time *arg); +const git_time *git_time_dup(const git_time *arg); +const git_diff_delta *git_diff_delta_dup(const git_diff_delta *arg); +const git_diff_file *git_diff_file_dup(const git_diff_file *arg); +const git_diff_range *git_diff_range_dup(const git_diff_range *arg); + +#endif diff --git a/include/functions/string.h b/include/functions/string.h deleted file mode 100644 index 85c63027b..000000000 --- a/include/functions/string.h +++ /dev/null @@ -1,8 +0,0 @@ -#include - -#ifndef STRING_FUNCTIONS -#define STRING_FUNCTIONS - -std::string stringArgToString(const v8::Local arg); - -#endif diff --git a/include/functions/utilities.h b/include/functions/utilities.h deleted file mode 100644 index ad9ec84c2..000000000 --- a/include/functions/utilities.h +++ /dev/null @@ -1,15 +0,0 @@ -#ifndef UTILITY_FUNCTIONS -#define UTILITY_FUNCTIONS - -#include -#include - -#include "git2.h" - -#include "../../include/error.h" - -using namespace v8; - -bool success(const git_error* error, Persistent callback); - -#endif diff --git a/include/index.h b/include/index.h index cf58288e2..e634d7ea0 100755 --- a/include/index.h +++ b/include/index.h @@ -1,58 +1,142 @@ /** - * Copyright (c) 2011, Tim Branyen @tbranyen - * @author Michael Robinson @codeofinterest - * - * Dual licensed under the MIT and GPL licenses. - */ + * This code is auto-generated; unless you know what you're doing, do not modify! + **/ -#ifndef INDEX_H -#define INDEX_H +#ifndef GITINDEX_H +#define GITINDEX_H +#include #include +#include #include "git2.h" using namespace node; +using namespace v8; -/** - * Class: GitIndex - * Wrapper for libgit2 git_error. - */ class GitIndex : public ObjectWrap { public: - /** - * Variable: constructor_template - * Used to create Node.js constructor. - */ - static v8::Persistent constructor_template; - /** - * Function: Initialize - * Used to intialize the EventEmitter from Node.js - * - * Parameters: - * target - v8::Object the Node.js global module object - */ - static void Initialize(v8::Handle target); - - protected: - /** - * Constructor: GitIndex - */ - GitIndex() {}; - /** - * Deconstructor: GitIndex - */ - ~GitIndex() {}; - /** - * Function: New - * - * Parameters: - * args v8::Arguments function call - * - * Returns: - * v8::Object args.This() - */ - static v8::Handle New(const v8::Arguments& args); + + static Persistent constructor_template; + static void Initialize (Handle target); + + git_index *GetValue(); + + static Handle New(void *raw); + + private: + GitIndex(git_index *raw); + ~GitIndex(); + + static Handle New(const Arguments& args); + + + static Handle Open(const Arguments& args); + static void OpenWork(uv_work_t* req); + static void OpenAfterWork(uv_work_t* req); + + struct OpenBaton { + uv_work_t request; + int error_code; + const git_error* error; + git_index * out; + Persistent index_pathReference; + const char * index_path; + Persistent callback; + }; + static Handle Read(const Arguments& args); + static void ReadWork(uv_work_t* req); + static void ReadAfterWork(uv_work_t* req); + + struct ReadBaton { + uv_work_t request; + int error_code; + const git_error* error; + Persistent indexReference; + git_index * index; + Persistent callback; + }; + static Handle Write(const Arguments& args); + static void WriteWork(uv_work_t* req); + static void WriteAfterWork(uv_work_t* req); + + struct WriteBaton { + uv_work_t request; + int error_code; + const git_error* error; + Persistent indexReference; + git_index * index; + Persistent callback; + }; + static Handle ReadTree(const Arguments& args); + static void ReadTreeWork(uv_work_t* req); + static void ReadTreeAfterWork(uv_work_t* req); + + struct ReadTreeBaton { + uv_work_t request; + int error_code; + const git_error* error; + Persistent indexReference; + git_index * index; + Persistent treeReference; + const git_tree * tree; + Persistent callback; + }; + static Handle WriteTree(const Arguments& args); + static void WriteTreeWork(uv_work_t* req); + static void WriteTreeAfterWork(uv_work_t* req); + + struct WriteTreeBaton { + uv_work_t request; + int error_code; + const git_error* error; + git_oid * out; + Persistent indexReference; + git_index * index; + Persistent callback; + }; + static Handle Size(const Arguments& args); + static Handle Clear(const Arguments& args); + static Handle Entry(const Arguments& args); + static Handle Remove(const Arguments& args); + static Handle RemoveDirectory(const Arguments& args); + static Handle AddBypath(const Arguments& args); + static void AddBypathWork(uv_work_t* req); + static void AddBypathAfterWork(uv_work_t* req); + + struct AddBypathBaton { + uv_work_t request; + int error_code; + const git_error* error; + Persistent indexReference; + git_index * index; + Persistent pathReference; + const char * path; + Persistent callback; + }; + static Handle RemoveBypath(const Arguments& args); + static Handle Find(const Arguments& args); + static Handle ConflictRemove(const Arguments& args); + static Handle ConflictCleanup(const Arguments& args); + static Handle HasConflicts(const Arguments& args); + static Handle IndexToWorkdir(const Arguments& args); + static void IndexToWorkdirWork(uv_work_t* req); + static void IndexToWorkdirAfterWork(uv_work_t* req); + + struct IndexToWorkdirBaton { + uv_work_t request; + int error_code; + const git_error* error; + git_diff_list * diff; + Persistent repoReference; + git_repository * repo; + Persistent indexReference; + git_index * index; + Persistent optsReference; + const git_diff_options * opts; + Persistent callback; + }; + git_index *raw; }; #endif diff --git a/include/index_entry.h b/include/index_entry.h new file mode 100644 index 000000000..0416e4f5c --- /dev/null +++ b/include/index_entry.h @@ -0,0 +1,40 @@ +/** + * This code is auto-generated; unless you know what you're doing, do not modify! + **/ + +#ifndef GITINDEXENTRY_H +#define GITINDEXENTRY_H + +#include +#include +#include + +#include "git2.h" + +using namespace node; +using namespace v8; + +class GitIndexEntry : public ObjectWrap { + public: + + static Persistent constructor_template; + static void Initialize (Handle target); + + git_index_entry *GetValue(); + + static Handle New(void *raw); + + private: + GitIndexEntry(git_index_entry *raw); + ~GitIndexEntry(); + + static Handle New(const Arguments& args); + + static Handle Ctime(const Arguments& args); + static Handle Mtime(const Arguments& args); + static Handle Path(const Arguments& args); + + git_index_entry *raw; +}; + +#endif diff --git a/include/index_time.h b/include/index_time.h new file mode 100644 index 000000000..765ce6cc7 --- /dev/null +++ b/include/index_time.h @@ -0,0 +1,39 @@ +/** + * This code is auto-generated; unless you know what you're doing, do not modify! + **/ + +#ifndef GITINDEXTIME_H +#define GITINDEXTIME_H + +#include +#include +#include + +#include "git2.h" + +using namespace node; +using namespace v8; + +class GitIndexTime : public ObjectWrap { + public: + + static Persistent constructor_template; + static void Initialize (Handle target); + + git_index_time *GetValue(); + + static Handle New(void *raw); + + private: + GitIndexTime(git_index_time *raw); + ~GitIndexTime(); + + static Handle New(const Arguments& args); + + static Handle Seconds(const Arguments& args); + static Handle Nanoseconds(const Arguments& args); + + git_index_time *raw; +}; + +#endif diff --git a/include/object.h b/include/object.h new file mode 100644 index 000000000..6ab9d3537 --- /dev/null +++ b/include/object.h @@ -0,0 +1,54 @@ +/** + * This code is auto-generated; unless you know what you're doing, do not modify! + **/ + +#ifndef GITOBJECT_H +#define GITOBJECT_H + +#include +#include +#include + +#include "git2.h" + +using namespace node; +using namespace v8; + +class GitObject : public ObjectWrap { + public: + + static Persistent constructor_template; + static void Initialize (Handle target); + + git_object *GetValue(); + + static Handle New(void *raw); + + private: + GitObject(git_object *raw); + ~GitObject(); + + static Handle New(const Arguments& args); + + + static Handle Oid(const Arguments& args); + static Handle Type(const Arguments& args); + static Handle Peel(const Arguments& args); + static void PeelWork(uv_work_t* req); + static void PeelAfterWork(uv_work_t* req); + + struct PeelBaton { + uv_work_t request; + int error_code; + const git_error* error; + git_object * peeled; + Persistent objectReference; + const git_object * object; + Persistent target_typeReference; + git_otype target_type; + Persistent callback; + }; + git_object *raw; +}; + +#endif diff --git a/include/odb.h b/include/odb.h old mode 100755 new mode 100644 index 19c07e900..6ed9913d9 --- a/include/odb.h +++ b/include/odb.h @@ -1,58 +1,80 @@ /** - * Copyright (c) 2011, Tim Branyen @tbranyen - * @author Michael Robinson @codeofinterest - * - * Dual licensed under the MIT and GPL licenses. - */ + * This code is auto-generated; unless you know what you're doing, do not modify! + **/ -#ifndef ODB_H -#define ODB_H +#ifndef GITODB_H +#define GITODB_H +#include #include +#include #include "git2.h" using namespace node; +using namespace v8; -/** - * Class: GitOdb - * Wrapper for libgit2 git_error. - */ class GitOdb : public ObjectWrap { public: - /** - * Variable: constructor_template - * Used to create Node.js constructor. - */ - static v8::Persistent constructor_template; - /** - * Function: Initialize - * Used to intialize the EventEmitter from Node.js - * - * Parameters: - * target - v8::Object the Node.js global module object - */ - static void Initialize(v8::Handle target); - - protected: - /** - * Constructor: GitOdb - */ - GitOdb() {}; - /** - * Deconstructor: GitOdb - */ - ~GitOdb() {}; - /** - * Function: New - * - * Parameters: - * args v8::Arguments function call - * - * Returns: - * v8::Object args.This() - */ - static v8::Handle New(const v8::Arguments& args); + + static Persistent constructor_template; + static void Initialize (Handle target); + + git_odb *GetValue(); + + static Handle New(void *raw); + + private: + GitOdb(git_odb *raw); + ~GitOdb(); + + static Handle New(const Arguments& args); + + + static Handle Create(const Arguments& args); + static Handle Open(const Arguments& args); + static Handle AddDiskAlternate(const Arguments& args); + static Handle Read(const Arguments& args); + static void ReadWork(uv_work_t* req); + static void ReadAfterWork(uv_work_t* req); + + struct ReadBaton { + uv_work_t request; + int error_code; + const git_error* error; + git_odb_object * out; + Persistent dbReference; + git_odb * db; + Persistent idReference; + const git_oid * id; + Persistent callback; + }; + static Handle ReadPrefix(const Arguments& args); + static Handle ReadHeader(const Arguments& args); + static Handle Exists(const Arguments& args); + static Handle Refresh(const Arguments& args); + static Handle Write(const Arguments& args); + static void WriteWork(uv_work_t* req); + static void WriteAfterWork(uv_work_t* req); + + struct WriteBaton { + uv_work_t request; + int error_code; + const git_error* error; + git_oid * out; + Persistent odbReference; + git_odb * odb; + Persistent dataReference; + const void * data; + Persistent lenReference; + size_t len; + Persistent typeReference; + git_otype type; + Persistent callback; + }; + static Handle Hash(const Arguments& args); + static Handle Hashfile(const Arguments& args); + git_odb *raw; }; #endif diff --git a/include/odb_object.h b/include/odb_object.h new file mode 100644 index 000000000..7938dfa49 --- /dev/null +++ b/include/odb_object.h @@ -0,0 +1,41 @@ +/** + * This code is auto-generated; unless you know what you're doing, do not modify! + **/ + +#ifndef GITODBOBJECT_H +#define GITODBOBJECT_H + +#include +#include +#include + +#include "git2.h" + +using namespace node; +using namespace v8; + +class GitOdbObject : public ObjectWrap { + public: + + static Persistent constructor_template; + static void Initialize (Handle target); + + git_odb_object *GetValue(); + + static Handle New(void *raw); + + private: + GitOdbObject(git_odb_object *raw); + ~GitOdbObject(); + + static Handle New(const Arguments& args); + + + static Handle Data(const Arguments& args); + static Handle Size(const Arguments& args); + static Handle Type(const Arguments& args); + static Handle Oid(const Arguments& args); + git_odb_object *raw; +}; + +#endif diff --git a/include/oid.h b/include/oid.h index 4f61e8665..2ce3a9e5c 100755 --- a/include/oid.h +++ b/include/oid.h @@ -1,12 +1,9 @@ -/* - * Copyright 2013, Tim Branyen @tbranyen - * @author Michael Robinson @codeofinterest - * - * Dual licensed under the MIT and GPL licenses. - */ +/** + * This code is auto-generated; unless you know what you're doing, do not modify! + **/ -#ifndef OID_H -#define OID_H +#ifndef GITOID_H +#define GITOID_H #include #include @@ -21,36 +18,22 @@ class GitOid : public ObjectWrap { public: static Persistent constructor_template; - static void Initialize (Handle target); - git_oid GetValue(); - void SetValue(git_oid oid); - protected: - GitOid() {} - ~GitOid() {} + git_oid *GetValue(); - static Handle New(const Arguments& args); - - static Handle Sha(const Arguments& args); - - static Handle FromString(const Arguments& args); - static void FromStringWork(uv_work_t* req); - static void FromStringAfterWork(uv_work_t* req); + static Handle New(void *raw); private: - git_oid oid; + GitOid(git_oid *raw); + ~GitOid(); - struct FromStringBaton { - uv_work_t request; - const git_error* error; + static Handle New(const Arguments& args); - std::string fromString; - GitOid* oid; - git_oid rawOid; - Persistent callback; - }; + static Handle FromString(const Arguments& args); + static Handle Sha(const Arguments& args); + git_oid *raw; }; #endif diff --git a/include/patch.h b/include/patch.h new file mode 100644 index 000000000..7a4d408ff --- /dev/null +++ b/include/patch.h @@ -0,0 +1,44 @@ +/** + * This code is auto-generated; unless you know what you're doing, do not modify! + **/ + +#ifndef GITPATCH_H +#define GITPATCH_H + +#include +#include +#include + +#include "git2.h" + +using namespace node; +using namespace v8; + +class GitPatch : public ObjectWrap { + public: + + static Persistent constructor_template; + static void Initialize (Handle target); + + git_diff_patch *GetValue(); + + static Handle New(void *raw); + + private: + GitPatch(git_diff_patch *raw); + ~GitPatch(); + + static Handle New(const Arguments& args); + + + static Handle Delta(const Arguments& args); + static Handle Size(const Arguments& args); + static Handle Stats(const Arguments& args); + static Handle Hunk(const Arguments& args); + static Handle Lines(const Arguments& args); + static Handle Line(const Arguments& args); + static Handle ToString(const Arguments& args); + git_diff_patch *raw; +}; + +#endif diff --git a/include/refdb.h b/include/refdb.h new file mode 100644 index 000000000..51355028f --- /dev/null +++ b/include/refdb.h @@ -0,0 +1,37 @@ +/** + * This code is auto-generated; unless you know what you're doing, do not modify! + **/ + +#ifndef GITREFDB_H +#define GITREFDB_H + +#include +#include +#include + +#include "git2.h" + +using namespace node; +using namespace v8; + +class GitRefDb : public ObjectWrap { + public: + + static Persistent constructor_template; + static void Initialize (Handle target); + + git_refdb *GetValue(); + + static Handle New(void *raw); + + private: + GitRefDb(git_refdb *raw); + ~GitRefDb(); + + static Handle New(const Arguments& args); + + + git_refdb *raw; +}; + +#endif diff --git a/include/reference.h b/include/reference.h index 4f28bcca4..ae7d18ad4 100644 --- a/include/reference.h +++ b/include/reference.h @@ -1,12 +1,9 @@ /** - * Copyright (c) 2011, Tim Branyen @tbranyen - * @author Michael Robinson @codeofinterest - * - * Dual licensed under the MIT and GPL licenses. - */ + * This code is auto-generated; unless you know what you're doing, do not modify! + **/ -#ifndef REF_H -#define REF_H +#ifndef GITREFERENCE_H +#define GITREFERENCE_H #include #include @@ -14,59 +11,94 @@ #include "git2.h" -#include "repo.h" -#include "oid.h" - using namespace node; using namespace v8; class GitReference : public ObjectWrap { public: - const git_oid* Oid(); + static Persistent constructor_template; - static void Initialize(Handle target); + static void Initialize (Handle target); - git_reference* GetValue(); - void SetValue(git_reference* ref); + git_reference *GetValue(); - protected: - GitReference() {} - ~GitReference() {} - static Handle New(const Arguments& args); + static Handle New(void *raw); - static Handle Oid(const Arguments& args); - static void OidWork(uv_work_t* req); - static void OidAfterWork(uv_work_t* req); + private: + GitReference(git_reference *raw); + ~GitReference(); - static Handle Lookup(const Arguments& args); - static void LookupWork(uv_work_t* req); - static void LookupAfterWork(uv_work_t* req); + static Handle New(const Arguments& args); - private: - git_reference *ref; + static Handle OidForName(const Arguments& args); + static void OidForNameWork(uv_work_t* req); + static void OidForNameAfterWork(uv_work_t* req); - struct LookupBaton { + struct OidForNameBaton { uv_work_t request; + int error_code; const git_error* error; - - GitReference* ref; - git_reference* rawRef; - git_repository* rawRepo; - std::string name; - + git_oid * out; + Persistent repoReference; + git_repository * repo; + Persistent nameReference; + const char * name; Persistent callback; }; - - struct OidBaton { + static Handle Target(const Arguments& args); + static Handle SymbolicTarget(const Arguments& args); + static Handle Type(const Arguments& args); + static Handle Name(const Arguments& args); + static Handle Resolve(const Arguments& args); + static void ResolveWork(uv_work_t* req); + static void ResolveAfterWork(uv_work_t* req); + + struct ResolveBaton { uv_work_t request; + int error_code; const git_error* error; + git_reference * out; + Persistent refReference; + const git_reference * ref; + Persistent callback; + }; + static Handle SetSymbolicTarget(const Arguments& args); + static Handle setTarget(const Arguments& args); + static Handle Rename(const Arguments& args); + static void RenameWork(uv_work_t* req); + static void RenameAfterWork(uv_work_t* req); - const git_oid* rawOid; - git_reference* rawRef; + struct RenameBaton { + uv_work_t request; + int error_code; + const git_error* error; + git_reference * out; + Persistent refReference; + git_reference * ref; + Persistent new_nameReference; + const char * new_name; + Persistent forceReference; + int force; + Persistent callback; + }; + static Handle Delete(const Arguments& args); + static void DeleteWork(uv_work_t* req); + static void DeleteAfterWork(uv_work_t* req); + struct DeleteBaton { + uv_work_t request; + int error_code; + const git_error* error; + Persistent refReference; + git_reference * ref; Persistent callback; }; + static Handle IsBranch(const Arguments& args); + static Handle IsRemote(const Arguments& args); + static Handle Peel(const Arguments& args); + static Handle IsValidName(const Arguments& args); + git_reference *raw; }; #endif diff --git a/include/remote.h b/include/remote.h new file mode 100644 index 000000000..81fd1ac68 --- /dev/null +++ b/include/remote.h @@ -0,0 +1,93 @@ +/** + * This code is auto-generated; unless you know what you're doing, do not modify! + **/ + +#ifndef GITREMOTE_H +#define GITREMOTE_H + +#include +#include +#include + +#include "git2.h" + +using namespace node; +using namespace v8; + +class GitRemote : public ObjectWrap { + public: + + static Persistent constructor_template; + static void Initialize (Handle target); + + git_remote *GetValue(); + + static Handle New(void *raw); + + private: + GitRemote(git_remote *raw); + ~GitRemote(); + + static Handle New(const Arguments& args); + + + static Handle Name(const Arguments& args); + static Handle Url(const Arguments& args); + static Handle PushUrl(const Arguments& args); + static Handle SetUrl(const Arguments& args); + static Handle SetPushUrl(const Arguments& args); + static Handle Connect(const Arguments& args); + static void ConnectWork(uv_work_t* req); + static void ConnectAfterWork(uv_work_t* req); + + struct ConnectBaton { + uv_work_t request; + int error_code; + const git_error* error; + Persistent remoteReference; + git_remote * remote; + Persistent directionReference; + git_direction direction; + Persistent callback; + }; + static Handle Download(const Arguments& args); + static void DownloadWork(uv_work_t* req); + static void DownloadAfterWork(uv_work_t* req); + + struct DownloadBaton { + uv_work_t request; + int error_code; + const git_error* error; + Persistent remoteReference; + git_remote * remote; + Persistent progress_cbReference; + git_transfer_progress_callback progress_cb; + Persistent payloadReference; + void * payload; + Persistent callback; + }; + static Handle Connected(const Arguments& args); + static Handle Stop(const Arguments& args); + static Handle Disconnect(const Arguments& args); + static void DisconnectWork(uv_work_t* req); + static void DisconnectAfterWork(uv_work_t* req); + + struct DisconnectBaton { + uv_work_t request; + int error_code; + const git_error* error; + Persistent remoteReference; + git_remote * remote; + Persistent callback; + }; + static Handle UpdateTips(const Arguments& args); + static Handle ValidUrl(const Arguments& args); + static Handle SupportedUrl(const Arguments& args); + static Handle CheckCert(const Arguments& args); + static Handle UpdateFetchhead(const Arguments& args); + static Handle SetUpdateFetchhead(const Arguments& args); + static Handle IsValidName(const Arguments& args); + git_remote *raw; +}; + +#endif diff --git a/include/repo.h b/include/repo.h index 55eb04d38..8f10f3427 100755 --- a/include/repo.h +++ b/include/repo.h @@ -1,12 +1,9 @@ -/* - * Copyright 2013, Tim Branyen @tbranyen - * @author Michael Robinson @codeofinterest - * - * Dual licensed under the MIT and GPL licenses. - */ +/** + * This code is auto-generated; unless you know what you're doing, do not modify! + **/ -#ifndef REPO_H -#define REPO_H +#ifndef GITREPO_H +#define GITREPO_H #include #include @@ -19,55 +16,355 @@ using namespace v8; class GitRepo : public ObjectWrap { public: + static Persistent constructor_template; - static void Initialize(Handle target); + static void Initialize (Handle target); + + git_repository *GetValue(); - git_repository* GetValue(); - void SetValue(git_repository* repo); + static Handle New(void *raw); - void Free(); + private: + GitRepo(git_repository *raw); + ~GitRepo(); - protected: - GitRepo() {} - ~GitRepo() {} static Handle New(const Arguments& args); + static Handle Open(const Arguments& args); static void OpenWork(uv_work_t* req); static void OpenAfterWork(uv_work_t* req); - static Handle Free(const Arguments& args); - + struct OpenBaton { + uv_work_t request; + int error_code; + const git_error* error; + git_repository * out; + Persistent pathReference; + const char * path; + Persistent callback; + }; static Handle Init(const Arguments& args); static void InitWork(uv_work_t* req); static void InitAfterWork(uv_work_t* req); - private: - git_repository* repo; + struct InitBaton { + uv_work_t request; + int error_code; + const git_error* error; + git_repository * out; + Persistent pathReference; + const char * path; + Persistent is_bareReference; + unsigned is_bare; + Persistent callback; + }; + static Handle Path(const Arguments& args); + static Handle Workdir(const Arguments& args); + static Handle Odb(const Arguments& args); + static Handle openIndex(const Arguments& args); + static void openIndexWork(uv_work_t* req); + static void openIndexAfterWork(uv_work_t* req); - struct OpenBaton { + struct openIndexBaton { uv_work_t request; + int error_code; const git_error* error; + git_index * out; + Persistent repoReference; + git_repository * repo; + Persistent callback; + }; + static Handle GetBlob(const Arguments& args); + static void GetBlobWork(uv_work_t* req); + static void GetBlobAfterWork(uv_work_t* req); - git_repository* rawRepo; - GitRepo *repo; + struct GetBlobBaton { + uv_work_t request; + int error_code; + const git_error* error; + git_blob * blob; + Persistent repoReference; + git_repository * repo; + Persistent idReference; + const git_oid * id; + Persistent callback; + }; + static Handle GetCommit(const Arguments& args); + static void GetCommitWork(uv_work_t* req); + static void GetCommitAfterWork(uv_work_t* req); - std::string path; + struct GetCommitBaton { + uv_work_t request; + int error_code; + const git_error* error; + git_commit * commit; + Persistent repoReference; + git_repository * repo; + Persistent idReference; + const git_oid * id; + Persistent callback; + }; + static Handle CreateCommit(const Arguments& args); + static void CreateCommitWork(uv_work_t* req); + static void CreateCommitAfterWork(uv_work_t* req); + struct CreateCommitBaton { + uv_work_t request; + int error_code; + const git_error* error; + git_oid * id; + Persistent repoReference; + git_repository * repo; + Persistent update_refReference; + const char * update_ref; + Persistent authorReference; + const git_signature * author; + Persistent committerReference; + const git_signature * committer; + Persistent message_encodingReference; + const char * message_encoding; + Persistent messageReference; + const char * message; + Persistent treeReference; + const git_tree * tree; + Persistent parent_countReference; + int parent_count; + Persistent parentsReference; + const git_commit ** parents; Persistent callback; }; + static Handle GetObject(const Arguments& args); + static void GetObjectWork(uv_work_t* req); + static void GetObjectAfterWork(uv_work_t* req); - struct InitBaton { + struct GetObjectBaton { uv_work_t request; + int error_code; const git_error* error; + git_object * object; + Persistent repoReference; + git_repository * repo; + Persistent idReference; + const git_oid * id; + Persistent typeReference; + git_otype type; + Persistent callback; + }; + static Handle GetReference(const Arguments& args); + static void GetReferenceWork(uv_work_t* req); + static void GetReferenceAfterWork(uv_work_t* req); - GitRepo* repo; - git_repository* rawRepo; - std::string path; - bool isBare; + struct GetReferenceBaton { + uv_work_t request; + int error_code; + const git_error* error; + git_reference * out; + Persistent repoReference; + git_repository * repo; + Persistent nameReference; + const char * name; + Persistent callback; + }; + static Handle CreateSymbolicReference(const Arguments& args); + static Handle CreateReference(const Arguments& args); + static Handle AddRemote(const Arguments& args); + static void AddRemoteWork(uv_work_t* req); + static void AddRemoteAfterWork(uv_work_t* req); + struct AddRemoteBaton { + uv_work_t request; + int error_code; + const git_error* error; + git_remote * out; + Persistent repoReference; + git_repository * repo; + Persistent nameReference; + const char * name; + Persistent urlReference; + const char * url; + Persistent callback; + }; + static Handle CreateRevWalk(const Arguments& args); + static Handle GetSubmodule(const Arguments& args); + static Handle AddSubmodule(const Arguments& args); + static Handle GetTag(const Arguments& args); + static void GetTagWork(uv_work_t* req); + static void GetTagAfterWork(uv_work_t* req); + + struct GetTagBaton { + uv_work_t request; + int error_code; + const git_error* error; + git_tag * out; + Persistent repoReference; + git_repository * repo; + Persistent idReference; + const git_oid * id; + Persistent callback; + }; + static Handle CreateTag(const Arguments& args); + static void CreateTagWork(uv_work_t* req); + static void CreateTagAfterWork(uv_work_t* req); + + struct CreateTagBaton { + uv_work_t request; + int error_code; + const git_error* error; + git_oid * oid; + Persistent repoReference; + git_repository * repo; + Persistent tag_nameReference; + const char * tag_name; + Persistent targetReference; + const git_object * target; + Persistent taggerReference; + const git_signature * tagger; + Persistent messageReference; + const char * message; + Persistent forceReference; + int force; + Persistent callback; + }; + static Handle CreateLightweightTag(const Arguments& args); + static void CreateLightweightTagWork(uv_work_t* req); + static void CreateLightweightTagAfterWork(uv_work_t* req); + + struct CreateLightweightTagBaton { + uv_work_t request; + int error_code; + const git_error* error; + git_oid * oid; + Persistent repoReference; + git_repository * repo; + Persistent tag_nameReference; + const char * tag_name; + Persistent targetReference; + const git_object * target; + Persistent forceReference; + int force; + Persistent callback; + }; + static Handle GetTree(const Arguments& args); + static void GetTreeWork(uv_work_t* req); + static void GetTreeAfterWork(uv_work_t* req); + + struct GetTreeBaton { + uv_work_t request; + int error_code; + const git_error* error; + git_tree * out; + Persistent repoReference; + git_repository * repo; + Persistent idReference; + const git_oid * id; + Persistent callback; + }; + static Handle ReloadSubmodules(const Arguments& args); + static void ReloadSubmodulesWork(uv_work_t* req); + static void ReloadSubmodulesAfterWork(uv_work_t* req); + + struct ReloadSubmodulesBaton { + uv_work_t request; + int error_code; + const git_error* error; + Persistent repoReference; + git_repository * repo; + Persistent callback; + }; + static Handle Delete(const Arguments& args); + static void DeleteWork(uv_work_t* req); + static void DeleteAfterWork(uv_work_t* req); + + struct DeleteBaton { + uv_work_t request; + int error_code; + const git_error* error; + Persistent repoReference; + git_repository * repo; + Persistent tag_nameReference; + const char * tag_name; + Persistent callback; + }; + static Handle GetReferences(const Arguments& args); + static void GetReferencesWork(uv_work_t* req); + static void GetReferencesAfterWork(uv_work_t* req); + + struct GetReferencesBaton { + uv_work_t request; + int error_code; + const git_error* error; + git_strarray * array; + Persistent repoReference; + git_repository * repo; + Persistent list_flagsReference; + unsigned int list_flags; + Persistent callback; + }; + static Handle CreateBlobFromBuffer(const Arguments& args); + static void CreateBlobFromBufferWork(uv_work_t* req); + static void CreateBlobFromBufferAfterWork(uv_work_t* req); + + struct CreateBlobFromBufferBaton { + uv_work_t request; + int error_code; + const git_error* error; + git_oid * oid; + Persistent repoReference; + git_repository * repo; + Persistent bufferReference; + const void * buffer; + Persistent lenReference; + size_t len; + Persistent callback; + }; + static Handle CreateBlobFromFile(const Arguments& args); + static void CreateBlobFromFileWork(uv_work_t* req); + static void CreateBlobFromFileAfterWork(uv_work_t* req); + + struct CreateBlobFromFileBaton { + uv_work_t request; + int error_code; + const git_error* error; + git_oid * id; + Persistent repoReference; + git_repository * repo; + Persistent pathReference; + const char * path; + Persistent callback; + }; + static Handle GetRemotes(const Arguments& args); + static void GetRemotesWork(uv_work_t* req); + static void GetRemotesAfterWork(uv_work_t* req); + + struct GetRemotesBaton { + uv_work_t request; + int error_code; + const git_error* error; + git_strarray * out; + Persistent repoReference; + git_repository * repo; + Persistent callback; + }; + static Handle Clone(const Arguments& args); + static void CloneWork(uv_work_t* req); + static void CloneAfterWork(uv_work_t* req); + + struct CloneBaton { + uv_work_t request; + int error_code; + const git_error* error; + git_repository * out; + Persistent urlReference; + const char * url; + Persistent local_pathReference; + const char * local_path; + Persistent optionsReference; + const git_clone_options * options; Persistent callback; }; + static Handle GetRemote(const Arguments& args); + git_repository *raw; }; #endif diff --git a/include/revwalk.h b/include/revwalk.h index 46ef8db07..c2096cc61 100755 --- a/include/revwalk.h +++ b/include/revwalk.h @@ -1,91 +1,160 @@ -/* - * Copyright 2013, Tim Branyen @tbranyen - * @author Michael Robinson @codeofinterest - * - * Dual licensed under the MIT and GPL licenses. - */ -#ifndef REVWALK_H -#define REVWALK_H +/** + * This code is auto-generated; unless you know what you're doing, do not modify! + **/ + +#ifndef GITREVWALK_H +#define GITREVWALK_H #include #include +#include #include "git2.h" -#include "repo.h" - using namespace node; using namespace v8; class GitRevWalk : public ObjectWrap { public: + static Persistent constructor_template; - static void Initialize(Handle target); + static void Initialize (Handle target); - git_revwalk* GetValue(); - void SetValue(git_revwalk* revwalk); - git_repository* GetRepo(); - void SetRepo(git_repository* repository); + git_revwalk *GetValue(); - protected: - GitRevWalk() {} - ~GitRevWalk() {} + static Handle New(void *raw); - static Handle New(const Arguments& args); - static Handle Free(const Arguments& args); + private: + GitRevWalk(git_revwalk *raw); + ~GitRevWalk(); - static Handle Reset(const Arguments& args); + static Handle New(const Arguments& args); - static Handle Allocate(const Arguments& args); - static void AllocateWork(uv_work_t *req); - static void AllocateAfterWork(uv_work_t *req); + static Handle Reset(const Arguments& args); static Handle Push(const Arguments& args); - static void PushWork(uv_work_t *req); - static void PushAfterWork(uv_work_t *req); - - static Handle Next(const Arguments& args); - static void NextWork(uv_work_t* req); - static void NextAfterWork(uv_work_t* req); + static void PushWork(uv_work_t* req); + static void PushAfterWork(uv_work_t* req); - static Handle Sorting(const Arguments& args); + struct PushBaton { + uv_work_t request; + int error_code; + const git_error* error; + Persistent walkReference; + git_revwalk * walk; + Persistent idReference; + const git_oid * id; + Persistent callback; + }; + static Handle PushGlob(const Arguments& args); + static void PushGlobWork(uv_work_t* req); + static void PushGlobAfterWork(uv_work_t* req); - private: - git_revwalk* revwalk; - git_repository* repo; + struct PushGlobBaton { + uv_work_t request; + int error_code; + const git_error* error; + Persistent walkReference; + git_revwalk * walk; + Persistent globReference; + const char * glob; + Persistent callback; + }; + static Handle PushHead(const Arguments& args); + static void PushHeadWork(uv_work_t* req); + static void PushHeadAfterWork(uv_work_t* req); - struct AllocateBaton { + struct PushHeadBaton { uv_work_t request; + int error_code; const git_error* error; + Persistent walkReference; + git_revwalk * walk; + Persistent callback; + }; + static Handle Hide(const Arguments& args); + static void HideWork(uv_work_t* req); + static void HideAfterWork(uv_work_t* req); - GitRevWalk* revwalk; - git_revwalk *rawRevwalk; - git_repository* rawRepo; + struct HideBaton { + uv_work_t request; + int error_code; + const git_error* error; + Persistent walkReference; + git_revwalk * walk; + Persistent commit_idReference; + const git_oid * commit_id; + Persistent callback; + }; + static Handle HideGlob(const Arguments& args); + static void HideGlobWork(uv_work_t* req); + static void HideGlobAfterWork(uv_work_t* req); + struct HideGlobBaton { + uv_work_t request; + int error_code; + const git_error* error; + Persistent walkReference; + git_revwalk * walk; + Persistent globReference; + const char * glob; Persistent callback; }; + static Handle HideHead(const Arguments& args); + static void HideHeadWork(uv_work_t* req); + static void HideHeadAfterWork(uv_work_t* req); - struct PushBaton { + struct HideHeadBaton { uv_work_t request; + int error_code; const git_error* error; + Persistent walkReference; + git_revwalk * walk; + Persistent callback; + }; + static Handle PushRef(const Arguments& args); + static void PushRefWork(uv_work_t* req); + static void PushRefAfterWork(uv_work_t* req); - git_revwalk *rawRevwalk; - git_oid rawOid; + struct PushRefBaton { + uv_work_t request; + int error_code; + const git_error* error; + Persistent walkReference; + git_revwalk * walk; + Persistent refnameReference; + const char * refname; + Persistent callback; + }; + static Handle HideRef(const Arguments& args); + static void HideRefWork(uv_work_t* req); + static void HideRefAfterWork(uv_work_t* req); + struct HideRefBaton { + uv_work_t request; + int error_code; + const git_error* error; + Persistent walkReference; + git_revwalk * walk; + Persistent refnameReference; + const char * refname; Persistent callback; }; + static Handle Next(const Arguments& args); + static void NextWork(uv_work_t* req); + static void NextAfterWork(uv_work_t* req); struct NextBaton { uv_work_t request; - + int error_code; const git_error* error; - bool walkOver; - - git_revwalk *rawRevwalk; - git_oid rawOid; - + git_oid * out; + Persistent walkReference; + git_revwalk * walk; Persistent callback; }; + static Handle Sorting(const Arguments& args); + git_revwalk *raw; }; #endif diff --git a/include/signature.h b/include/signature.h index bc83ad529..14d542c82 100755 --- a/include/signature.h +++ b/include/signature.h @@ -1,45 +1,42 @@ -/* - * Copyright 2013, Tim Branyen @tbranyen - * @author Michael Robinson @codeofinterest - * - * Dual licensed under the MIT and GPL licenses. - */ +/** + * This code is auto-generated; unless you know what you're doing, do not modify! + **/ -#ifndef GitSignature_H -#define GitSignature_H +#ifndef GITSIGNATURE_H +#define GITSIGNATURE_H #include #include +#include #include "git2.h" -#include "repo.h" - -using namespace v8; using namespace node; +using namespace v8; class GitSignature : public ObjectWrap { public: + static Persistent constructor_template; + static void Initialize (Handle target); - static void Initialize(Handle target); + git_signature *GetValue(); - git_signature* GetValue(); - void SetValue(git_signature* signature); + static Handle New(void *raw); - protected: - GitSignature() {}; - ~GitSignature() {}; + private: + GitSignature(git_signature *raw); + ~GitSignature(); static Handle New(const Arguments& args); - static Handle Duplicate(const Arguments& args); - static Handle Free(const Arguments& args); static Handle Name(const Arguments& args); static Handle Email(const Arguments& args); + static Handle Time(const Arguments& args); - private: - git_signature* signature; + static Handle Create(const Arguments& args); + static Handle Now(const Arguments& args); + git_signature *raw; }; #endif diff --git a/include/submodule.h b/include/submodule.h new file mode 100644 index 000000000..f80d8ee3d --- /dev/null +++ b/include/submodule.h @@ -0,0 +1,146 @@ +/** + * This code is auto-generated; unless you know what you're doing, do not modify! + **/ + +#ifndef GITSUBMODULE_H +#define GITSUBMODULE_H + +#include +#include +#include + +#include "git2.h" + +using namespace node; +using namespace v8; + +class GitSubmodule : public ObjectWrap { + public: + + static Persistent constructor_template; + static void Initialize (Handle target); + + git_submodule *GetValue(); + + static Handle New(void *raw); + + private: + GitSubmodule(git_submodule *raw); + ~GitSubmodule(); + + static Handle New(const Arguments& args); + + + static Handle AddFinalize(const Arguments& args); + static void AddFinalizeWork(uv_work_t* req); + static void AddFinalizeAfterWork(uv_work_t* req); + + struct AddFinalizeBaton { + uv_work_t request; + int error_code; + const git_error* error; + Persistent submoduleReference; + git_submodule * submodule; + Persistent callback; + }; + static Handle AddToIndex(const Arguments& args); + static void AddToIndexWork(uv_work_t* req); + static void AddToIndexAfterWork(uv_work_t* req); + + struct AddToIndexBaton { + uv_work_t request; + int error_code; + const git_error* error; + Persistent submoduleReference; + git_submodule * submodule; + Persistent write_indexReference; + int write_index; + Persistent callback; + }; + static Handle Save(const Arguments& args); + static void SaveWork(uv_work_t* req); + static void SaveAfterWork(uv_work_t* req); + + struct SaveBaton { + uv_work_t request; + int error_code; + const git_error* error; + Persistent submoduleReference; + git_submodule * submodule; + Persistent callback; + }; + static Handle Name(const Arguments& args); + static Handle Path(const Arguments& args); + static Handle Url(const Arguments& args); + static Handle SetUrl(const Arguments& args); + static Handle IndexId(const Arguments& args); + static Handle HeadId(const Arguments& args); + static Handle Init(const Arguments& args); + static void InitWork(uv_work_t* req); + static void InitAfterWork(uv_work_t* req); + + struct InitBaton { + uv_work_t request; + int error_code; + const git_error* error; + Persistent submoduleReference; + git_submodule * submodule; + Persistent overwriteReference; + int overwrite; + Persistent callback; + }; + static Handle Sync(const Arguments& args); + static void SyncWork(uv_work_t* req); + static void SyncAfterWork(uv_work_t* req); + + struct SyncBaton { + uv_work_t request; + int error_code; + const git_error* error; + Persistent submoduleReference; + git_submodule * submodule; + Persistent callback; + }; + static Handle Open(const Arguments& args); + static void OpenWork(uv_work_t* req); + static void OpenAfterWork(uv_work_t* req); + + struct OpenBaton { + uv_work_t request; + int error_code; + const git_error* error; + git_repository * repo; + Persistent submoduleReference; + git_submodule * submodule; + Persistent callback; + }; + static Handle Reload(const Arguments& args); + static void ReloadWork(uv_work_t* req); + static void ReloadAfterWork(uv_work_t* req); + + struct ReloadBaton { + uv_work_t request; + int error_code; + const git_error* error; + Persistent submoduleReference; + git_submodule * submodule; + Persistent callback; + }; + static Handle Status(const Arguments& args); + static void StatusWork(uv_work_t* req); + static void StatusAfterWork(uv_work_t* req); + + struct StatusBaton { + uv_work_t request; + int error_code; + const git_error* error; + Persistent statusReference; + unsigned int * status; + Persistent submoduleReference; + git_submodule * submodule; + Persistent callback; + }; + git_submodule *raw; +}; + +#endif diff --git a/include/tag.h b/include/tag.h index f75b28f90..f89ded8b1 100755 --- a/include/tag.h +++ b/include/tag.h @@ -1,58 +1,57 @@ /** - * Copyright (c) 2011, Tim Branyen @tbranyen - * @author Michael Robinson @codeofinterest - * - * Dual licensed under the MIT and GPL licenses. - */ + * This code is auto-generated; unless you know what you're doing, do not modify! + **/ -#ifndef TAG_H -#define TAG_H +#ifndef GITTAG_H +#define GITTAG_H +#include #include +#include #include "git2.h" using namespace node; +using namespace v8; -/** - * Class: GitTag - * Wrapper for libgit2 git_error. - */ class GitTag : public ObjectWrap { public: - /** - * Variable: constructor_template - * Used to create Node.js constructor. - */ - static v8::Persistent constructor_template; - /** - * Function: Initialize - * Used to intialize the EventEmitter from Node.js - * - * Parameters: - * target - v8::Object the Node.js global module object - */ - static void Initialize(v8::Handle target); - - protected: - /** - * Constructor: GitTag - */ - GitTag() {}; - /** - * Deconstructor: GitTag - */ - ~GitTag() {}; - /** - * Function: New - * - * Parameters: - * args v8::Arguments function call - * - * Returns: - * v8::Object args.This() - */ - static v8::Handle New(const v8::Arguments& args); + + static Persistent constructor_template; + static void Initialize (Handle target); + + git_tag *GetValue(); + + static Handle New(void *raw); + + private: + GitTag(git_tag *raw); + ~GitTag(); + + static Handle New(const Arguments& args); + + + static Handle Oid(const Arguments& args); + static Handle GetTarget(const Arguments& args); + static void GetTargetWork(uv_work_t* req); + static void GetTargetAfterWork(uv_work_t* req); + + struct GetTargetBaton { + uv_work_t request; + int error_code; + const git_error* error; + git_object * target_out; + Persistent tagReference; + const git_tag * tag; + Persistent callback; + }; + static Handle TargetId(const Arguments& args); + static Handle TargetType(const Arguments& args); + static Handle Name(const Arguments& args); + static Handle Tagger(const Arguments& args); + static Handle Message(const Arguments& args); + static Handle Peel(const Arguments& args); + git_tag *raw; }; #endif diff --git a/include/threads.h b/include/threads.h index bf9f8c392..7a67b0295 100755 --- a/include/threads.h +++ b/include/threads.h @@ -1,41 +1,33 @@ -/* - * Copyright 2011, Tim Branyen @tbranyen - * @author Michael Robinson @codeofinterest - * - * Dual licensed under the MIT and GPL licenses. - */ +/** + * This code is auto-generated; unless you know what you're doing, do not modify! + **/ + +#ifndef GITTHREADS_H +#define GITTHREADS_H #include #include +#include #include "git2.h" using namespace node; using namespace v8; -/** - * Class wrapper for libgit2 git_threads_* - */ class GitThreads : public ObjectWrap { public: - /** - * v8::FunctionTemplate used to create Node.js constructor - */ - static Persistent constructor_template; + static Persistent constructor_template; static void Initialize (Handle target); - /** - * Calls git_threads_init synchronously. This is called one time - * on initialization, and is required for libgit2 to run correctly. - */ - static Handle Init(const Arguments& args); - - protected: - GitThreads() {} - ~GitThreads() {} + private: static Handle New(const Arguments& args); + + static Handle Init(const Arguments& args); + static Handle Shutdown(const Arguments& args); }; + +#endif diff --git a/include/time.h b/include/time.h new file mode 100644 index 000000000..b742a88b0 --- /dev/null +++ b/include/time.h @@ -0,0 +1,39 @@ +/** + * This code is auto-generated; unless you know what you're doing, do not modify! + **/ + +#ifndef GITTIME_H +#define GITTIME_H + +#include +#include +#include + +#include "git2.h" + +using namespace node; +using namespace v8; + +class GitTime : public ObjectWrap { + public: + + static Persistent constructor_template; + static void Initialize (Handle target); + + git_time *GetValue(); + + static Handle New(void *raw); + + private: + GitTime(git_time *raw); + ~GitTime(); + + static Handle New(const Arguments& args); + + static Handle Time(const Arguments& args); + static Handle Offset(const Arguments& args); + + git_time *raw; +}; + +#endif diff --git a/include/tree.h b/include/tree.h index 4cc84c457..5462a82b1 100755 --- a/include/tree.h +++ b/include/tree.h @@ -1,9 +1,6 @@ -/* - * Copyright 2013, Tim Branyen @tbranyen - * @author Michael Robinson @codeofinterest - * - * Dual licensed under the MIT and GPL licenses. - */ +/** + * This code is auto-generated; unless you know what you're doing, do not modify! + **/ #ifndef GITTREE_H #define GITTREE_H @@ -11,98 +8,106 @@ #include #include #include -#include #include "git2.h" -#include "repo.h" -#include "tree_entry.h" - -using namespace v8; using namespace node; +using namespace v8; -/** - * Class wrapper for libgit2 git_tree - */ class GitTree : public ObjectWrap { public: static Persistent constructor_template; + static void Initialize (Handle target); - static const int WALK_ENTRY_SEND_THRESHOLD = 10; - - static void Initialize(Handle target); + git_tree *GetValue(); - git_tree* GetValue(); - void SetValue(git_tree* tree); + static Handle New(void *raw); - protected: - GitTree() {}; - ~GitTree() {}; + private: + GitTree(git_tree *raw); + ~GitTree(); static Handle New(const Arguments& args); - static Handle Lookup(const Arguments& args); - static void LookupWork(uv_work_t* req); - static void LookupAfterWork(uv_work_t* req); - - static Handle Walk(const Arguments& args); - static void WalkWork(void* payload); - static int WalkWorkEntry(const char *root, const git_tree_entry *entry, void *payload); - static void WalkWorkSendEntry(uv_async_t *handle, int status /*UNUSED*/); - static void WalkWorkSendEnd(uv_async_t *handle, int status /*UNUSED*/); - - static Handle EntryByPath(const Arguments& args); - static void EntryByPathWork(uv_work_t *req); - static void EntryByPathAfterWork(uv_work_t *req); - private: - - git_tree* tree; + static Handle Oid(const Arguments& args); + static Handle Size(const Arguments& args); + static Handle EntryByName(const Arguments& args); + static Handle EntryByIndex(const Arguments& args); + static Handle EntryByOid(const Arguments& args); + static Handle GetEntry(const Arguments& args); + static void GetEntryWork(uv_work_t* req); + static void GetEntryAfterWork(uv_work_t* req); - struct LookupBaton { + struct GetEntryBaton { uv_work_t request; + int error_code; const git_error* error; - - git_oid rawOid; - git_repository* rawRepo; - git_tree* rawTree; - + git_tree_entry * out; + Persistent rootReference; + git_tree * root; + Persistent pathReference; + const char * path; Persistent callback; }; + static Handle Builder(const Arguments& args); + static Handle DiffTree(const Arguments& args); + static void DiffTreeWork(uv_work_t* req); + static void DiffTreeAfterWork(uv_work_t* req); - struct WalkEntry { - git_tree_entry* rawEntry; - std::string root; + struct DiffTreeBaton { + uv_work_t request; + int error_code; + const git_error* error; + git_diff_list * diff; + Persistent repoReference; + git_repository * repo; + Persistent old_treeReference; + git_tree * old_tree; + Persistent new_treeReference; + git_tree * new_tree; + Persistent optsReference; + const git_diff_options * opts; + Persistent callback; }; + static Handle DiffIndex(const Arguments& args); + static void DiffIndexWork(uv_work_t* req); + static void DiffIndexAfterWork(uv_work_t* req); - struct WalkBaton { - uv_thread_t threadId; - uv_mutex_t mutex; - uv_async_t asyncEntry; - uv_async_t asyncEnd; - + struct DiffIndexBaton { + uv_work_t request; + int error_code; const git_error* error; - - std::vector rawTreeEntries; - - git_tree* rawTree; - bool blobsOnly; - - Persistent entryCallback; - Persistent endCallback; + git_diff_list * diff; + Persistent repoReference; + git_repository * repo; + Persistent old_treeReference; + git_tree * old_tree; + Persistent indexReference; + git_index * index; + Persistent optsReference; + const git_diff_options * opts; + Persistent callback; }; + static Handle DiffWorkDir(const Arguments& args); + static void DiffWorkDirWork(uv_work_t* req); + static void DiffWorkDirAfterWork(uv_work_t* req); - struct EntryByPathBaton { + struct DiffWorkDirBaton { uv_work_t request; + int error_code; const git_error* error; - - git_tree* rawTree; - std::string path; - git_tree_entry* rawEntry; - + git_diff_list * diff; + Persistent repoReference; + git_repository * repo; + Persistent old_treeReference; + git_tree * old_tree; + Persistent optsReference; + const git_diff_options * opts; Persistent callback; }; + git_tree *raw; }; #endif diff --git a/include/tree_builder.h b/include/tree_builder.h new file mode 100644 index 000000000..93d08a69f --- /dev/null +++ b/include/tree_builder.h @@ -0,0 +1,58 @@ +/** + * This code is auto-generated; unless you know what you're doing, do not modify! + **/ + +#ifndef GITTREEBUILDER_H +#define GITTREEBUILDER_H + +#include +#include +#include + +#include "git2.h" + +using namespace node; +using namespace v8; + +class GitTreeBuilder : public ObjectWrap { + public: + + static Persistent constructor_template; + static void Initialize (Handle target); + + git_treebuilder *GetValue(); + + static Handle New(void *raw); + + private: + GitTreeBuilder(git_treebuilder *raw); + ~GitTreeBuilder(); + + static Handle New(const Arguments& args); + + + static Handle Create(const Arguments& args); + static Handle Clear(const Arguments& args); + static Handle Size(const Arguments& args); + static Handle Get(const Arguments& args); + static Handle Insert(const Arguments& args); + static Handle GitTreebuilderRemove(const Arguments& args); + static Handle Write(const Arguments& args); + static void WriteWork(uv_work_t* req); + static void WriteAfterWork(uv_work_t* req); + + struct WriteBaton { + uv_work_t request; + int error_code; + const git_error* error; + git_oid * id; + Persistent repoReference; + git_repository * repo; + Persistent bldReference; + git_treebuilder * bld; + Persistent callback; + }; + git_treebuilder *raw; +}; + +#endif diff --git a/include/tree_entry.h b/include/tree_entry.h index eb97ad6a6..7c78ec1e9 100755 --- a/include/tree_entry.h +++ b/include/tree_entry.h @@ -1,9 +1,6 @@ -/* - * Copyright 2011, Tim Branyen @tbranyen - * @author Michael Robinson @codeofinterest - * - * Dual licensed under the MIT and GPL licenses. - */ +/** + * This code is auto-generated; unless you know what you're doing, do not modify! + **/ #ifndef GITTREEENTRY_H #define GITTREEENTRY_H @@ -14,89 +11,46 @@ #include "git2.h" -#include "repo.h" -#include "tree.h" -#include "oid.h" - -using namespace v8; using namespace node; +using namespace v8; -/** - * Class wrapper for libgit2 git_tree_entry - */ -class GitTreeEntry : ObjectWrap { +class GitTreeEntry : public ObjectWrap { public: static Persistent constructor_template; + static void Initialize (Handle target); - static void Initialize(Handle target); - git_tree_entry* GetValue(); - void SetValue(git_tree_entry* tree); - void SetRoot(std::string root); - std::string GetRoot(); + git_tree_entry *GetValue(); - protected: - static Handle New(const Arguments& args); - - static Handle Root(const Arguments& args); - - static Handle Name(const Arguments& args); - static void NameWork(uv_work_t* req); - static void NameAfterWork(uv_work_t* req); - - static Handle FileMode(const Arguments& args); - static void FileModeWork(uv_work_t* req); - static void FileModeAfterWork(uv_work_t* req); - - static Handle Oid(const Arguments& args); - static void OidWork(uv_work_t* req); - static void OidAfterWork(uv_work_t* req); - - static Handle ToBlob(const Arguments& args); - static void ToBlobWork(uv_work_t *req); - static void ToBlobAfterWork(uv_work_t *req); + static Handle New(void *raw); private: - git_tree_entry* entry; - std::string root; + GitTreeEntry(git_tree_entry *raw); + ~GitTreeEntry(); - struct NameBaton { - uv_work_t request; - - git_tree_entry* rawEntry; - const char* name; - - Persistent callback; - }; - - struct FileModeBaton { - uv_work_t request; - - git_tree_entry* rawEntry; - git_filemode_t fileMode; - - Persistent callback; - }; - - struct OidBaton { - uv_work_t request; + static Handle New(const Arguments& args); - git_tree_entry* rawEntry; - const git_oid* rawOid; - Persistent callback; - }; + static Handle Name(const Arguments& args); + static Handle Oid(const Arguments& args); + static Handle Type(const Arguments& args); + static Handle filemode(const Arguments& args); + static Handle GetObject(const Arguments& args); + static void GetObjectWork(uv_work_t* req); + static void GetObjectAfterWork(uv_work_t* req); - struct ToBlobBaton { + struct GetObjectBaton { uv_work_t request; + int error_code; const git_error* error; - - git_repository* rawRepo; - git_tree_entry* rawEntry; - git_blob* rawBlob; - + git_object * object_out; + Persistent repoReference; + git_repository * repo; + Persistent entryReference; + const git_tree_entry * entry; Persistent callback; }; + git_tree_entry *raw; }; #endif diff --git a/include/utils.h b/include/utils.h deleted file mode 100644 index f8a4faf55..000000000 --- a/include/utils.h +++ /dev/null @@ -1,19 +0,0 @@ -#ifndef UTILS_H -#define UTILS_H - -// Credit: @samcday -// http://sambro.is-super-awesome.com/2011/03/03/creating-a-proper-buffer-in-a-node-c-addon/ -#define MAKE_FAST_BUFFER(NG_SLOW_BUFFER, NG_FAST_BUFFER) \ - Local NG_JS_BUFFER = Local::Cast( \ - Context::GetCurrent()->Global()->Get( \ - String::New("Buffer"))); \ - \ - Handle NG_JS_ARGS[3] = { \ - NG_SLOW_BUFFER->handle_, \ - Integer::New(Buffer::Length(NG_SLOW_BUFFER)), \ - Integer::New(0) \ - }; \ - \ - NG_FAST_BUFFER = NG_JS_BUFFER->NewInstance(3, NG_JS_ARGS); - -#endif diff --git a/include/wrapper.h b/include/wrapper.h new file mode 100644 index 000000000..668a64465 --- /dev/null +++ b/include/wrapper.h @@ -0,0 +1,32 @@ +/** + * This code is auto-generated; unless you know what you're doing, do not modify! + **/ + +#ifndef WRAPPER_H +#define WRAPPER_H + +#include +#include + +using namespace node; +using namespace v8; + +class Wrapper : public ObjectWrap { + public: + + static Persistent constructor_template; + static void Initialize (Handle target); + + void *GetValue(); + static Handle New(void *raw); + + private: + Wrapper(void *raw); + + static Handle New(const Arguments& args); + static Handle ToBuffer(const Arguments& args); + + void *raw; +}; + +#endif diff --git a/index.js b/index.js new file mode 100755 index 000000000..6ca1b327d --- /dev/null +++ b/index.js @@ -0,0 +1,38 @@ +// Used to detect for Cygwin +var os = require('os'); + +// Required for Windows/Cygwin support +var root = [__dirname, '/vendor/libgit2/build/shared'].join(''), + path = process.env.PATH; + +if (~os.type().indexOf('CYGWIN') && !~path.indexOf(root)) { + process.env.PATH = root + ':' + path; +} + +// Assign raw api to module +var rawApi = require('./build/Release/nodegit'); +for (var key in rawApi) { + exports[key] = rawApi[key]; +} + +// Import extensions +require('./lib/commit.js'); +require('./lib/blob.js'); +require('./lib/object.js'); +require('./lib/signature.js'); +require('./lib/odb.js'); +require('./lib/oid.js'); +require('./lib/index.js'); +require('./lib/repo.js'); +require('./lib/reference.js'); +require('./lib/revwalk.js'); +require('./lib/tree.js'); +require('./lib/diff_list.js'); +require('./lib/tree_entry.js'); +require('./lib/tree_builder.js'); + +// Set version +exports.version = require('./package').version; + +// Initialize threads +exports.Threads.init(); diff --git a/lib/blob.js b/lib/blob.js index c3d368008..341eef637 100644 --- a/lib/blob.js +++ b/lib/blob.js @@ -1,124 +1,27 @@ var git = require('../'), - success = require('./utilities').success; + TreeEntry = git.TreeEntry, + Blob = git.Blob; -/** - * Blob convenience class constructor. - * - * @constructor - * @param {git.raw.Repo} rawRepo Raw repository object. - * @param {git.raw.Blob} [rawBlob = new git.raw.Blob(rawRepo)] Raw blob object. - */ -var Blob = function(rawRepo, rawBlob) { - if(!(rawRepo instanceof git.raw.Repo)) { - throw new git.error('First parameter for Blob must be a raw repo'); - } - this.rawRepo = rawRepo; - - if(typeof rawBlob !== 'undefined' && - rawBlob instanceof git.raw.Blob) { - this.rawBlob = rawBlob; - } else { - this.rawBlob = new git.raw.Blob(this.rawRepo); - } -}; +var oldContent = Blob.prototype.content; /** - * Retrieve the blob represented by the oid. - * - * @param {git.raw.Oid} oid The OID representing the blob to lookup. - * @param {Blob~lookupCallback} callback + * Retrieve the content of the blob. + * @return {Buffer} content */ -Blob.prototype.lookup = function(oid, callback) { - /** - * @callback Blob~lookupCallback Callback executed on lookup completion. - * @param {GitError|null} error An Error or null if successful. - * @param {Blob|null} blob Retrieved blob object or null. - */ - var self = this; - self.rawBlob.lookup(self.rawRepo, oid, function blobLookup(error, rawBlob) { - if (success(error, callback)) { - self.rawBlob = rawBlob; - callback(null, self); - } - }); +Blob.prototype.content = function() { + return oldContent.call(this).toBuffer(this.size()); }; /** - * Retrieve the blob's raw content buffer. - * - * @param {Blob~rawContentCallback} callback + * Retrieve the blob's content as String. */ -Blob.prototype.rawContent = function(callback) { - /** - * @callback Blob~rawContentCallback Callback executed after raw content is retrieved. - * @param {GitError|null} error An Error or null if successful. - * @param {Buffer|null} content The raw content of the blob or null. - */ - this.rawBlob.rawContent(function(error, content) { - if (success(error, callback)) { - callback(null, content); - } - }); +Blob.prototype.toString = function() { + return this.content().toString(); }; /** - * Retrieve the blob's content. - * - * @param {Blob~contentCallback} callback + * Retrieve the blob's type. */ -Blob.prototype.content = function(callback) { - /** - * @callback Blob~contentCallback Callback executed after content is retrieved. - * @param {GitError|null} error An Error or null if successful. - * @param {String|null} content The content of the blob or null. - */ - this.rawContent(function(error, content) { - if (success(error, callback)) { - callback(null, content.toString()); - } - }); +Blob.prototype.filemode = function() { + return this.isBinary() ? TreeEntry.FileMode.Executable : TreeEntry.FileMode.Blob; }; - -/** - * Create a new blob from the file at the given path. - * - * @param {String} path Full path to the file. - * @param {Blob~createFromFileCallback} callback - */ -Blob.prototype.createFromFile = function(path, callback) { - /** - * @callback Blob~createFromFileCallback Callback executed after blob is created. - * @param {GitError|null} error An Error or null if successful. - * @param {Blob|null} blob The new blob or null. - */ - var self = this; - self.rawBlob.createFromFile(path, self.rawRepo, function blobCreateFromFileCallback(error, rawBlob) { - if (success(error, callback)) { - self.rawBlob = rawBlob; - callback(null, self); - } - }); -}; - -/** - * Create a new blob from the given buffer. - * - * @param {Buffer} buffer Buffer used to create blob. - * @param {Blob~createFromBufferCallback} callback - */ -Blob.prototype.createFromFile = function(path, callback) { - /** - * @callback Blob~createFromBufferCallback Callback executed after blob is created. - * @param {GitError|null} error An Error or null if successful. - * @param {Blob|null} content The new blob or null. - */ - var self = this; - self.rawBlob.createFromBuffer(buffer, self.rawRepo, function blobCreateFromBufferCallback(error, rawBlob) { - if (success(error, callback)) { - self.rawBlob = rawBlob; - callback(null, self); - } - }); -}; - -exports.blob = Blob; diff --git a/lib/commit.js b/lib/commit.js index 75f2fc18e..8dc0851f6 100644 --- a/lib/commit.js +++ b/lib/commit.js @@ -1,242 +1,52 @@ -var git = require( '../' ), - success = require('./utilities').success, - events = require('events'); - -/** - * Convenience commit constructor. - * - * @constructor - * @param {git.raw.Repo} rawRepo Raw repository object. - * @param {git.raw.Commit} [rawCommit = new git.raw.Commit(rawRepo)] Raw commit object. - */ -var Commit = function(rawRepo, rawCommit) { - if (!(rawRepo instanceof git.raw.Repo)) { - throw new git.error('First parameter for Commit must be a raw repo'); - } - - this.rawRepo = rawRepo; - - if (rawCommit instanceof git.raw.Commit) { - this.rawCommit = rawCommit; - } else { - this.rawCommit = new git.raw.Commit(); - } -}; - -/** - * Look up the commit referenced by oid, replace this.commit with the result. - * - * @param {Oid|git.raw.Oid|String} oid A representation of an OID used to lookup the commit. - * @param {Commit~lookupCallback} callback - */ -Commit.prototype.lookup = function(oid, callback) { - /** - * @callback Commit~lookupCallback Callback executed on lookup completion. - * @param {GitError|null} error An Error or null if successful. - * @param {Commit|null} commit Retrieved commit object or null. - */ - if (typeof oid !== 'undefined' && - typeof oid !== 'string' && - !(oid instanceof git.raw.Oid)) { - oid = oid.getRawOid(); - } - var self = this; - self.rawCommit.lookup(self.rawRepo, oid, function commitLookup(error, rawCommit) { - if (success(error, callback)) { - self.rawCommit = rawCommit; - callback(null, self); - } - }); -}; - -/** - * Retrieve the commit's OID. - * - * @param {Commit~oidCallback} callback - */ -Commit.prototype.oid = function(callback) { - /** - * @callback Commit~oidCallback Callback executed on OID retrieval. - * @param {GitError|null} error An Error or null if successful. - * @param {Oid|null} commit Retrieved OID object or null. - */ - callback(null, new git.oid(this.rawCommit.oid())); -}; +var git = require('../'), + Commit = git.Commit, + events = require('events'); /** * Retrieve the SHA. - * - * @param {Commit~shaCallback} callback + * @return {String} */ -Commit.prototype.sha = function(callback) { - /** - * @callback Commit~shaCallback Callback executed on SHA retrieval. - * @param {GitError|null} error An Error or null if successful. - * @param {String|null} sha Retrieved SHA. - */ - this.oid(function(error, oid) { - if (!success(error, callback)) { - return; - } - oid.sha(function(error, sha) { - if (!success(error, callback)) { - return; - } - callback(null, sha); - }); - }); -}; - -/** - * Retrieve the message - * - * @param {Commit~messageCallback} callback - */ -Commit.prototype.message = function(callback) { - /** - * @callback Commit~messageCallback Callback executed on message retrieval. - * @param {GitError|null} error An Error or null if successful. - * @param {String|null} message Retrieved message. - */ - this.rawCommit.message(function(error, message) { - if (success(error, callback)) { - callback(null, message); - } - }); +Commit.prototype.sha = function() { + return this.oid().sha(); }; /** * Retrieve the commit time as a unix timestamp. - * - * @param {Commit~timeCallback} callback + * @return {Number} */ -Commit.prototype.time = function(callback) { - /** - * @callback Commit~timeCallback Callback executed on time retrieval. - * @param {GitError|null} error An Error or null if successful. - * @param {Integer|null} time Retrieved time in seconds. - */ - this.rawCommit.time(function(error, time) { - if (success(error, callback)) { - // git_commit_time returns timestamp in s, converting to ms here - callback(null, time * 1000); - } - }); +Commit.prototype.timeMs = function() { + return this.time() * 1000; }; /** * Retrieve the commit time as a Date object. - * - * @param {Commit~dateCallback} callback - */ -Commit.prototype.date = function(callback) { - /** - * @callback Commit~dateCallback Callback executed on date retrieval. - * @param {GitError|null} error An Error or null if successful. - * @param {Date|null} time Retrieved time as a Date object. - */ - this.time(function(error, time) { - if (success(error, callback)) { - callback(null, new Date(time)); - } - }); -}; - -/** - * Retrieve the commit's positive or negative timezone offset, in minutes from UTC. - * - * @param {Commit~offsetCallback} callback - */ -Commit.prototype.offset = function(callback) { - /** - * @callback Commit~offsetCallback Callback executed on offset retrieval. - * @param {GitError|null} error An Error or null if successful. - * @param {Integer|null} offset Retrieved offset in in minutes from UTC. - */ - this.rawCommit.offset(function(error, offset) { - if (success(error, callback)) { - callback(null, offset); - } - }); -}; - -/** - * Retrieve the commit's author signature. - * - * @param {Commit~authorCallback} callback + * @return {Date} */ -Commit.prototype.author = function(callback) { - /** - * @callback Commit~authorCallback Callback executed on author retrieval. - * @param {GitError|null} error An Error or null if successful. - * @param {Signature|null} author Retrieved author signature. - */ - this.rawCommit.author(function(error, rawSignature) { - if (success(error, callback)) { - callback(null, new git.signature(rawSignature)); - } - }); -}; - -/** - * Retrieve the commit's committer. - * - * @param {Commit~committerCallback} callback - */ -Commit.prototype.committer = function(callback) { - /** - * @callback Commit~committerCallback Callback executed on committer retrieval. - * @param {GitError|null} error An Error or null if successful. - * @param {Signature|null} committer Retrieved committer signature. - */ - this.rawCommit.committer(function(error, rawSignature) { - if (success(error, callback)) { - callback(null, new git.signature(rawSignature)); - } - }); +Commit.prototype.date = function() { + return new Date(this.timeMs()); }; /** - * Retrieve the tree for this commit. - * - * @param {Commit~treeCallback} callback + * Get the tree associated with this commit. + * @return {Tree} */ -Commit.prototype.tree = function(callback) { - /** - * @callback Commit~treeCallback Callback executed on tree retrieval. - * @param {GitError|null} error An Error or null if successful. - * @param {Tree|null} tree Retrieved tree. - */ - var self = this; - self.rawCommit.tree(function commitTree(error, rawTree) { - if (success(error, callback)) { - callback(null, new git.tree(self.rawRepo, rawTree)); - } - }); +Commit.prototype.getTree = function(callback) { + this.repo.getTree(this.treeId(), callback); }; /** - * Retrieve the file represented by path for this commit. + * Retrieve the entry represented by path for this commit. * Path must be relative to repository root. * * @param {String} path - * @param {Commit~fileCallback} callback + * @param {Function} callback + * @return {TreeEntry} */ -Commit.prototype.file = function(path, callback) { - /** - * @callback Commit~fileCallback Callback executed on file retrieval. - * @param {GitError|null} error An Error or null if successful. - * @param {Entry|null} file Retrieved file entry. - */ - this.tree(function commitFileCallback(error, tree) { - if (!success(error, callback)) { - return; - } - tree.entry(path, function(error, entry) { - if (success(error, callback)) { - callback(null, entry); - } - }); +Commit.prototype.getEntry = function(path, callback) { + this.getTree(function(error, tree) { + if (error) return callback(error); + + tree.getEntry(path, callback); }); }; @@ -244,105 +54,93 @@ Commit.prototype.file = function(path, callback) { * Walk the history from this commit backwards. * An EventEmitter is returned that will emit a 'commit' event for each * commit in the history, and one 'end' event when the walk is completed. + * Don't forget to call `start()` on the returned event. * * @fires Commit#commit * @fires Commit#end * - * @return {EventEmitter} historyWalkEmitter + * @return {EventEmitter} */ Commit.prototype.history = function() { - var event = new events.EventEmitter(), - self = this; + var event = new events.EventEmitter(); - self.oid(function commitOid(error, oid) { - (new git.revwalk(self.rawRepo)).allocate(function createRevwalk(error, revwalk) { - var commits = []; - revwalk.walk(oid, function commitRevWalk(error, index, commit, noMoreCommits) { - if(error) { - event.emit('end', error, commits); - return false; - } + var oid = this.oid(); + var revwalk = this.repo.createRevWalk(); + revwalk.sorting.apply(revwalk, arguments); - if (noMoreCommits) { - /** - * End event. - * - * @event Commit#end - * - * @param {GitError|null} error An error object if there was an issue, null otherwise. - * @param {Commit[]} commits The commits. - */ - event.emit('end', null, commits); - return; - } - /** - * Commit event. - * - * @event Commit#commit - * - * @param {GitError|null} error An error object if there was an issue, null otherwise. - * @param {Commit} commit The commit. - */ - event.emit('commit', null, commit); - commits.push(commit); - }); - }); - }); + var commits = []; + event.start = function() { + revwalk.walk(oid, function commitRevWalk(error, commit) { + if (error) return event.emit('error', error); + if (!commit) { + event.emit('end', commits); + return; + } + event.emit('commit', commit); + commits.push(commit); + }); + }; return event; }; /** - * Retrieve the commit's parents. + * Retrieve the commit's parents -- as commit objects. * - * @param {Commit~parentsCallback} callback + * @param {Function} callback + * @return {[Commit]} array of commits */ -Commit.prototype.parents = function(callback) { - /** - * @callback Commit~parentsCallback Callback executed on parents retrieval. - * @param {GitError|null} error An Error or null if successful. - * @param {Commit[]|null} parents Commit's parent(s). - */ +Commit.prototype.getParents = function(callback) { var self = this; - self.rawCommit.parents(function processParent(error, rawParents) { - if (success(error, callback)) { - var parents = []; - rawParents.forEach(function eachParent(rawParent) { - parents.push(new Commit(self.rawRepo, rawParent)); - }); - callback(null, parents); - } - }); + function processParents(commit, n, acc, callback) { + if (n < 0) return callback(null, acc); + + self.repo.getCommit(self.parentId(n), function nextParent(error, parent) { + if (error) return callback(error); + processParents(parent, n-1, acc.concat([parent]), callback); + }); + } + + processParents(this, this.parentCount() - 1, [], callback); }; +/** + * Retrieve the commit's parent shas. + * + * @param {Function} callback + * @return {[Oid]} array of oids + */ +Commit.prototype.parents = function() { + var result = []; + for (var i = 0; i < this.parentCount(); i++) { + result.push(this.parentId(i)); + } + return result; +} + /** * Generate an array of diff trees showing changes between this commit * and its parent(s). * - * @param {Commit~parentsDiffTreesCallback} callback + * @param {Function} callback + * @return {[DiffList]} an array of difflists */ -Commit.prototype.parentsDiffTrees = function(callback) { - /** - * @callback Commit~parentsDiffTreesCallback Callback executed on diff trees retrieval. - * @param {GitError|null} error An Error or null if successful. - * @param {DiffList[]|null} diffLists Array of DiffTrees showing changes between this commit and its parent(s) - */ +Commit.prototype.getDiff = function(callback) { var self = this; - self.sha(function(error, commitSha) { - if (!success(error, callback)) { - return; - } - self.parents(function commitParents(error, parents) { - if (!success(error, callback)) { - return; - } - var parentDiffLists = []; - parents.forEach(function commitEachParent(parent) { - parent.sha(function commitParentSha(error, parentSha) { - (new git.diffList(self.rawRepo)).treeToTree(parentSha, commitSha, function walkDiffList(error, diffList) { - if (!success(error, callback)) { - return; - } + self.getParents(function commitParents(error, parents) { + if (error) return callback(error); + + var parentDiffLists = []; + parents.forEach(function commitEachParent(parent) { + parent.getTree(function(error, parentTree) { + if (error) return callback(error); + + self.getTree(function(error, thisTree) { + if (error) return callback(error); + + parentTree.diff(thisTree, function walkDiffList(error, diffList) { + if (error) return callback(error); + parentDiffLists.push(diffList); if (parentDiffLists.length === parents.length) { callback(null, parentDiffLists); @@ -354,4 +152,10 @@ Commit.prototype.parentsDiffTrees = function(callback) { }); }; -exports.commit = Commit; +/** + * The sha of this commit + * @return {String} + */ +Commit.prototype.toString = function() { + return this.sha(); +}; diff --git a/lib/convenient_hunk.js b/lib/convenient_hunk.js new file mode 100644 index 000000000..9f032a6a5 --- /dev/null +++ b/lib/convenient_hunk.js @@ -0,0 +1,34 @@ +function ConvenientHunk(raw, i) { + this.raw = raw; + this.i = i; +} + +/** + * Diff header string that represents the context of this hunk + * of the diff. Something like `@@ -169,14 +167,12 @@ ...` + * @return {String} + */ +ConvenientHunk.prototype.header = function() { + return this.raw.hunk(this.i).header; +}; + +/** + * Number of lines in this hunk + * @return {Number} + */ +ConvenientHunk.prototype.size = function() { + return this.raw.hunk(this.i).lines; +}; + +/** + * The lines in this hunk + * @return {[String]} array of strings + */ +ConvenientHunk.prototype.lines = function() { + var result = []; + for (var i = 0; i < this.size(); i++) + result.push(this.raw.line(this.i, i)); + return result; +}; + +exports.ConvenientHunk = ConvenientHunk; diff --git a/lib/convenient_patch.js b/lib/convenient_patch.js new file mode 100644 index 000000000..ed34735cb --- /dev/null +++ b/lib/convenient_patch.js @@ -0,0 +1,124 @@ +var git = require('../'), + DiffList = git.DiffList, + ConvenientHunk = require('./convenient_hunk').ConvenientHunk; + +function ConvenientPatch(raw) { + this.raw = raw; +} + +/** + * Old name of the file + * @return {String} + */ +ConvenientPatch.prototype.oldFile = function() { + return this.raw.delta.oldFile(); +}; + +/** + * New name of the file + * @return {String} + */ +ConvenientPatch.prototype.newFile = function() { + return this.raw.delta.newFile(); +}; + +/** + * The number of hunks in this patch + * @return {Number} + */ +ConvenientPatch.prototype.size = function() { + return this.raw.patch.size(); +}; + +/** + * The hunks in this patch + * @return {[ConvenientHunk]} an array of ConvenientHunks + */ +ConvenientPatch.prototype.hunks = function() { + var result = []; + for (var i = 0; i < this.size(); i++) + result.push(new ConvenientHunk(this.raw.patch, i)); + return result; +}; + +/** + * The status of this patch (unmodified, added, deleted) + * @return {Number} + */ +ConvenientPatch.prototype.status = function() { + return this.raw.delta.status(); +}; + +/** + * Is this an unmodified patch? + * @return {Boolean} + */ +ConvenientPatch.prototype.isUnmodified = function() { + return this.status() == DiffList.Delta.Unmodified; +}; + +/** + * Is this an added patch? + * @return {Boolean} + */ +ConvenientPatch.prototype.isAdded = function() { + return this.status() == DiffList.Delta.Added; +}; + +/** + * Is this a deleted patch? + * @return {Boolean} + */ +ConvenientPatch.prototype.isDeleted = function() { + return this.status() == DiffList.Delta.Deleted; +}; + +/** + * Is this an modified patch? + * @return {Boolean} + */ +ConvenientPatch.prototype.isModified = function() { + return this.status() == DiffList.Delta.Modified; +}; + +/** + * Is this a renamed patch? + * @return {Boolean} + */ +ConvenientPatch.prototype.isRenamed = function() { + return this.status() == DiffList.Delta.Renamed; +}; + +/** + * Is this a copied patch? + * @return {Boolean} + */ +ConvenientPatch.prototype.isCopied = function() { + return this.status() == DiffList.Delta.Copied; +}; + +/** + * Is this an ignored patch? + * @return {Boolean} + */ +ConvenientPatch.prototype.isIgnored = function() { + return this.status() == DiffList.Delta.Ignored; +}; + +/** + * Is this an untracked patch? + * @return {Boolean} + */ +ConvenientPatch.prototype.isUntracked = function() { + return this.status() == DiffList.Delta.Untracked; +}; + +/** + * Is this a type change? + * @return {Boolean} + */ +ConvenientPatch.prototype.isTypeChange = function() { + return this.status() == DiffList.Delta.TypeChange; +}; + +exports.ConvenientPatch = ConvenientPatch; diff --git a/lib/diff_list.js b/lib/diff_list.js index 56a269314..5cc125085 100644 --- a/lib/diff_list.js +++ b/lib/diff_list.js @@ -1,42 +1,24 @@ var git = require('../'), + DiffList = git.DiffList, + ConvenientPatch = require('./convenient_patch').ConvenientPatch, events = require('events'); -/** - * Convenience diff list class. - * - * @constructor - * @param {git.raw.Repo} rawRepo - * @param {git.raw.DiffList} [rawDiffList = new git.raw.DiffList] - */ -var DiffList = function(rawRepo, rawDiffList) { - if (!(rawRepo instanceof git.raw.Repo)) { - throw new git.error('First parameter for DiffList must be a raw repo'); - } - this.rawRepo = rawRepo; - - if (rawDiffList instanceof git.raw.DiffList) { - this.rawDiffList = rawDiffList; - } else { - this.rawDiffList = new git.raw.DiffList(); - } -}; - /** * Refer to vendor/libgit2/include/git2/diff.h for delta type definitions. * * @readonly * @enum {Integer} */ -DiffList.prototype.deltaTypes = { - /** 0 */ GIT_DELTA_UNMODIFIED: git.raw.DiffList.deltaTypes.GIT_DELTA_UNMODIFIED, - /** 1 */ GIT_DELTA_ADDED: git.raw.DiffList.deltaTypes.GIT_DELTA_ADDED, - /** 2 */ GIT_DELTA_DELETED: git.raw.DiffList.deltaTypes.GIT_DELTA_DELETED, - /** 3 */ GIT_DELTA_MODIFIED: git.raw.DiffList.deltaTypes.GIT_DELTA_MODIFIED, - /** 4 */ GIT_DELTA_RENAMED: git.raw.DiffList.deltaTypes.GIT_DELTA_RENAMED, - /** 5 */ GIT_DELTA_COPIED: git.raw.DiffList.deltaTypes.GIT_DELTA_COPIED, - /** 6 */ GIT_DELTA_IGNORED: git.raw.DiffList.deltaTypes.GIT_DELTA_IGNORED, - /** 7 */ GIT_DELTA_UNTRACKED: git.raw.DiffList.deltaTypes.GIT_DELTA_UNTRACKED, - /** 8 */ GIT_DELTA_TYPECHANGE: git.raw.DiffList.deltaTypes.GIT_DELTA_TYPECHANGE +DiffList.Delta = { + /** 0 */ Unmodified: 0, + /** 1 */ Added: 1, + /** 2 */ Deleted: 2, + /** 3 */ Modified: 3, + /** 4 */ Renamed: 4, + /** 5 */ Copied: 5, + /** 6 */ Ignored: 6, + /** 7 */ Untracked: 7, + /** 8 */ TypeChange: 8 }; /** @@ -45,121 +27,27 @@ DiffList.prototype.deltaTypes = { * @readOnly * @enum {String} */ -DiffList.prototype.lineOriginTypes = { - /** ' ' */ GIT_DIFF_LINE_CONTEXT: git.raw.DiffList.lineOriginTypes.GIT_DIFF_LINE_CONTEXT, - /** '+' */ GIT_DIFF_LINE_ADDITION: git.raw.DiffList.lineOriginTypes.GIT_DIFF_LINE_ADDITION, - /** '-' */ GIT_DIFF_LINE_DELETION: git.raw.DiffList.lineOriginTypes.GIT_DIFF_LINE_DELETION, - /** '\n' */ GIT_DIFF_LINE_ADD_EOFNL: git.raw.DiffList.lineOriginTypes.GIT_DIFF_LINE_ADD_EOFNL, - /** '' */ GIT_DIFF_LINE_DEL_EOFNL: git.raw.DiffList.lineOriginTypes.GIT_DIFF_LINE_DEL_EOFNL, - /** 'F' */ GIT_DIFF_LINE_FILE_HDR: git.raw.DiffList.lineOriginTypes.GIT_DIFF_LINE_FILE_HDR, - /** 'H' */ GIT_DIFF_LINE_HUNK_HDR: git.raw.DiffList.lineOriginTypes.GIT_DIFF_LINE_HUNK_HDR, - /** 'B' */ GIT_DIFF_LINE_BINARY: git.raw.DiffList.lineOriginTypes.GIT_DIFF_LINE_BINARY +DiffList.LineOrigin = { + /** ' ' */ Context: 32, + /** '+' */ Addition: 43, + /** '-' */ Deletion: 45, + /** '\n' */ AddEofNl: 13, + /** '' */ DelEofNl: 0, + /** 'F' */ FileHdr: 106, + /** 'H' */ HunkHdr: 110, + /** 'B' */ Binary: 102 }; /** - * Walk the current diff list tree. + * Retrieve patches in this difflist * - * @fires DiffList#delta - * @fires DiffList#end - * - * @return {EventEmitter} diffListWalkEmitter + * @return {[ConvenientPatch]} an array of ConvenientPatches */ -DiffList.prototype.walk = function() { - var event = new events.EventEmitter(), - allFileDeltas = [], - self = this; - - self.rawDiffList.walk(function fileCallback(error, fileDeltas) { - if (error) { - event.emit('end', new git.error(error.message, error.code), null); - } - fileDeltas.forEach(function(fileDelta) { - /** - * Delta event. - * - * @event DiffList#delta - * - * @param {GitError|null} error An error object if there was an issue, null otherwise. - * @param {FileDelta} fileDelta The file delta object. - */ - event.emit('delta', null, fileDelta); - allFileDeltas.push(fileDelta); - }); - }, function hunkCallback(error, diffHunk) { - /** TO BE IMPLEMENTED */ - }, function lineCallback(error, diffLine) { - /** TO BE IMPLEMENTED */ - }, function endCallback(error) { - /** - * End event. - * - * @event DiffList#end - * - * @param {GitError|null} error An error object if there was an issue, null otherwise. - * @param {FileDelta[]} fileDeltas The file delta objects. - */ - event.emit('end', error ? new git.error(error.message, error.code) : null, allFileDeltas); - }); - - return event; -}; - -DiffList.prototype.treeToTree = function(oldSha, newSha, callback) { - var self = this; - self.rawDiffList.treeToTree(self.rawRepo, oldSha, newSha, function(error, rawDifflist) { - if (error) { - callback(new git.error(error.message, error.code), null); - return; - } - self.rawDiffList = rawDifflist; - callback(null, self); - }); -}; - -exports.diffList = DiffList; - -/** - * @namespace - * @property {Object} oldFile Contains details for the old file state - * @property {String} oldFile.path The path to the old file, relative to the repository - * @property {Object} newFile Contains details for the new file state - * @property {String} newFile.path The path to the new file, relative to the repository - * @property {Object[]} content Array of context & differences - * @property {Object} content[].range - * @property {Object} content[].range.old - * @property {Integer} content[].range.old.start - * @property {Integer} content[].range.old.lines - * @property {Object} content[].range.new - * @property {Integer} content[].range.new.start - * @property {Integer} content[].range.new.lines - * @property {Object} content[].content Content of the delta - * @property {DiffList.lineOriginTypes} content[].lineOrigin - * @property {Integer} content[].contentLength - * @property {Integer} status Type of delta - */ -var FileDelta = { - oldFile: { - path: String - }, - newFile: { - path: String - }, - content: [ - { - range: { - old: { - start: Number, - lines: Number - }, - 'new': { - start: Number, - lines: Number - } - }, - content: String, - lineOrigin: String, - contentLength: Number - } - ], - status: Number +DiffList.prototype.patches = function() { + var size = this.size(); + result = []; + for (var i = 0; i < size; i++) { + result.push(new ConvenientPatch(this.patch(i))); + } + return result; }; diff --git a/lib/error.js b/lib/error.js deleted file mode 100644 index 9fbeac5a4..000000000 --- a/lib/error.js +++ /dev/null @@ -1,62 +0,0 @@ -var git = require('../'), - util = require('util'); - -/** - * GitError constructor. - * - * @constructor - * @param {String} [message = 'No message'] The error description. Set from giterr_last->message. - * @param {Integer} [code = git.raw.Error.codes.GITERR_INVALID] The error code. Set from giterr_last->klass - */ -var GitError = function(message, code) { - Error.call(this); - Error.captureStackTrace(this, exports.error); - - this.name = 'GitError'; - this.message = message || 'No message'; - this.code = code || git.raw.Error.codes.GITERR_INVALID; -}; - -util.inherits(GitError, Error); - -/** - * Refer to vendor/libgit2/include/git2/errors.h for error code definitions. - * - * @readonly - * @enum {Integer} - */ -GitError.prototype.codes = { - /** 0 */ GITERR_NOMEMORY: git.raw.Error.codes.GITERR_NOMEMORY, - /** 1 */ GITERR_OS: git.raw.Error.codes.GITERR_OS, - /** 2 */ GITERR_INVALID: git.raw.Error.codes.GITERR_INVALID, - /** 3 */ GITERR_REFERENCE: git.raw.Error.codes.GITERR_REFERENCE, - /** 4 */ GITERR_ZLIB: git.raw.Error.codes.GITERR_ZLIB, - /** 5 */ GITERR_REPOSITORY: git.raw.Error.codes.GITERR_REPOSITORY, - /** 6 */ GITERR_CONFIG: git.raw.Error.codes.GITERR_CONFIG, - /** 7 */ GITERR_REGEX: git.raw.Error.codes.GITERR_REGEX, - /** 8 */ GITERR_ODB: git.raw.Error.codes.GITERR_ODB, - /** 9 */ GITERR_INDEX: git.raw.Error.codes.GITERR_INDEX, - /** 10 */ GITERR_OBJECT: git.raw.Error.codes.GITERR_OBJECT, - /** 11 */ GITERR_NET: git.raw.Error.codes.GITERR_NET, - /** 12 */ GITERR_TAG: git.raw.Error.codes.GITERR_TAG, - /** 13 */ GITERR_TREE: git.raw.Error.codes.GITERR_TREE -}; - -/** - * Refer to vendor/libgit2/include/git2/errors.h for return code definitions. - * - * @readonly - * @enum {Integer} - */ -GitError.prototype.returnCodes = { - /** 0 */ GIT_OK: git.raw.Error.returnCodes.GIT_OK, - /** -1 */ GIT_ERROR: git.raw.Error.returnCodes.GIT_ERROR, - /** -3 */ GIT_ENOTFOUND: git.raw.Error.returnCodes.GIT_ENOTFOUND, - /** -4 */ GIT_EEXISTS: git.raw.Error.returnCodes.GIT_EEXISTS, - /** -5 */ GIT_EAMBIGUOUS: git.raw.Error.returnCodes.GIT_EAMBIGUOUS, - /** -6 */ GIT_EBUFS: git.raw.Error.returnCodes.GIT_EBUFS, - /** -30 */ GIT_PASSTHROUGH: git.raw.Error.returnCodes.GIT_PASSTHROUGH, - /** -31 */ GIT_ITEROVER: git.raw.Error.returnCodes.GIT_ITEROVER -}; - -exports.error = GitError; diff --git a/lib/index.js b/lib/index.js old mode 100755 new mode 100644 index 197f77abb..6dd690e54 --- a/lib/index.js +++ b/lib/index.js @@ -1,38 +1,15 @@ -// Used to detect for Cygwin -var os = require('os'); - -// Required for Windows/Cygwin support -var root = [__dirname, '/../vendor/libgit2/build/shared'].join(''), - path = process.env.PATH; - -if (~os.type().indexOf('CYGWIN') && !~path.indexOf(root)) { - process.env.PATH = root + ':' + path; -} - -// Import libraries -exports.blob = require('./blob.js').blob; -exports.repo = require('./repo.js').repo; -exports.signature = require('./signature.js').signature; -exports.oid = require('./oid.js').oid; -exports.reference = require('./reference.js').reference; -exports.revwalk = require('./revwalk.js').revwalk; -exports.commit = require('./commit.js').commit; -exports.tree = require('./tree.js').tree; - -// Assign raw api to module -try { - exports.raw = require('../build/Debug/nodegit'); -} catch (error) { - exports.raw = require('../build/Release/nodegit'); -} - -// Initialize objects that need to access their raw counterparts -exports.diffList = require('./diff_list.js').diffList; -exports.error = require('./error.js').error; -exports.entry = require('./tree_entry.js').entry; - -// Set version -exports.version = require('../package').version; - -// Initialize threads -(new exports.raw.Threads()).init(); +var git = require('../'), + Index = git.Index; + +/** + * Return an array of the entries in this index. + * @return {[IndexEntry]} an array of IndexEntrys + */ +Index.prototype.entries = function() { + var size = this.size(), + result = []; + for (var i = 0; i < size; i++) { + result.push(this.entry(i)); + } + return result; +}; diff --git a/lib/object.js b/lib/object.js new file mode 100644 index 000000000..df6300f1b --- /dev/null +++ b/lib/object.js @@ -0,0 +1,46 @@ +var git = require('../'); + +git.Object.Type = { + Any: -2, /**< Object can be any of the following */ + Bad: -1, /**< Object is invalid. */ + Ext1: 0, /**< Reserved for future use. */ + Commit: 1, /**< A commit object. */ + Tree: 2, /**< A tree (directory listing) object. */ + Blob: 3, /**< A file revision object. */ + Tag: 4, /**< An annotated tag object. */ + Ext2: 5, /**< Reserved for future use. */ + OffsetDelta: 6, /**< A delta, base is given by an offset. */ + OidDelta: 7 /**< A delta, base is given by object id. */ +}; + +/** + * Is this object a commit? + * @return {Boolean} + */ +git.Object.prototype.isCommit = function() { + return this.type() == Object.Type.Commit; +}; + +/** + * Is this object a tree? + * @return {Boolean} + */ +git.Object.prototype.isTree = function() { + return this.type() == Object.Type.Tree; +}; + +/** + * Is this object a blob? + * @return {Boolean} + */ +git.Object.prototype.isBlob = function() { + return this.type() == Object.Type.Blob; +}; + +/** + * Is this object a tag? + * @return {Boolean} + */ +git.Object.prototype.isTag = function() { + return this.type() == Object.Type.Tag; +}; diff --git a/lib/odb.js b/lib/odb.js new file mode 100644 index 000000000..28213903d --- /dev/null +++ b/lib/odb.js @@ -0,0 +1,13 @@ +var git = require('../'), + util = require('./util.js'), + Odb = git.Odb; + +/** + * Retrieve the object identified by oid. + * + * @param {String|Oid} String sha or Oid + * @param {Function} callback + * @return {git.Object} a git odb object + */ +util.normalizeOid(Odb.prototype, 'read'); +util.makeSafe(Odb.prototype, 'read'); diff --git a/lib/oid.js b/lib/oid.js index c32b58a3c..cb531d7d8 100644 --- a/lib/oid.js +++ b/lib/oid.js @@ -1,60 +1,14 @@ var git = require('../'), - success = require('./utilities').success; + Oid = git.Oid; /** - * Convenience Oid constructor. - * - * @constructor - * @param {git.raw.Oid} [rawOid = new git.rawOid] Raw Oid object. + * The hex representation of the SHA + * @return {String} */ -var Oid = function(rawOid) { - if(rawOid instanceof git.raw.Oid) { - this.rawOid = rawOid; - } else { - this.rawOid = new git.raw.Oid(); - } +Oid.prototype.toString = function() { + return this.sha(); }; -/** - * @return {git.raw.Oid} The wrapped raw Oid object. - */ -Oid.prototype.getRawOid = function() { - return this.rawOid; -}; - -/** - * Create Oid object from string. - * - * @param {String} sha - * @param {Oid~fromStringCallback} callback - */ -Oid.prototype.fromString = function(sha, callback) { - /** - * @callback Oid~fromStringCallback Callback executed after raw Oid is created. - * @param {GitError|null} error An Error or null if successful. - * @param {Oid|null} oid The new Oid object. - */ - var self = this; - self.rawOid.fromString(sha, function(error, rawOid) { - if (success(error, callback)) { - self.rawOid = rawOid; - callback(null, self); - } - }); +Oid.prototype.inspect = function() { + return "[Oid " + this.sha() + "]"; }; - -/** - * Convert the raw Oid to a SHA - * - * @param {Oid~shaCallback} callback - */ -Oid.prototype.sha = function(callback) { - /** - * @callback Oid~shaCallback Callback executed after SHA is retrieved. - * @param {GitError|null} error An Error or null if successful. - * @param {String|null} sha The SHA. - */ - callback(null, this.rawOid.sha()); -}; - -exports.oid = Oid; diff --git a/lib/reference.js b/lib/reference.js index 51e7d5a2f..ce909cc0a 100644 --- a/lib/reference.js +++ b/lib/reference.js @@ -1,64 +1,57 @@ var git = require('../'), - success = require('./utilities').success; + Reference = git.Reference; + +var oldSymbolicTarget = Reference.prototype.symbolicTarget, + oldTarget = Reference.prototype.target; + +Reference.Type = { + Oid: 1, + Symbolic: 2, + All: 3 +}; /** - * Convenience reference constructor. - * - * @constructor - * @param {git.raw.Repo} rawRepo - * @param {git.raw.Reference} [rawReference = new git.raw.Reference()] + * Returns true if this reference is not symbolic + * @return {Boolean} */ -var Reference = function(rawRepo, rawReference) { - if (!(rawRepo instanceof git.raw.Repo)) { - throw new git.error('First parameter for Reference must be a raw repo'); - } - this.rawRepo = rawRepo; +Reference.prototype.isConcrete = function() { + return this.type() == Reference.Type.Oid; +}; - if (rawReference instanceof git.raw.Reference) { - this.rawReference = rawReference; - } else { - this.rawReference = new git.raw.Reference(this.rawRepo); - } +/** + * Returns true if this reference is symbolic + * @return {Boolean} + */ +Reference.prototype.isSymbolic = function() { + return this.type() == Reference.Type.Symbolic; }; /** - * Lookup the reference with the given name. - * - * @param {String} name - * @param {Reference~lookupCallback} callback + * Returns the target of this symbolic reference. + * @return {Reference} + * @throws if the target is not symbolic. */ -Reference.prototype.lookup = function(name, callback) { - /** - * @callback Reference~lookupCallback Callback executed on lookup completion. - * @param {GitError|null} error An Error or null if successful. - * @param {Reference|null} reference Retrieved reference object or null. - */ - var self = this; - self.rawReference.lookup(self.rawRepo, name, function referenceLookup(error, rawReference) { - if (!success(error, callback)) { - return; - } - self.rawReference = rawReference; - callback(null, self); - }); +Reference.prototype.symbolicTarget = function() { + if (!this.isSymbolic()) throw this.name() + " is not symbolic"; + + return oldSymbolicTarget.call(this); }; /** - * Get the Oid representing this reference. - * - * @param {Reference~oidCallback} callback + * Returns the oid of this non-symbolic reference. + * @return {Oid} + * @throws if the target is symbolic. */ -Reference.prototype.oid = function(callback) { - /** - * @callback Reference~oidCallback Callback executed on oid retrieval. - * @param {GitError|null} error An Error or null if successful. - * @param {Oid|null} oid Retrieved Oid object or null. - */ - this.rawReference.oid(function referenceOid(error, rawOid) { - if (success(error, callback)) { - callback(null, new git.oid(rawOid)); - } - }); +Reference.prototype.target = function() { + if (!this.isConcrete()) throw this.name() + " is symbolic"; + + return oldTarget.call(this); }; -exports.reference = Reference; +/** + * Returns the name of the reference. + * @return {String} + */ +Reference.prototype.toString = function() { + return this.name(); +} \ No newline at end of file diff --git a/lib/repo.js b/lib/repo.js index 343af1dd4..199d95fff 100644 --- a/lib/repo.js +++ b/lib/repo.js @@ -1,132 +1,220 @@ var git = require('../'), - success = require('./utilities').success; + util = require('./util.js'), + Repo = git.Repo, + Tree = git.Tree, + TreeBuilder = git.TreeBuilder, + Reference = git.Reference; + +var oldGetReference = Repo.prototype.getReference, + oldGetCommit = Repo.prototype.getCommit, + oldBlob = Repo.prototype.getBlob, + oldGetTree = Repo.prototype.getTree, + oldGetTag = Repo.prototype.getTag, + oldCreateRevWalk = Repo.prototype.createRevWalk, + oldCreateCommit = Repo.prototype.createCommit, + oldCreateBlobFromBuffer = Repo.prototype.createBlobFromBuffer; /** - * Convenience repository class. + * Look up a branch's most recent commit. * - * @constructor + * @param {String} name Branch name, e.g. 'master' + * @param {Function} callback + * @return {Branch} */ -var Repo = function() { - this.rawRepo = new git.raw.Repo(); +Repo.prototype.getBranch = function(name, callback) { + var self = this; + this.getReference('refs/heads/' + name, function referenceLookupCallback(error, reference) { + if (error) return callback(error); + + self.getCommit(reference.target(), function commitLookupCallback(error, commit) { + if (error) return callback(error); + + callback(null, commit); + }); + }); }; +util.makeSafe(Repo.prototype, 'getBranch'); /** - * Open the git repository at directory. - * - * @example - * git.repo('/path/to/repository/.git', function(error, repo) { }); + * Lookup the reference with the given name. * - * @param {String} directory The .git directory for the repository to open. - * @param {Repo~openCallback} callback + * @param {String} name + * @param {Function} callback + * @return {Reference} */ -Repo.prototype.open = function(directory, callback) { - /** - * @callback Repo~openCallback Callback executed when repository is opened. - * @param {GitError|null} error An Error or null if successful. - * @param {Repo|null} repo Opened repository. - */ - if (typeof callback !== 'function') { - throw new git.error('Callback is required and must be a Function'); - } +Repo.prototype.getReference = function(name, callback) { var self = this; - self.rawRepo.open(directory, function openRepository(error, rawRepo) { - if (success(error, callback)) { - self.rawRepo = rawRepo; - callback(null, self); + oldGetReference.call(this, name, function(error, reference) { + if (error) return callback(error); + + if (reference.type() == Reference.Type.Symbolic) { + reference.resolve(function (error, reference) { + if (error) return callback(error); + reference.repo = self; + callback(null, reference); + }); + } else { + reference.repo = self; + callback(null, reference); } }); }; +util.makeSafe(Repo.prototype, 'getReference'); /** - * Look up a branch's most recent commit. + * Retrieve the commit identified by oid. * - * @param {String} name Branch name, e.g. 'master' - * @param {Repo~branchCallback} callback + * @param {String|Oid} String sha or Oid + * @param {Function} callback + * @return {Commit} */ -Repo.prototype.branch = function(name, callback) { - /** - * @callback Repo~branchCallback Callback executed when the branch is checked out. - * @param {GitError|null} error An Error or null if successful. - * @param {Commit|null} repo HEAD commit for the branch. - */ +Repo.prototype.getCommit = function(oid, callback) { var self = this; - (new git.reference(self.rawRepo)).lookup('refs/heads/' + name, function referenceLookupCallback(error, reference) { - if (!success(error, callback)) { - return; - } - reference.oid(function oidCallback(error, oid) { - if (!success(error, callback)) { - return; - } - self.commit(oid, function commitLookupCallback(error, commit) { - if (!success(error, callback)) { - return; - } - callback(null, commit); - }); - }); + oldGetCommit.call(this, oid, function(error, commit) { + if (error) return callback(error); + commit.repo = self; + callback(null, commit); }); }; +util.normalizeOid(Repo.prototype, 'getCommit'); +util.makeSafe(Repo.prototype, 'getCommit'); /** - * Retrieve the commit identified by oid. + * Retrieve the blob represented by the oid. * - * @param {String|Oid|git.raw.Oid} sha - * @param {Repo~commitCallback} callback + * @param {String|Oid} String sha or Oid + * @param {Function} callback + * @return {Blob} */ -Repo.prototype.commit = function(sha, callback) { - /** - * @callback Repo~commitCallback Callback executed when the commit is looked up. - * @param {GitError|null} error An Error or null if successful. - * @param {Commit|null} commit Commit represented by sha. - */ - (new git.commit(this.rawRepo)).lookup(sha, function(error, commit) { - if (success(error, callback)) { - callback(null, commit); - } +Repo.prototype.getBlob = function(oid, callback) { + var self = this; + oldBlob.call(this, oid, function(error, blob) { + if (error) return callback(error); + blob.repo = self; + callback(null, blob); }); }; +util.normalizeOid(Repo.prototype, 'getBlob'); +util.makeSafe(Repo.prototype, 'getBlob'); /** - * Initialise a git repository at directory. + * Retrieve the tree represented by the oid. * - * @param {String} directory - * @param {Boolean} isBare True if the repository is to be bare, false otherwise. - * @param {Repo~initCallback} callback + * @param {String|Oid} String sha or Oid + * @param {Function} callback + * @return {Tree} */ -Repo.prototype.init = function(directory, isBare, callback) { - /** - * @callback Repo~initCallback Callback executed when repository is initialized. - * @param {GitError|null} error An Error or null if successful. - * @param {Repo|null} repo Initialized repository. - */ +Repo.prototype.getTree = function(oid, callback) { var self = this; - self.rawRepo.init(directory, isBare, function(error, rawRepo) { - if (success(error, callback)) { - self.rawRepo = rawRepo; - callback(null, self); - } + oldGetTree.call(this, oid, function(error, tree) { + if (error) return callback(error); + tree.repo = self; + callback(null, tree); }); }; +util.normalizeOid(Repo.prototype, 'getTree'); +util.makeSafe(Repo.prototype, 'getTree'); + +/** + * Retrieve the tag represented by the oid. + * + * @param {String|Oid} String sha or Oid + * @param {Function} callback + * @return {Tag} + */ +Repo.prototype.getTag = function(oid, callback) { + var self = this; + oldGetTag.call(this, oid, callback); +}; +util.normalizeOid(Repo.prototype, 'getTag'); +util.makeSafe(Repo.prototype, 'getTag'); /** - * Create a new Repo object. If directory is not provided, simply return it. - * Otherwise open the repo asynchronously. + * Instantiate a new revision walker for browsing the Repo's history. + * See also `Commit.prototype.history()` * - * @param {String|null} directory The directory for the git repo to open. Null - * if one does not want to open a repo. - * @param {repoCallback|null} callback - * @return {Repo|null} The Repo if no directory is provided, else undefined. + * @param {String|Oid} String sha or Oid + * @param {Function} callback + * @return {RevWalk} */ -exports.repo = function(directory, callback) { - /** - * @callback repoCallback Callback executed if repository is opened. - * @param {GitError|null} error An Error or null if successful. - * @param {Repo|null} repo Opened repository. - */ - var repo = new Repo(); - if (typeof directory === 'undefined') { - return repo; +Repo.prototype.createRevWalk = function() { + var revWalk = oldCreateRevWalk.call(this); + revWalk.repo = this; + return revWalk; +}; + +/** + * Retrieve the master branch. + * + * @param {Function} callback + * @return {Branch} + */ +Repo.prototype.getMaster = function(callback) { + this.getBranch('master', callback); +}; + +/** + * Create a commit + * + * @param {String} updateRef + * @param {Signature} author + * @param {Signature} commiter + * @param {String} message + * @param {Tree|Oid|String} Tree + * @param {Array} parents + * @param {Function} callback + * @return {Oid} The oid of the commit + */ +Repo.prototype.createCommit = function(updateRef, author, committer, message, tree, parents, callback) { + if (tree instanceof Tree) { + oldCreateCommit.call( + this, + updateRef, + author, + committer, + null /* use default message encoding */, + message, + tree, + parents.length, parents, + callback); + } else { + var self = this; + this.getTree(tree, function(error, tree) { + if (error) return callback(error); + oldCreateCommit.call( + self, + updateRef, + author, + committer, + null /* use default message encoding */, + message, + tree, + parents.length, parents, + callback); + }); } - repo.open(directory, callback); }; + +/** + * Create a blob from a buffer + * + * @param {Buffer} buffer + * @param {Function} callback + * @return {Blob} + */ +Repo.prototype.createBlobFromBuffer = function(buffer, callback) { + oldCreateBlobFromBuffer.call(this, buffer, buffer.length, callback); +}; + +/** + * Create a new tree builder. + * + * @param {Tree} tree + * @param {Function} callback + */ +Repo.prototype.treeBuilder = function(callback) { + var builder = TreeBuilder.create(null); + builder.root = builder; + builder.repo = this; + return builder; +}; \ No newline at end of file diff --git a/lib/revwalk.js b/lib/revwalk.js index 30fc2b4b4..bd48b7481 100644 --- a/lib/revwalk.js +++ b/lib/revwalk.js @@ -1,84 +1,53 @@ var git = require('../'), - success = require('./utilities').success; + RevWalk = git.RevWalk; + +var oldSorting = RevWalk.prototype.sorting; /** - * Convenience revision walking class - * - * @constructor - * @param {git.raw.Repo} rawRepo - * @param {git.raw.RevWalk|null} rawRevWalk + * Refer to vendor/libgit2/include/git2/revwalk.h for sort definitions. */ -var RevWalk = function(rawRepo, rawRevWalk) { - if (!(rawRepo instanceof git.raw.Repo)) { - throw new git.error('First parameter for RevWalk must be a raw repo'); - } - this.rawRepo = rawRepo; - - if (typeof rawRevWalk !== 'undefined' && - rawRevWalk instanceof git.raw.RevWalk) { - this.rawRevWalk = rawRevWalk; - } else { - this.rawRevWalk = new git.raw.RevWalk(rawRepo); - } +RevWalk.Sort = { + None: 0, + Topological: 1, + Time: 2, + Reverse: 4 }; /** - * Allocate new revwalker. + * Set the sort order for the revwalk. This function takes variable arguments + * like `revwalk.sorting(git.RevWalk.Topological, git.RevWalk.Reverse).` * - * @param {Function} callback + * @param {Number} sort */ -RevWalk.prototype.allocate = function(callback) { - var self = this; - self.rawRevWalk.allocate(function revwalkAllocate(error, rawRevwalk) { - if (success(error, callback)) { - self.rawRevwalk = rawRevwalk; - callback(null, self); - } - }); +RevWalk.prototype.sorting = function() { + var sort = 0; + for (var i = 0; i < arguments.length; i++) + sort |= arguments[i]; + oldSorting.call(this, sort); }; /** - * Walk the history from the given oid. + * Walk the history from the given oid. The callback is invoked for each commit; + * When the walk is over, the callback is invoked with `(null, null)`. * * @param {Oid} oid - * @param {Function} callback Callback accepting the following arguments: - * error, index, commit, noMoreCommits + * @param {Function} callback + * @return {Commit} */ RevWalk.prototype.walk = function(oid, callback) { var self = this; - self.rawRevWalk.push(oid.getRawOid(), function revWalkPush(error) { - if (!success(error, callback)) { - return; - } - - var shouldContinue = true, index = 0; + this.push(oid, function revWalkPush(error) { + if (error) return callback(error); function walk() { - if(!shouldContinue) { - return; - } - - self.rawRevWalk.next(function revWalkNext(error, oid, walkOver) { - if(error) { - callback(new git.error(error.message, error.code), index, commit); - return; - } + self.next(function revWalkNext(error, oid) { + if (error) return callback(error); + if (!oid) return callback(); - // Finished walking history, apply callback with noMoreCommits = true - if (walkOver) { - callback(null, index, null, walkOver); - return; - } + self.repo.getCommit(oid, function revWalkCommitLookup(error, commit) { + if (error) return callback(error); - (new git.commit(self.rawRepo)).lookup(oid, function revWalkCommitLookup(error, commit) { - if(error) { - callback(new git.error(error.message, error.code), index, commit); - return; - } - if(callback(null, index, commit) === false) { - shouldContinue = false; - } - index++; + callback(null, commit); walk(); }); }); @@ -86,5 +55,3 @@ RevWalk.prototype.walk = function(oid, callback) { walk(); }); }; - -exports.revwalk = RevWalk; diff --git a/lib/signature.js b/lib/signature.js index c33f91b13..652793a07 100644 --- a/lib/signature.js +++ b/lib/signature.js @@ -1,23 +1,10 @@ -var git = require('../'); +var git = require('../'), + Signature = git.Signature; -var Signature = function(rawSignature) { - if (rawSignature instanceof git.raw.Signature) { - this.rawSignature = rawSignature; - } else { - this.rawSignature = new git.raw.Signature(); - } +/** + * Standard string representation of an author. + * @return {String} + */ +Signature.prototype.toString = function() { + return this.name().toString() + " <" + this.email().toString() + ">"; }; - -Signature.prototype.name = function(callback) { - callback(null, this.rawSignature.name()); -}; - -Signature.prototype.email = function(callback) { - callback(null, this.rawSignature.email()); -}; - -Signature.prototype.duplicate = function(callback) { - callback(null, new Signature(git.rawSignature.duplicate())); -}; - -exports.signature = Signature; diff --git a/lib/threads.js b/lib/threads.js deleted file mode 100644 index ae9f31efe..000000000 --- a/lib/threads.js +++ /dev/null @@ -1,36 +0,0 @@ -var git = require('../'); - -var _Blob = function(obj) { - var self = {}; - - if( obj instanceof git.raw.Repo ) { - self.repo = obj; - self.blob = new git.raw.Blob( obj ); - } - else if( obj instanceof git.raw.Blob ) { - self.blob = obj; - } - - Object.defineProperty( self, 'raw', { - get: function() { - return self.blob.rawContent().toString(); - }, - enumerable: true - }); - - self.lookup = function( oid ) { - self.blob.lookup( self.repo, oid, function() { - var args = Array.prototype.slice.call( arguments ); - args[0] = git.util().error( args[0] ); - - callback.apply( self, args.concat( self ) ); - }); - }; - - return self; -}; - -exports.blob = _Blob; - - -exports = _Threads; diff --git a/lib/tree.js b/lib/tree.js index d56d11eff..eada1462f 100644 --- a/lib/tree.js +++ b/lib/tree.js @@ -1,70 +1,81 @@ var git = require('../'), - success = require('./utilities').success, - events = require('events'); + Tree = git.Tree, + events = require('events'), + path = require('path'); + +var oldEntryByIndex = Tree.prototype.entryByIndex, + oldEntryByName = Tree.prototype.entryByName, + oldGetEntry = Tree.prototype.getEntry; /** - * Tree convenience class constructor. - * - * @constructor - * @param {git.raw.Repo} rawRepo Raw repository object. - * @param {git.raw.Tree} [rawTree = new git.raw.Tree(rawRepo)] Raw tree object. + * Diff two trees + * @param {Tree} tree to diff against + * @param {Function} callback + * @return {DiffList} */ -var Tree = function(rawRepo, rawTree) { - if(!(rawRepo instanceof git.raw.Repo)) { - throw new git.error('First parameter for Tree must be a raw repo'); - } - this.rawRepo = rawRepo; +Tree.prototype.diff = function(that, callback) { + this.diffTree(this.repo, that, null, callback); +}; - if(rawTree instanceof git.raw.Tree) { - this.rawTree = rawTree; - } else { - this.rawTree = new git.raw.Tree(rawRepo); - } +/** + * Get an entry at the ith position. + * + * @param {Number} i + * @return {TreeEntry} + */ +Tree.prototype.entryByIndex = function(i) { + var entry = oldEntryByIndex.call(this, i); + entry.parent = this; + return entry; }; /** - * Retrieve the raw tree identified by the given Oid. + * Get an entry by name; if the tree is a directory, the name is the filename. * - * @param {Oid} oid The Oid identifying a tree. - * @param {Tree~lookupCallback} callback + * @param {String} name + * @return {TreeEntry} */ -Tree.prototype.lookup = function(oid, callback) { - /** - * @callback Tree~lookupCallback Callback executed when the tree is retrieved. - * @param {GitError|null} error An Error or null if successful. - * @param {Tree|null} tree The tree object or null. - */ - var self = this; - self.rawTree.lookup(oid.getRawOid(), self.rawRepo, function(error, rawTree) { - if (success(error, callback)) { - self.rawTree = rawTree; - callback(null, self); - } - }); +Tree.prototype.entryByName = function(name) { + var entry = oldEntryByName.call(this, name); + entry.parent = this; + return entry; }; /** - * Retrieve the entry by path. + * Get an entry at a path. Unlike by name, this takes a fully + * qualified path, like `/foo/bar/baz.javascript` * - * @param {String} path Path to the tree entry, relative to repository root. - * @param {Tree~entryCallback} callback + * @param {String} path + * @return {TreeEntry} */ -Tree.prototype.entry = function(path, callback) { - /** - * @callback Tree~entryCallback Callback executed when an entry is retrieved. - * @param {GitError|null} error An Error or null if successful. - * @param {Entry|null} entry The tree entry object or null. - */ +Tree.prototype.getEntry = function(path, callback) { + // FIXME: this method ought to implement the recursion directly, rather than + // rely on oldGetEntry, in order to ensure that `parent` pointers are direct. var self = this; - self.rawTree.entryByPath(path, function(error, rawEntry) { - if (success(error, callback)) { - callback(null, new git.entry(self.rawRepo, rawEntry)); - } + oldGetEntry.call(this, path, function(error, entry) { + if (error) return callback(error); + + entry.parent = self; + entry.path = function() { return path }; + callback(null, entry); }); }; /** - * Walk the tree. + * Return an array of the entries in this tree (excluding its children). + * @return {[TreeEntry]} an array of TreeEntrys + */ +Tree.prototype.entries = function() { + var size = this.size(), + result = []; + for (var i = 0; i < size; i++) { + result.push(this.entryByIndex(i)); + } + return result; +}; + +/** + * Recursively walk the tree in breadth-first order. Fires an event for each entry. * * @fires Tree#entry * @fires Tree#end @@ -74,41 +85,59 @@ Tree.prototype.entry = function(path, callback) { * @return {EventEmitter} */ Tree.prototype.walk = function(blobsOnly) { - blobsOnly = typeof blobsOnly === 'undefined' ? true : blobsOnly; + if (typeof blobsOnly == 'undefined') blobsOnly = true; var self = this, event = new events.EventEmitter(), - entries = []; - - var total = 0; - - self.rawTree.walk(blobsOnly, function treeWalkEntries(error, rawEntries) { - rawEntries.forEach(function treeWalkEntryEmitter(rawEntry) { - var entry = new git.entry(self.rawRepo, rawEntry); - entries.push(entry); - /** - * Entry event. - * - * @event Tree#entry - * - * @param {GitError|null} error An error object if there was an issue, null otherwise. - * @param {Entry} entry The tree entry. - */ - event.emit('entry', null, entry); + entries = [], + errors = []; + + var total = 1; + + // This looks like a DFS, but it is a BFS because of implicit queueing in + // the recursive call to `entry.getTree(bfs)` + function bfs(error, tree) { + total--; + if (error) return errors.push(error); + + tree.entries().forEach(function (entry) { + if (!blobsOnly || entry.isFile()) { + event.emit('entry', entry); + entries.push(entry); + } + + if (entry.isTree()) { + total++; + entry.getTree(bfs); + } }); - }, function treeWalkEnd(error) { - /** - * End event. - * - * @event Tree#end - * - * @param {GitError|null} error An error object if there was an issue, null otherwise. - * @param {Entry[]} entries The tree entries. - */ - event.emit('end', error ? new git.error(error.message, error.code) : null, entries); - }); + if (total === 0) + event.emit('end', errors.length ? errors : null, entries); + } + + event.start = function() { + bfs(null, self); + }; return event; }; -exports.tree = Tree; +/** + * Return the path of this tree, like `/lib/foo/bar` + * @return {String} + */ +Tree.prototype.path = function(blobsOnly) { + return this.entry ? this.entry.path() : ''; +}; + +/** + * Make builder. This is helpful for modifying trees. + * @return {TreeBuilder} + */ +var oldBuilder = Tree.prototype.builder; +Tree.prototype.builder = function() { + var builder = oldBuilder.call(this); + builder.root = builder; + builder.repo = this.repo; + return builder; +}; diff --git a/lib/tree_builder.js b/lib/tree_builder.js new file mode 100644 index 000000000..c3570c14c --- /dev/null +++ b/lib/tree_builder.js @@ -0,0 +1,144 @@ +var git = require('../'), + TreeBuilder = git.TreeBuilder, + TreeEntry = git.TreeEntry, + path = require('path'); + +var oldInsert = TreeBuilder.prototype.insert; + +/** + * Insert an object into this tree by oid + * + * @param {String} filename + * @param {Oid} oid + * @param {Number} filemode + */ +TreeBuilder.prototype.insert = function(filename, oid, filemode) { + if (!this.insertions) this.insertions = []; + + this.insertions.push([filename, oid, filemode]); +}; + +/** + * Insert a blob into this tree + * + * @param {String} filename + * @param {Blob} blob + * @param {Boolean} isExecutable + */ +TreeBuilder.prototype.insertBlob = function(filename, blob, isExecutable) { + if (!this.blobs) this.blobs = []; + + this.blobs.push([filename, blob, isExecutable ? TreeEntry.FileMode.Executable : TreeEntry.FileMode.Blob]); +}; + +var oldWrite = TreeBuilder.prototype.write; + +/** + * Write this tree to the repo. + * + * @param {Function} callback + */ +TreeBuilder.prototype.write = function(callback) { + var self = this; + this.doInsertions(function(error) { + if (error) return callback(error); + + if (self.builders && self.builders.length) { + writeNextLevel(self.repo, self.builders, function(error, previousName, previousTreeId) { + if (previousName && previousTreeId) { + oldInsert.call(self, previousName, previousTreeId, TreeEntry.FileMode.Tree); + } + oldWrite.call(self, self.repo, callback); + }); + } else { + oldWrite.call(self, self.repo, callback); + } + }) +}; + +TreeBuilder.prototype.doInsertions = function(callback) { + var self = this; + + this.createBlobs(function(error) { + if (error) return callback(error); + + self.doOidInsertions(callback); + }) +}; + +TreeBuilder.prototype.createBlobs = function(callback) { + if (!this.blobs || !this.blobs.length) return callback(); + + var self = this, + data = this.blobs.pop(), + path = data[0], buffer = data[1], filemode = data[2]; + + this.repo.createBlobFromBuffer(buffer, function(error, blobId) { + if (error) return callback(error); + + self.insert(path, blobId, filemode); + self.createBlobs(callback); + }); +} + +TreeBuilder.prototype.doOidInsertions = function(callback) { + if (!this.insertions || !this.insertions.length) return callback(); + + var self = this, + data = this.insertions.pop(), + filename = data[0], oid = data[1], filemode = data[2], + parts = filename.split(path.sep), + pathParts = parts.slice(0, parts.length - 1), + filename = parts[parts.length - 1]; + + insertOneLevel(this, pathParts, function(error, builder) { + if (error) return callback(error); + oldInsert.call(builder, filename, oid, filemode); + self.doOidInsertions(callback); + }); +}; + +function writeNextLevel(repo, builders, callback, previousName, previousTreeId) { + var builder = builders.pop(); + if (!builder) return callback(null, previousName, previousTreeId); + + if (previousName && previousTreeId) { + oldInsert.call(builder, previousName, previousTreeId, TreeEntry.FileMode.Tree); + } + oldWrite.call(builder, repo, function(error, previousTreeId) { + if (error) return callback(error); + + previousName = builder.name; + writeNextLevel(repo, builders, callback, previousName, previousTreeId); + }); +} + +function insertOneLevel(builder, parts, callback) { + if (!parts.length) return callback(null, builder); + + var part = parts[0], rest = parts.slice(1, parts.length); + if (!part) return insertOneLevel(builder, rest, callback); + + if (!builder.root.builders) builder.root.builders = []; + var entry = builder.get(part); + if (entry) { + if (!entry.isTree()) return callback("Invalid path part " + part); + entry.parent = builder; + + entry.getTree(function(error, tree) { + if (error) return callback(error); + + var next = tree.builder(); + next.name = part; + next.root = builder.root; + builder.root.builders.push(next); + insertOneLevel(next, rest, callback); + }); + } else { + var next = TreeBuilder.create(); + next.name = part; + next.root = builder.root; + builder.root.builders.push(next); + insertOneLevel(next, rest, callback); + } +} \ No newline at end of file diff --git a/lib/tree_entry.js b/lib/tree_entry.js index a78de137b..02f29b315 100644 --- a/lib/tree_entry.js +++ b/lib/tree_entry.js @@ -1,36 +1,6 @@ var git = require('../'), - path = require('path'), - success = require('./utilities').success; - -var fileModeIsFile = function(fileMode, instance) { - return fileMode === instance.fileModes.GIT_FILEMODE_BLOB || - fileMode === instance.fileModes.GIT_FILEMODE_BLOB_EXECUTABLE; -}; - -var fileModeIsDirectory = function(fileMode, instance) { - return fileMode === instance.fileModes.GIT_FILEMODE_TREE; -}; - -/** - * Convenience tree entry constructor. - * - * @constructor - * @param {git.raw.Repo} rawRepo Raw repository object. - * @param {git.raw.TreeEntry} rawTreeEntry Raw tree entry object. - */ -var TreeEntry = function(rawRepo, rawTreeEntry) { - if(!(rawRepo instanceof git.raw.Repo)) { - throw new git.error('First parameter for Tree Entry must be a raw repo', 0); - } - - if(!(rawTreeEntry instanceof git.raw.TreeEntry)) { - throw new git.error('Second parameter for Tree Entry must be a raw tree entry', 0); - } - - this.rawRepo = rawRepo; - this.rawEntry = rawTreeEntry; - this._cache = {}; -}; + TreeEntry = git.TreeEntry, + path = require('path'); /** * Refer to vendor/libgit2/include/git2/types.h for filemode definitions. @@ -38,229 +8,85 @@ var TreeEntry = function(rawRepo, rawTreeEntry) { * @readonly * @enum {Integer} */ -TreeEntry.prototype.fileModes = { - /** 0 (0000000) */ GIT_FILEMODE_NEW: git.raw.TreeEntry.fileModes.GIT_FILEMODE_NEW, - /** 16384 (0040000) */ GIT_FILEMODE_TREE: git.raw.TreeEntry.fileModes.GIT_FILEMODE_TREE, - /** 33188 (0100644) */ GIT_FILEMODE_BLOB: git.raw.TreeEntry.fileModes.GIT_FILEMODE_BLOB, - /** 33261 (0100755) */ GIT_FILEMODE_BLOB_EXECUTABLE: git.raw.TreeEntry.fileModes.GIT_FILEMODE_BLOB_EXECUTABLE, - /** 40960 (0120000) */ GIT_FILEMODE_LINK: git.raw.TreeEntry.fileModes.GIT_FILEMODE_LINK, - /** 57344 (0160000) */ GIT_FILEMODE_COMMIT: git.raw.TreeEntry.fileModes.GIT_FILEMODE_COMMIT +TreeEntry.FileMode = { + /** 0000000 */ New: 0, + /** 0040000 */ Tree: 16384, + /** 0100644 */ Blob: 33188, + /** 0100755 */ Executable: 33261, + /** 0120000 */ Link: 40960, + /** 0160000 */ Commit: 57344 }; /** - * Retrieve the Oid for this TreeEntry. - * - * @param {TreeEntry~oidCallback} callback + * Is this TreeEntry a blob? (i.e., a file) + * @return {Boolean} */ -TreeEntry.prototype.oid = function(callback) { - /** - * @callback TreeEntry~oidCallback Callback executed after the Oid is retrieved. - * @param {GitError|null} error An Error or null if successful. - * @param {TreeEntry|null} oid The Oid object or null. - */ - this.rawEntry.oid(function(error, rawOid) { - if (success(error, callback)) { - callback(null, new git.oid(rawOid)); - } - }); +TreeEntry.prototype.isFile = function() { + return this.filemode() === TreeEntry.FileMode.Blob || + this.filemode() === TreeEntry.FileMode.Executable; }; /** - * Retrieve the SHA for this TreeEntry. - * - * @param {TreeEntry~shaCallback} callback + * Is this TreeEntry a tree? (i.e., a directory) + * @return {Boolean} */ -TreeEntry.prototype.sha = function(callback) { - /** - * @callback TreeEntry~shaCallback Callback executed after the SHA is retrieved. - * @param {GitError|null} error An Error or null if successful. - * @param {String|null} sha The SHA object or null. - */ - this.rawEntry.oid(function(error, oid) { - if (!success(error, callback)) { - return; - } - (new git.oid(oid)).sha(function(error, sha) { - if (success(error, callback)) { - callback(null, sha); - } - }); - }); -}; - -/** - * Determine whether this TreeEntry is a file (blob or blob executable). - * - * @param {TreeEntry~isFileCallback} callback - */ -TreeEntry.prototype.isFile = function(callback) { - /** - * @callback TreeEntry~isFileCallback Callback executed after type is determined. - * @param {GitError|null} error An Error or null if successful. - * @param {Boolean|null} content True if the entry is a blob or blob executable, false otherwise. - */ - var self = this; - if (typeof self._cache.fileMode !== 'undefined') { - callback(null, fileModeIsFile(self._cache.fileMode, self)); - return; - } - self.rawEntry.fileMode(function(error, fileMode) { - if (success(error, callback)) { - self._cache.fileMode = fileMode; - callback(null, fileModeIsFile(self._cache.fileMode, self)); - } - }); +TreeEntry.prototype.isTree = function() { + return this.filemode() === TreeEntry.FileMode.Tree; }; /** - * Determine whether this Tree Entry is a directory. - * - * @param {TreeEntry~isDirectoryCallback} callback + * Is this TreeEntry a directory? Alias for `isTree` + * @return {Boolean} */ -TreeEntry.prototype.isDirectory = function(callback) { - /** - * @callback TreeEntry~isDirectoryCallback Callback executed after type is determined. - * @param {GitError|null} error An Error or null if successful. - * @param {Boolean|null} content True if the entry is a directory, false otherwise. - */ - var self = this; - if (typeof self._cache.fileMode !== 'undefined') { - callback(null, fileModeIsDirectory(self._cache.fileMode, self)); - return; - } - self.rawEntry.fileMode(function(error, fileMode) { - if (success(error, callback)) { - self._cache.fileMode = fileMode; - callback(null, fileModeIsDirectory(self._cache.fileMode, self)); - } - }); -}; +TreeEntry.prototype.isDirectory = TreeEntry.prototype.isTree; /** - * Retrieve the name for this TreeEntry. - * - * @param {TreeEntry~nameCallback} callback + * Is this TreeEntry a blob? Alias for `isFile` + * @return {Boolean} */ -TreeEntry.prototype.name = function(callback) { - /** - * @callback TreeEntry~nameCallback Callback executed after name is retrieved. - * @param {GitError|null} error An Error or null if successful. - * @param {String|null} name the entry's name. - */ - this.rawEntry.name(function treeEntryName(error, name) { - if (success(error, callback)) { - callback(null, name); - } - }); -}; +TreeEntry.prototype.isBlob = TreeEntry.prototype.isFile; /** - * Retrieve the entry's root path. - * - * @param {TreeEntry~rootCallback} callback + * Retrieve the SHA for this TreeEntry. + * @return {String} */ -TreeEntry.prototype.root = function(callback) { - /** - * @callback TreeEntry~rootCallback Callback executed after root path is retrieved. - * @param {GitError|null} error An Error or null if successful. - * @param {String|null} root the entry's root path, relative to repository. - */ - this.rawEntry.root(function treeEntryRoot(error, root) { - if (success(error, callback)) { - callback(null, root); - } - }); +TreeEntry.prototype.sha = function() { + return this.oid().sha(); }; /** - * Retrieve the path relative to the repository root for this TreeEntry. - * - * @param {TreeEntry~pathCallback} callback + * Retrieve the tree for this entry. Make sure to call `isTree` first! + * @return {Tree} */ -TreeEntry.prototype.path = function(callback) { - /** - * @callback TreeEntry~pathCallback Callback executed after path is retrieved. - * @param {GitError|null} error An Error or null if successful. - * @param {String|null} path the entry's full path relative to repository. - */ +TreeEntry.prototype.getTree = function(callback) { var self = this; - self.root(function treeEntryRoot(error, root) { - if (!success(error, callback)) { - return; - } - self.rawEntry.name(function treeEntryName(error, name) { - if (success(error, callback)) { - callback(null, path.join(root, name)); - } - }); + this.parent.repo.getTree(this.oid(), function(error, tree) { + if (error) return callback(error); + + tree.entry = self; + callback(null, tree); }); }; /** - * Retrieve the TreeEntry's content. - * - * @param {TreeEntry~contentCallback} callback + * Retrieve the tree for this entry. Make sure to call `isTree` first! + * @return {Blob} */ -TreeEntry.prototype.content = function(callback) { - /** - * @callback TreeEntry~contentCallback Callback executed after content is retrieved. - * @param {GitError|null} error An Error or null if successful. - * @param {String|null} content the entry's content. - */ - this.toBlob(function convertBlob(error, blob) { - if (!success(error, callback)) { - return; - } - blob.content(function blobContent(error, content) { - if (success(error, callback)) { - callback(null, content); - } - }); - }); +TreeEntry.prototype.getBlob = function(callback) { + this.parent.repo.getBlob(this.oid(), callback); }; /** - * Convert the TreeEntry to a blob. - * - * @param {TreeEntry~blobCallback} callback + * Returns the path for this entry. + * @return {String} */ -TreeEntry.prototype.toBlob = function(callback) { - /** - * @callback TreeEntry~blobCallback Callback executed after blob is retrieved. - * @param {GitError|null} error An Error or null if successful. - * @param {Blob|null} blob the blob representation of the entry. - */ - var self = this; - self.rawEntry.toBlob(self.rawRepo, function blobCallback(error, rawBlob) { - if (success(error, callback)) { - callback(null, new git.blob(self.rawRepo, rawBlob)); - } - }); +TreeEntry.prototype.path = function(callback) { + return path.join(this.parent.path(), this.name()); }; /** - * Retrieve the TreeEntry's Tree. - * - * @param {TreeEntry~treeCallback} callback + * Alias for `path` */ -TreeEntry.prototype.tree = function(callback) { - /** - * @callback TreeEntry~treeCallback Callback executed after tree is retrieved. - * @param {GitError|null} error An Error or null if successful. - * @param {Tree|null} tree the entry's tree. - */ - var self = this; - self.oid(function treeEntryOid(error, oid) { - if (!success(error, callback)) { - return; - } - (new git.tree(self.rawRepo)).lookup(oid, function(error, tree) { - if (!success(error, callback)) { - return; - } - callback(null, tree); - }); - }); +TreeEntry.prototype.toString = function() { + return this.path(); }; - -exports.entry = TreeEntry; diff --git a/lib/util.js b/lib/util.js new file mode 100644 index 000000000..096a34291 --- /dev/null +++ b/lib/util.js @@ -0,0 +1,25 @@ +var git = require('../'); + +exports.makeSafe = function(object, key) { + var oldFn = object[key]; + object[key] = function() { + try { + oldFn.apply(this, arguments); + } catch (e) { + var callback = arguments[arguments.length - 1]; + callback(e); + } + }; +}; + +exports.normalizeOid = function(object, key) { + var oldFn = object[key]; + object[key] = function() { + var oid = arguments[0]; + if (typeof oid === 'string') oid = git.Oid.fromString(oid); + var newArguments = [oid]; + for (var i = 1; i < arguments.length; i++) + newArguments[i] = arguments[i]; + oldFn.apply(this, newArguments); + }; +}; diff --git a/lib/utilities.js b/lib/utilities.js deleted file mode 100755 index f7d62b3c0..000000000 --- a/lib/utilities.js +++ /dev/null @@ -1,31 +0,0 @@ -var git = require('../'); - -/** - * @namespace - */ -var utilities = { - /** - * Check if error is null, if it is not, convert it to a GitError and call - * the callback. - * - * @param {Object} error - * @param {Function} callback - * - * @return {Boolean} True if the error was null, false otherwise. - */ - success: function(error, callback) { - if (typeof callback !== 'function') { - throw new Error('Callback must be provided'); - } - if (error) { - if (error instanceof git.error) { - callback(error); - } else { - callback(new git.error(error.message, error.code)); - } - return false; - } - return true; - } -}; -exports.success = utilities.success; diff --git a/package.json b/package.json index 314dd6df0..ecdcec807 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "nodegit", "description": "Node.js libgit2 asynchronous native bindings", - "version": "0.0.79", + "version": "0.1.0", "homepage": "https://github.com/tbranyen/nodegit", "keywords": [ "libgit2", @@ -9,7 +9,7 @@ "git", "native" ], - "license": "GPLv2", + "license": "MIT", "author": "Tim Branyen (http://twitter.com/tbranyen)", "contributors": [ { @@ -17,7 +17,7 @@ "email": "mike@pagesofinterest.net" } ], - "main": "./lib/index.js", + "main": "index.js", "repository": { "type": "git", "url": "git://github.com/tbranyen/nodegit.git" @@ -38,10 +38,12 @@ }, "devDependencies": { "nodeunit": "", - "rimraf": "1.0.x" + "rimraf": "1.0.x", + "ejs": "0.8.x" }, "scripts": { "install": "node install.js", - "test": "cd test && nodeunit *.js" + "test": "cd test && nodeunit *.js", + "gen": "node gen.js" } } diff --git a/src/base.cc b/src/base.cc index 725303bec..bd6db11b5 100755 --- a/src/base.cc +++ b/src/base.cc @@ -10,36 +10,75 @@ #include "git2.h" +#include "../include/wrapper.h" #include "../include/reference.h" #include "../include/signature.h" -#include "../include/error.h" +#include "../include/time.h" #include "../include/blob.h" #include "../include/repo.h" #include "../include/oid.h" +#include "../include/object.h" #include "../include/commit.h" #include "../include/revwalk.h" #include "../include/tree.h" #include "../include/tree_entry.h" +#include "../include/diff_find_options.h" +#include "../include/diff_options.h" #include "../include/diff_list.h" +#include "../include/diff_range.h" +#include "../include/diff_file.h" +#include "../include/patch.h" +#include "../include/delta.h" #include "../include/threads.h" +#include "../include/index.h" +#include "../include/index_entry.h" +#include "../include/index_time.h" +#include "../include/tag.h" +#include "../include/refdb.h" +#include "../include/odb_object.h" +#include "../include/odb.h" +#include "../include/submodule.h" +#include "../include/tree_builder.h" +#include "../include/remote.h" +#include "../include/clone_options.h" extern "C" void init(Handle target) { HandleScope scope; - GitError::Initialize(target); + Wrapper::Initialize(target); GitReference::Initialize(target); + GitIndex::Initialize(target); + GitIndexEntry::Initialize(target); + GitIndexTime::Initialize(target); + GitTag::Initialize(target); GitSignature::Initialize(target); + GitTime::Initialize(target); GitBlob::Initialize(target); GitOid::Initialize(target); + GitObject::Initialize(target); GitRepo::Initialize(target); GitCommit::Initialize(target); GitRevWalk::Initialize(target); + GitRefDb::Initialize(target); + GitOdb::Initialize(target); + GitOdbObject::Initialize(target); + GitSubmodule::Initialize(target); GitTree::Initialize(target); GitTreeEntry::Initialize(target); + GitTreeBuilder::Initialize(target); + GitDiffRange::Initialize(target); + GitDiffFindOptions::Initialize(target); + GitDiffOptions::Initialize(target); GitDiffList::Initialize(target); + GitPatch::Initialize(target); + GitDiffFile::Initialize(target); + GitDelta::Initialize(target); + + GitRemote::Initialize(target); + GitCloneOptions::Initialize(target); GitThreads::Initialize(target); diff --git a/src/blob.cc b/src/blob.cc index 391e7534d..bc6068608 100755 --- a/src/blob.cc +++ b/src/blob.cc @@ -1,25 +1,32 @@ /** - * Copyright (c) 2011, Tim Branyen @tbranyen - * @author Michael Robinson @codeofinterest - * - * Dual licensed under the MIT and GPL licenses. - */ - -#include + * This code is auto-generated; unless you know what you're doing, do not modify! + **/ +#include +#include +#include #include "git2.h" -#include "../include/utils.h" -#include "../include/repo.h" -#include "../include/blob.h" +#include "../include/functions/copy.h" -#include "../include/functions/string.h" -#include "../include/functions/utilities.h" +#include "../include/blob.h" +#include "../include/repo.h" +#include "../include/oid.h" +#include "../include/wrapper.h" +#include "node_buffer.h" using namespace v8; using namespace node; -void GitBlob::Initialize (Handle target) { +GitBlob::GitBlob(git_blob *raw) { + this->raw = raw; +} + +GitBlob::~GitBlob() { + git_blob_free(this->raw); +} + +void GitBlob::Initialize(Handle target) { HandleScope scope; Local tpl = FunctionTemplate::New(New); @@ -27,264 +34,113 @@ void GitBlob::Initialize (Handle target) { tpl->InstanceTemplate()->SetInternalFieldCount(1); tpl->SetClassName(String::NewSymbol("Blob")); - NODE_SET_PROTOTYPE_METHOD(tpl, "lookup", Lookup); - NODE_SET_PROTOTYPE_METHOD(tpl, "rawContent", RawContent); - NODE_SET_PROTOTYPE_METHOD(tpl, "free", Free); - NODE_SET_PROTOTYPE_METHOD(tpl, "createFromFile", CreateFromFile); - NODE_SET_PROTOTYPE_METHOD(tpl, "createFromBuffer", CreateFromBuffer); + NODE_SET_PROTOTYPE_METHOD(tpl, "oid", Oid); + NODE_SET_PROTOTYPE_METHOD(tpl, "content", Content); + NODE_SET_PROTOTYPE_METHOD(tpl, "size", Size); + NODE_SET_PROTOTYPE_METHOD(tpl, "isBinary", IsBinary); + constructor_template = Persistent::New(tpl->GetFunction()); target->Set(String::NewSymbol("Blob"), constructor_template); } -git_blob* GitBlob::GetValue() { - return this->blob; -} -void GitBlob::SetValue(git_blob* blob) { - this->blob = blob; -} - Handle GitBlob::New(const Arguments& args) { HandleScope scope; - GitBlob* blob = new GitBlob(); - blob->Wrap(args.This()); - - return scope.Close( args.This() ); -} -Handle GitBlob::Free(const Arguments& args) { - HandleScope scope; - - GitBlob* blob = ObjectWrap::Unwrap(args.This()); - git_blob_free(blob->blob); - - return scope.Close( Undefined() ); -} - -Handle GitBlob::Lookup(const Arguments& args) { - HandleScope scope; - - if(args.Length() == 0 || !args[0]->IsObject()) { - return ThrowException(Exception::Error(String::New("Repo is required and must be an Object."))); - } - - if(args.Length() == 1 || !args[1]->IsObject()) { - return ThrowException(Exception::Error(String::New("Oid is required and must be an Object."))); - } - - if(args.Length() == 2 || !args[2]->IsFunction()) { - return ThrowException(Exception::Error(String::New("Callback is required and must be a Function."))); - } - - LookupBaton* baton = new LookupBaton; - baton->request.data = baton; - baton->blob = ObjectWrap::Unwrap(args.This()); - baton->blob->Ref(); - baton->rawBlob = baton->blob->GetValue(); - baton->rawRepo = ObjectWrap::Unwrap(args[0]->ToObject())->GetValue(); - baton->rawOid = ObjectWrap::Unwrap(args[1]->ToObject())->GetValue(); - baton->callback = Persistent::New(Local::Cast(args[2])); - - uv_queue_work(uv_default_loop(), &baton->request, LookupWork, (uv_after_work_cb)LookupAfterWork); - - return Undefined(); -} -void GitBlob::LookupWork(uv_work_t* req) { - LookupBaton* baton = static_cast(req->data); - int returnCode = git_blob_lookup(&baton->rawBlob, baton->rawRepo, &baton->rawOid); - if (returnCode != GIT_OK) { - baton->error = giterr_last(); + if (args.Length() == 0 || !args[0]->IsExternal()) { + return ThrowException(Exception::Error(String::New("git_blob is required."))); } -} -void GitBlob::LookupAfterWork(uv_work_t* req) { - HandleScope scope; - LookupBaton* baton = static_cast(req->data); - - if (success(baton->error, baton->callback)) { - baton->blob->SetValue(baton->rawBlob); - Handle argv[2] = { - Local::New(Null()), - baton->blob->handle_ - }; + GitBlob* object = new GitBlob((git_blob *) External::Unwrap(args[0])); + object->Wrap(args.This()); - TryCatch try_catch; - baton->callback->Call(Context::GetCurrent()->Global(), 2, argv); - if (try_catch.HasCaught()) { - node::FatalException(try_catch); - } - } - delete req; + return scope.Close(args.This()); } -Handle GitBlob::RawContent(const Arguments& args) { +Handle GitBlob::New(void *raw) { HandleScope scope; - - if(args.Length() == 0 || !args[0]->IsFunction()) { - return ThrowException(Exception::Error(String::New("Callback is required and must be a Function."))); - } - - RawContentBaton* baton = new RawContentBaton; - baton->request.data = baton; - baton->rawBlob = ObjectWrap::Unwrap(args.This())->GetValue(); - baton->callback = Persistent::New(Local::Cast(args[0])); - - uv_queue_work(uv_default_loop(), &baton->request, RawContentWork, (uv_after_work_cb)RawContentAfterWork); - - return Undefined(); + Handle argv[1] = { External::New((void *)raw) }; + return scope.Close(GitBlob::constructor_template->NewInstance(1, argv)); } -void GitBlob::RawContentWork(uv_work_t* req) { - RawContentBaton* baton = static_cast(req->data); - baton->rawContent = (const char *)const_cast(git_blob_rawcontent(baton->rawBlob)); - baton->rawSize = git_blob_rawsize(baton->rawBlob); +git_blob *GitBlob::GetValue() { + return this->raw; } -void GitBlob::RawContentAfterWork(uv_work_t* req) { - HandleScope scope; - RawContentBaton* baton = static_cast(req->data); - Local fastBuffer; - Buffer* buffer = Buffer::New(const_cast(baton->rawContent.c_str()), baton->rawSize); - MAKE_FAST_BUFFER(buffer, fastBuffer); - Handle argv[2] = { - Local::New(Null()), - fastBuffer - }; - - TryCatch try_catch; - baton->callback->Call(Context::GetCurrent()->Global(), 2, argv); - if (try_catch.HasCaught()) { - node::FatalException(try_catch); - } - delete req; -} - -Handle GitBlob::CreateFromFile(const Arguments& args) { +/** + * @return {Oid} result + */ +Handle GitBlob::Oid(const Arguments& args) { HandleScope scope; + - if(args.Length() == 0 || !args[0]->IsObject()) { - return ThrowException(Exception::Error(String::New("Repo is required and must be an Object."))); - } + const git_oid * result = git_blob_id( + ObjectWrap::Unwrap(args.This())->GetValue() + ); - if(args.Length() == 1 || !args[1]->IsString()) { - return ThrowException(Exception::Error(String::New("Path is required and must be an String."))); + Handle to; + if (result != NULL) { + result = (const git_oid * )git_oid_dup(result); } - - if(args.Length() == 2 || !args[2]->IsFunction()) { - return ThrowException(Exception::Error(String::New("Callback is required and must be an Function."))); + if (result != NULL) { + to = GitOid::New((void *)result); + } else { + to = Null(); } - - CreateFromFileBaton* baton = new CreateFromFileBaton; - baton->request.data = baton; - baton->error = NULL; - baton->blob = ObjectWrap::Unwrap(args.This()); - baton->blob->Ref(); - baton->rawBlob = baton->blob->GetValue(); - baton->rawRepo = ObjectWrap::Unwrap(args[0]->ToObject())->GetValue(); - baton->path = stringArgToString(args[1]->ToString()); - baton->callback = Persistent::New(Local::Cast(args[2])); - - uv_queue_work(uv_default_loop(), &baton->request, CreateFromFileWork, (uv_after_work_cb)CreateFromFileAfterWork); - - return Undefined(); + return scope.Close(to); } -void GitBlob::CreateFromFileWork(uv_work_t* req) { - CreateFromFileBaton* baton = static_cast(req->data); - - git_oid* rawOid = NULL; - int returnCode = git_blob_create_fromdisk(rawOid, baton->rawRepo, baton->path.c_str()); - if (returnCode != GIT_OK) { - baton->error = giterr_last(); - return; - } - returnCode = git_blob_lookup(&baton->rawBlob, baton->rawRepo, rawOid); - if (returnCode != GIT_OK) { - baton->error = giterr_last(); - } -} -void GitBlob::CreateFromFileAfterWork(uv_work_t* req) { +/** + * @return {Wrapper} result + */ +Handle GitBlob::Content(const Arguments& args) { HandleScope scope; - CreateFromFileBaton* baton = static_cast(req->data); - - baton->blob->SetValue(baton->rawBlob); + - Handle argv[2] = { - Local::New(Null()), - baton->blob->handle_ - }; + const void * result = git_blob_rawcontent( + ObjectWrap::Unwrap(args.This())->GetValue() + ); - TryCatch try_catch; - baton->callback->Call(Context::GetCurrent()->Global(), 2, argv); - if (try_catch.HasCaught()) { - node::FatalException(try_catch); + Handle to; + if (result != NULL) { + to = Wrapper::New((void *)result); + } else { + to = Null(); } - delete req; + return scope.Close(to); } -Handle GitBlob::CreateFromBuffer(const Arguments& args) { +/** + * @return {Number} result + */ +Handle GitBlob::Size(const Arguments& args) { HandleScope scope; + - if(args.Length() == 0 || !args[0]->IsObject()) { - return ThrowException(Exception::Error(String::New("Repo is required and must be an Object."))); - } - - if(args.Length() == 1 || !Buffer::HasInstance(args[1])) { - return ThrowException(Exception::Error(String::New("Buffer is required and must be an Buffer."))); - } - - if(args.Length() == 2 || !args[2]->IsFunction()) { - return ThrowException(Exception::Error(String::New("Callback is required and must be an Function."))); - } + git_off_t result = git_blob_rawsize( + ObjectWrap::Unwrap(args.This())->GetValue() + ); - CreateFromBufferBaton* baton = new CreateFromBufferBaton; - baton->request.data = baton; - baton->error = NULL; - baton->blob = ObjectWrap::Unwrap(args.This()); - baton->blob->Ref(); - baton->rawBlob = baton->blob->GetValue(); - baton->rawRepo = ObjectWrap::Unwrap(args[0]->ToObject())->GetValue(); - Local buffer = args[1]->ToObject(); - baton->data = Buffer::Data(buffer); - baton->dataLength = Buffer::Length(buffer); - baton->callback = Persistent::New(Local::Cast(args[2])); - - uv_queue_work(uv_default_loop(), &baton->request, CreateFromFileWork, (uv_after_work_cb)CreateFromFileAfterWork); - - return Undefined(); + Handle to; + to = Number::New(result); + return scope.Close(to); } -void GitBlob::CreateFromBufferWork(uv_work_t* req) { - CreateFromBufferBaton* baton = static_cast(req->data); - - git_oid* rawOid = NULL; - int returnCode = git_blob_create_frombuffer(rawOid, baton->rawRepo, baton->data, baton->dataLength); - if (returnCode != GIT_OK) { - baton->error = giterr_last(); - } - returnCode = git_blob_lookup(&baton->rawBlob, baton->rawRepo, rawOid); - if (returnCode != GIT_OK) { - baton->error = giterr_last(); - } -} -void GitBlob::CreateFromBufferAfterWork(uv_work_t* req) { +/** + * @return {Boolean} result + */ +Handle GitBlob::IsBinary(const Arguments& args) { HandleScope scope; - CreateFromBufferBaton* baton = static_cast(req->data); + - baton->blob->SetValue(baton->rawBlob); + int result = git_blob_is_binary( + ObjectWrap::Unwrap(args.This())->GetValue() + ); - Handle argv[2] = { - Local::New(Null()), - baton->blob->handle_ - }; - - TryCatch try_catch; - baton->callback->Call(Context::GetCurrent()->Global(), 2, argv); - if (try_catch.HasCaught()) { - node::FatalException(try_catch); - } - delete req; + Handle to; + to = Boolean::New(result); + return scope.Close(to); } Persistent GitBlob::constructor_template; diff --git a/src/branch.cc b/src/branch.cc new file mode 100644 index 000000000..e633ffce6 --- /dev/null +++ b/src/branch.cc @@ -0,0 +1,536 @@ +/** + * This code is auto-generated; unless you know what you're doing, do not modify! + **/ +#include +#include +#include + +#include "git2.h" + +#include "../include/functions/copy.h" + +#include "../include/branch.h" + +using namespace v8; +using namespace node; + +Branch::Branch(git_branch *raw) { + this->raw = raw; +} + +Branch::~Branch() { + git_branch_free(this->raw); +} + +void Branch::Initialize(Handle target) { + HandleScope scope; + + Local tpl = FunctionTemplate::New(New); + + tpl->InstanceTemplate()->SetInternalFieldCount(1); + tpl->SetClassName(String::NewSymbol("Branch")); + + NODE_SET_METHOD(tpl, "create", Create); + NODE_SET_METHOD(tpl, "delete", Delete); + NODE_SET_METHOD(tpl, "foreach", Foreach); + NODE_SET_METHOD(tpl, "move", Move); + NODE_SET_METHOD(tpl, "lookup", Lookup); + NODE_SET_METHOD(tpl, "name", Name); + NODE_SET_METHOD(tpl, "upstream", Upstream); + NODE_SET_METHOD(tpl, "setUpstream", SetUpstream); + NODE_SET_METHOD(tpl, "upstreamName", UpstreamName); + NODE_SET_METHOD(tpl, "isHead", IsHead); + NODE_SET_METHOD(tpl, "remoteName", RemoteName); + + + constructor_template = Persistent::New(tpl->GetFunction()); + target->Set(String::NewSymbol("Branch"), constructor_template); +} + +Handle Branch::New(const Arguments& args) { + HandleScope scope; + + if (args.Length() == 0 || !args[0]->IsExternal()) { + return ThrowException(Exception::Error(String::New("git_branch is required."))); + } + + Branch* object = new Branch((git_branch *) External::Unwrap(args[0])); + object->Wrap(args.This()); + + return scope.Close(args.This()); +} + +Handle Branch::New(void *raw) { + HandleScope scope; + Handle argv[1] = { External::New((void *)raw) }; + return scope.Close(Branch::constructor_template->NewInstance(1, argv)); +} + +git_branch *Branch::GetValue() { + return this->raw; +} + + +/** + * @param {Repository} repo + * @param {String} branch_name + * @param {Commit} target + * @param {Number} force + * @return {Reference} out + */ +Handle Branch::Create(const Arguments& args) { + HandleScope scope; + if (args.Length() == 0 || !args[0]->IsObject()) { + return ThrowException(Exception::Error(String::New("Repository repo is required."))); + } + if (args.Length() == 1 || !args[1]->IsString()) { + return ThrowException(Exception::Error(String::New("String branch_name is required."))); + } + if (args.Length() == 2 || !args[2]->IsObject()) { + return ThrowException(Exception::Error(String::New("Commit target is required."))); + } + if (args.Length() == 3 || !args[3]->IsInt32()) { + return ThrowException(Exception::Error(String::New("Number force is required."))); + } + + git_reference *out = NULL; + git_repository * from_repo; + from_repo = ObjectWrap::Unwrap(args[0]->ToObject())->GetValue(); + const char * from_branch_name; + String::Utf8Value branch_name(args[1]->ToString()); + from_branch_name = strdup(*branch_name); + const git_commit * from_target; + from_target = ObjectWrap::Unwrap(args[2]->ToObject())->GetValue(); + int from_force; + from_force = (int) args[3]->ToInt32()->Value(); + + int result = git_branch_create( + &out + , from_repo + , from_branch_name + , from_target + , from_force + ); + free((void *)from_branch_name); + if (result != GIT_OK) { + if (giterr_last()) { + return ThrowException(Exception::Error(String::New(giterr_last()->message))); + } else { + return ThrowException(Exception::Error(String::New("Unkown Error"))); + } + } + + Handle to; + if (out != NULL) { + to = GitReference::New((void *)out); + } else { + to = Null(); + } + return scope.Close(to); +} + +/** + * @param {Reference} branch + */ +Handle Branch::Delete(const Arguments& args) { + HandleScope scope; + if (args.Length() == 0 || !args[0]->IsObject()) { + return ThrowException(Exception::Error(String::New("Reference branch is required."))); + } + + git_reference * from_branch; + from_branch = ObjectWrap::Unwrap(args[0]->ToObject())->GetValue(); + + int result = git_branch_delete( + from_branch + ); + if (result != GIT_OK) { + if (giterr_last()) { + return ThrowException(Exception::Error(String::New(giterr_last()->message))); + } else { + return ThrowException(Exception::Error(String::New("Unkown Error"))); + } + } + + return Undefined(); +} + +/** + * @param {Repository} repo + * @param {Number} list_flags + * @param {BranchForeachCb} branch_cb + * @param {void} payload + */ +Handle Branch::Foreach(const Arguments& args) { + HandleScope scope; + if (args.Length() == 0 || !args[0]->IsObject()) { + return ThrowException(Exception::Error(String::New("Repository repo is required."))); + } + if (args.Length() == 1 || !args[1]->IsUint32()) { + return ThrowException(Exception::Error(String::New("Number list_flags is required."))); + } + if (args.Length() == 2 || !args[2]->IsObject()) { + return ThrowException(Exception::Error(String::New("BranchForeachCb branch_cb is required."))); + } + if (args.Length() == 3 || !args[3]->IsObject()) { + return ThrowException(Exception::Error(String::New("void payload is required."))); + } + + git_repository * from_repo; + from_repo = ObjectWrap::Unwrap(args[0]->ToObject())->GetValue(); + unsigned int from_list_flags; + from_list_flags = (unsigned int) args[1]->ToUint32()->Value(); + git_branch_foreach_cb from_branch_cb; + from_branch_cb = ObjectWrap::Unwrap(args[2]->ToObject())->GetValue(); + void * from_payload; + from_payload = ObjectWrap::Unwrap(args[3]->ToObject())->GetValue(); + + int result = git_branch_foreach( + from_repo + , from_list_flags + , from_branch_cb + , from_payload + ); + if (result != GIT_OK) { + if (giterr_last()) { + return ThrowException(Exception::Error(String::New(giterr_last()->message))); + } else { + return ThrowException(Exception::Error(String::New("Unkown Error"))); + } + } + + return Undefined(); +} + +/** + * @param {Reference} branch + * @param {String} new_branch_name + * @param {Number} force + * @return {Reference} out + */ +Handle Branch::Move(const Arguments& args) { + HandleScope scope; + if (args.Length() == 0 || !args[0]->IsObject()) { + return ThrowException(Exception::Error(String::New("Reference branch is required."))); + } + if (args.Length() == 1 || !args[1]->IsString()) { + return ThrowException(Exception::Error(String::New("String new_branch_name is required."))); + } + if (args.Length() == 2 || !args[2]->IsInt32()) { + return ThrowException(Exception::Error(String::New("Number force is required."))); + } + + git_reference *out = NULL; + git_reference * from_branch; + from_branch = ObjectWrap::Unwrap(args[0]->ToObject())->GetValue(); + const char * from_new_branch_name; + String::Utf8Value new_branch_name(args[1]->ToString()); + from_new_branch_name = strdup(*new_branch_name); + int from_force; + from_force = (int) args[2]->ToInt32()->Value(); + + int result = git_branch_move( + &out + , from_branch + , from_new_branch_name + , from_force + ); + free((void *)from_new_branch_name); + if (result != GIT_OK) { + if (giterr_last()) { + return ThrowException(Exception::Error(String::New(giterr_last()->message))); + } else { + return ThrowException(Exception::Error(String::New("Unkown Error"))); + } + } + + Handle to; + if (out != NULL) { + to = GitReference::New((void *)out); + } else { + to = Null(); + } + return scope.Close(to); +} + +/** + * @param {Repository} repo + * @param {String} branch_name + * @param {BranchT} branch_type + * @return {Reference} out + */ +Handle Branch::Lookup(const Arguments& args) { + HandleScope scope; + if (args.Length() == 0 || !args[0]->IsObject()) { + return ThrowException(Exception::Error(String::New("Repository repo is required."))); + } + if (args.Length() == 1 || !args[1]->IsString()) { + return ThrowException(Exception::Error(String::New("String branch_name is required."))); + } + if (args.Length() == 2 || !args[2]->IsObject()) { + return ThrowException(Exception::Error(String::New("BranchT branch_type is required."))); + } + + git_reference *out = NULL; + git_repository * from_repo; + from_repo = ObjectWrap::Unwrap(args[0]->ToObject())->GetValue(); + const char * from_branch_name; + String::Utf8Value branch_name(args[1]->ToString()); + from_branch_name = strdup(*branch_name); + git_branch_t from_branch_type; + from_branch_type = ObjectWrap::Unwrap(args[2]->ToObject())->GetValue(); + + int result = git_branch_lookup( + &out + , from_repo + , from_branch_name + , from_branch_type + ); + free((void *)from_branch_name); + if (result != GIT_OK) { + if (giterr_last()) { + return ThrowException(Exception::Error(String::New(giterr_last()->message))); + } else { + return ThrowException(Exception::Error(String::New("Unkown Error"))); + } + } + + Handle to; + if (out != NULL) { + to = GitReference::New((void *)out); + } else { + to = Null(); + } + return scope.Close(to); +} + +/** + * @param {Reference} ref + * @return {String} out + */ +Handle Branch::Name(const Arguments& args) { + HandleScope scope; + if (args.Length() == 0 || !args[0]->IsObject()) { + return ThrowException(Exception::Error(String::New("Reference ref is required."))); + } + + const char *out = NULL; + git_reference * from_ref; + from_ref = ObjectWrap::Unwrap(args[0]->ToObject())->GetValue(); + + int result = git_branch_name( + &out + , from_ref + ); + if (result != GIT_OK) { + if (giterr_last()) { + return ThrowException(Exception::Error(String::New(giterr_last()->message))); + } else { + return ThrowException(Exception::Error(String::New("Unkown Error"))); + } + } + + Handle to; + to = String::New(out); + return scope.Close(to); +} + +/** + * @param {Reference} branch + * @return {Reference} out + */ +Handle Branch::Upstream(const Arguments& args) { + HandleScope scope; + if (args.Length() == 0 || !args[0]->IsObject()) { + return ThrowException(Exception::Error(String::New("Reference branch is required."))); + } + + git_reference *out = NULL; + git_reference * from_branch; + from_branch = ObjectWrap::Unwrap(args[0]->ToObject())->GetValue(); + + int result = git_branch_upstream( + &out + , from_branch + ); + if (result != GIT_OK) { + if (giterr_last()) { + return ThrowException(Exception::Error(String::New(giterr_last()->message))); + } else { + return ThrowException(Exception::Error(String::New("Unkown Error"))); + } + } + + Handle to; + if (out != NULL) { + to = GitReference::New((void *)out); + } else { + to = Null(); + } + return scope.Close(to); +} + +/** + * @param {Reference} branch + * @param {String} upstream_name + */ +Handle Branch::SetUpstream(const Arguments& args) { + HandleScope scope; + if (args.Length() == 0 || !args[0]->IsObject()) { + return ThrowException(Exception::Error(String::New("Reference branch is required."))); + } + if (args.Length() == 1 || !args[1]->IsString()) { + return ThrowException(Exception::Error(String::New("String upstream_name is required."))); + } + + git_reference * from_branch; + from_branch = ObjectWrap::Unwrap(args[0]->ToObject())->GetValue(); + const char * from_upstream_name; + String::Utf8Value upstream_name(args[1]->ToString()); + from_upstream_name = strdup(*upstream_name); + + int result = git_branch_set_upstream( + from_branch + , from_upstream_name + ); + free((void *)from_upstream_name); + if (result != GIT_OK) { + if (giterr_last()) { + return ThrowException(Exception::Error(String::New(giterr_last()->message))); + } else { + return ThrowException(Exception::Error(String::New("Unkown Error"))); + } + } + + return Undefined(); +} + +/** + * @param {String} tracking_branch_name_out + * @param {Number} buffer_size + * @param {Repository} repo + * @param {String} canonical_branch_name + */ +Handle Branch::UpstreamName(const Arguments& args) { + HandleScope scope; + if (args.Length() == 0 || !args[0]->IsString()) { + return ThrowException(Exception::Error(String::New("String tracking_branch_name_out is required."))); + } + if (args.Length() == 1 || !args[1]->IsUint32()) { + return ThrowException(Exception::Error(String::New("Number buffer_size is required."))); + } + if (args.Length() == 2 || !args[2]->IsObject()) { + return ThrowException(Exception::Error(String::New("Repository repo is required."))); + } + if (args.Length() == 3 || !args[3]->IsString()) { + return ThrowException(Exception::Error(String::New("String canonical_branch_name is required."))); + } + + char * from_tracking_branch_name_out; + String::Utf8Value tracking_branch_name_out(args[0]->ToString()); + from_tracking_branch_name_out = strdup(*tracking_branch_name_out); + size_t from_buffer_size; + from_buffer_size = (size_t) args[1]->ToUint32()->Value(); + git_repository * from_repo; + from_repo = ObjectWrap::Unwrap(args[2]->ToObject())->GetValue(); + const char * from_canonical_branch_name; + String::Utf8Value canonical_branch_name(args[3]->ToString()); + from_canonical_branch_name = strdup(*canonical_branch_name); + + int result = git_branch_upstream_name( + from_tracking_branch_name_out + , from_buffer_size + , from_repo + , from_canonical_branch_name + ); + free((void *)from_tracking_branch_name_out); + free((void *)from_canonical_branch_name); + if (result != GIT_OK) { + if (giterr_last()) { + return ThrowException(Exception::Error(String::New(giterr_last()->message))); + } else { + return ThrowException(Exception::Error(String::New("Unkown Error"))); + } + } + + return Undefined(); +} + +/** + * @param {Reference} branch + */ +Handle Branch::IsHead(const Arguments& args) { + HandleScope scope; + if (args.Length() == 0 || !args[0]->IsObject()) { + return ThrowException(Exception::Error(String::New("Reference branch is required."))); + } + + git_reference * from_branch; + from_branch = ObjectWrap::Unwrap(args[0]->ToObject())->GetValue(); + + int result = git_branch_is_head( + from_branch + ); + if (result != GIT_OK) { + if (giterr_last()) { + return ThrowException(Exception::Error(String::New(giterr_last()->message))); + } else { + return ThrowException(Exception::Error(String::New("Unkown Error"))); + } + } + + return Undefined(); +} + +/** + * @param {String} remote_name_out + * @param {Number} buffer_size + * @param {Repository} repo + * @param {String} canonical_branch_name + */ +Handle Branch::RemoteName(const Arguments& args) { + HandleScope scope; + if (args.Length() == 0 || !args[0]->IsString()) { + return ThrowException(Exception::Error(String::New("String remote_name_out is required."))); + } + if (args.Length() == 1 || !args[1]->IsUint32()) { + return ThrowException(Exception::Error(String::New("Number buffer_size is required."))); + } + if (args.Length() == 2 || !args[2]->IsObject()) { + return ThrowException(Exception::Error(String::New("Repository repo is required."))); + } + if (args.Length() == 3 || !args[3]->IsString()) { + return ThrowException(Exception::Error(String::New("String canonical_branch_name is required."))); + } + + char * from_remote_name_out; + String::Utf8Value remote_name_out(args[0]->ToString()); + from_remote_name_out = strdup(*remote_name_out); + size_t from_buffer_size; + from_buffer_size = (size_t) args[1]->ToUint32()->Value(); + git_repository * from_repo; + from_repo = ObjectWrap::Unwrap(args[2]->ToObject())->GetValue(); + const char * from_canonical_branch_name; + String::Utf8Value canonical_branch_name(args[3]->ToString()); + from_canonical_branch_name = strdup(*canonical_branch_name); + + int result = git_branch_remote_name( + from_remote_name_out + , from_buffer_size + , from_repo + , from_canonical_branch_name + ); + free((void *)from_remote_name_out); + free((void *)from_canonical_branch_name); + if (result != GIT_OK) { + if (giterr_last()) { + return ThrowException(Exception::Error(String::New(giterr_last()->message))); + } else { + return ThrowException(Exception::Error(String::New("Unkown Error"))); + } + } + + return Undefined(); +} + +Persistent Branch::constructor_template; diff --git a/src/clone_options.cc b/src/clone_options.cc new file mode 100644 index 000000000..3f4b058c5 --- /dev/null +++ b/src/clone_options.cc @@ -0,0 +1,63 @@ +/** + * This code is auto-generated; unless you know what you're doing, do not modify! + **/ +#include +#include +#include + +#include "git2.h" + +#include "../include/functions/copy.h" + +#include "../include/clone_options.h" + +using namespace v8; +using namespace node; + +GitCloneOptions::GitCloneOptions(git_clone_options *raw) { + this->raw = raw; +} + +GitCloneOptions::~GitCloneOptions() { + free(this->raw); +} + +void GitCloneOptions::Initialize(Handle target) { + HandleScope scope; + + Local tpl = FunctionTemplate::New(New); + + tpl->InstanceTemplate()->SetInternalFieldCount(1); + tpl->SetClassName(String::NewSymbol("CloneOptions")); + + + + constructor_template = Persistent::New(tpl->GetFunction()); + target->Set(String::NewSymbol("CloneOptions"), constructor_template); +} + +Handle GitCloneOptions::New(const Arguments& args) { + HandleScope scope; + + if (args.Length() == 0 || !args[0]->IsExternal()) { + return ThrowException(Exception::Error(String::New("git_clone_options is required."))); + } + + GitCloneOptions* object = new GitCloneOptions((git_clone_options *) External::Unwrap(args[0])); + object->Wrap(args.This()); + + return scope.Close(args.This()); +} + +Handle GitCloneOptions::New(void *raw) { + HandleScope scope; + Handle argv[1] = { External::New((void *)raw) }; + return scope.Close(GitCloneOptions::constructor_template->NewInstance(1, argv)); +} + +git_clone_options *GitCloneOptions::GetValue() { + return this->raw; +} + + +Persistent GitCloneOptions::constructor_template; diff --git a/src/commit.cc b/src/commit.cc index d4eecd555..43423dd35 100755 --- a/src/commit.cc +++ b/src/commit.cc @@ -1,33 +1,32 @@ -/* - * Copyright 2013, Tim Branyen @tbranyen - * @author Michael Robinson @codeofinterest - * - * Dual licensed under the MIT and GPL licenses. - */ - +/** + * This code is auto-generated; unless you know what you're doing, do not modify! + **/ #include #include #include #include "git2.h" -#include "cvv8/v8-convert.hpp" -#include "../include/reference.h" -#include "../include/signature.h" -#include "../include/repo.h" +#include "../include/functions/copy.h" + +#include "../include/commit.h" #include "../include/oid.h" +#include "../include/repo.h" +#include "../include/signature.h" #include "../include/tree.h" -#include "../include/commit.h" -#include "../include/error.h" - -#include "../include/functions/utilities.h" -#include "../include/functions/string.h" using namespace v8; -using namespace cvv8; using namespace node; -void GitCommit::Initialize(Handle target) { +GitCommit::GitCommit(git_commit *raw) { + this->raw = raw; +} + +GitCommit::~GitCommit() { + git_commit_free(this->raw); +} + +void GitCommit::Initialize(Handle target) { HandleScope scope; Local tpl = FunctionTemplate::New(New); @@ -35,453 +34,283 @@ void GitCommit::Initialize(Handle target) { tpl->InstanceTemplate()->SetInternalFieldCount(1); tpl->SetClassName(String::NewSymbol("Commit")); - NODE_SET_PROTOTYPE_METHOD(tpl, "lookup", Lookup); NODE_SET_PROTOTYPE_METHOD(tpl, "oid", Oid); + NODE_SET_PROTOTYPE_METHOD(tpl, "messageEncoding", MessageEncoding); NODE_SET_PROTOTYPE_METHOD(tpl, "message", Message); NODE_SET_PROTOTYPE_METHOD(tpl, "time", Time); NODE_SET_PROTOTYPE_METHOD(tpl, "offset", Offset); - NODE_SET_PROTOTYPE_METHOD(tpl, "author", Author); NODE_SET_PROTOTYPE_METHOD(tpl, "committer", Committer); - NODE_SET_PROTOTYPE_METHOD(tpl, "tree", Tree); - NODE_SET_PROTOTYPE_METHOD(tpl, "parents", Parents); + NODE_SET_PROTOTYPE_METHOD(tpl, "author", Author); + NODE_SET_PROTOTYPE_METHOD(tpl, "treeId", TreeId); + NODE_SET_PROTOTYPE_METHOD(tpl, "parentCount", ParentCount); + NODE_SET_PROTOTYPE_METHOD(tpl, "parentId", ParentId); + NODE_SET_PROTOTYPE_METHOD(tpl, "nthGenAncestor", NthGenAncestor); - NODE_SET_PROTOTYPE_METHOD(tpl, "free", Free); constructor_template = Persistent::New(tpl->GetFunction()); target->Set(String::NewSymbol("Commit"), constructor_template); } -git_commit* GitCommit::GetValue() { - return this->commit; -} -void GitCommit::SetValue(git_commit* commit) { - this->commit = commit; -} -void GitCommit::SetOid(git_oid* oid) { - this->oid = oid; -} - Handle GitCommit::New(const Arguments& args) { HandleScope scope; - GitCommit *commit = new GitCommit(); - commit->Wrap(args.This()); + if (args.Length() == 0 || !args[0]->IsExternal()) { + return ThrowException(Exception::Error(String::New("git_commit is required."))); + } + + GitCommit* object = new GitCommit((git_commit *) External::Unwrap(args[0])); + object->Wrap(args.This()); return scope.Close(args.This()); } -Handle GitCommit::Free(const Arguments& args) { - HandleScope scope; - GitCommit *commit = ObjectWrap::Unwrap(args.This()); - git_commit_free(commit->commit); - commit->commit = NULL; +Handle GitCommit::New(void *raw) { + HandleScope scope; + Handle argv[1] = { External::New((void *)raw) }; + return scope.Close(GitCommit::constructor_template->NewInstance(1, argv)); +} - return Undefined(); +git_commit *GitCommit::GetValue() { + return this->raw; } -Handle GitCommit::Lookup(const Arguments& args) { - HandleScope scope; - if(args.Length() == 0 || !args[0]->IsObject()) { - return ThrowException(Exception::Error(String::New("Repo is required and must be an Object."))); - } +/** + * @return {Oid} result + */ +Handle GitCommit::Oid(const Arguments& args) { + HandleScope scope; + - if(args.Length() == 1 || !(args[1]->IsObject() || args[1]->IsString())) { - return ThrowException(Exception::Error(String::New("Oid is required and must be an Object or String"))); - } + const git_oid * result = git_commit_id( + ObjectWrap::Unwrap(args.This())->GetValue() + ); - if(args.Length() == 2 || !args[2]->IsFunction()) { - return ThrowException(Exception::Error(String::New("Callback is required and must be a Function."))); + Handle to; + if (result != NULL) { + result = (const git_oid * )git_oid_dup(result); } - - LookupBaton *baton = new LookupBaton; - baton->request.data = baton; - baton->error = NULL; - baton->repo = ObjectWrap::Unwrap(args[0]->ToObject())->GetValue(); - - if (args[1]->IsObject()) { - baton->rawOid = ObjectWrap::Unwrap(args[1]->ToObject())->GetValue(); + if (result != NULL) { + to = GitOid::New((void *)result); } else { - baton->sha = stringArgToString(args[1]->ToString()); + to = Null(); } - - baton->callback = Persistent::New(Local::Cast(args[2])); - - uv_queue_work(uv_default_loop(), &baton->request, LookupWork, (uv_after_work_cb)LookupAfterWork); - - return Undefined(); + return scope.Close(to); } -void GitCommit::LookupWork(uv_work_t *req) { - LookupBaton *baton = static_cast(req->data); - - if (!baton->sha.empty()) { - int returnCode = git_oid_fromstr(&baton->rawOid, baton->sha.c_str()); - if (returnCode != GIT_OK) { - baton->error = giterr_last(); - return; - } - } - baton->rawCommit = NULL; - int returnCode = git_commit_lookup(&baton->rawCommit, baton->repo, &baton->rawOid); - if (returnCode != GIT_OK) { - baton->error = giterr_last(); - } -} -void GitCommit::LookupAfterWork(uv_work_t *req) { - HandleScope scope; - LookupBaton *baton = static_cast(req->data); - - if (success(baton->error, baton->callback)) { - Local commit = GitCommit::constructor_template->NewInstance(); - GitCommit *commitInstance = ObjectWrap::Unwrap(commit); - commitInstance->SetValue(baton->rawCommit); - commitInstance->SetOid(&baton->rawOid); - - Handle argv[2] = { - Local::New(Null()), - commit - }; - - TryCatch try_catch; - baton->callback->Call(Context::GetCurrent()->Global(), 2, argv); - if (try_catch.HasCaught()) { - node::FatalException(try_catch); - } - } - delete req; -} - -Handle GitCommit::Oid(const Arguments& args) { +/** + * @return {String} result + */ +Handle GitCommit::MessageEncoding(const Arguments& args) { HandleScope scope; + - Local oid = GitOid::constructor_template->NewInstance(); - GitOid *oidInstance = ObjectWrap::Unwrap(oid); - oidInstance->SetValue(*const_cast(ObjectWrap::Unwrap(args.This())->oid)); + const char * result = git_commit_message_encoding( + ObjectWrap::Unwrap(args.This())->GetValue() + ); - return scope.Close(oid); + Handle to; + to = String::New(result); + return scope.Close(to); } +/** + * @return {String} result + */ Handle GitCommit::Message(const Arguments& args) { HandleScope scope; + - if(args.Length() == 0 || !args[0]->IsFunction()) { - return ThrowException(Exception::Error(String::New("Callback is required and must be a Function."))); - } - - MessageBaton* baton = new MessageBaton; - baton->request.data = baton; - baton->rawCommit = ObjectWrap::Unwrap(args.This())->GetValue(); - baton->callback = Persistent::New(Local::Cast(args[0])); - - uv_queue_work(uv_default_loop(), &baton->request, MessageWork, (uv_after_work_cb)MessageAfterWork); + const char * result = git_commit_message( + ObjectWrap::Unwrap(args.This())->GetValue() + ); - return Undefined(); -} -void GitCommit::MessageWork(uv_work_t* req) { - MessageBaton *baton = static_cast(req->data); - - baton->message = git_commit_message(baton->rawCommit); -} -void GitCommit::MessageAfterWork(uv_work_t* req) { - HandleScope scope; - MessageBaton *baton = static_cast(req->data); - - Handle argv[2] = { - Local::New(Null()), - String::New(baton->message.c_str()) - }; - - TryCatch try_catch; - baton->callback->Call(Context::GetCurrent()->Global(), 2, argv); - if (try_catch.HasCaught()) { - node::FatalException(try_catch); - } - delete req; + Handle to; + to = String::New(result); + return scope.Close(to); } +/** + * @return {Number} result + */ Handle GitCommit::Time(const Arguments& args) { HandleScope scope; + - if(args.Length() == 0 || !args[0]->IsFunction()) { - return ThrowException(Exception::Error(String::New("Callback is required and must be a Function."))); - } - - TimeBaton* baton = new TimeBaton; - baton->request.data = baton; - baton->rawCommit = ObjectWrap::Unwrap(args.This())->GetValue(); - baton->callback = Persistent::New(Local::Cast(args[0])); - - uv_queue_work(uv_default_loop(), &baton->request, TimeWork, (uv_after_work_cb)TimeAfterWork); - - return Undefined(); -} -void GitCommit::TimeWork(uv_work_t* req) { - TimeBaton *baton = static_cast(req->data); + git_time_t result = git_commit_time( + ObjectWrap::Unwrap(args.This())->GetValue() + ); - baton->time = git_commit_time(baton->rawCommit); -} -void GitCommit::TimeAfterWork(uv_work_t* req) { - HandleScope scope; - TimeBaton *baton = static_cast(req->data); - - Handle argv[2] = { - Local::New(Null()), - Integer::New(baton->time) - }; - - TryCatch try_catch; - baton->callback->Call(Context::GetCurrent()->Global(), 2, argv); - if (try_catch.HasCaught()) { - node::FatalException(try_catch); - } - delete req; + Handle to; + to = Number::New(result); + return scope.Close(to); } +/** + * @return {Number} result + */ Handle GitCommit::Offset(const Arguments& args) { HandleScope scope; + - if(args.Length() == 0 || !args[0]->IsFunction()) { - return ThrowException(Exception::Error(String::New("Callback is required and must be a Function."))); - } - - OffsetBaton* baton = new OffsetBaton; - baton->request.data = baton; - baton->rawCommit = ObjectWrap::Unwrap(args.This())->GetValue(); - baton->callback = Persistent::New(Local::Cast(args[0])); + int result = git_commit_time_offset( + ObjectWrap::Unwrap(args.This())->GetValue() + ); - uv_queue_work(uv_default_loop(), &baton->request, OffsetWork, (uv_after_work_cb)OffsetAfterWork); - - return Undefined(); + Handle to; + to = Integer::New(result); + return scope.Close(to); } -void GitCommit::OffsetWork(uv_work_t* req) { - OffsetBaton *baton = static_cast(req->data); - baton->offset = git_commit_time_offset(baton->rawCommit); -} -void GitCommit::OffsetAfterWork(uv_work_t* req) { +/** + * @return {Signature} result + */ +Handle GitCommit::Committer(const Arguments& args) { HandleScope scope; - OffsetBaton *baton = static_cast(req->data); + - Handle argv[2] = { - Local::New(Null()), - Integer::New(baton->offset) - }; + const git_signature * result = git_commit_committer( + ObjectWrap::Unwrap(args.This())->GetValue() + ); - TryCatch try_catch; - baton->callback->Call(Context::GetCurrent()->Global(), 2, argv); - if (try_catch.HasCaught()) { - node::FatalException(try_catch); + Handle to; + if (result != NULL) { + result = (const git_signature * )git_signature_dup(result); } - delete req; + if (result != NULL) { + to = GitSignature::New((void *)result); + } else { + to = Null(); + } + return scope.Close(to); } +/** + * @return {Signature} result + */ Handle GitCommit::Author(const Arguments& args) { HandleScope scope; + - if(args.Length() == 0 || !args[0]->IsFunction()) { - return ThrowException(Exception::Error(String::New("Callback is required and must be a Function."))); - } - - SignatureBaton* baton = new SignatureBaton; - baton->request.data = baton; - baton->rawCommit = ObjectWrap::Unwrap(args.This())->GetValue(); - baton->callback = Persistent::New(Local::Cast(args[0])); - - uv_queue_work(uv_default_loop(), &baton->request, AuthorWork, (uv_after_work_cb)AuthorAfterWork); + const git_signature * result = git_commit_author( + ObjectWrap::Unwrap(args.This())->GetValue() + ); - return Undefined(); + Handle to; + if (result != NULL) { + result = (const git_signature * )git_signature_dup(result); + } + if (result != NULL) { + to = GitSignature::New((void *)result); + } else { + to = Null(); + } + return scope.Close(to); } -void GitCommit::AuthorWork(uv_work_t* req) { - SignatureBaton *baton = static_cast(req->data); - baton->rawSignature = git_commit_author(baton->rawCommit); -} -void GitCommit::AuthorAfterWork(uv_work_t* req) { +/** + * @return {Oid} result + */ +Handle GitCommit::TreeId(const Arguments& args) { HandleScope scope; - SignatureBaton *baton = static_cast(req->data); - - Local signature = GitSignature::constructor_template->NewInstance(); - GitSignature *signatureInstance = ObjectWrap::Unwrap(signature); - signatureInstance->SetValue(const_cast(baton->rawSignature)); + - Handle argv[2] = { - Local::New(Null()), - signature - }; + const git_oid * result = git_commit_tree_id( + ObjectWrap::Unwrap(args.This())->GetValue() + ); - TryCatch try_catch; - baton->callback->Call(Context::GetCurrent()->Global(), 2, argv); - if (try_catch.HasCaught()) { - node::FatalException(try_catch); + Handle to; + if (result != NULL) { + result = (const git_oid * )git_oid_dup(result); } - delete req; -} - -Handle GitCommit::Committer(const Arguments& args) { - HandleScope scope; - - if(args.Length() == 0 || !args[0]->IsFunction()) { - return ThrowException(Exception::Error(String::New("Callback is required and must be a Function."))); + if (result != NULL) { + to = GitOid::New((void *)result); + } else { + to = Null(); } - - SignatureBaton* baton = new SignatureBaton; - baton->request.data = baton; - baton->rawCommit = ObjectWrap::Unwrap(args.This())->GetValue(); - baton->callback = Persistent::New(Local::Cast(args[0])); - - uv_queue_work(uv_default_loop(), &baton->request, CommitterWork, (uv_after_work_cb)CommitterAfterWork); - - return Undefined(); + return scope.Close(to); } -void GitCommit::CommitterWork(uv_work_t* req) { - SignatureBaton *baton = static_cast(req->data); - baton->rawSignature = git_commit_committer(baton->rawCommit); -} -void GitCommit::CommitterAfterWork(uv_work_t* req) { +/** + * @return {Number} result + */ +Handle GitCommit::ParentCount(const Arguments& args) { HandleScope scope; - SignatureBaton *baton = static_cast(req->data); - - Local signature = GitSignature::constructor_template->NewInstance(); - GitSignature *signatureInstance = ObjectWrap::Unwrap(signature); - signatureInstance->SetValue(const_cast(baton->rawSignature)); + - Handle argv[2] = { - Local::New(Null()), - signature - }; + unsigned int result = git_commit_parentcount( + ObjectWrap::Unwrap(args.This())->GetValue() + ); - TryCatch try_catch; - baton->callback->Call(Context::GetCurrent()->Global(), 2, argv); - if (try_catch.HasCaught()) { - node::FatalException(try_catch); - } - delete req; + Handle to; + to = Uint32::New(result); + return scope.Close(to); } -Handle GitCommit::Tree(const Arguments& args) { +/** + * @param {Number} n + * @return {Oid} result + */ +Handle GitCommit::ParentId(const Arguments& args) { HandleScope scope; - - if(args.Length() == 0 || !args[0]->IsFunction()) { - return ThrowException(Exception::Error(String::New("Callback is required and must be a Function."))); + if (args.Length() == 0 || !args[0]->IsUint32()) { + return ThrowException(Exception::Error(String::New("Number n is required."))); } - TreeBaton* baton = new TreeBaton; - baton->request.data = baton; - baton->error = NULL; - baton->rawTree = NULL; - baton->rawCommit = ObjectWrap::Unwrap(args.This())->GetValue(); - baton->callback = Persistent::New(Local::Cast(args[0])); - - uv_queue_work(uv_default_loop(), &baton->request, TreeWork, (uv_after_work_cb)TreeAfterWork); - - return Undefined(); -} -void GitCommit::TreeWork(uv_work_t* req) { - TreeBaton* baton = static_cast(req->data); - - int returnCode = git_commit_tree(&baton->rawTree, baton->rawCommit); - if (returnCode != GIT_OK) { - baton->error = giterr_last(); + unsigned int from_n; + from_n = (unsigned int) args[0]->ToUint32()->Value(); + + const git_oid * result = git_commit_parent_id( + ObjectWrap::Unwrap(args.This())->GetValue() + , from_n + ); + + Handle to; + if (result != NULL) { + result = (const git_oid * )git_oid_dup(result); } -} -void GitCommit::TreeAfterWork(uv_work_t* req) { - HandleScope scope; - TreeBaton* baton = static_cast(req->data); - - if (success(baton->error, baton->callback)) { - Local tree = GitTree::constructor_template->NewInstance(); - GitTree *treeInstance = ObjectWrap::Unwrap(tree); - treeInstance->SetValue(baton->rawTree); - - Handle argv[2] = { - Local::New(Null()), - tree - }; - - TryCatch try_catch; - baton->callback->Call(Context::GetCurrent()->Global(), 2, argv); - if (try_catch.HasCaught()) { - node::FatalException(try_catch); - } + if (result != NULL) { + to = GitOid::New((void *)result); + } else { + to = Null(); } - delete req; + return scope.Close(to); } -Handle GitCommit::Parents(const Arguments& args) { +/** + * @param {Number} n + * @return {Commit} ancestor + */ +Handle GitCommit::NthGenAncestor(const Arguments& args) { HandleScope scope; - - if(args.Length() == 0 && !args[0]->IsFunction()) { - return ThrowException(Exception::Error(String::New("Callback is required and must be a Function."))); + if (args.Length() == 0 || !args[0]->IsUint32()) { + return ThrowException(Exception::Error(String::New("Number n is required."))); } - ParentsBaton* baton = new ParentsBaton; - baton->request.data = baton; - baton->error = NULL; - baton->rawCommit = ObjectWrap::Unwrap(args.This())->GetValue(); - baton->callback = Persistent::New(Local::Cast(args[0])); - - uv_queue_work(uv_default_loop(), &baton->request, ParentsWork, (uv_after_work_cb)ParentsAfterWork); - - return Undefined(); -} -void GitCommit::ParentsWork(uv_work_t* req) { - ParentsBaton* baton = static_cast(req->data); - - int parentCount = git_commit_parentcount(baton->rawCommit); - while (parentCount > 0) { - git_commit* rawParentCommit = NULL; - - int parentIndex = parentCount -1; - int returnCode = git_commit_parent(&rawParentCommit, baton->rawCommit, parentIndex); - - if (returnCode != GIT_OK) { - baton->error = giterr_last(); - return; + git_commit *ancestor = NULL; + unsigned int from_n; + from_n = (unsigned int) args[0]->ToUint32()->Value(); + + int result = git_commit_nth_gen_ancestor( + &ancestor + , ObjectWrap::Unwrap(args.This())->GetValue() + , from_n + ); + if (result != GIT_OK) { + if (giterr_last()) { + return ThrowException(Exception::Error(String::New(giterr_last()->message))); + } else { + return ThrowException(Exception::Error(String::New("Unkown Error"))); } - - const git_oid* rawParentOid = git_commit_id(rawParentCommit); - - Parent* parent = new Parent; - parent->rawCommit = rawParentCommit; - parent->rawOid = rawParentOid; - - baton->parents.push_back(parent); - - parentCount--; } -} -void GitCommit::ParentsAfterWork(uv_work_t* req) { - HandleScope scope; - ParentsBaton* baton = static_cast(req->data); - if (success(baton->error, baton->callback)) { - std::vector > parents; - - for(std::vector::iterator parentIterator = baton->parents.begin(); parentIterator != baton->parents.end(); ++parentIterator) { - Parent *parentData = (*parentIterator); - - Local parent = GitCommit::constructor_template->NewInstance(); - GitCommit *parentInstance = ObjectWrap::Unwrap(parent); - parentInstance->SetValue(parentData->rawCommit); - parentInstance->SetOid(const_cast(parentData->rawOid)); - - parents.push_back(parent); - } - - Handle argv[2] = { - Local::New(Null()), - cvv8::CastToJS(parents) - }; - - TryCatch try_catch; - baton->callback->Call(Context::GetCurrent()->Global(), 2, argv); - if (try_catch.HasCaught()) { - node::FatalException(try_catch); - } + Handle to; + if (ancestor != NULL) { + to = GitCommit::New((void *)ancestor); + } else { + to = Null(); } - delete req; + return scope.Close(to); } Persistent GitCommit::constructor_template; diff --git a/src/delta.cc b/src/delta.cc new file mode 100644 index 000000000..7b45d35f9 --- /dev/null +++ b/src/delta.cc @@ -0,0 +1,138 @@ +/** + * This code is auto-generated; unless you know what you're doing, do not modify! + **/ +#include +#include +#include + +#include "git2.h" + +#include "../include/functions/copy.h" + +#include "../include/delta.h" +#include "../include/diff_file.h" + +using namespace v8; +using namespace node; + +GitDelta::GitDelta(git_diff_delta *raw) { + this->raw = raw; +} + +GitDelta::~GitDelta() { + free(this->raw); +} + +void GitDelta::Initialize(Handle target) { + HandleScope scope; + + Local tpl = FunctionTemplate::New(New); + + tpl->InstanceTemplate()->SetInternalFieldCount(1); + tpl->SetClassName(String::NewSymbol("Delta")); + + + NODE_SET_PROTOTYPE_METHOD(tpl, "oldFile", OldFile); + NODE_SET_PROTOTYPE_METHOD(tpl, "newFile", NewFile); + NODE_SET_PROTOTYPE_METHOD(tpl, "status", Status); + NODE_SET_PROTOTYPE_METHOD(tpl, "similarity", Similarity); + NODE_SET_PROTOTYPE_METHOD(tpl, "flags", Flags); + + constructor_template = Persistent::New(tpl->GetFunction()); + target->Set(String::NewSymbol("Delta"), constructor_template); +} + +Handle GitDelta::New(const Arguments& args) { + HandleScope scope; + + if (args.Length() == 0 || !args[0]->IsExternal()) { + return ThrowException(Exception::Error(String::New("git_diff_delta is required."))); + } + + GitDelta* object = new GitDelta((git_diff_delta *) External::Unwrap(args[0])); + object->Wrap(args.This()); + + return scope.Close(args.This()); +} + +Handle GitDelta::New(void *raw) { + HandleScope scope; + Handle argv[1] = { External::New((void *)raw) }; + return scope.Close(GitDelta::constructor_template->NewInstance(1, argv)); +} + +git_diff_delta *GitDelta::GetValue() { + return this->raw; +} + + +Handle GitDelta::OldFile(const Arguments& args) { + HandleScope scope; + Handle to; + + git_diff_file *old_file = + &ObjectWrap::Unwrap(args.This())->GetValue()->old_file; + + if (old_file != NULL) { + old_file = (git_diff_file *)git_diff_file_dup(old_file); + } + if (old_file != NULL) { + to = GitDiffFile::New((void *)old_file); + } else { + to = Null(); + } + return scope.Close(to); +} + +Handle GitDelta::NewFile(const Arguments& args) { + HandleScope scope; + Handle to; + + git_diff_file *new_file = + &ObjectWrap::Unwrap(args.This())->GetValue()->new_file; + + if (new_file != NULL) { + new_file = (git_diff_file *)git_diff_file_dup(new_file); + } + if (new_file != NULL) { + to = GitDiffFile::New((void *)new_file); + } else { + to = Null(); + } + return scope.Close(to); +} + +Handle GitDelta::Status(const Arguments& args) { + HandleScope scope; + Handle to; + + git_delta_t status = + ObjectWrap::Unwrap(args.This())->GetValue()->status; + + to = Integer::New(status); + return scope.Close(to); +} + +Handle GitDelta::Similarity(const Arguments& args) { + HandleScope scope; + Handle to; + + uint32_t similarity = + ObjectWrap::Unwrap(args.This())->GetValue()->similarity; + + to = Integer::New(similarity); + return scope.Close(to); +} + +Handle GitDelta::Flags(const Arguments& args) { + HandleScope scope; + Handle to; + + uint32_t flags = + ObjectWrap::Unwrap(args.This())->GetValue()->flags; + + to = Integer::New(flags); + return scope.Close(to); +} + +Persistent GitDelta::constructor_template; diff --git a/src/diff.cc b/src/diff.cc new file mode 100644 index 000000000..2573941ef --- /dev/null +++ b/src/diff.cc @@ -0,0 +1,519 @@ +/** + * This code is auto-generated; unless you know what you're doing, do not modify! + **/ +#include +#include +#include + +#include "git2.h" + +#include "../include/diff.h" + +#include "../include/functions/utilities.h" +#include "../include/functions/string.h" + +using namespace v8; +using namespace node; + +GitDiff::GitDiff(git_diff_list *raw) { + this->raw = raw; +} + +GitDiff::~GitDiff() { + git_diff_list_free(this->raw); +} + +void GitDiff::Initialize(Handle target) { + HandleScope scope; + + Local tpl = FunctionTemplate::New(New); + + tpl->InstanceTemplate()->SetInternalFieldCount(1); + tpl->SetClassName(String::NewSymbol("Diff")); + + NODE_SET_METHOD(tpl, "treeToTree", TreeToTree); + NODE_SET_METHOD(tpl, "treeToIndex", TreeToIndex); + NODE_SET_METHOD(tpl, "indexToWorkdir", IndexToWorkdir); + NODE_SET_METHOD(tpl, "treeToWorkdir", TreeToWorkdir); + NODE_SET_PROTOTYPE_METHOD(tpl, "merge", Merge); + NODE_SET_PROTOTYPE_METHOD(tpl, "findSimilar", FindSimilar); + NODE_SET_METHOD(tpl, "statusChar", StatusChar); + NODE_SET_PROTOTYPE_METHOD(tpl, "numDeltas", NumDeltas); + NODE_SET_METHOD(tpl, "numDeltasOfType", NumDeltasOfType); + NODE_SET_PROTOTYPE_METHOD(tpl, "getPatch", GetPatch); + + + constructor_template = Persistent::New(tpl->GetFunction()); + target->Set(String::NewSymbol("Diff"), constructor_template); +} + +Handle GitDiff::New(const Arguments& args) { + HandleScope scope; + + if (args.Length() == 0 || !args[0]->IsExternal()) { + return ThrowException(Exception::Error(String::New("git_diff_list is required."))); + } + + GitDiff* object = new GitDiff((git_diff_list *) External::Unwrap(args[0])); + object->Wrap(args.This()); + + return scope.Close(args.This()); +} + +git_diff_list *GitDiff::GetValue() { + return this->raw; +} + + +Handle GitDiff::TreeToTree(const Arguments& args) { + HandleScope scope; + + if (args.Length() == 0 || !args[0]->IsObject()) { + return ThrowException(Exception::Error(String::New("Repository repo is required."))); + } + if (args.Length() == 1 || !args[1]->IsObject()) { + return ThrowException(Exception::Error(String::New("Tree old_tree is required."))); + } + if (args.Length() == 2 || !args[2]->IsObject()) { + return ThrowException(Exception::Error(String::New("Tree new_tree is required."))); + } + if (args.Length() == 3 || !args[3]->IsObject()) { + return ThrowException(Exception::Error(String::New("DiffOptions opts is required."))); + } + if (args.Length() == 4 || !args[4]->IsFunction()) { + return ThrowException(Exception::Error(String::New("Callback is required and must be a Function."))); + } + + TreeToTreeBaton* baton = new TreeToTreeBaton; + baton->error = NULL; + baton->request.data = baton; + baton->repoReference = Persistent::New(args[0]); + baton->repo = ObjectWrap::Unwrap(args[0]->ToObject())->GetValue(); + baton->old_treeReference = Persistent::New(args[1]); + baton->old_tree = ObjectWrap::Unwrap(args[1]->ToObject())->GetValue(); + baton->new_treeReference = Persistent::New(args[2]); + baton->new_tree = ObjectWrap::Unwrap(args[2]->ToObject())->GetValue(); + baton->optsReference = Persistent::New(args[3]); + baton->opts = ObjectWrap::Unwrap(args[3]->ToObject())->GetValue(); + baton->callback = Persistent::New(Local::Cast(args[4])); + + uv_queue_work(uv_default_loop(), &baton->request, TreeToTreeWork, (uv_after_work_cb)TreeToTreeAfterWork); + + return Undefined(); +} + +void GitDiff::TreeToTreeWork(uv_work_t *req) { + TreeToTreeBaton *baton = static_cast(req->data); + int diff = git_diff_tree_to_tree( + &baton->diff, + baton->repo, + baton->old_tree, + baton->new_tree, + baton->opts + ); + if (diff != GIT_OK) { + baton->error = giterr_last(); + } +} + +void GitDiff::TreeToTreeAfterWork(uv_work_t *req) { + HandleScope scope; + TreeToTreeBaton *baton = static_cast(req->data); + + TryCatch try_catch; + if (!baton->error) { + Handle argv[1] = { External::New(baton->diff) }; + Handle diff = GitDiffList::constructor_template->NewInstance(1, argv); + Handle argv2[2] = { + Local::New(Null()), + diff + }; + baton->callback->Call(Context::GetCurrent()->Global(), 2, argv2); + } else { + Handle argv2[1] = { + GitError::WrapError(baton->error) + }; + baton->callback->Call(Context::GetCurrent()->Global(), 1, argv2); + } + + if (try_catch.HasCaught()) { + node::FatalException(try_catch); + } + baton->repoReference.Dispose(); + baton->old_treeReference.Dispose(); + baton->new_treeReference.Dispose(); + baton->optsReference.Dispose(); + baton->callback.Dispose(); + delete baton; +} + +Handle GitDiff::TreeToIndex(const Arguments& args) { + HandleScope scope; + + if (args.Length() == 0 || !args[0]->IsObject()) { + return ThrowException(Exception::Error(String::New("Repository repo is required."))); + } + if (args.Length() == 1 || !args[1]->IsObject()) { + return ThrowException(Exception::Error(String::New("Tree old_tree is required."))); + } + if (args.Length() == 2 || !args[2]->IsObject()) { + return ThrowException(Exception::Error(String::New("Index index is required."))); + } + if (args.Length() == 3 || !args[3]->IsObject()) { + return ThrowException(Exception::Error(String::New("DiffOptions opts is required."))); + } + if (args.Length() == 4 || !args[4]->IsFunction()) { + return ThrowException(Exception::Error(String::New("Callback is required and must be a Function."))); + } + + TreeToIndexBaton* baton = new TreeToIndexBaton; + baton->error = NULL; + baton->request.data = baton; + baton->repoReference = Persistent::New(args[0]); + baton->repo = ObjectWrap::Unwrap(args[0]->ToObject())->GetValue(); + baton->old_treeReference = Persistent::New(args[1]); + baton->old_tree = ObjectWrap::Unwrap(args[1]->ToObject())->GetValue(); + baton->indexReference = Persistent::New(args[2]); + baton->index = ObjectWrap::Unwrap(args[2]->ToObject())->GetValue(); + baton->optsReference = Persistent::New(args[3]); + baton->opts = ObjectWrap::Unwrap(args[3]->ToObject())->GetValue(); + baton->callback = Persistent::New(Local::Cast(args[4])); + + uv_queue_work(uv_default_loop(), &baton->request, TreeToIndexWork, (uv_after_work_cb)TreeToIndexAfterWork); + + return Undefined(); +} + +void GitDiff::TreeToIndexWork(uv_work_t *req) { + TreeToIndexBaton *baton = static_cast(req->data); + int diff = git_diff_tree_to_index( + &baton->diff, + baton->repo, + baton->old_tree, + baton->index, + baton->opts + ); + if (diff != GIT_OK) { + baton->error = giterr_last(); + } +} + +void GitDiff::TreeToIndexAfterWork(uv_work_t *req) { + HandleScope scope; + TreeToIndexBaton *baton = static_cast(req->data); + + TryCatch try_catch; + if (!baton->error) { + Handle argv[1] = { External::New(baton->diff) }; + Handle diff = GitDiffList::constructor_template->NewInstance(1, argv); + Handle argv2[2] = { + Local::New(Null()), + diff + }; + baton->callback->Call(Context::GetCurrent()->Global(), 2, argv2); + } else { + Handle argv2[1] = { + GitError::WrapError(baton->error) + }; + baton->callback->Call(Context::GetCurrent()->Global(), 1, argv2); + } + + if (try_catch.HasCaught()) { + node::FatalException(try_catch); + } + baton->repoReference.Dispose(); + baton->old_treeReference.Dispose(); + baton->indexReference.Dispose(); + baton->optsReference.Dispose(); + baton->callback.Dispose(); + delete baton; +} + +Handle GitDiff::IndexToWorkdir(const Arguments& args) { + HandleScope scope; + + if (args.Length() == 0 || !args[0]->IsObject()) { + return ThrowException(Exception::Error(String::New("Repository repo is required."))); + } + if (args.Length() == 1 || !args[1]->IsObject()) { + return ThrowException(Exception::Error(String::New("Index index is required."))); + } + if (args.Length() == 2 || !args[2]->IsObject()) { + return ThrowException(Exception::Error(String::New("DiffOptions opts is required."))); + } + if (args.Length() == 3 || !args[3]->IsFunction()) { + return ThrowException(Exception::Error(String::New("Callback is required and must be a Function."))); + } + + IndexToWorkdirBaton* baton = new IndexToWorkdirBaton; + baton->error = NULL; + baton->request.data = baton; + baton->repoReference = Persistent::New(args[0]); + baton->repo = ObjectWrap::Unwrap(args[0]->ToObject())->GetValue(); + baton->indexReference = Persistent::New(args[1]); + baton->index = ObjectWrap::Unwrap(args[1]->ToObject())->GetValue(); + baton->optsReference = Persistent::New(args[2]); + baton->opts = ObjectWrap::Unwrap(args[2]->ToObject())->GetValue(); + baton->callback = Persistent::New(Local::Cast(args[3])); + + uv_queue_work(uv_default_loop(), &baton->request, IndexToWorkdirWork, (uv_after_work_cb)IndexToWorkdirAfterWork); + + return Undefined(); +} + +void GitDiff::IndexToWorkdirWork(uv_work_t *req) { + IndexToWorkdirBaton *baton = static_cast(req->data); + int diff = git_diff_index_to_workdir( + &baton->diff, + baton->repo, + baton->index, + baton->opts + ); + if (diff != GIT_OK) { + baton->error = giterr_last(); + } +} + +void GitDiff::IndexToWorkdirAfterWork(uv_work_t *req) { + HandleScope scope; + IndexToWorkdirBaton *baton = static_cast(req->data); + + TryCatch try_catch; + if (!baton->error) { + Handle argv[1] = { External::New(baton->diff) }; + Handle diff = GitDiffList::constructor_template->NewInstance(1, argv); + Handle argv2[2] = { + Local::New(Null()), + diff + }; + baton->callback->Call(Context::GetCurrent()->Global(), 2, argv2); + } else { + Handle argv2[1] = { + GitError::WrapError(baton->error) + }; + baton->callback->Call(Context::GetCurrent()->Global(), 1, argv2); + } + + if (try_catch.HasCaught()) { + node::FatalException(try_catch); + } + baton->repoReference.Dispose(); + baton->indexReference.Dispose(); + baton->optsReference.Dispose(); + baton->callback.Dispose(); + delete baton; +} + +Handle GitDiff::TreeToWorkdir(const Arguments& args) { + HandleScope scope; + + if (args.Length() == 0 || !args[0]->IsObject()) { + return ThrowException(Exception::Error(String::New("Repository repo is required."))); + } + if (args.Length() == 1 || !args[1]->IsObject()) { + return ThrowException(Exception::Error(String::New("Tree old_tree is required."))); + } + if (args.Length() == 2 || !args[2]->IsObject()) { + return ThrowException(Exception::Error(String::New("DiffOptions opts is required."))); + } + if (args.Length() == 3 || !args[3]->IsFunction()) { + return ThrowException(Exception::Error(String::New("Callback is required and must be a Function."))); + } + + TreeToWorkdirBaton* baton = new TreeToWorkdirBaton; + baton->error = NULL; + baton->request.data = baton; + baton->repoReference = Persistent::New(args[0]); + baton->repo = ObjectWrap::Unwrap(args[0]->ToObject())->GetValue(); + baton->old_treeReference = Persistent::New(args[1]); + baton->old_tree = ObjectWrap::Unwrap(args[1]->ToObject())->GetValue(); + baton->optsReference = Persistent::New(args[2]); + baton->opts = ObjectWrap::Unwrap(args[2]->ToObject())->GetValue(); + baton->callback = Persistent::New(Local::Cast(args[3])); + + uv_queue_work(uv_default_loop(), &baton->request, TreeToWorkdirWork, (uv_after_work_cb)TreeToWorkdirAfterWork); + + return Undefined(); +} + +void GitDiff::TreeToWorkdirWork(uv_work_t *req) { + TreeToWorkdirBaton *baton = static_cast(req->data); + int diff = git_diff_tree_to_workdir( + &baton->diff, + baton->repo, + baton->old_tree, + baton->opts + ); + if (diff != GIT_OK) { + baton->error = giterr_last(); + } +} + +void GitDiff::TreeToWorkdirAfterWork(uv_work_t *req) { + HandleScope scope; + TreeToWorkdirBaton *baton = static_cast(req->data); + + TryCatch try_catch; + if (!baton->error) { + Handle argv[1] = { External::New(baton->diff) }; + Handle diff = GitDiffList::constructor_template->NewInstance(1, argv); + Handle argv2[2] = { + Local::New(Null()), + diff + }; + baton->callback->Call(Context::GetCurrent()->Global(), 2, argv2); + } else { + Handle argv2[1] = { + GitError::WrapError(baton->error) + }; + baton->callback->Call(Context::GetCurrent()->Global(), 1, argv2); + } + + if (try_catch.HasCaught()) { + node::FatalException(try_catch); + } + baton->repoReference.Dispose(); + baton->old_treeReference.Dispose(); + baton->optsReference.Dispose(); + baton->callback.Dispose(); + delete baton; +} + +Handle GitDiff::Merge(const Arguments& args) { + HandleScope scope; + + if (args.Length() == 0 || !args[0]->IsObject()) { + return ThrowException(Exception::Error(String::New("DiffList from is required."))); + } + + int result = git_diff_merge( + + + ObjectWrap::Unwrap(args.This())->GetValue() +, + + ObjectWrap::Unwrap(args[0]->ToObject())->GetValue() + ); + + if (result != GIT_OK) { + return ThrowException(GitError::WrapError(giterr_last())); + } + + return scope.Close(Int32::New(result)); +} + +Handle GitDiff::FindSimilar(const Arguments& args) { + HandleScope scope; + + if (args.Length() == 0 || !args[0]->IsObject()) { + return ThrowException(Exception::Error(String::New("DiffFindOptions options is required."))); + } + + int result = git_diff_find_similar( + + + ObjectWrap::Unwrap(args.This())->GetValue() +, + + ObjectWrap::Unwrap(args[0]->ToObject())->GetValue() + ); + + if (result != GIT_OK) { + return ThrowException(GitError::WrapError(giterr_last())); + } + + return scope.Close(Int32::New(result)); +} + +Handle GitDiff::StatusChar(const Arguments& args) { + HandleScope scope; + + if (args.Length() == 0 || !args[0]->IsInt32()) { + return ThrowException(Exception::Error(String::New("Number status is required."))); + } + + char result = git_diff_status_char( + + + (git_delta_t) args[0]->ToInt32()->Value() + ); + + + return scope.Close(String::New(result)); +} + +Handle GitDiff::NumDeltas(const Arguments& args) { + HandleScope scope; + + size_t result = git_diff_num_deltas( + + + ObjectWrap::Unwrap(args.This())->GetValue() + ); + + + return scope.Close(Uint32::New(result)); +} + +Handle GitDiff::NumDeltasOfType(const Arguments& args) { + HandleScope scope; + + if (args.Length() == 0 || !args[0]->IsObject()) { + return ThrowException(Exception::Error(String::New("DiffList diff is required."))); + } + + if (args.Length() == 1 || !args[1]->IsInt32()) { + return ThrowException(Exception::Error(String::New("Number type is required."))); + } + + size_t result = git_diff_num_deltas_of_type( + + + ObjectWrap::Unwrap(args[0]->ToObject())->GetValue() +, + + (git_delta_t) args[1]->ToInt32()->Value() + ); + + + return scope.Close(Uint32::New(result)); +} + +Handle GitDiff::GetPatch(const Arguments& args) { + HandleScope scope; + + if (args.Length() == 0 || !args[0]->IsObject()) { + return ThrowException(Exception::Error(String::New("DiffDelta delta_out is required."))); + } + + if (args.Length() == 1 || !args[1]->IsUint32()) { + return ThrowException(Exception::Error(String::New("Number idx is required."))); + } + git_diff_patch * patch_out; + + int result = git_diff_get_patch( + +& + patch_out +, +& + ObjectWrap::Unwrap(args[0]->ToObject())->GetValue() +, + + ObjectWrap::Unwrap(args.This())->GetValue() +, + + (size_t) args[1]->ToUint32()->Value() + ); + + if (result != GIT_OK) { + return ThrowException(GitError::WrapError(giterr_last())); + } + + // XXX need to copy object? + Handle argv[1] = { External::New((void *)patch_out) }; + return scope.Close(DiffPatch::constructor_template->NewInstance(1, argv)); +} + + +Persistent GitDiff::constructor_template; diff --git a/src/diff_file.cc b/src/diff_file.cc new file mode 100644 index 000000000..c96d4c8be --- /dev/null +++ b/src/diff_file.cc @@ -0,0 +1,131 @@ +/** + * This code is auto-generated; unless you know what you're doing, do not modify! + **/ +#include +#include +#include + +#include "git2.h" + +#include "../include/functions/copy.h" + +#include "../include/diff_file.h" +#include "../include/oid.h" + +using namespace v8; +using namespace node; + +GitDiffFile::GitDiffFile(git_diff_file *raw) { + this->raw = raw; +} + +GitDiffFile::~GitDiffFile() { + free(this->raw); +} + +void GitDiffFile::Initialize(Handle target) { + HandleScope scope; + + Local tpl = FunctionTemplate::New(New); + + tpl->InstanceTemplate()->SetInternalFieldCount(1); + tpl->SetClassName(String::NewSymbol("DiffFile")); + + + NODE_SET_PROTOTYPE_METHOD(tpl, "oid", Oid); + NODE_SET_PROTOTYPE_METHOD(tpl, "path", Path); + NODE_SET_PROTOTYPE_METHOD(tpl, "size", Size); + NODE_SET_PROTOTYPE_METHOD(tpl, "flags", Flags); + NODE_SET_PROTOTYPE_METHOD(tpl, "mode", Mode); + + constructor_template = Persistent::New(tpl->GetFunction()); + target->Set(String::NewSymbol("DiffFile"), constructor_template); +} + +Handle GitDiffFile::New(const Arguments& args) { + HandleScope scope; + + if (args.Length() == 0 || !args[0]->IsExternal()) { + return ThrowException(Exception::Error(String::New("git_diff_file is required."))); + } + + GitDiffFile* object = new GitDiffFile((git_diff_file *) External::Unwrap(args[0])); + object->Wrap(args.This()); + + return scope.Close(args.This()); +} + +Handle GitDiffFile::New(void *raw) { + HandleScope scope; + Handle argv[1] = { External::New((void *)raw) }; + return scope.Close(GitDiffFile::constructor_template->NewInstance(1, argv)); +} + +git_diff_file *GitDiffFile::GetValue() { + return this->raw; +} + + +Handle GitDiffFile::Oid(const Arguments& args) { + HandleScope scope; + Handle to; + + git_oid *oid = + &ObjectWrap::Unwrap(args.This())->GetValue()->oid; + + if (oid != NULL) { + oid = (git_oid *)git_oid_dup(oid); + } + if (oid != NULL) { + to = GitOid::New((void *)oid); + } else { + to = Null(); + } + return scope.Close(to); +} + +Handle GitDiffFile::Path(const Arguments& args) { + HandleScope scope; + Handle to; + + const char * path = + ObjectWrap::Unwrap(args.This())->GetValue()->path; + + to = String::New(path); + return scope.Close(to); +} + +Handle GitDiffFile::Size(const Arguments& args) { + HandleScope scope; + Handle to; + + git_off_t size = + ObjectWrap::Unwrap(args.This())->GetValue()->size; + + to = Integer::New(size); + return scope.Close(to); +} + +Handle GitDiffFile::Flags(const Arguments& args) { + HandleScope scope; + Handle to; + + uint32_t flags = + ObjectWrap::Unwrap(args.This())->GetValue()->flags; + + to = Integer::New(flags); + return scope.Close(to); +} + +Handle GitDiffFile::Mode(const Arguments& args) { + HandleScope scope; + Handle to; + + uint16_t mode = + ObjectWrap::Unwrap(args.This())->GetValue()->mode; + + to = Integer::New(mode); + return scope.Close(to); +} + +Persistent GitDiffFile::constructor_template; diff --git a/src/diff_find_options.cc b/src/diff_find_options.cc new file mode 100644 index 000000000..f6fd85756 --- /dev/null +++ b/src/diff_find_options.cc @@ -0,0 +1,63 @@ +/** + * This code is auto-generated; unless you know what you're doing, do not modify! + **/ +#include +#include +#include + +#include "git2.h" + +#include "../include/functions/copy.h" + +#include "../include/diff_find_options.h" + +using namespace v8; +using namespace node; + +GitDiffFindOptions::GitDiffFindOptions(git_diff_find_options *raw) { + this->raw = raw; +} + +GitDiffFindOptions::~GitDiffFindOptions() { + free(this->raw); +} + +void GitDiffFindOptions::Initialize(Handle target) { + HandleScope scope; + + Local tpl = FunctionTemplate::New(New); + + tpl->InstanceTemplate()->SetInternalFieldCount(1); + tpl->SetClassName(String::NewSymbol("DiffFindOptions")); + + + + constructor_template = Persistent::New(tpl->GetFunction()); + target->Set(String::NewSymbol("DiffFindOptions"), constructor_template); +} + +Handle GitDiffFindOptions::New(const Arguments& args) { + HandleScope scope; + + if (args.Length() == 0 || !args[0]->IsExternal()) { + return ThrowException(Exception::Error(String::New("git_diff_find_options is required."))); + } + + GitDiffFindOptions* object = new GitDiffFindOptions((git_diff_find_options *) External::Unwrap(args[0])); + object->Wrap(args.This()); + + return scope.Close(args.This()); +} + +Handle GitDiffFindOptions::New(void *raw) { + HandleScope scope; + Handle argv[1] = { External::New((void *)raw) }; + return scope.Close(GitDiffFindOptions::constructor_template->NewInstance(1, argv)); +} + +git_diff_find_options *GitDiffFindOptions::GetValue() { + return this->raw; +} + + +Persistent GitDiffFindOptions::constructor_template; diff --git a/src/diff_list.cc b/src/diff_list.cc index 1204f6399..37691b435 100755 --- a/src/diff_list.cc +++ b/src/diff_list.cc @@ -1,32 +1,35 @@ -/* - * Copyright 2011, Tim Branyen @tbranyen - * @author Michael Robinson @codeofinterest - * - * Dual licensed under the MIT and GPL licenses. - */ - +/** + * This code is auto-generated; unless you know what you're doing, do not modify! + **/ #include #include +#include -#include "cvv8/v8-convert.hpp" #include "git2.h" -#include "../include/diff_list.h" -#include "../include/error.h" +#include "../include/functions/copy.h" -#include "../include/functions/string.h" -#include "../include/functions/utilities.h" +#include "../include/diff_list.h" +#include "../include/diff_options.h" +#include "../include/diff_find_options.h" +#include "../include/repo.h" +#include "../include/tree.h" +#include "../include/index.h" +#include "../include/patch.h" +#include "../include/delta.h" using namespace v8; using namespace node; -using namespace cvv8; -namespace cvv8 { - template <> - struct NativeToJS : NativeToJS {}; +GitDiffList::GitDiffList(git_diff_list *raw) { + this->raw = raw; } -void GitDiffList::Initialize(Handle target) { +GitDiffList::~GitDiffList() { + git_diff_list_free(this->raw); +} + +void GitDiffList::Initialize(Handle target) { HandleScope scope; Local tpl = FunctionTemplate::New(New); @@ -34,466 +37,187 @@ void GitDiffList::Initialize(Handle target) { tpl->InstanceTemplate()->SetInternalFieldCount(1); tpl->SetClassName(String::NewSymbol("DiffList")); - NODE_SET_PROTOTYPE_METHOD(tpl, "treeToTree", TreeToTree); - NODE_SET_PROTOTYPE_METHOD(tpl, "walk", Walk); - NODE_SET_PROTOTYPE_METHOD(tpl, "free", Free); - - // Add libgit2 delta types to diff_list object - Local libgit2DeltaTypes = Object::New(); - - libgit2DeltaTypes->Set(String::NewSymbol("GIT_DELTA_UNMODIFIED"), cvv8::CastToJS(GIT_DELTA_UNMODIFIED), ReadOnly); - libgit2DeltaTypes->Set(String::NewSymbol("GIT_DELTA_ADDED"), cvv8::CastToJS(GIT_DELTA_ADDED), ReadOnly); - libgit2DeltaTypes->Set(String::NewSymbol("GIT_DELTA_DELETED"), cvv8::CastToJS(GIT_DELTA_DELETED), ReadOnly); - libgit2DeltaTypes->Set(String::NewSymbol("GIT_DELTA_MODIFIED"), cvv8::CastToJS(GIT_DELTA_MODIFIED), ReadOnly); - libgit2DeltaTypes->Set(String::NewSymbol("GIT_DELTA_RENAMED"), cvv8::CastToJS(GIT_DELTA_RENAMED), ReadOnly); - libgit2DeltaTypes->Set(String::NewSymbol("GIT_DELTA_COPIED"), cvv8::CastToJS(GIT_DELTA_COPIED), ReadOnly); - libgit2DeltaTypes->Set(String::NewSymbol("GIT_DELTA_IGNORED"), cvv8::CastToJS(GIT_DELTA_IGNORED), ReadOnly); - libgit2DeltaTypes->Set(String::NewSymbol("GIT_DELTA_UNTRACKED"), cvv8::CastToJS(GIT_DELTA_UNTRACKED), ReadOnly); - libgit2DeltaTypes->Set(String::NewSymbol("GIT_DELTA_TYPECHANGE"), cvv8::CastToJS(GIT_DELTA_TYPECHANGE), ReadOnly); - - Local libgit2LineOriginConstants = Object::New(); - - // @todo refactor this into something sane - char _GIT_DIFF_LINE_CONTEXT[2]; - _GIT_DIFF_LINE_CONTEXT[0] = GIT_DIFF_LINE_CONTEXT; - _GIT_DIFF_LINE_CONTEXT[1] = '\0'; - libgit2LineOriginConstants->Set(String::NewSymbol("GIT_DIFF_LINE_CONTEXT"), cvv8::CastToJS(_GIT_DIFF_LINE_CONTEXT), ReadOnly); - - char _GIT_DIFF_LINE_ADDITION[2]; - _GIT_DIFF_LINE_ADDITION[0] = GIT_DIFF_LINE_ADDITION; - _GIT_DIFF_LINE_ADDITION[1] = '\0'; - libgit2LineOriginConstants->Set(String::NewSymbol("GIT_DIFF_LINE_ADDITION"), cvv8::CastToJS(_GIT_DIFF_LINE_ADDITION), ReadOnly); - - char _GIT_DIFF_LINE_DELETION[2]; - _GIT_DIFF_LINE_DELETION[0] = GIT_DIFF_LINE_DELETION; - _GIT_DIFF_LINE_DELETION[1] = '\0'; - libgit2LineOriginConstants->Set(String::NewSymbol("GIT_DIFF_LINE_DELETION"), cvv8::CastToJS(_GIT_DIFF_LINE_DELETION), ReadOnly); - - char _GIT_DIFF_LINE_ADD_EOFNL[2]; - _GIT_DIFF_LINE_ADD_EOFNL[0] = GIT_DIFF_LINE_ADD_EOFNL; - _GIT_DIFF_LINE_ADD_EOFNL[1] = '\0'; - libgit2LineOriginConstants->Set(String::NewSymbol("GIT_DIFF_LINE_ADD_EOFNL"), cvv8::CastToJS(_GIT_DIFF_LINE_ADD_EOFNL), ReadOnly); - - char _GIT_DIFF_LINE_DEL_EOFNL[2]; - _GIT_DIFF_LINE_DEL_EOFNL[0] = GIT_DIFF_LINE_DEL_EOFNL; - _GIT_DIFF_LINE_DEL_EOFNL[1] = '\0'; - libgit2LineOriginConstants->Set(String::NewSymbol("GIT_DIFF_LINE_DEL_EOFNL"), cvv8::CastToJS(_GIT_DIFF_LINE_DEL_EOFNL), ReadOnly); - - char _GIT_DIFF_LINE_FILE_HDR[2]; - _GIT_DIFF_LINE_FILE_HDR[0] = GIT_DIFF_LINE_FILE_HDR; - _GIT_DIFF_LINE_FILE_HDR[1] = '\0'; - libgit2LineOriginConstants->Set(String::NewSymbol("GIT_DIFF_LINE_FILE_HDR"), cvv8::CastToJS(_GIT_DIFF_LINE_FILE_HDR), ReadOnly); - - char _GIT_DIFF_LINE_HUNK_HDR[2]; - _GIT_DIFF_LINE_HUNK_HDR[0] = GIT_DIFF_LINE_HUNK_HDR; - _GIT_DIFF_LINE_HUNK_HDR[1] = '\0'; - libgit2LineOriginConstants->Set(String::NewSymbol("GIT_DIFF_LINE_HUNK_HDR"), cvv8::CastToJS(_GIT_DIFF_LINE_HUNK_HDR), ReadOnly); - - char _GIT_DIFF_LINE_BINARY[2]; - _GIT_DIFF_LINE_BINARY[0] = GIT_DIFF_LINE_BINARY; - _GIT_DIFF_LINE_BINARY[1] = '\0'; - libgit2LineOriginConstants->Set(String::NewSymbol("GIT_DIFF_LINE_BINARY"), cvv8::CastToJS(_GIT_DIFF_LINE_BINARY), ReadOnly); + NODE_SET_PROTOTYPE_METHOD(tpl, "merge", Merge); + NODE_SET_PROTOTYPE_METHOD(tpl, "findSimilar", FindSimilar); + NODE_SET_PROTOTYPE_METHOD(tpl, "size", Size); + NODE_SET_METHOD(tpl, "numDeltasOfType", NumDeltasOfType); + NODE_SET_PROTOTYPE_METHOD(tpl, "patch", Patch); + constructor_template = Persistent::New(tpl->GetFunction()); - constructor_template->Set(String::NewSymbol("deltaTypes"), libgit2DeltaTypes, ReadOnly); - constructor_template->Set(String::NewSymbol("lineOriginTypes"), libgit2LineOriginConstants, ReadOnly); target->Set(String::NewSymbol("DiffList"), constructor_template); } -git_diff_list* GitDiffList::GetValue() { - return this->diffList; -} - -void GitDiffList::SetValue(git_diff_list* diffList) { - this->diffList = diffList; -} - Handle GitDiffList::New(const Arguments& args) { HandleScope scope; - GitDiffList *diffList = new GitDiffList(); - diffList->Wrap(args.This()); - - return scope.Close(args.This()); -} -Handle GitDiffList::Free(const Arguments& args) { - HandleScope scope; + if (args.Length() == 0 || !args[0]->IsExternal()) { + return ThrowException(Exception::Error(String::New("git_diff_list is required."))); + } - GitDiffList *diffList = ObjectWrap::Unwrap(args.This()); - git_diff_list_free(diffList->diffList); - diffList->diffList = NULL; + GitDiffList* object = new GitDiffList((git_diff_list *) External::Unwrap(args[0])); + object->Wrap(args.This()); - return scope.Close(Undefined()); + return scope.Close(args.This()); } -Handle GitDiffList::TreeToTree(const Arguments& args) { +Handle GitDiffList::New(void *raw) { HandleScope scope; + Handle argv[1] = { External::New((void *)raw) }; + return scope.Close(GitDiffList::constructor_template->NewInstance(1, argv)); +} - if(args.Length() == 0 || !(args[0]->IsObject() || args[0]->IsString())) { - return ThrowException(Exception::Error(String::New("Repo is required and must be an Object or String"))); - } - - if(args.Length() == 1 || !(args[1]->IsObject() || args[1]->IsString())) { - return ThrowException(Exception::Error(String::New("Old Oid/SHA is required and must be an Object or String"))); - } - - if(args.Length() == 2 || !(args[2]->IsObject() || args[2]->IsString())) { - return ThrowException(Exception::Error(String::New("New Oid/SHA is required and must be an Object or String"))); - } - - if(args.Length() == 3 || !args[3]->IsFunction()) { - return ThrowException(Exception::Error(String::New("Callback is required and must be a Function."))); - } - - TreeToTreeBaton *baton = new TreeToTreeBaton; - baton->request.data = baton; - baton->error = NULL; - baton->diffList = ObjectWrap::Unwrap(args.This()); - baton->repo = ObjectWrap::Unwrap(args[0]->ToObject())->GetValue(); +git_diff_list *GitDiffList::GetValue() { + return this->raw; +} - if (args[1]->IsObject()) { - baton->oldOid = ObjectWrap::Unwrap(args[1]->ToObject())->GetValue(); - } else { - baton->oldSha = stringArgToString(args[1]->ToString()); - } - if (args[2]->IsObject()) { - baton->newOid = ObjectWrap::Unwrap(args[2]->ToObject())->GetValue(); - } else { - baton->newSha = stringArgToString(args[2]->ToString()); +/** + * @param {DiffList} from + */ +Handle GitDiffList::Merge(const Arguments& args) { + HandleScope scope; + if (args.Length() == 0 || !args[0]->IsObject()) { + return ThrowException(Exception::Error(String::New("DiffList from is required."))); + } + + const git_diff_list * from_from; + from_from = ObjectWrap::Unwrap(args[0]->ToObject())->GetValue(); + + int result = git_diff_merge( + ObjectWrap::Unwrap(args.This())->GetValue() + , from_from + ); + if (result != GIT_OK) { + if (giterr_last()) { + return ThrowException(Exception::Error(String::New(giterr_last()->message))); + } else { + return ThrowException(Exception::Error(String::New("Unkown Error"))); + } } - baton->callback = Persistent::New(Local::Cast(args[3])); - - uv_queue_work(uv_default_loop(), &baton->request, TreeToTreeWork, (uv_after_work_cb)TreeToTreeAfterWork); - return Undefined(); } -void GitDiffList::TreeToTreeWork(uv_work_t *req) { - TreeToTreeBaton *baton = static_cast(req->data); - - // Prepare git_oid's - git_oid *oldOid = &baton->oldOid; - if (!baton->oldSha.empty()) { - int returnCode = git_oid_fromstr(oldOid, baton->oldSha.c_str()); - if (returnCode != GIT_OK) { - baton->error = giterr_last(); - return; - } - } - git_oid *newOid = &baton->newOid; - if (!baton->newSha.empty()) { - int returnCode = git_oid_fromstr(newOid, baton->newSha.c_str()); - if (returnCode != GIT_OK) { - baton->error = giterr_last(); - return; +/** + * @param {DiffFindOptions} options + */ +Handle GitDiffList::FindSimilar(const Arguments& args) { + HandleScope scope; + if (args.Length() == 0 || !args[0]->IsObject()) { + return ThrowException(Exception::Error(String::New("DiffFindOptions options is required."))); + } + + git_diff_find_options * from_options; + from_options = ObjectWrap::Unwrap(args[0]->ToObject())->GetValue(); + + int result = git_diff_find_similar( + ObjectWrap::Unwrap(args.This())->GetValue() + , from_options + ); + if (result != GIT_OK) { + if (giterr_last()) { + return ThrowException(Exception::Error(String::New(giterr_last()->message))); + } else { + return ThrowException(Exception::Error(String::New("Unkown Error"))); } } - // Get commits - git_commit* oldCommit = NULL; - int returnCode = git_commit_lookup(&oldCommit, baton->repo, oldOid); - if (returnCode != GIT_OK) { - baton->error = giterr_last(); - return; - } - - git_commit* newCommit = NULL; - returnCode = git_commit_lookup(&newCommit, baton->repo, newOid); - if (returnCode != GIT_OK) { - baton->error = giterr_last(); - return; - } - - // Prepare trees - git_tree* oldTree = NULL; - returnCode = git_commit_tree(&oldTree, oldCommit); - if (returnCode != GIT_OK) { - baton->error = giterr_last(); - return; - } - git_tree* newTree = NULL; - returnCode = git_commit_tree(&newTree, newCommit); - if (returnCode != GIT_OK) { - baton->error = giterr_last(); - return; - } - - baton->rawDiffList = NULL; - returnCode = git_diff_tree_to_tree(&baton->rawDiffList, baton->repo, oldTree, newTree, NULL); - if (returnCode != GIT_OK) { - baton->error = giterr_last(); - } + return Undefined(); } -void GitDiffList::TreeToTreeAfterWork(uv_work_t *req) { +/** + * @return {Number} result + */ +Handle GitDiffList::Size(const Arguments& args) { HandleScope scope; - TreeToTreeBaton *baton = static_cast(req->data); + - if (baton->error) { - Local argv[1] = { - GitError::WrapError(baton->error) - }; + size_t result = git_diff_num_deltas( + ObjectWrap::Unwrap(args.This())->GetValue() + ); - TryCatch try_catch; - baton->callback->Call(Context::GetCurrent()->Global(), 1, argv); - if (try_catch.HasCaught()) { - node::FatalException(try_catch); - } - } else { - - baton->diffList->SetValue(baton->rawDiffList); - - Handle argv[2] = { - Local::New(Null()), - baton->diffList->handle_ - }; - - TryCatch try_catch; - baton->callback->Call(Context::GetCurrent()->Global(), 2, argv); - if (try_catch.HasCaught()) { - node::FatalException(try_catch); - } - } - delete req; + Handle to; + to = Uint32::New(result); + return scope.Close(to); } -Handle GitDiffList::Walk(const Arguments& args) { +/** + * @param {DiffList} diff + * @param {Number} type + * @return {Number} result + */ +Handle GitDiffList::NumDeltasOfType(const Arguments& args) { HandleScope scope; - - GitDiffList* diffList = ObjectWrap::Unwrap(args.This()); - - if (diffList->GetValue() == NULL) { - return ThrowException(Exception::Error(String::New("No diff list to Walk."))); - } - - if(args.Length() == 0 || !args[0]->IsFunction()) { - return ThrowException(Exception::Error(String::New("Diff callback is required and must be a Function."))); + if (args.Length() == 0 || !args[0]->IsObject()) { + return ThrowException(Exception::Error(String::New("DiffList diff is required."))); } - - if(args.Length() == 1 || !args[1]->IsFunction()) { - return ThrowException(Exception::Error(String::New("Hunk callback is required and must be a Function."))); + if (args.Length() == 1 || !args[1]->IsInt32()) { + return ThrowException(Exception::Error(String::New("Number type is required."))); } - if(args.Length() == 2 || !args[2]->IsFunction()) { - return ThrowException(Exception::Error(String::New("Line callback is required and must be a Function."))); - } + git_diff_list * from_diff; + from_diff = ObjectWrap::Unwrap(args[0]->ToObject())->GetValue(); + git_delta_t from_type; + from_type = (git_delta_t) args[1]->ToInt32()->Value(); + + size_t result = git_diff_num_deltas_of_type( + from_diff + , from_type + ); - if(args.Length() == 3 || !args[3]->IsFunction()) { - return ThrowException(Exception::Error(String::New("End callback is required and must be a Function."))); - } - - - WalkBaton* baton = new WalkBaton; - uv_async_init(uv_default_loop(), &baton->asyncFile, WalkWorkSendFile); - uv_async_init(uv_default_loop(), &baton->asyncHunk, WalkWorkSendHunk); - uv_async_init(uv_default_loop(), &baton->asyncData, WalkWorkSendData); - uv_async_init(uv_default_loop(), &baton->asyncEnd, WalkWorkSendEnd); - - uv_mutex_init(&baton->mutex); - - baton->rawDiffList = diffList->GetValue(); - diffList->Ref(); - baton->error = NULL; - baton->fileCallback = Persistent::New(Local::Cast(args[0])); - baton->hunkCallback = Persistent::New(Local::Cast(args[1])); - baton->lineCallback = Persistent::New(Local::Cast(args[2])); - baton->endCallback = Persistent::New(Local::Cast(args[3])); - - uv_thread_create(&baton->threadId, WalkWork, baton); - - return Undefined(); + Handle to; + to = Uint32::New(result); + return scope.Close(to); } -void GitDiffList::WalkWork(void *payload) { - WalkBaton *baton = static_cast(payload); - - int returnCode = git_diff_foreach(baton->rawDiffList, WalkWorkFile, WalkWorkHunk, WalkWorkData, payload); - if (returnCode != GIT_OK) { - baton->error = giterr_last(); - baton->asyncEnd.data = baton; - uv_async_send(&baton->asyncEnd); - return; - } - - baton->asyncFile.data = baton; - uv_async_send(&baton->asyncFile); - - baton->asyncEnd.data = baton; - uv_async_send(&baton->asyncEnd); -} -int GitDiffList::WalkWorkFile(const git_diff_delta *delta, float progress, - void *payload) { - WalkBaton *baton = static_cast(payload); - - /* - diff_file_delta - git_diff_file old_file - git_oid oid - const char *path - git_off_t size - uint32_t flags - uint16_t mode - - git_diff_file new_file - git_delta_t status - uint32_t similarity - uint32_t flags - */ - - uv_mutex_lock(&baton->mutex); - - Delta* newDelta = new Delta; - newDelta->raw = (git_diff_delta*)malloc(sizeof(git_diff_delta)); - memcpy(newDelta->raw, delta, sizeof(git_diff_delta)); - - // @todo use combined OID or another less stupid way to index deltas - std::string key(newDelta->raw->old_file.path); - key.append(newDelta->raw->new_file.path); - baton->fileDeltas[key] = newDelta; - uv_mutex_unlock(&baton->mutex); - - if ((unsigned int)baton->fileDeltas.size() == (unsigned int)GitDiffList::WALK_DELTA_SEND_THRESHHOLD) { - baton->asyncFile.data = baton; - uv_async_send(&baton->asyncFile); - } - - return GIT_OK; -} -int GitDiffList::WalkWorkHunk(const git_diff_delta *delta, const git_diff_range *range, const char *header, size_t header_len, void *payload) { - return GIT_OK; -} -int GitDiffList::WalkWorkData(const git_diff_delta *delta, const git_diff_range *range, - char line_origin, const char *content, size_t content_len, - void *payload) { - WalkBaton *baton = static_cast(payload); - uv_mutex_lock(&baton->mutex); - - GitDiffList::DeltaContent *deltaContent = new GitDiffList::DeltaContent; - - deltaContent->range = (git_diff_range*)malloc(sizeof(git_diff_range)); - memcpy(deltaContent->range, range, sizeof(git_diff_range)); - - deltaContent->lineOrigin = line_origin; - - deltaContent->contentLength = content_len; - deltaContent->content = content; - - std::string key(delta->old_file.path); - key.append(delta->new_file.path); - baton->fileDeltas[key]->contents.push_back(deltaContent); - - uv_mutex_unlock(&baton->mutex); - return GIT_OK; -} -void GitDiffList::WalkWorkSendFile(uv_async_t *handle, int status /*UNUSED*/) { +/** + * @param {Number} idx + * @return {Patch} patch_out + * @return {Delta} delta_out + */ +Handle GitDiffList::Patch(const Arguments& args) { HandleScope scope; - - WalkBaton *baton = static_cast(handle->data); - - uv_mutex_lock(&baton->mutex); - if (success(baton->error, baton->fileCallback)) { - - std::vector > fileDeltasArray; - - for(std::map::iterator iterator = baton->fileDeltas.begin(); iterator != baton->fileDeltas.end(); ++iterator) { - - Local fileDelta = Object::New(); - GitDiffList::Delta* delta = iterator->second; - - Local oldFile = Object::New(); - oldFile->Set(String::NewSymbol("path"), String::New(delta->raw->old_file.path)); - fileDelta->Set(String::NewSymbol("oldFile"), oldFile); - - Local newFile = Object::New(); - newFile->Set(String::NewSymbol("path"), String::New(delta->raw->new_file.path)); - fileDelta->Set(String::NewSymbol("newFile"), newFile); - - std::vector > deltaContent; - for(std::vector::iterator contentIterator = delta->contents.begin(); contentIterator != delta->contents.end(); ++contentIterator) { - DeltaContent* rawContent = (*contentIterator); - Local content = Object::New(); - - Local range = Object::New(); - /* - int old_start - int old_lines - int new_start - int new_lines - */ - Local oldRange = Object::New(); - oldRange->Set(String::New("start"), Integer::New(rawContent->range->old_start)); - oldRange->Set(String::New("lines"), Integer::New(rawContent->range->old_lines)); - range->Set(String::New("old"), oldRange); - - Local newRange = Object::New(); - newRange->Set(String::New("start"), Integer::New(rawContent->range->new_start)); - newRange->Set(String::New("lines"), Integer::New(rawContent->range->new_lines)); - range->Set(String::New("new"), newRange); - - content->Set(String::New("range"), range); - content->Set(String::New("content"), String::New(rawContent->content.c_str())); - - // char lineOrigin[2]; - // strncpy(lineOrigin, &rawContent->lineOrigin, 1); - char lineOrigin[2]; - lineOrigin[0] = rawContent->lineOrigin; - lineOrigin[1] = '\0'; - // std::string lineOrigin(rawContent->lineOrigin); - content->Set(String::New("lineOrigin"), String::New(lineOrigin)); - content->Set(String::New("contentLength"), Integer::New(rawContent->contentLength)); - - deltaContent.push_back(content); - } - - fileDelta->Set(String::NewSymbol("content"), cvv8::CastToJS(deltaContent)); - fileDelta->Set(String::NewSymbol("status"), cvv8::CastToJS(delta->raw->status)); - - fileDeltasArray.push_back(fileDelta); - } - - baton->fileDeltas.clear(); - - - Handle argv[2] = { - Local::New(Null()), - cvv8::CastToJS(fileDeltasArray) - }; - - TryCatch try_catch; - baton->fileCallback->Call(Context::GetCurrent()->Global(), 2, argv); - if (try_catch.HasCaught()) { - node::FatalException(try_catch); + if (args.Length() == 0 || !args[0]->IsUint32()) { + return ThrowException(Exception::Error(String::New("Number idx is required."))); + } + + git_diff_patch *patch_out = NULL; + const git_diff_delta *delta_out = NULL; + size_t from_idx; + from_idx = (size_t) args[0]->ToUint32()->Value(); + + int result = git_diff_get_patch( + &patch_out + , &delta_out + , ObjectWrap::Unwrap(args.This())->GetValue() + , from_idx + ); + if (result != GIT_OK) { + if (giterr_last()) { + return ThrowException(Exception::Error(String::New(giterr_last()->message))); + } else { + return ThrowException(Exception::Error(String::New("Unkown Error"))); } } - uv_mutex_unlock(&baton->mutex); -} -void GitDiffList::WalkWorkSendHunk(uv_async_t *handle, int status /*UNUSED*/) { } -void GitDiffList::WalkWorkSendData(uv_async_t *handle, int status /*UNUSED*/) { } -void GitDiffList::WalkWorkSendEnd(uv_async_t *handle, int status /*UNUSED*/) { - WalkBaton *baton = static_cast(handle->data); - - uv_mutex_destroy(&baton->mutex); - uv_close((uv_handle_t*) &baton->asyncFile, NULL); - uv_close((uv_handle_t*) &baton->asyncHunk, NULL); - uv_close((uv_handle_t*) &baton->asyncData, NULL); - uv_close((uv_handle_t*) &baton->asyncEnd, NULL); - - Local argv[1]; - if (baton->error) { - argv[0] = GitError::WrapError(baton->error); + + Handle toReturn = Object::New(); + Handle to; + if (patch_out != NULL) { + to = GitPatch::New((void *)patch_out); } else { - argv[0] = Local::New(Null()); + to = Null(); } + toReturn->Set(String::NewSymbol("patch"), to); - TryCatch try_catch; - - baton->endCallback->Call(Context::GetCurrent()->Global(), 1, argv); - - if (try_catch.HasCaught()) { - node::FatalException(try_catch); + if (delta_out != NULL) { + to = GitDelta::New((void *)delta_out); + } else { + to = Null(); } + toReturn->Set(String::NewSymbol("delta"), to); + + return scope.Close(toReturn); } Persistent GitDiffList::constructor_template; diff --git a/src/diff_options.cc b/src/diff_options.cc new file mode 100644 index 000000000..dad3fd108 --- /dev/null +++ b/src/diff_options.cc @@ -0,0 +1,63 @@ +/** + * This code is auto-generated; unless you know what you're doing, do not modify! + **/ +#include +#include +#include + +#include "git2.h" + +#include "../include/functions/copy.h" + +#include "../include/diff_options.h" + +using namespace v8; +using namespace node; + +GitDiffOptions::GitDiffOptions(git_diff_options *raw) { + this->raw = raw; +} + +GitDiffOptions::~GitDiffOptions() { + free(this->raw); +} + +void GitDiffOptions::Initialize(Handle target) { + HandleScope scope; + + Local tpl = FunctionTemplate::New(New); + + tpl->InstanceTemplate()->SetInternalFieldCount(1); + tpl->SetClassName(String::NewSymbol("DiffOptions")); + + + + constructor_template = Persistent::New(tpl->GetFunction()); + target->Set(String::NewSymbol("DiffOptions"), constructor_template); +} + +Handle GitDiffOptions::New(const Arguments& args) { + HandleScope scope; + + if (args.Length() == 0 || !args[0]->IsExternal()) { + return ThrowException(Exception::Error(String::New("git_diff_options is required."))); + } + + GitDiffOptions* object = new GitDiffOptions((git_diff_options *) External::Unwrap(args[0])); + object->Wrap(args.This()); + + return scope.Close(args.This()); +} + +Handle GitDiffOptions::New(void *raw) { + HandleScope scope; + Handle argv[1] = { External::New((void *)raw) }; + return scope.Close(GitDiffOptions::constructor_template->NewInstance(1, argv)); +} + +git_diff_options *GitDiffOptions::GetValue() { + return this->raw; +} + + +Persistent GitDiffOptions::constructor_template; diff --git a/src/diff_range.cc b/src/diff_range.cc new file mode 100644 index 000000000..cacbd49b5 --- /dev/null +++ b/src/diff_range.cc @@ -0,0 +1,111 @@ +/** + * This code is auto-generated; unless you know what you're doing, do not modify! + **/ +#include +#include +#include + +#include "git2.h" + +#include "../include/functions/copy.h" + +#include "../include/diff_range.h" + +using namespace v8; +using namespace node; + +GitDiffRange::GitDiffRange(git_diff_range *raw) { + this->raw = raw; +} + +GitDiffRange::~GitDiffRange() { + free(this->raw); +} + +void GitDiffRange::Initialize(Handle target) { + HandleScope scope; + + Local tpl = FunctionTemplate::New(New); + + tpl->InstanceTemplate()->SetInternalFieldCount(1); + tpl->SetClassName(String::NewSymbol("DiffRange")); + + + NODE_SET_PROTOTYPE_METHOD(tpl, "oldStart", OldStart); + NODE_SET_PROTOTYPE_METHOD(tpl, "oldLines", OldLines); + NODE_SET_PROTOTYPE_METHOD(tpl, "newStart", NewStart); + NODE_SET_PROTOTYPE_METHOD(tpl, "newLines", NewLines); + + constructor_template = Persistent::New(tpl->GetFunction()); + target->Set(String::NewSymbol("DiffRange"), constructor_template); +} + +Handle GitDiffRange::New(const Arguments& args) { + HandleScope scope; + + if (args.Length() == 0 || !args[0]->IsExternal()) { + return ThrowException(Exception::Error(String::New("git_diff_range is required."))); + } + + GitDiffRange* object = new GitDiffRange((git_diff_range *) External::Unwrap(args[0])); + object->Wrap(args.This()); + + return scope.Close(args.This()); +} + +Handle GitDiffRange::New(void *raw) { + HandleScope scope; + Handle argv[1] = { External::New((void *)raw) }; + return scope.Close(GitDiffRange::constructor_template->NewInstance(1, argv)); +} + +git_diff_range *GitDiffRange::GetValue() { + return this->raw; +} + + +Handle GitDiffRange::OldStart(const Arguments& args) { + HandleScope scope; + Handle to; + + int old_start = + ObjectWrap::Unwrap(args.This())->GetValue()->old_start; + + to = Integer::New(old_start); + return scope.Close(to); +} + +Handle GitDiffRange::OldLines(const Arguments& args) { + HandleScope scope; + Handle to; + + int old_lines = + ObjectWrap::Unwrap(args.This())->GetValue()->old_lines; + + to = Integer::New(old_lines); + return scope.Close(to); +} + +Handle GitDiffRange::NewStart(const Arguments& args) { + HandleScope scope; + Handle to; + + int new_start = + ObjectWrap::Unwrap(args.This())->GetValue()->new_start; + + to = Integer::New(new_start); + return scope.Close(to); +} + +Handle GitDiffRange::NewLines(const Arguments& args) { + HandleScope scope; + Handle to; + + int new_lines = + ObjectWrap::Unwrap(args.This())->GetValue()->new_lines; + + to = Integer::New(new_lines); + return scope.Close(to); +} + +Persistent GitDiffRange::constructor_template; diff --git a/src/error.cc b/src/error.cc deleted file mode 100755 index 5ecee568a..000000000 --- a/src/error.cc +++ /dev/null @@ -1,112 +0,0 @@ -/** - * Copyright (c) 2011, Tim Branyen @tbranyen - * @author Michael Robinson @codeofinterest - * - * Dual licensed under the MIT and GPL licenses. - */ - -#include -#include - -#include "cvv8/v8-convert.hpp" - -#include "git2.h" - -#include "../include/error.h" - -using namespace v8; -using namespace node; -using namespace cvv8; - -/** - * Copied from libgit2/include/errors.h, to allow exporting to JS - */ -typedef enum { - _GIT_OK = 0, - _GIT_ERROR = -1, - _GIT_ENOTFOUND = -3, - _GIT_EEXISTS = -4, - _GIT_EAMBIGUOUS = -5, - _GIT_EBUFS = -6, - - _GIT_PASSTHROUGH = -30, - _GIT_ITEROVER = -31, -} git_error_return_t; - -namespace cvv8 { - template <> - struct NativeToJS : NativeToJS {}; - - template <> - struct NativeToJS : NativeToJS {}; -} - -void GitError::Initialize (Handle target) { - HandleScope scope; - - Local tpl = FunctionTemplate::New(New); - - tpl->InstanceTemplate()->SetInternalFieldCount(1); - tpl->SetClassName(String::NewSymbol("Error")); - - // Add libgit2 error codes to error object - Local libgit2Errors = Object::New(); - - libgit2Errors->Set(String::NewSymbol("GITERR_NOMEMORY"), CastToJS(GITERR_NOMEMORY), ReadOnly); - libgit2Errors->Set(String::NewSymbol("GITERR_OS"), CastToJS(GITERR_OS), ReadOnly); - libgit2Errors->Set(String::NewSymbol("GITERR_INVALID"), CastToJS(GITERR_INVALID), ReadOnly); - libgit2Errors->Set(String::NewSymbol("GITERR_REFERENCE"), CastToJS(GITERR_REFERENCE), ReadOnly); - libgit2Errors->Set(String::NewSymbol("GITERR_ZLIB"), CastToJS(GITERR_ZLIB), ReadOnly); - libgit2Errors->Set(String::NewSymbol("GITERR_REPOSITORY"), CastToJS(GITERR_REPOSITORY), ReadOnly); - libgit2Errors->Set(String::NewSymbol("GITERR_CONFIG"), CastToJS(GITERR_CONFIG), ReadOnly); - libgit2Errors->Set(String::NewSymbol("GITERR_REGEX"), CastToJS(GITERR_REGEX), ReadOnly); - libgit2Errors->Set(String::NewSymbol("GITERR_ODB"), CastToJS(GITERR_ODB), ReadOnly); - libgit2Errors->Set(String::NewSymbol("GITERR_INDEX"), CastToJS(GITERR_INDEX), ReadOnly); - libgit2Errors->Set(String::NewSymbol("GITERR_OBJECT"), CastToJS(GITERR_OBJECT), ReadOnly); - libgit2Errors->Set(String::NewSymbol("GITERR_NET"), CastToJS(GITERR_NET), ReadOnly); - libgit2Errors->Set(String::NewSymbol("GITERR_TAG"), CastToJS(GITERR_TAG), ReadOnly); - libgit2Errors->Set(String::NewSymbol("GITERR_TREE"), CastToJS(GITERR_TREE), ReadOnly); - libgit2Errors->Set(String::NewSymbol("GITERR_INDEXER"), CastToJS(GITERR_INDEXER), ReadOnly); - - // Add libgit2 error codes to error object - Local libgit2ReturnCodes = Object::New(); - - libgit2ReturnCodes->Set(String::NewSymbol("GIT_OK"), CastToJS(_GIT_OK), ReadOnly); - libgit2ReturnCodes->Set(String::NewSymbol("GIT_ERROR"), CastToJS(_GIT_ERROR), ReadOnly); - libgit2ReturnCodes->Set(String::NewSymbol("GIT_ENOTFOUND"), CastToJS(_GIT_ENOTFOUND), ReadOnly); - libgit2ReturnCodes->Set(String::NewSymbol("GIT_EEXISTS"), CastToJS(_GIT_EEXISTS), ReadOnly); - libgit2ReturnCodes->Set(String::NewSymbol("GIT_EAMBIGUOUS"), CastToJS(_GIT_EAMBIGUOUS), ReadOnly); - libgit2ReturnCodes->Set(String::NewSymbol("GIT_EBUFS"), CastToJS(_GIT_EBUFS), ReadOnly); - libgit2ReturnCodes->Set(String::NewSymbol("GIT_PASSTHROUGH"), CastToJS(_GIT_PASSTHROUGH), ReadOnly); - libgit2ReturnCodes->Set(String::NewSymbol("GIT_ITEROVER"), CastToJS(_GIT_ITEROVER), ReadOnly); - - constructor_template = Persistent::New(tpl->GetFunction()); - constructor_template->Set(String::NewSymbol("codes"), libgit2Errors, ReadOnly); - constructor_template->Set(String::NewSymbol("returnCodes"), libgit2ReturnCodes, ReadOnly); - - - target->Set(String::NewSymbol("Error"), constructor_template); -} - -Local GitError::WrapError(const git_error* error) { - - Local gitError = GitError::constructor_template->NewInstance(); - Local stackTrace = StackTrace::CurrentStackTrace(10); - - gitError->Set(String::NewSymbol("stackTrace"), CastToJS(stackTrace->AsArray())); - gitError->Set(String::NewSymbol("message"), String::New(error->message)); - gitError->Set(String::NewSymbol("code"), Integer::New(error->klass)); - - return gitError; -} - -Handle GitError::New(const Arguments& args) { - HandleScope scope; - - GitError *error = new GitError(); - error->Wrap(args.This()); - - return scope.Close(args.This()); -} - -Persistent GitError::constructor_template; diff --git a/src/functions/copy.cc b/src/functions/copy.cc new file mode 100644 index 000000000..c6e86ca2b --- /dev/null +++ b/src/functions/copy.cc @@ -0,0 +1,45 @@ +#include + +#include "git2.h" + +const git_oid *git_oid_dup(const git_oid *arg) { + git_oid *result = (git_oid *)malloc(sizeof(git_oid)); + git_oid_cpy(result, arg); + return result; +} + +const git_index_entry *git_index_entry_dup(const git_index_entry *arg) { + git_index_entry *result = (git_index_entry *)malloc(sizeof(git_index_entry)); + *result = *arg; + return result; +} + +const git_index_time *git_index_time_dup(const git_index_time *arg) { + git_index_time *result = (git_index_time *)malloc(sizeof(git_index_time)); + *result = (const git_index_time) *arg; + return result; +} + +const git_time *git_time_dup(const git_time *arg) { + git_time *result = (git_time *)malloc(sizeof(git_time)); + *result = *arg; + return result; +} + +const git_diff_delta *git_diff_delta_dup(const git_diff_delta *arg) { + git_diff_delta *result = (git_diff_delta *)malloc(sizeof(git_diff_delta)); + *result = *arg; + return result; +} + +const git_diff_file *git_diff_file_dup(const git_diff_file *arg) { + git_diff_file *result = (git_diff_file *)malloc(sizeof(git_diff_file)); + *result = *arg; + return result; +} + +const git_diff_range *git_diff_range_dup(const git_diff_range *arg) { + git_diff_range *result = (git_diff_range *)malloc(sizeof(git_diff_range)); + *result = *arg; + return result; +} diff --git a/src/functions/string.cc b/src/functions/string.cc deleted file mode 100644 index 5c74f4aa7..000000000 --- a/src/functions/string.cc +++ /dev/null @@ -1,9 +0,0 @@ -#include -#include - -#include "../../include/functions/string.h" - -std::string stringArgToString(const v8::Local arg) { - v8::String::Utf8Value param1(arg); - return std::string(*param1); -} diff --git a/src/functions/utilities.cc b/src/functions/utilities.cc deleted file mode 100644 index ec5904dcc..000000000 --- a/src/functions/utilities.cc +++ /dev/null @@ -1,21 +0,0 @@ -#include "../../include/functions/utilities.h" - -using namespace v8; - -bool success(const git_error* error, Persistent callback) { - HandleScope scope; - - if (error) { - Local argv[1] = { - GitError::WrapError(error) - }; - - TryCatch try_catch; - callback->Call(Context::GetCurrent()->Global(), 1, argv); - if (try_catch.HasCaught()) { - FatalException(try_catch); - } - return false; - } - return true; -} diff --git a/src/index.cc b/src/index.cc new file mode 100644 index 000000000..725192951 --- /dev/null +++ b/src/index.cc @@ -0,0 +1,866 @@ +/** + * This code is auto-generated; unless you know what you're doing, do not modify! + **/ +#include +#include +#include + +#include "git2.h" + +#include "../include/functions/copy.h" + +#include "../include/index.h" +#include "../include/oid.h" +#include "../include/repo.h" +#include "../include/tree.h" +#include "../include/diff_list.h" +#include "../include/diff_options.h" +#include "../include/index_entry.h" + +using namespace v8; +using namespace node; + +GitIndex::GitIndex(git_index *raw) { + this->raw = raw; +} + +GitIndex::~GitIndex() { + git_index_free(this->raw); +} + +void GitIndex::Initialize(Handle target) { + HandleScope scope; + + Local tpl = FunctionTemplate::New(New); + + tpl->InstanceTemplate()->SetInternalFieldCount(1); + tpl->SetClassName(String::NewSymbol("Index")); + + NODE_SET_METHOD(tpl, "open", Open); + NODE_SET_PROTOTYPE_METHOD(tpl, "read", Read); + NODE_SET_PROTOTYPE_METHOD(tpl, "write", Write); + NODE_SET_PROTOTYPE_METHOD(tpl, "readTree", ReadTree); + NODE_SET_PROTOTYPE_METHOD(tpl, "writeTree", WriteTree); + NODE_SET_PROTOTYPE_METHOD(tpl, "size", Size); + NODE_SET_PROTOTYPE_METHOD(tpl, "clear", Clear); + NODE_SET_PROTOTYPE_METHOD(tpl, "entry", Entry); + NODE_SET_PROTOTYPE_METHOD(tpl, "remove", Remove); + NODE_SET_PROTOTYPE_METHOD(tpl, "removeDirectory", RemoveDirectory); + NODE_SET_PROTOTYPE_METHOD(tpl, "addByPath", AddBypath); + NODE_SET_PROTOTYPE_METHOD(tpl, "removeByPath", RemoveBypath); + NODE_SET_PROTOTYPE_METHOD(tpl, "find", Find); + NODE_SET_PROTOTYPE_METHOD(tpl, "conflictRemove", ConflictRemove); + NODE_SET_PROTOTYPE_METHOD(tpl, "conflictCleanup", ConflictCleanup); + NODE_SET_PROTOTYPE_METHOD(tpl, "hasConflicts", HasConflicts); + NODE_SET_METHOD(tpl, "indexToWorkdir", IndexToWorkdir); + + + constructor_template = Persistent::New(tpl->GetFunction()); + target->Set(String::NewSymbol("Index"), constructor_template); +} + +Handle GitIndex::New(const Arguments& args) { + HandleScope scope; + + if (args.Length() == 0 || !args[0]->IsExternal()) { + return ThrowException(Exception::Error(String::New("git_index is required."))); + } + + GitIndex* object = new GitIndex((git_index *) External::Unwrap(args[0])); + object->Wrap(args.This()); + + return scope.Close(args.This()); +} + +Handle GitIndex::New(void *raw) { + HandleScope scope; + Handle argv[1] = { External::New((void *)raw) }; + return scope.Close(GitIndex::constructor_template->NewInstance(1, argv)); +} + +git_index *GitIndex::GetValue() { + return this->raw; +} + + +/** + * @param {String} index_path + * @param {Index} callback + */ +Handle GitIndex::Open(const Arguments& args) { + HandleScope scope; + if (args.Length() == 0 || !args[0]->IsString()) { + return ThrowException(Exception::Error(String::New("String index_path is required."))); + } + + if (args.Length() == 1 || !args[1]->IsFunction()) { + return ThrowException(Exception::Error(String::New("Callback is required and must be a Function."))); + } + + OpenBaton* baton = new OpenBaton; + baton->error_code = GIT_OK; + baton->error = NULL; + baton->request.data = baton; + baton->index_pathReference = Persistent::New(args[0]); + const char * from_index_path; + String::Utf8Value index_path(args[0]->ToString()); + from_index_path = strdup(*index_path); + baton->index_path = from_index_path; + baton->callback = Persistent::New(Local::Cast(args[1])); + + uv_queue_work(uv_default_loop(), &baton->request, OpenWork, (uv_after_work_cb)OpenAfterWork); + + return Undefined(); +} + +void GitIndex::OpenWork(uv_work_t *req) { + OpenBaton *baton = static_cast(req->data); + int result = git_index_open( + &baton->out, + baton->index_path + ); + baton->error_code = result; + if (result != GIT_OK) { + baton->error = giterr_last(); + } +} + +void GitIndex::OpenAfterWork(uv_work_t *req) { + HandleScope scope; + OpenBaton *baton = static_cast(req->data); + + TryCatch try_catch; + if (baton->error_code == GIT_OK) { + Handle to; + if (baton->out != NULL) { + to = GitIndex::New((void *)baton->out); + } else { + to = Null(); + } + Handle result = to; + Handle argv[2] = { + Local::New(Null()), + result + }; + baton->callback->Call(Context::GetCurrent()->Global(), 2, argv); + } else { + if (baton->error) { + Handle argv[1] = { + Exception::Error(String::New(baton->error->message)) + }; + baton->callback->Call(Context::GetCurrent()->Global(), 1, argv); + } else { + baton->callback->Call(Context::GetCurrent()->Global(), 0, NULL); + } + } + + if (try_catch.HasCaught()) { + node::FatalException(try_catch); + } + baton->index_pathReference.Dispose(); + baton->callback.Dispose(); + free((void *)baton->index_path); + delete baton; +} + +/** + */ +Handle GitIndex::Read(const Arguments& args) { + HandleScope scope; + + if (args.Length() == 0 || !args[0]->IsFunction()) { + return ThrowException(Exception::Error(String::New("Callback is required and must be a Function."))); + } + + ReadBaton* baton = new ReadBaton; + baton->error_code = GIT_OK; + baton->error = NULL; + baton->request.data = baton; + baton->indexReference = Persistent::New(args.This()); + baton->index = ObjectWrap::Unwrap(args.This())->GetValue(); + baton->callback = Persistent::New(Local::Cast(args[0])); + + uv_queue_work(uv_default_loop(), &baton->request, ReadWork, (uv_after_work_cb)ReadAfterWork); + + return Undefined(); +} + +void GitIndex::ReadWork(uv_work_t *req) { + ReadBaton *baton = static_cast(req->data); + int result = git_index_read( + baton->index + ); + baton->error_code = result; + if (result != GIT_OK) { + baton->error = giterr_last(); + } +} + +void GitIndex::ReadAfterWork(uv_work_t *req) { + HandleScope scope; + ReadBaton *baton = static_cast(req->data); + + TryCatch try_catch; + if (baton->error_code == GIT_OK) { + Handle result = Local::New(Undefined()); + Handle argv[2] = { + Local::New(Null()), + result + }; + baton->callback->Call(Context::GetCurrent()->Global(), 2, argv); + } else { + if (baton->error) { + Handle argv[1] = { + Exception::Error(String::New(baton->error->message)) + }; + baton->callback->Call(Context::GetCurrent()->Global(), 1, argv); + } else { + baton->callback->Call(Context::GetCurrent()->Global(), 0, NULL); + } + } + + if (try_catch.HasCaught()) { + node::FatalException(try_catch); + } + baton->indexReference.Dispose(); + baton->callback.Dispose(); + delete baton; +} + +/** + */ +Handle GitIndex::Write(const Arguments& args) { + HandleScope scope; + + if (args.Length() == 0 || !args[0]->IsFunction()) { + return ThrowException(Exception::Error(String::New("Callback is required and must be a Function."))); + } + + WriteBaton* baton = new WriteBaton; + baton->error_code = GIT_OK; + baton->error = NULL; + baton->request.data = baton; + baton->indexReference = Persistent::New(args.This()); + baton->index = ObjectWrap::Unwrap(args.This())->GetValue(); + baton->callback = Persistent::New(Local::Cast(args[0])); + + uv_queue_work(uv_default_loop(), &baton->request, WriteWork, (uv_after_work_cb)WriteAfterWork); + + return Undefined(); +} + +void GitIndex::WriteWork(uv_work_t *req) { + WriteBaton *baton = static_cast(req->data); + int result = git_index_write( + baton->index + ); + baton->error_code = result; + if (result != GIT_OK) { + baton->error = giterr_last(); + } +} + +void GitIndex::WriteAfterWork(uv_work_t *req) { + HandleScope scope; + WriteBaton *baton = static_cast(req->data); + + TryCatch try_catch; + if (baton->error_code == GIT_OK) { + Handle result = Local::New(Undefined()); + Handle argv[2] = { + Local::New(Null()), + result + }; + baton->callback->Call(Context::GetCurrent()->Global(), 2, argv); + } else { + if (baton->error) { + Handle argv[1] = { + Exception::Error(String::New(baton->error->message)) + }; + baton->callback->Call(Context::GetCurrent()->Global(), 1, argv); + } else { + baton->callback->Call(Context::GetCurrent()->Global(), 0, NULL); + } + } + + if (try_catch.HasCaught()) { + node::FatalException(try_catch); + } + baton->indexReference.Dispose(); + baton->callback.Dispose(); + delete baton; +} + +/** + * @param {Tree} tree + */ +Handle GitIndex::ReadTree(const Arguments& args) { + HandleScope scope; + if (args.Length() == 0 || !args[0]->IsObject()) { + return ThrowException(Exception::Error(String::New("Tree tree is required."))); + } + + if (args.Length() == 1 || !args[1]->IsFunction()) { + return ThrowException(Exception::Error(String::New("Callback is required and must be a Function."))); + } + + ReadTreeBaton* baton = new ReadTreeBaton; + baton->error_code = GIT_OK; + baton->error = NULL; + baton->request.data = baton; + baton->indexReference = Persistent::New(args.This()); + baton->index = ObjectWrap::Unwrap(args.This())->GetValue(); + baton->treeReference = Persistent::New(args[0]); + const git_tree * from_tree; + from_tree = ObjectWrap::Unwrap(args[0]->ToObject())->GetValue(); + baton->tree = from_tree; + baton->callback = Persistent::New(Local::Cast(args[1])); + + uv_queue_work(uv_default_loop(), &baton->request, ReadTreeWork, (uv_after_work_cb)ReadTreeAfterWork); + + return Undefined(); +} + +void GitIndex::ReadTreeWork(uv_work_t *req) { + ReadTreeBaton *baton = static_cast(req->data); + int result = git_index_read_tree( + baton->index, + baton->tree + ); + baton->error_code = result; + if (result != GIT_OK) { + baton->error = giterr_last(); + } +} + +void GitIndex::ReadTreeAfterWork(uv_work_t *req) { + HandleScope scope; + ReadTreeBaton *baton = static_cast(req->data); + + TryCatch try_catch; + if (baton->error_code == GIT_OK) { + Handle result = Local::New(Undefined()); + Handle argv[2] = { + Local::New(Null()), + result + }; + baton->callback->Call(Context::GetCurrent()->Global(), 2, argv); + } else { + if (baton->error) { + Handle argv[1] = { + Exception::Error(String::New(baton->error->message)) + }; + baton->callback->Call(Context::GetCurrent()->Global(), 1, argv); + } else { + baton->callback->Call(Context::GetCurrent()->Global(), 0, NULL); + } + } + + if (try_catch.HasCaught()) { + node::FatalException(try_catch); + } + baton->indexReference.Dispose(); + baton->treeReference.Dispose(); + baton->callback.Dispose(); + delete baton; +} + +/** + * @param {Oid} callback + */ +Handle GitIndex::WriteTree(const Arguments& args) { + HandleScope scope; + + if (args.Length() == 0 || !args[0]->IsFunction()) { + return ThrowException(Exception::Error(String::New("Callback is required and must be a Function."))); + } + + WriteTreeBaton* baton = new WriteTreeBaton; + baton->error_code = GIT_OK; + baton->error = NULL; + baton->request.data = baton; + baton->out = (git_oid *)malloc(sizeof(git_oid )); + baton->indexReference = Persistent::New(args.This()); + baton->index = ObjectWrap::Unwrap(args.This())->GetValue(); + baton->callback = Persistent::New(Local::Cast(args[0])); + + uv_queue_work(uv_default_loop(), &baton->request, WriteTreeWork, (uv_after_work_cb)WriteTreeAfterWork); + + return Undefined(); +} + +void GitIndex::WriteTreeWork(uv_work_t *req) { + WriteTreeBaton *baton = static_cast(req->data); + int result = git_index_write_tree( + baton->out, + baton->index + ); + baton->error_code = result; + if (result != GIT_OK) { + baton->error = giterr_last(); + } +} + +void GitIndex::WriteTreeAfterWork(uv_work_t *req) { + HandleScope scope; + WriteTreeBaton *baton = static_cast(req->data); + + TryCatch try_catch; + if (baton->error_code == GIT_OK) { + Handle to; + if (baton->out != NULL) { + to = GitOid::New((void *)baton->out); + } else { + to = Null(); + } + Handle result = to; + Handle argv[2] = { + Local::New(Null()), + result + }; + baton->callback->Call(Context::GetCurrent()->Global(), 2, argv); + } else { + if (baton->error) { + Handle argv[1] = { + Exception::Error(String::New(baton->error->message)) + }; + baton->callback->Call(Context::GetCurrent()->Global(), 1, argv); + } else { + baton->callback->Call(Context::GetCurrent()->Global(), 0, NULL); + } + free(baton->out); + } + + if (try_catch.HasCaught()) { + node::FatalException(try_catch); + } + baton->indexReference.Dispose(); + baton->callback.Dispose(); + delete baton; +} + +/** + * @return {Number} result + */ +Handle GitIndex::Size(const Arguments& args) { + HandleScope scope; + + + size_t result = git_index_entrycount( + ObjectWrap::Unwrap(args.This())->GetValue() + ); + + Handle to; + to = Uint32::New(result); + return scope.Close(to); +} + +/** + */ +Handle GitIndex::Clear(const Arguments& args) { + HandleScope scope; + + + git_index_clear( + ObjectWrap::Unwrap(args.This())->GetValue() + ); + + return Undefined(); +} + +/** + * @param {Number} n + * @return {IndexEntry} result + */ +Handle GitIndex::Entry(const Arguments& args) { + HandleScope scope; + if (args.Length() == 0 || !args[0]->IsUint32()) { + return ThrowException(Exception::Error(String::New("Number n is required."))); + } + + size_t from_n; + from_n = (size_t) args[0]->ToUint32()->Value(); + + const git_index_entry * result = git_index_get_byindex( + ObjectWrap::Unwrap(args.This())->GetValue() + , from_n + ); + + Handle to; + if (result != NULL) { + result = (const git_index_entry * )git_index_entry_dup(result); + } + if (result != NULL) { + to = GitIndexEntry::New((void *)result); + } else { + to = Null(); + } + return scope.Close(to); +} + +/** + * @param {String} path + * @param {Number} stage + */ +Handle GitIndex::Remove(const Arguments& args) { + HandleScope scope; + if (args.Length() == 0 || !args[0]->IsString()) { + return ThrowException(Exception::Error(String::New("String path is required."))); + } + if (args.Length() == 1 || !args[1]->IsInt32()) { + return ThrowException(Exception::Error(String::New("Number stage is required."))); + } + + const char * from_path; + String::Utf8Value path(args[0]->ToString()); + from_path = strdup(*path); + int from_stage; + from_stage = (int) args[1]->ToInt32()->Value(); + + int result = git_index_remove( + ObjectWrap::Unwrap(args.This())->GetValue() + , from_path + , from_stage + ); + free((void *)from_path); + if (result != GIT_OK) { + if (giterr_last()) { + return ThrowException(Exception::Error(String::New(giterr_last()->message))); + } else { + return ThrowException(Exception::Error(String::New("Unkown Error"))); + } + } + + return Undefined(); +} + +/** + * @param {String} dir + * @param {Number} stage + */ +Handle GitIndex::RemoveDirectory(const Arguments& args) { + HandleScope scope; + if (args.Length() == 0 || !args[0]->IsString()) { + return ThrowException(Exception::Error(String::New("String dir is required."))); + } + if (args.Length() == 1 || !args[1]->IsInt32()) { + return ThrowException(Exception::Error(String::New("Number stage is required."))); + } + + const char * from_dir; + String::Utf8Value dir(args[0]->ToString()); + from_dir = strdup(*dir); + int from_stage; + from_stage = (int) args[1]->ToInt32()->Value(); + + int result = git_index_remove_directory( + ObjectWrap::Unwrap(args.This())->GetValue() + , from_dir + , from_stage + ); + free((void *)from_dir); + if (result != GIT_OK) { + if (giterr_last()) { + return ThrowException(Exception::Error(String::New(giterr_last()->message))); + } else { + return ThrowException(Exception::Error(String::New("Unkown Error"))); + } + } + + return Undefined(); +} + +/** + * @param {String} path + */ +Handle GitIndex::AddBypath(const Arguments& args) { + HandleScope scope; + if (args.Length() == 0 || !args[0]->IsString()) { + return ThrowException(Exception::Error(String::New("String path is required."))); + } + + if (args.Length() == 1 || !args[1]->IsFunction()) { + return ThrowException(Exception::Error(String::New("Callback is required and must be a Function."))); + } + + AddBypathBaton* baton = new AddBypathBaton; + baton->error_code = GIT_OK; + baton->error = NULL; + baton->request.data = baton; + baton->indexReference = Persistent::New(args.This()); + baton->index = ObjectWrap::Unwrap(args.This())->GetValue(); + baton->pathReference = Persistent::New(args[0]); + const char * from_path; + String::Utf8Value path(args[0]->ToString()); + from_path = strdup(*path); + baton->path = from_path; + baton->callback = Persistent::New(Local::Cast(args[1])); + + uv_queue_work(uv_default_loop(), &baton->request, AddBypathWork, (uv_after_work_cb)AddBypathAfterWork); + + return Undefined(); +} + +void GitIndex::AddBypathWork(uv_work_t *req) { + AddBypathBaton *baton = static_cast(req->data); + int result = git_index_add_bypath( + baton->index, + baton->path + ); + baton->error_code = result; + if (result != GIT_OK) { + baton->error = giterr_last(); + } +} + +void GitIndex::AddBypathAfterWork(uv_work_t *req) { + HandleScope scope; + AddBypathBaton *baton = static_cast(req->data); + + TryCatch try_catch; + if (baton->error_code == GIT_OK) { + Handle result = Local::New(Undefined()); + Handle argv[2] = { + Local::New(Null()), + result + }; + baton->callback->Call(Context::GetCurrent()->Global(), 2, argv); + } else { + if (baton->error) { + Handle argv[1] = { + Exception::Error(String::New(baton->error->message)) + }; + baton->callback->Call(Context::GetCurrent()->Global(), 1, argv); + } else { + baton->callback->Call(Context::GetCurrent()->Global(), 0, NULL); + } + } + + if (try_catch.HasCaught()) { + node::FatalException(try_catch); + } + baton->indexReference.Dispose(); + baton->pathReference.Dispose(); + baton->callback.Dispose(); + free((void *)baton->path); + delete baton; +} + +/** + * @param {String} path + */ +Handle GitIndex::RemoveBypath(const Arguments& args) { + HandleScope scope; + if (args.Length() == 0 || !args[0]->IsString()) { + return ThrowException(Exception::Error(String::New("String path is required."))); + } + + const char * from_path; + String::Utf8Value path(args[0]->ToString()); + from_path = strdup(*path); + + int result = git_index_remove_bypath( + ObjectWrap::Unwrap(args.This())->GetValue() + , from_path + ); + free((void *)from_path); + if (result != GIT_OK) { + if (giterr_last()) { + return ThrowException(Exception::Error(String::New(giterr_last()->message))); + } else { + return ThrowException(Exception::Error(String::New("Unkown Error"))); + } + } + + return Undefined(); +} + +/** + * @param {Number} at_pos + * @param {String} path + * @return {Number} result + */ +Handle GitIndex::Find(const Arguments& args) { + HandleScope scope; + if (args.Length() == 0 || !args[0]->IsUint32()) { + return ThrowException(Exception::Error(String::New("Number at_pos is required."))); + } + if (args.Length() == 1 || !args[1]->IsString()) { + return ThrowException(Exception::Error(String::New("String path is required."))); + } + + size_t * from_at_pos; + from_at_pos = (size_t *) args[0]->ToUint32()->Value(); + const char * from_path; + String::Utf8Value path(args[1]->ToString()); + from_path = strdup(*path); + + int result = git_index_find( + from_at_pos + , ObjectWrap::Unwrap(args.This())->GetValue() + , from_path + ); + free((void *)from_path); + + Handle to; + to = Int32::New(result); + return scope.Close(to); +} + +/** + * @param {String} path + */ +Handle GitIndex::ConflictRemove(const Arguments& args) { + HandleScope scope; + if (args.Length() == 0 || !args[0]->IsString()) { + return ThrowException(Exception::Error(String::New("String path is required."))); + } + + const char * from_path; + String::Utf8Value path(args[0]->ToString()); + from_path = strdup(*path); + + int result = git_index_conflict_remove( + ObjectWrap::Unwrap(args.This())->GetValue() + , from_path + ); + free((void *)from_path); + if (result != GIT_OK) { + if (giterr_last()) { + return ThrowException(Exception::Error(String::New(giterr_last()->message))); + } else { + return ThrowException(Exception::Error(String::New("Unkown Error"))); + } + } + + return Undefined(); +} + +/** + */ +Handle GitIndex::ConflictCleanup(const Arguments& args) { + HandleScope scope; + + + git_index_conflict_cleanup( + ObjectWrap::Unwrap(args.This())->GetValue() + ); + + return Undefined(); +} + +/** + * @return {Number} result + */ +Handle GitIndex::HasConflicts(const Arguments& args) { + HandleScope scope; + + + int result = git_index_has_conflicts( + ObjectWrap::Unwrap(args.This())->GetValue() + ); + + Handle to; + to = Int32::New(result); + return scope.Close(to); +} + +/** + * @param {Repository} repo + * @param {Index} index + * @param {DiffOptions} opts + * @param {DiffList} callback + */ +Handle GitIndex::IndexToWorkdir(const Arguments& args) { + HandleScope scope; + if (args.Length() == 0 || !args[0]->IsObject()) { + return ThrowException(Exception::Error(String::New("Repository repo is required."))); + } + if (args.Length() == 1 || !args[1]->IsObject()) { + return ThrowException(Exception::Error(String::New("Index index is required."))); + } + if (args.Length() == 2 || !args[2]->IsObject()) { + return ThrowException(Exception::Error(String::New("DiffOptions opts is required."))); + } + + if (args.Length() == 3 || !args[3]->IsFunction()) { + return ThrowException(Exception::Error(String::New("Callback is required and must be a Function."))); + } + + IndexToWorkdirBaton* baton = new IndexToWorkdirBaton; + baton->error_code = GIT_OK; + baton->error = NULL; + baton->request.data = baton; + baton->repoReference = Persistent::New(args[0]); + git_repository * from_repo; + from_repo = ObjectWrap::Unwrap(args[0]->ToObject())->GetValue(); + baton->repo = from_repo; + baton->indexReference = Persistent::New(args[1]); + git_index * from_index; + from_index = ObjectWrap::Unwrap(args[1]->ToObject())->GetValue(); + baton->index = from_index; + baton->optsReference = Persistent::New(args[2]); + const git_diff_options * from_opts; + from_opts = ObjectWrap::Unwrap(args[2]->ToObject())->GetValue(); + baton->opts = from_opts; + baton->callback = Persistent::New(Local::Cast(args[3])); + + uv_queue_work(uv_default_loop(), &baton->request, IndexToWorkdirWork, (uv_after_work_cb)IndexToWorkdirAfterWork); + + return Undefined(); +} + +void GitIndex::IndexToWorkdirWork(uv_work_t *req) { + IndexToWorkdirBaton *baton = static_cast(req->data); + int result = git_diff_index_to_workdir( + &baton->diff, + baton->repo, + baton->index, + baton->opts + ); + baton->error_code = result; + if (result != GIT_OK) { + baton->error = giterr_last(); + } +} + +void GitIndex::IndexToWorkdirAfterWork(uv_work_t *req) { + HandleScope scope; + IndexToWorkdirBaton *baton = static_cast(req->data); + + TryCatch try_catch; + if (baton->error_code == GIT_OK) { + Handle to; + if (baton->diff != NULL) { + to = GitDiffList::New((void *)baton->diff); + } else { + to = Null(); + } + Handle result = to; + Handle argv[2] = { + Local::New(Null()), + result + }; + baton->callback->Call(Context::GetCurrent()->Global(), 2, argv); + } else { + if (baton->error) { + Handle argv[1] = { + Exception::Error(String::New(baton->error->message)) + }; + baton->callback->Call(Context::GetCurrent()->Global(), 1, argv); + } else { + baton->callback->Call(Context::GetCurrent()->Global(), 0, NULL); + } + } + + if (try_catch.HasCaught()) { + node::FatalException(try_catch); + } + baton->repoReference.Dispose(); + baton->indexReference.Dispose(); + baton->optsReference.Dispose(); + baton->callback.Dispose(); + delete baton; +} + +Persistent GitIndex::constructor_template; diff --git a/src/index_entry.cc b/src/index_entry.cc new file mode 100644 index 000000000..4e94a9595 --- /dev/null +++ b/src/index_entry.cc @@ -0,0 +1,114 @@ +/** + * This code is auto-generated; unless you know what you're doing, do not modify! + **/ +#include +#include +#include + +#include "git2.h" + +#include "../include/functions/copy.h" + +#include "../include/index_entry.h" +#include "../include/index_time.h" + +using namespace v8; +using namespace node; + +GitIndexEntry::GitIndexEntry(git_index_entry *raw) { + this->raw = raw; +} + +GitIndexEntry::~GitIndexEntry() { + free(this->raw); +} + +void GitIndexEntry::Initialize(Handle target) { + HandleScope scope; + + Local tpl = FunctionTemplate::New(New); + + tpl->InstanceTemplate()->SetInternalFieldCount(1); + tpl->SetClassName(String::NewSymbol("IndexEntry")); + + + NODE_SET_PROTOTYPE_METHOD(tpl, "ctime", Ctime); + NODE_SET_PROTOTYPE_METHOD(tpl, "mtime", Mtime); + NODE_SET_PROTOTYPE_METHOD(tpl, "path", Path); + + constructor_template = Persistent::New(tpl->GetFunction()); + target->Set(String::NewSymbol("IndexEntry"), constructor_template); +} + +Handle GitIndexEntry::New(const Arguments& args) { + HandleScope scope; + + if (args.Length() == 0 || !args[0]->IsExternal()) { + return ThrowException(Exception::Error(String::New("git_index_entry is required."))); + } + + GitIndexEntry* object = new GitIndexEntry((git_index_entry *) External::Unwrap(args[0])); + object->Wrap(args.This()); + + return scope.Close(args.This()); +} + +Handle GitIndexEntry::New(void *raw) { + HandleScope scope; + Handle argv[1] = { External::New((void *)raw) }; + return scope.Close(GitIndexEntry::constructor_template->NewInstance(1, argv)); +} + +git_index_entry *GitIndexEntry::GetValue() { + return this->raw; +} + + +Handle GitIndexEntry::Ctime(const Arguments& args) { + HandleScope scope; + Handle to; + + git_index_time *ctime = + &ObjectWrap::Unwrap(args.This())->GetValue()->ctime; + + if (ctime != NULL) { + ctime = (git_index_time *)git_index_time_dup(ctime); + } + if (ctime != NULL) { + to = GitIndexTime::New((void *)ctime); + } else { + to = Null(); + } + return scope.Close(to); +} + +Handle GitIndexEntry::Mtime(const Arguments& args) { + HandleScope scope; + Handle to; + + git_index_time *mtime = + &ObjectWrap::Unwrap(args.This())->GetValue()->mtime; + + if (mtime != NULL) { + mtime = (git_index_time *)git_index_time_dup(mtime); + } + if (mtime != NULL) { + to = GitIndexTime::New((void *)mtime); + } else { + to = Null(); + } + return scope.Close(to); +} + +Handle GitIndexEntry::Path(const Arguments& args) { + HandleScope scope; + Handle to; + + char * path = + ObjectWrap::Unwrap(args.This())->GetValue()->path; + + to = String::New(path); + return scope.Close(to); +} + +Persistent GitIndexEntry::constructor_template; diff --git a/src/index_time.cc b/src/index_time.cc new file mode 100644 index 000000000..5501bd61a --- /dev/null +++ b/src/index_time.cc @@ -0,0 +1,87 @@ +/** + * This code is auto-generated; unless you know what you're doing, do not modify! + **/ +#include +#include +#include + +#include "git2.h" + +#include "../include/functions/copy.h" + +#include "../include/index_time.h" + +using namespace v8; +using namespace node; + +GitIndexTime::GitIndexTime(git_index_time *raw) { + this->raw = raw; +} + +GitIndexTime::~GitIndexTime() { + free(this->raw); +} + +void GitIndexTime::Initialize(Handle target) { + HandleScope scope; + + Local tpl = FunctionTemplate::New(New); + + tpl->InstanceTemplate()->SetInternalFieldCount(1); + tpl->SetClassName(String::NewSymbol("IndexTime")); + + + NODE_SET_PROTOTYPE_METHOD(tpl, "seconds", Seconds); + NODE_SET_PROTOTYPE_METHOD(tpl, "nanoseconds", Nanoseconds); + + constructor_template = Persistent::New(tpl->GetFunction()); + target->Set(String::NewSymbol("IndexTime"), constructor_template); +} + +Handle GitIndexTime::New(const Arguments& args) { + HandleScope scope; + + if (args.Length() == 0 || !args[0]->IsExternal()) { + return ThrowException(Exception::Error(String::New("git_index_time is required."))); + } + + GitIndexTime* object = new GitIndexTime((git_index_time *) External::Unwrap(args[0])); + object->Wrap(args.This()); + + return scope.Close(args.This()); +} + +Handle GitIndexTime::New(void *raw) { + HandleScope scope; + Handle argv[1] = { External::New((void *)raw) }; + return scope.Close(GitIndexTime::constructor_template->NewInstance(1, argv)); +} + +git_index_time *GitIndexTime::GetValue() { + return this->raw; +} + + +Handle GitIndexTime::Seconds(const Arguments& args) { + HandleScope scope; + Handle to; + + git_time_t seconds = + ObjectWrap::Unwrap(args.This())->GetValue()->seconds; + + to = Uint32::New(seconds); + return scope.Close(to); +} + +Handle GitIndexTime::Nanoseconds(const Arguments& args) { + HandleScope scope; + Handle to; + + unsigned int nanoseconds = + ObjectWrap::Unwrap(args.This())->GetValue()->nanoseconds; + + to = Uint32::New(nanoseconds); + return scope.Close(to); +} + +Persistent GitIndexTime::constructor_template; diff --git a/src/object.cc b/src/object.cc new file mode 100644 index 000000000..efb43047b --- /dev/null +++ b/src/object.cc @@ -0,0 +1,189 @@ +/** + * This code is auto-generated; unless you know what you're doing, do not modify! + **/ +#include +#include +#include + +#include "git2.h" + +#include "../include/functions/copy.h" + +#include "../include/object.h" +#include "../include/oid.h" +#include "../include/repo.h" + +using namespace v8; +using namespace node; + +GitObject::GitObject(git_object *raw) { + this->raw = raw; +} + +GitObject::~GitObject() { + git_object_free(this->raw); +} + +void GitObject::Initialize(Handle target) { + HandleScope scope; + + Local tpl = FunctionTemplate::New(New); + + tpl->InstanceTemplate()->SetInternalFieldCount(1); + tpl->SetClassName(String::NewSymbol("Object")); + + NODE_SET_PROTOTYPE_METHOD(tpl, "oid", Oid); + NODE_SET_PROTOTYPE_METHOD(tpl, "type", Type); + NODE_SET_PROTOTYPE_METHOD(tpl, "peel", Peel); + + + constructor_template = Persistent::New(tpl->GetFunction()); + target->Set(String::NewSymbol("Object"), constructor_template); +} + +Handle GitObject::New(const Arguments& args) { + HandleScope scope; + + if (args.Length() == 0 || !args[0]->IsExternal()) { + return ThrowException(Exception::Error(String::New("git_object is required."))); + } + + GitObject* object = new GitObject((git_object *) External::Unwrap(args[0])); + object->Wrap(args.This()); + + return scope.Close(args.This()); +} + +Handle GitObject::New(void *raw) { + HandleScope scope; + Handle argv[1] = { External::New((void *)raw) }; + return scope.Close(GitObject::constructor_template->NewInstance(1, argv)); +} + +git_object *GitObject::GetValue() { + return this->raw; +} + + +/** + * @return {Oid} result + */ +Handle GitObject::Oid(const Arguments& args) { + HandleScope scope; + + + const git_oid * result = git_object_id( + ObjectWrap::Unwrap(args.This())->GetValue() + ); + + Handle to; + if (result != NULL) { + result = (const git_oid * )git_oid_dup(result); + } + if (result != NULL) { + to = GitOid::New((void *)result); + } else { + to = Null(); + } + return scope.Close(to); +} + +/** + * @return {Number} result + */ +Handle GitObject::Type(const Arguments& args) { + HandleScope scope; + + + git_otype result = git_object_type( + ObjectWrap::Unwrap(args.This())->GetValue() + ); + + Handle to; + to = Number::New(result); + return scope.Close(to); +} + +/** + * @param {Number} target_type + * @param {Object} callback + */ +Handle GitObject::Peel(const Arguments& args) { + HandleScope scope; + if (args.Length() == 0 || !args[0]->IsInt32()) { + return ThrowException(Exception::Error(String::New("Number target_type is required."))); + } + + if (args.Length() == 1 || !args[1]->IsFunction()) { + return ThrowException(Exception::Error(String::New("Callback is required and must be a Function."))); + } + + PeelBaton* baton = new PeelBaton; + baton->error_code = GIT_OK; + baton->error = NULL; + baton->request.data = baton; + baton->objectReference = Persistent::New(args.This()); + baton->object = ObjectWrap::Unwrap(args.This())->GetValue(); + baton->target_typeReference = Persistent::New(args[0]); + git_otype from_target_type; + from_target_type = (git_otype) args[0]->ToInt32()->Value(); + baton->target_type = from_target_type; + baton->callback = Persistent::New(Local::Cast(args[1])); + + uv_queue_work(uv_default_loop(), &baton->request, PeelWork, (uv_after_work_cb)PeelAfterWork); + + return Undefined(); +} + +void GitObject::PeelWork(uv_work_t *req) { + PeelBaton *baton = static_cast(req->data); + int result = git_object_peel( + &baton->peeled, + baton->object, + baton->target_type + ); + baton->error_code = result; + if (result != GIT_OK) { + baton->error = giterr_last(); + } +} + +void GitObject::PeelAfterWork(uv_work_t *req) { + HandleScope scope; + PeelBaton *baton = static_cast(req->data); + + TryCatch try_catch; + if (baton->error_code == GIT_OK) { + Handle to; + if (baton->peeled != NULL) { + to = GitObject::New((void *)baton->peeled); + } else { + to = Null(); + } + Handle result = to; + Handle argv[2] = { + Local::New(Null()), + result + }; + baton->callback->Call(Context::GetCurrent()->Global(), 2, argv); + } else { + if (baton->error) { + Handle argv[1] = { + Exception::Error(String::New(baton->error->message)) + }; + baton->callback->Call(Context::GetCurrent()->Global(), 1, argv); + } else { + baton->callback->Call(Context::GetCurrent()->Global(), 0, NULL); + } + } + + if (try_catch.HasCaught()) { + node::FatalException(try_catch); + } + baton->objectReference.Dispose(); + baton->target_typeReference.Dispose(); + baton->callback.Dispose(); + delete baton; +} + +Persistent GitObject::constructor_template; diff --git a/src/odb.cc b/src/odb.cc new file mode 100644 index 000000000..b02857571 --- /dev/null +++ b/src/odb.cc @@ -0,0 +1,597 @@ +/** + * This code is auto-generated; unless you know what you're doing, do not modify! + **/ +#include +#include +#include + +#include "git2.h" + +#include "../include/functions/copy.h" + +#include "../include/odb.h" +#include "../include/oid.h" +#include "../include/odb_object.h" +#include "node_buffer.h" + +using namespace v8; +using namespace node; + +GitOdb::GitOdb(git_odb *raw) { + this->raw = raw; +} + +GitOdb::~GitOdb() { + git_odb_free(this->raw); +} + +void GitOdb::Initialize(Handle target) { + HandleScope scope; + + Local tpl = FunctionTemplate::New(New); + + tpl->InstanceTemplate()->SetInternalFieldCount(1); + tpl->SetClassName(String::NewSymbol("Odb")); + + NODE_SET_METHOD(tpl, "create()", Create); + NODE_SET_METHOD(tpl, "open", Open); + NODE_SET_PROTOTYPE_METHOD(tpl, "addDiskAlternate", AddDiskAlternate); + NODE_SET_PROTOTYPE_METHOD(tpl, "read", Read); + NODE_SET_METHOD(tpl, "readPrefix", ReadPrefix); + NODE_SET_METHOD(tpl, "readHeader", ReadHeader); + NODE_SET_PROTOTYPE_METHOD(tpl, "exists", Exists); + NODE_SET_PROTOTYPE_METHOD(tpl, "refresh", Refresh); + NODE_SET_PROTOTYPE_METHOD(tpl, "write", Write); + NODE_SET_METHOD(tpl, "hash", Hash); + NODE_SET_METHOD(tpl, "hashfile", Hashfile); + + + constructor_template = Persistent::New(tpl->GetFunction()); + target->Set(String::NewSymbol("Odb"), constructor_template); +} + +Handle GitOdb::New(const Arguments& args) { + HandleScope scope; + + if (args.Length() == 0 || !args[0]->IsExternal()) { + return ThrowException(Exception::Error(String::New("git_odb is required."))); + } + + GitOdb* object = new GitOdb((git_odb *) External::Unwrap(args[0])); + object->Wrap(args.This()); + + return scope.Close(args.This()); +} + +Handle GitOdb::New(void *raw) { + HandleScope scope; + Handle argv[1] = { External::New((void *)raw) }; + return scope.Close(GitOdb::constructor_template->NewInstance(1, argv)); +} + +git_odb *GitOdb::GetValue() { + return this->raw; +} + + +/** + * @return {Odb} out + */ +Handle GitOdb::Create(const Arguments& args) { + HandleScope scope; + + git_odb *out = NULL; + + int result = git_odb_new( + &out + ); + if (result != GIT_OK) { + if (giterr_last()) { + return ThrowException(Exception::Error(String::New(giterr_last()->message))); + } else { + return ThrowException(Exception::Error(String::New("Unkown Error"))); + } + } + + Handle to; + if (out != NULL) { + to = GitOdb::New((void *)out); + } else { + to = Null(); + } + return scope.Close(to); +} + +/** + * @param {String} objects_dir + * @return {Odb} out + */ +Handle GitOdb::Open(const Arguments& args) { + HandleScope scope; + if (args.Length() == 0 || !args[0]->IsString()) { + return ThrowException(Exception::Error(String::New("String objects_dir is required."))); + } + + git_odb *out = NULL; + const char * from_objects_dir; + String::Utf8Value objects_dir(args[0]->ToString()); + from_objects_dir = strdup(*objects_dir); + + int result = git_odb_open( + &out + , from_objects_dir + ); + free((void *)from_objects_dir); + if (result != GIT_OK) { + if (giterr_last()) { + return ThrowException(Exception::Error(String::New(giterr_last()->message))); + } else { + return ThrowException(Exception::Error(String::New("Unkown Error"))); + } + } + + Handle to; + if (out != NULL) { + to = GitOdb::New((void *)out); + } else { + to = Null(); + } + return scope.Close(to); +} + +/** + * @param {String} path + */ +Handle GitOdb::AddDiskAlternate(const Arguments& args) { + HandleScope scope; + if (args.Length() == 0 || !args[0]->IsString()) { + return ThrowException(Exception::Error(String::New("String path is required."))); + } + + const char * from_path; + String::Utf8Value path(args[0]->ToString()); + from_path = strdup(*path); + + int result = git_odb_add_disk_alternate( + ObjectWrap::Unwrap(args.This())->GetValue() + , from_path + ); + free((void *)from_path); + if (result != GIT_OK) { + if (giterr_last()) { + return ThrowException(Exception::Error(String::New(giterr_last()->message))); + } else { + return ThrowException(Exception::Error(String::New("Unkown Error"))); + } + } + + return Undefined(); +} + +/** + * @param {Oid} id + * @param {OdbObject} callback + */ +Handle GitOdb::Read(const Arguments& args) { + HandleScope scope; + if (args.Length() == 0 || !args[0]->IsObject()) { + return ThrowException(Exception::Error(String::New("Oid id is required."))); + } + + if (args.Length() == 1 || !args[1]->IsFunction()) { + return ThrowException(Exception::Error(String::New("Callback is required and must be a Function."))); + } + + ReadBaton* baton = new ReadBaton; + baton->error_code = GIT_OK; + baton->error = NULL; + baton->request.data = baton; + baton->dbReference = Persistent::New(args.This()); + baton->db = ObjectWrap::Unwrap(args.This())->GetValue(); + baton->idReference = Persistent::New(args[0]); + const git_oid * from_id; + from_id = ObjectWrap::Unwrap(args[0]->ToObject())->GetValue(); + baton->id = from_id; + baton->callback = Persistent::New(Local::Cast(args[1])); + + uv_queue_work(uv_default_loop(), &baton->request, ReadWork, (uv_after_work_cb)ReadAfterWork); + + return Undefined(); +} + +void GitOdb::ReadWork(uv_work_t *req) { + ReadBaton *baton = static_cast(req->data); + int result = git_odb_read( + &baton->out, + baton->db, + baton->id + ); + baton->error_code = result; + if (result != GIT_OK) { + baton->error = giterr_last(); + } +} + +void GitOdb::ReadAfterWork(uv_work_t *req) { + HandleScope scope; + ReadBaton *baton = static_cast(req->data); + + TryCatch try_catch; + if (baton->error_code == GIT_OK) { + Handle to; + if (baton->out != NULL) { + to = GitOdbObject::New((void *)baton->out); + } else { + to = Null(); + } + Handle result = to; + Handle argv[2] = { + Local::New(Null()), + result + }; + baton->callback->Call(Context::GetCurrent()->Global(), 2, argv); + } else { + if (baton->error) { + Handle argv[1] = { + Exception::Error(String::New(baton->error->message)) + }; + baton->callback->Call(Context::GetCurrent()->Global(), 1, argv); + } else { + baton->callback->Call(Context::GetCurrent()->Global(), 0, NULL); + } + } + + if (try_catch.HasCaught()) { + node::FatalException(try_catch); + } + baton->dbReference.Dispose(); + baton->idReference.Dispose(); + baton->callback.Dispose(); + delete baton; +} + +/** + * @param {Odb} db + * @param {Oid} short_id + * @param {Number} len + * @return {OdbObject} out + */ +Handle GitOdb::ReadPrefix(const Arguments& args) { + HandleScope scope; + if (args.Length() == 0 || !args[0]->IsObject()) { + return ThrowException(Exception::Error(String::New("Odb db is required."))); + } + if (args.Length() == 1 || !args[1]->IsObject()) { + return ThrowException(Exception::Error(String::New("Oid short_id is required."))); + } + if (args.Length() == 2 || !args[2]->IsUint32()) { + return ThrowException(Exception::Error(String::New("Number len is required."))); + } + + git_odb_object *out = NULL; + git_odb * from_db; + from_db = ObjectWrap::Unwrap(args[0]->ToObject())->GetValue(); + const git_oid * from_short_id; + from_short_id = ObjectWrap::Unwrap(args[1]->ToObject())->GetValue(); + size_t from_len; + from_len = (size_t) args[2]->ToUint32()->Value(); + + int result = git_odb_read_prefix( + &out + , from_db + , from_short_id + , from_len + ); + if (result != GIT_OK) { + if (giterr_last()) { + return ThrowException(Exception::Error(String::New(giterr_last()->message))); + } else { + return ThrowException(Exception::Error(String::New("Unkown Error"))); + } + } + + Handle to; + if (out != NULL) { + to = GitOdbObject::New((void *)out); + } else { + to = Null(); + } + return scope.Close(to); +} + +/** + * @param {Number} len_out + * @param {Number} type_out + * @param {Odb} db + * @param {Oid} id + */ +Handle GitOdb::ReadHeader(const Arguments& args) { + HandleScope scope; + if (args.Length() == 0 || !args[0]->IsUint32()) { + return ThrowException(Exception::Error(String::New("Number len_out is required."))); + } + if (args.Length() == 1 || !args[1]->IsInt32()) { + return ThrowException(Exception::Error(String::New("Number type_out is required."))); + } + if (args.Length() == 2 || !args[2]->IsObject()) { + return ThrowException(Exception::Error(String::New("Odb db is required."))); + } + if (args.Length() == 3 || !args[3]->IsObject()) { + return ThrowException(Exception::Error(String::New("Oid id is required."))); + } + + size_t * from_len_out; + from_len_out = (size_t *) args[0]->ToUint32()->Value(); + git_otype * from_type_out; + from_type_out = (git_otype *) args[1]->ToInt32()->Value(); + git_odb * from_db; + from_db = ObjectWrap::Unwrap(args[2]->ToObject())->GetValue(); + const git_oid * from_id; + from_id = ObjectWrap::Unwrap(args[3]->ToObject())->GetValue(); + + int result = git_odb_read_header( + from_len_out + , from_type_out + , from_db + , from_id + ); + if (result != GIT_OK) { + if (giterr_last()) { + return ThrowException(Exception::Error(String::New(giterr_last()->message))); + } else { + return ThrowException(Exception::Error(String::New("Unkown Error"))); + } + } + + return Undefined(); +} + +/** + * @param {Oid} id + */ +Handle GitOdb::Exists(const Arguments& args) { + HandleScope scope; + if (args.Length() == 0 || !args[0]->IsObject()) { + return ThrowException(Exception::Error(String::New("Oid id is required."))); + } + + const git_oid * from_id; + from_id = ObjectWrap::Unwrap(args[0]->ToObject())->GetValue(); + + int result = git_odb_exists( + ObjectWrap::Unwrap(args.This())->GetValue() + , from_id + ); + if (result != GIT_OK) { + if (giterr_last()) { + return ThrowException(Exception::Error(String::New(giterr_last()->message))); + } else { + return ThrowException(Exception::Error(String::New("Unkown Error"))); + } + } + + return Undefined(); +} + +/** + */ +Handle GitOdb::Refresh(const Arguments& args) { + HandleScope scope; + + + int result = git_odb_refresh( + ObjectWrap::Unwrap(args.This())->GetValue() + ); + if (result != GIT_OK) { + if (giterr_last()) { + return ThrowException(Exception::Error(String::New(giterr_last()->message))); + } else { + return ThrowException(Exception::Error(String::New("Unkown Error"))); + } + } + + return Undefined(); +} + +/** + * @param {String} data + * @param {Number} len + * @param {Number} type + * @param {Oid} callback + */ +Handle GitOdb::Write(const Arguments& args) { + HandleScope scope; + if (args.Length() == 0 || !args[0]->IsString()) { + return ThrowException(Exception::Error(String::New("String data is required."))); + } + if (args.Length() == 1 || !args[1]->IsUint32()) { + return ThrowException(Exception::Error(String::New("Number len is required."))); + } + if (args.Length() == 2 || !args[2]->IsInt32()) { + return ThrowException(Exception::Error(String::New("Number type is required."))); + } + + if (args.Length() == 3 || !args[3]->IsFunction()) { + return ThrowException(Exception::Error(String::New("Callback is required and must be a Function."))); + } + + WriteBaton* baton = new WriteBaton; + baton->error_code = GIT_OK; + baton->error = NULL; + baton->request.data = baton; + baton->out = (git_oid *)malloc(sizeof(git_oid )); + baton->odbReference = Persistent::New(args.This()); + baton->odb = ObjectWrap::Unwrap(args.This())->GetValue(); + baton->dataReference = Persistent::New(args[0]); + const void * from_data; + String::Utf8Value data(args[0]->ToString()); + from_data = strdup(*data); + baton->data = from_data; + baton->lenReference = Persistent::New(args[1]); + size_t from_len; + from_len = (size_t) args[1]->ToUint32()->Value(); + baton->len = from_len; + baton->typeReference = Persistent::New(args[2]); + git_otype from_type; + from_type = (git_otype) args[2]->ToInt32()->Value(); + baton->type = from_type; + baton->callback = Persistent::New(Local::Cast(args[3])); + + uv_queue_work(uv_default_loop(), &baton->request, WriteWork, (uv_after_work_cb)WriteAfterWork); + + return Undefined(); +} + +void GitOdb::WriteWork(uv_work_t *req) { + WriteBaton *baton = static_cast(req->data); + int result = git_odb_write( + baton->out, + baton->odb, + baton->data, + baton->len, + baton->type + ); + baton->error_code = result; + if (result != GIT_OK) { + baton->error = giterr_last(); + } +} + +void GitOdb::WriteAfterWork(uv_work_t *req) { + HandleScope scope; + WriteBaton *baton = static_cast(req->data); + + TryCatch try_catch; + if (baton->error_code == GIT_OK) { + Handle to; + if (baton->out != NULL) { + to = GitOid::New((void *)baton->out); + } else { + to = Null(); + } + Handle result = to; + Handle argv[2] = { + Local::New(Null()), + result + }; + baton->callback->Call(Context::GetCurrent()->Global(), 2, argv); + } else { + if (baton->error) { + Handle argv[1] = { + Exception::Error(String::New(baton->error->message)) + }; + baton->callback->Call(Context::GetCurrent()->Global(), 1, argv); + } else { + baton->callback->Call(Context::GetCurrent()->Global(), 0, NULL); + } + free(baton->out); + } + + if (try_catch.HasCaught()) { + node::FatalException(try_catch); + } + baton->odbReference.Dispose(); + baton->dataReference.Dispose(); + baton->lenReference.Dispose(); + baton->typeReference.Dispose(); + baton->callback.Dispose(); + free((void *)baton->data); + delete baton; +} + +/** + * @param {Buffer} data + * @param {Number} len + * @param {Number} type + * @return {Oid} out + */ +Handle GitOdb::Hash(const Arguments& args) { + HandleScope scope; + if (args.Length() == 0 || !args[0]->IsObject()) { + return ThrowException(Exception::Error(String::New("Buffer data is required."))); + } + if (args.Length() == 1 || !args[1]->IsUint32()) { + return ThrowException(Exception::Error(String::New("Number len is required."))); + } + if (args.Length() == 2 || !args[2]->IsInt32()) { + return ThrowException(Exception::Error(String::New("Number type is required."))); + } + + git_oid *out = (git_oid *)malloc(sizeof(git_oid )); + const void * from_data; + from_data = Buffer::Data(args[0]->ToObject()); + size_t from_len; + from_len = (size_t) args[1]->ToUint32()->Value(); + git_otype from_type; + from_type = (git_otype) args[2]->ToInt32()->Value(); + + int result = git_odb_hash( + out + , from_data + , from_len + , from_type + ); + if (result != GIT_OK) { + free(out); + if (giterr_last()) { + return ThrowException(Exception::Error(String::New(giterr_last()->message))); + } else { + return ThrowException(Exception::Error(String::New("Unkown Error"))); + } + } + + Handle to; + if (out != NULL) { + to = GitOid::New((void *)out); + } else { + to = Null(); + } + return scope.Close(to); +} + +/** + * @param {String} path + * @param {Number} type + * @return {Oid} out + */ +Handle GitOdb::Hashfile(const Arguments& args) { + HandleScope scope; + if (args.Length() == 0 || !args[0]->IsString()) { + return ThrowException(Exception::Error(String::New("String path is required."))); + } + if (args.Length() == 1 || !args[1]->IsInt32()) { + return ThrowException(Exception::Error(String::New("Number type is required."))); + } + + git_oid *out = (git_oid *)malloc(sizeof(git_oid )); + const char * from_path; + String::Utf8Value path(args[0]->ToString()); + from_path = strdup(*path); + git_otype from_type; + from_type = (git_otype) args[1]->ToInt32()->Value(); + + int result = git_odb_hashfile( + out + , from_path + , from_type + ); + free((void *)from_path); + if (result != GIT_OK) { + free(out); + if (giterr_last()) { + return ThrowException(Exception::Error(String::New(giterr_last()->message))); + } else { + return ThrowException(Exception::Error(String::New("Unkown Error"))); + } + } + + Handle to; + if (out != NULL) { + to = GitOid::New((void *)out); + } else { + to = Null(); + } + return scope.Close(to); +} + +Persistent GitOdb::constructor_template; diff --git a/src/odb_object.cc b/src/odb_object.cc new file mode 100644 index 000000000..507d63736 --- /dev/null +++ b/src/odb_object.cc @@ -0,0 +1,144 @@ +/** + * This code is auto-generated; unless you know what you're doing, do not modify! + **/ +#include +#include +#include + +#include "git2.h" + +#include "../include/functions/copy.h" + +#include "../include/odb_object.h" +#include "../include/wrapper.h" +#include "../include/oid.h" + +using namespace v8; +using namespace node; + +GitOdbObject::GitOdbObject(git_odb_object *raw) { + this->raw = raw; +} + +GitOdbObject::~GitOdbObject() { + git_odb_object_free(this->raw); +} + +void GitOdbObject::Initialize(Handle target) { + HandleScope scope; + + Local tpl = FunctionTemplate::New(New); + + tpl->InstanceTemplate()->SetInternalFieldCount(1); + tpl->SetClassName(String::NewSymbol("OdbObject")); + + NODE_SET_PROTOTYPE_METHOD(tpl, "data", Data); + NODE_SET_PROTOTYPE_METHOD(tpl, "size", Size); + NODE_SET_PROTOTYPE_METHOD(tpl, "type", Type); + NODE_SET_PROTOTYPE_METHOD(tpl, "oid", Oid); + + + constructor_template = Persistent::New(tpl->GetFunction()); + target->Set(String::NewSymbol("OdbObject"), constructor_template); +} + +Handle GitOdbObject::New(const Arguments& args) { + HandleScope scope; + + if (args.Length() == 0 || !args[0]->IsExternal()) { + return ThrowException(Exception::Error(String::New("git_odb_object is required."))); + } + + GitOdbObject* object = new GitOdbObject((git_odb_object *) External::Unwrap(args[0])); + object->Wrap(args.This()); + + return scope.Close(args.This()); +} + +Handle GitOdbObject::New(void *raw) { + HandleScope scope; + Handle argv[1] = { External::New((void *)raw) }; + return scope.Close(GitOdbObject::constructor_template->NewInstance(1, argv)); +} + +git_odb_object *GitOdbObject::GetValue() { + return this->raw; +} + + +/** + * @return {Wrapper} result + */ +Handle GitOdbObject::Data(const Arguments& args) { + HandleScope scope; + + + const void * result = git_odb_object_data( + ObjectWrap::Unwrap(args.This())->GetValue() + ); + + Handle to; + if (result != NULL) { + to = Wrapper::New((void *)result); + } else { + to = Null(); + } + return scope.Close(to); +} + +/** + * @return {Number} result + */ +Handle GitOdbObject::Size(const Arguments& args) { + HandleScope scope; + + + size_t result = git_odb_object_size( + ObjectWrap::Unwrap(args.This())->GetValue() + ); + + Handle to; + to = Uint32::New(result); + return scope.Close(to); +} + +/** + * @return {Number} result + */ +Handle GitOdbObject::Type(const Arguments& args) { + HandleScope scope; + + + git_otype result = git_odb_object_type( + ObjectWrap::Unwrap(args.This())->GetValue() + ); + + Handle to; + to = Int32::New(result); + return scope.Close(to); +} + +/** + * @return {Oid} result + */ +Handle GitOdbObject::Oid(const Arguments& args) { + HandleScope scope; + + + const git_oid * result = git_odb_object_id( + ObjectWrap::Unwrap(args.This())->GetValue() + ); + + Handle to; + if (result != NULL) { + result = (const git_oid * )git_oid_dup(result); + } + if (result != NULL) { + to = GitOid::New((void *)result); + } else { + to = Null(); + } + return scope.Close(to); +} + +Persistent GitOdbObject::constructor_template; diff --git a/src/oid.cc b/src/oid.cc index fc68b7dea..fbd8ee4a2 100755 --- a/src/oid.cc +++ b/src/oid.cc @@ -1,25 +1,28 @@ -/* - * Copyright 2013, Tim Branyen @tbranyen - * @author Michael Robinson @codeofinterest - * - * Dual licensed under the MIT and GPL licenses. - */ - +/** + * This code is auto-generated; unless you know what you're doing, do not modify! + **/ #include #include #include #include "git2.h" -#include "../include/oid.h" +#include "../include/functions/copy.h" -#include "../include/functions/utilities.h" -#include "../include/functions/string.h" +#include "../include/oid.h" using namespace v8; using namespace node; -void GitOid::Initialize(Handle target) { +GitOid::GitOid(git_oid *raw) { + this->raw = raw; +} + +GitOid::~GitOid() { + free(this->raw); +} + +void GitOid::Initialize(Handle target) { HandleScope scope; Local tpl = FunctionTemplate::New(New); @@ -27,93 +30,91 @@ void GitOid::Initialize(Handle target) { tpl->InstanceTemplate()->SetInternalFieldCount(1); tpl->SetClassName(String::NewSymbol("Oid")); + NODE_SET_METHOD(tpl, "fromString", FromString); NODE_SET_PROTOTYPE_METHOD(tpl, "sha", Sha); - NODE_SET_PROTOTYPE_METHOD(tpl, "fromString", FromString); + constructor_template = Persistent::New(tpl->GetFunction()); target->Set(String::NewSymbol("Oid"), constructor_template); } -git_oid GitOid::GetValue() { - return this->oid; -} -void GitOid::SetValue(git_oid oid) { - this->oid = oid; -} - Handle GitOid::New(const Arguments& args) { HandleScope scope; - GitOid* oid = new GitOid(); - oid->Wrap(args.This()); + if (args.Length() == 0 || !args[0]->IsExternal()) { + return ThrowException(Exception::Error(String::New("git_oid is required."))); + } + + GitOid* object = new GitOid((git_oid *) External::Unwrap(args[0])); + object->Wrap(args.This()); return scope.Close(args.This()); } -Handle GitOid::Sha(const Arguments& args) { +Handle GitOid::New(void *raw) { HandleScope scope; + Handle argv[1] = { External::New((void *)raw) }; + return scope.Close(GitOid::constructor_template->NewInstance(1, argv)); +} - GitOid* oid = ObjectWrap::Unwrap(args.This()); - - char sha[GIT_OID_HEXSZ + 1]; - sha[GIT_OID_HEXSZ] = '\0'; - git_oid rawOid = oid->GetValue(); - git_oid_fmt(sha, const_cast(&rawOid)); - - return scope.Close(String::New(sha)); +git_oid *GitOid::GetValue() { + return this->raw; } + +/** + * @param {String} str + * @return {Oid} out + */ Handle GitOid::FromString(const Arguments& args) { HandleScope scope; - - if(args.Length() == 0 || !args[0]->IsString()) { - return ThrowException(Exception::Error(String::New("String is required and must be a String."))); + if (args.Length() == 0 || !args[0]->IsString()) { + return ThrowException(Exception::Error(String::New("String str is required."))); } - if(args.Length() == 1 || !args[1]->IsFunction()) { - return ThrowException(Exception::Error(String::New("Callback is required and must be a Function."))); + git_oid *out = (git_oid *)malloc(sizeof(git_oid )); + const char * from_str; + String::Utf8Value str(args[0]->ToString()); + from_str = strdup(*str); + + int result = git_oid_fromstr( + out + , from_str + ); + free((void *)from_str); + if (result != GIT_OK) { + free(out); + if (giterr_last()) { + return ThrowException(Exception::Error(String::New(giterr_last()->message))); + } else { + return ThrowException(Exception::Error(String::New("Unkown Error"))); + } } - FromStringBaton* baton = new FromStringBaton; - baton->request.data = baton; - baton->error = NULL; - baton->oid = ObjectWrap::Unwrap(args.This()); - baton->rawOid = baton->oid->GetValue(); - baton->fromString = stringArgToString(args[0]->ToString()); - baton->callback = Persistent::New(Local::Cast(args[1])); - - uv_queue_work(uv_default_loop(), &baton->request, FromStringWork, (uv_after_work_cb)FromStringAfterWork); - - return Undefined(); -} -void GitOid::FromStringWork(uv_work_t* req) { - FromStringBaton *baton = static_cast(req->data); - - int returnCode = git_oid_fromstr(&baton->rawOid, baton->fromString.c_str()); - if (returnCode != GIT_OK) { - baton->error = giterr_last(); + Handle to; + if (out != NULL) { + to = GitOid::New((void *)out); + } else { + to = Null(); } + return scope.Close(to); } -void GitOid::FromStringAfterWork(uv_work_t* req) { - HandleScope scope; - FromStringBaton *baton = static_cast(req->data); - if (success(baton->error, baton->callback)) { - - baton->oid->SetValue(baton->rawOid); +/** + * @return {String} result + */ +Handle GitOid::Sha(const Arguments& args) { + HandleScope scope; + - Handle argv[2] = { - Local::New(Null()), - baton->oid->handle_ - }; + char * result = git_oid_allocfmt( + ObjectWrap::Unwrap(args.This())->GetValue() + ); - TryCatch try_catch; - baton->callback->Call(Context::GetCurrent()->Global(), 2, argv); - if (try_catch.HasCaught()) { - node::FatalException(try_catch); - } - } - delete req; + Handle to; + to = String::New(result); + free(result); + return scope.Close(to); } Persistent GitOid::constructor_template; diff --git a/src/patch.cc b/src/patch.cc new file mode 100644 index 000000000..a28863254 --- /dev/null +++ b/src/patch.cc @@ -0,0 +1,326 @@ +/** + * This code is auto-generated; unless you know what you're doing, do not modify! + **/ +#include +#include +#include + +#include "git2.h" + +#include "../include/functions/copy.h" + +#include "../include/patch.h" +#include "../include/delta.h" +#include "../include/diff_range.h" + +using namespace v8; +using namespace node; + +GitPatch::GitPatch(git_diff_patch *raw) { + this->raw = raw; +} + +GitPatch::~GitPatch() { + git_diff_patch_free(this->raw); +} + +void GitPatch::Initialize(Handle target) { + HandleScope scope; + + Local tpl = FunctionTemplate::New(New); + + tpl->InstanceTemplate()->SetInternalFieldCount(1); + tpl->SetClassName(String::NewSymbol("Patch")); + + NODE_SET_PROTOTYPE_METHOD(tpl, "delta", Delta); + NODE_SET_PROTOTYPE_METHOD(tpl, "size", Size); + NODE_SET_PROTOTYPE_METHOD(tpl, "stats", Stats); + NODE_SET_PROTOTYPE_METHOD(tpl, "hunk", Hunk); + NODE_SET_PROTOTYPE_METHOD(tpl, "lines", Lines); + NODE_SET_PROTOTYPE_METHOD(tpl, "line", Line); + NODE_SET_METHOD(tpl, "toString", ToString); + + + constructor_template = Persistent::New(tpl->GetFunction()); + target->Set(String::NewSymbol("Patch"), constructor_template); +} + +Handle GitPatch::New(const Arguments& args) { + HandleScope scope; + + if (args.Length() == 0 || !args[0]->IsExternal()) { + return ThrowException(Exception::Error(String::New("git_diff_patch is required."))); + } + + GitPatch* object = new GitPatch((git_diff_patch *) External::Unwrap(args[0])); + object->Wrap(args.This()); + + return scope.Close(args.This()); +} + +Handle GitPatch::New(void *raw) { + HandleScope scope; + Handle argv[1] = { External::New((void *)raw) }; + return scope.Close(GitPatch::constructor_template->NewInstance(1, argv)); +} + +git_diff_patch *GitPatch::GetValue() { + return this->raw; +} + + +/** + * @return {Delta} result + */ +Handle GitPatch::Delta(const Arguments& args) { + HandleScope scope; + + + const git_diff_delta * result = git_diff_patch_delta( + ObjectWrap::Unwrap(args.This())->GetValue() + ); + + Handle to; + if (result != NULL) { + result = (const git_diff_delta * )git_diff_delta_dup(result); + } + if (result != NULL) { + to = GitDelta::New((void *)result); + } else { + to = Null(); + } + return scope.Close(to); +} + +/** + * @return {Number} result + */ +Handle GitPatch::Size(const Arguments& args) { + HandleScope scope; + + + size_t result = git_diff_patch_num_hunks( + ObjectWrap::Unwrap(args.This())->GetValue() + ); + + Handle to; + to = Uint32::New(result); + return scope.Close(to); +} + +/** + * @return {Number} total_context + * @return {Number} total_additions + * @return {Number} total_deletions + */ +Handle GitPatch::Stats(const Arguments& args) { + HandleScope scope; + + size_t total_context = NULL; + size_t total_additions = NULL; + size_t total_deletions = NULL; + + int result = git_diff_patch_line_stats( + &total_context + , &total_additions + , &total_deletions + , ObjectWrap::Unwrap(args.This())->GetValue() + ); + if (result != GIT_OK) { + if (giterr_last()) { + return ThrowException(Exception::Error(String::New(giterr_last()->message))); + } else { + return ThrowException(Exception::Error(String::New("Unkown Error"))); + } + } + + Handle toReturn = Object::New(); + Handle to; + to = Integer::New(total_context); + toReturn->Set(String::NewSymbol("total_context"), to); + + to = Integer::New(total_additions); + toReturn->Set(String::NewSymbol("total_additions"), to); + + to = Integer::New(total_deletions); + toReturn->Set(String::NewSymbol("total_deletions"), to); + + return scope.Close(toReturn); +} + +/** + * @param {Number} hunk_idx + * @return {DiffRange} range + * @return {String} header + * @return {Number} header_len + * @return {Number} lines_in_hunk + */ +Handle GitPatch::Hunk(const Arguments& args) { + HandleScope scope; + if (args.Length() == 0 || !args[0]->IsUint32()) { + return ThrowException(Exception::Error(String::New("Number hunk_idx is required."))); + } + + const git_diff_range *range = NULL; + const char *header = NULL; + size_t header_len = NULL; + size_t lines_in_hunk = NULL; + size_t from_hunk_idx; + from_hunk_idx = (size_t) args[0]->ToUint32()->Value(); + + int result = git_diff_patch_get_hunk( + &range + , &header + , &header_len + , &lines_in_hunk + , ObjectWrap::Unwrap(args.This())->GetValue() + , from_hunk_idx + ); + if (result != GIT_OK) { + if (giterr_last()) { + return ThrowException(Exception::Error(String::New(giterr_last()->message))); + } else { + return ThrowException(Exception::Error(String::New("Unkown Error"))); + } + } + + Handle toReturn = Object::New(); + Handle to; + if (range != NULL) { + range = (const git_diff_range * )git_diff_range_dup(range); + } + if (range != NULL) { + to = GitDiffRange::New((void *)range); + } else { + to = Null(); + } + toReturn->Set(String::NewSymbol("range"), to); + + to = String::New(header); + toReturn->Set(String::NewSymbol("header"), to); + + to = Uint32::New(header_len); + toReturn->Set(String::NewSymbol("headerLength"), to); + + to = Uint32::New(lines_in_hunk); + toReturn->Set(String::NewSymbol("lines"), to); + + return scope.Close(toReturn); +} + +/** + * @param {Number} hunk_idx + * @return {Number} result + */ +Handle GitPatch::Lines(const Arguments& args) { + HandleScope scope; + if (args.Length() == 0 || !args[0]->IsUint32()) { + return ThrowException(Exception::Error(String::New("Number hunk_idx is required."))); + } + + size_t from_hunk_idx; + from_hunk_idx = (size_t) args[0]->ToUint32()->Value(); + + int result = git_diff_patch_num_lines_in_hunk( + ObjectWrap::Unwrap(args.This())->GetValue() + , from_hunk_idx + ); + + Handle to; + to = Int32::New(result); + return scope.Close(to); +} + +/** + * @param {Number} hunk_idx + * @param {Number} line_of_hunk + * @return {Number} line_origin + * @return {String} content + * @return {Number} content_len + * @return {Number} old_lineno + * @return {Number} new_lineno + */ +Handle GitPatch::Line(const Arguments& args) { + HandleScope scope; + if (args.Length() == 0 || !args[0]->IsUint32()) { + return ThrowException(Exception::Error(String::New("Number hunk_idx is required."))); + } + if (args.Length() == 1 || !args[1]->IsUint32()) { + return ThrowException(Exception::Error(String::New("Number line_of_hunk is required."))); + } + + char line_origin = NULL; + const char *content = NULL; + size_t content_len = NULL; + int old_lineno = NULL; + int new_lineno = NULL; + size_t from_hunk_idx; + from_hunk_idx = (size_t) args[0]->ToUint32()->Value(); + size_t from_line_of_hunk; + from_line_of_hunk = (size_t) args[1]->ToUint32()->Value(); + + int result = git_diff_patch_get_line_in_hunk( + &line_origin + , &content + , &content_len + , &old_lineno + , &new_lineno + , ObjectWrap::Unwrap(args.This())->GetValue() + , from_hunk_idx + , from_line_of_hunk + ); + if (result != GIT_OK) { + if (giterr_last()) { + return ThrowException(Exception::Error(String::New(giterr_last()->message))); + } else { + return ThrowException(Exception::Error(String::New("Unkown Error"))); + } + } + + Handle toReturn = Object::New(); + Handle to; + to = Integer::New(line_origin); + toReturn->Set(String::NewSymbol("lineOrigin"), to); + + to = String::New(content, content_len); + toReturn->Set(String::NewSymbol("content"), to); + + to = Uint32::New(content_len); + toReturn->Set(String::NewSymbol("length"), to); + + to = Int32::New(old_lineno); + toReturn->Set(String::NewSymbol("oldLineNumber"), to); + + to = Int32::New(new_lineno); + toReturn->Set(String::NewSymbol("newLineNumber"), to); + + return scope.Close(toReturn); +} + +/** + * @return {String} string + */ +Handle GitPatch::ToString(const Arguments& args) { + HandleScope scope; + + char *string = NULL; + + int result = git_diff_patch_to_str( + &string + , ObjectWrap::Unwrap(args.This())->GetValue() + ); + if (result != GIT_OK) { + if (giterr_last()) { + return ThrowException(Exception::Error(String::New(giterr_last()->message))); + } else { + return ThrowException(Exception::Error(String::New("Unkown Error"))); + } + } + + Handle to; + to = String::New(string); + free(string); + return scope.Close(to); +} + +Persistent GitPatch::constructor_template; diff --git a/src/refdb.cc b/src/refdb.cc new file mode 100644 index 000000000..d1b344d76 --- /dev/null +++ b/src/refdb.cc @@ -0,0 +1,63 @@ +/** + * This code is auto-generated; unless you know what you're doing, do not modify! + **/ +#include +#include +#include + +#include "git2.h" + +#include "../include/functions/copy.h" + +#include "../include/refdb.h" + +using namespace v8; +using namespace node; + +GitRefDb::GitRefDb(git_refdb *raw) { + this->raw = raw; +} + +GitRefDb::~GitRefDb() { + free(this->raw); +} + +void GitRefDb::Initialize(Handle target) { + HandleScope scope; + + Local tpl = FunctionTemplate::New(New); + + tpl->InstanceTemplate()->SetInternalFieldCount(1); + tpl->SetClassName(String::NewSymbol("RefDb")); + + + + constructor_template = Persistent::New(tpl->GetFunction()); + target->Set(String::NewSymbol("RefDb"), constructor_template); +} + +Handle GitRefDb::New(const Arguments& args) { + HandleScope scope; + + if (args.Length() == 0 || !args[0]->IsExternal()) { + return ThrowException(Exception::Error(String::New("git_refdb is required."))); + } + + GitRefDb* object = new GitRefDb((git_refdb *) External::Unwrap(args[0])); + object->Wrap(args.This()); + + return scope.Close(args.This()); +} + +Handle GitRefDb::New(void *raw) { + HandleScope scope; + Handle argv[1] = { External::New((void *)raw) }; + return scope.Close(GitRefDb::constructor_template->NewInstance(1, argv)); +} + +git_refdb *GitRefDb::GetValue() { + return this->raw; +} + + +Persistent GitRefDb::constructor_template; diff --git a/src/reference.cc b/src/reference.cc index a80628ca9..86258e948 100755 --- a/src/reference.cc +++ b/src/reference.cc @@ -1,28 +1,31 @@ -/* - * Copyright 2011, Tim Branyen @tbranyen - * @author Michael Robinson @codeofinterest - * - * Dual licensed under the MIT and GPL licenses. - */ - +/** + * This code is auto-generated; unless you know what you're doing, do not modify! + **/ #include #include -#include +#include #include "git2.h" -#include "../include/repo.h" +#include "../include/functions/copy.h" + #include "../include/reference.h" +#include "../include/repo.h" #include "../include/oid.h" -#include "../include/error.h" - -#include "../include/functions/string.h" -#include "../include/functions/utilities.h" +#include "../include/object.h" using namespace v8; using namespace node; -void GitReference::Initialize(Handle target) { +GitReference::GitReference(git_reference *raw) { + this->raw = raw; +} + +GitReference::~GitReference() { + git_reference_free(this->raw); +} + +void GitReference::Initialize(Handle target) { HandleScope scope; Local tpl = FunctionTemplate::New(New); @@ -30,151 +33,619 @@ void GitReference::Initialize(Handle target) { tpl->InstanceTemplate()->SetInternalFieldCount(1); tpl->SetClassName(String::NewSymbol("Reference")); - NODE_SET_PROTOTYPE_METHOD(tpl, "oid", Oid); - NODE_SET_PROTOTYPE_METHOD(tpl, "lookup", Lookup); + NODE_SET_METHOD(tpl, "oidForName", OidForName); + NODE_SET_PROTOTYPE_METHOD(tpl, "target", Target); + NODE_SET_PROTOTYPE_METHOD(tpl, "symbolicTarget", SymbolicTarget); + NODE_SET_PROTOTYPE_METHOD(tpl, "type", Type); + NODE_SET_PROTOTYPE_METHOD(tpl, "name", Name); + NODE_SET_PROTOTYPE_METHOD(tpl, "resolve", Resolve); + NODE_SET_PROTOTYPE_METHOD(tpl, "setSymbolicTarget", SetSymbolicTarget); + NODE_SET_PROTOTYPE_METHOD(tpl, "setTarget", setTarget); + NODE_SET_PROTOTYPE_METHOD(tpl, "rename", Rename); + NODE_SET_PROTOTYPE_METHOD(tpl, "delete", Delete); + NODE_SET_PROTOTYPE_METHOD(tpl, "isBranch", IsBranch); + NODE_SET_PROTOTYPE_METHOD(tpl, "isRemote", IsRemote); + NODE_SET_PROTOTYPE_METHOD(tpl, "peel", Peel); + NODE_SET_METHOD(tpl, "isValidName", IsValidName); + constructor_template = Persistent::New(tpl->GetFunction()); target->Set(String::NewSymbol("Reference"), constructor_template); } -git_reference* GitReference::GetValue() { - return this->ref; -} -void GitReference::SetValue(git_reference *ref) { - this->ref = ref; -} - Handle GitReference::New(const Arguments& args) { HandleScope scope; - GitReference *ref = new GitReference(); + if (args.Length() == 0 || !args[0]->IsExternal()) { + return ThrowException(Exception::Error(String::New("git_reference is required."))); + } + + GitReference* object = new GitReference((git_reference *) External::Unwrap(args[0])); + object->Wrap(args.This()); - ref->Wrap(args.This()); + return scope.Close(args.This()); +} - return args.This(); +Handle GitReference::New(void *raw) { + HandleScope scope; + Handle argv[1] = { External::New((void *)raw) }; + return scope.Close(GitReference::constructor_template->NewInstance(1, argv)); } -Handle GitReference::Oid(const Arguments& args) { +git_reference *GitReference::GetValue() { + return this->raw; +} + + +/** + * @param {Repository} repo + * @param {String} name + * @param {Oid} callback + */ +Handle GitReference::OidForName(const Arguments& args) { HandleScope scope; + if (args.Length() == 0 || !args[0]->IsObject()) { + return ThrowException(Exception::Error(String::New("Repository repo is required."))); + } + if (args.Length() == 1 || !args[1]->IsString()) { + return ThrowException(Exception::Error(String::New("String name is required."))); + } - if(args.Length() == 0 || !args[0]->IsFunction()) { + if (args.Length() == 2 || !args[2]->IsFunction()) { return ThrowException(Exception::Error(String::New("Callback is required and must be a Function."))); } - OidBaton *baton = new OidBaton; - baton->request.data = baton; + OidForNameBaton* baton = new OidForNameBaton; + baton->error_code = GIT_OK; baton->error = NULL; - baton->rawOid = NULL; - baton->rawRef = ObjectWrap::Unwrap(args.This())->GetValue(); - baton->callback = Persistent::New(Local::Cast(args[0])); - - uv_queue_work(uv_default_loop(), &baton->request, OidWork, (uv_after_work_cb)OidAfterWork); + baton->request.data = baton; + baton->out = (git_oid *)malloc(sizeof(git_oid )); + baton->repoReference = Persistent::New(args[0]); + git_repository * from_repo; + from_repo = ObjectWrap::Unwrap(args[0]->ToObject())->GetValue(); + baton->repo = from_repo; + baton->nameReference = Persistent::New(args[1]); + const char * from_name; + String::Utf8Value name(args[1]->ToString()); + from_name = strdup(*name); + baton->name = from_name; + baton->callback = Persistent::New(Local::Cast(args[2])); + + uv_queue_work(uv_default_loop(), &baton->request, OidForNameWork, (uv_after_work_cb)OidForNameAfterWork); return Undefined(); } -void GitReference::OidWork(uv_work_t* req) { - OidBaton *baton = static_cast(req->data); - - git_ref_t referenceType = git_reference_type(baton->rawRef); - if (referenceType == GIT_REF_INVALID) { - giterr_set_str(GITERR_INVALID, "Invalid reference type"); +void GitReference::OidForNameWork(uv_work_t *req) { + OidForNameBaton *baton = static_cast(req->data); + int result = git_reference_name_to_id( + baton->out, + baton->repo, + baton->name + ); + baton->error_code = result; + if (result != GIT_OK) { baton->error = giterr_last(); - return; } +} - if (referenceType == GIT_REF_SYMBOLIC) { - int returnCode = git_reference_resolve(&baton->rawRef, baton->rawRef); - if (returnCode != GIT_OK) { - baton->error = giterr_last(); - return; +void GitReference::OidForNameAfterWork(uv_work_t *req) { + HandleScope scope; + OidForNameBaton *baton = static_cast(req->data); + + TryCatch try_catch; + if (baton->error_code == GIT_OK) { + Handle to; + if (baton->out != NULL) { + to = GitOid::New((void *)baton->out); + } else { + to = Null(); + } + Handle result = to; + Handle argv[2] = { + Local::New(Null()), + result + }; + baton->callback->Call(Context::GetCurrent()->Global(), 2, argv); + } else { + if (baton->error) { + Handle argv[1] = { + Exception::Error(String::New(baton->error->message)) + }; + baton->callback->Call(Context::GetCurrent()->Global(), 1, argv); + } else { + baton->callback->Call(Context::GetCurrent()->Global(), 0, NULL); } + free(baton->out); + } + + if (try_catch.HasCaught()) { + node::FatalException(try_catch); } + baton->repoReference.Dispose(); + baton->nameReference.Dispose(); + baton->callback.Dispose(); + free((void *)baton->name); + delete baton; +} + +/** + * @return {Oid} result + */ +Handle GitReference::Target(const Arguments& args) { + HandleScope scope; + + + const git_oid * result = git_reference_target( + ObjectWrap::Unwrap(args.This())->GetValue() + ); - baton->rawOid = git_reference_target(baton->rawRef); + Handle to; + if (result != NULL) { + result = (const git_oid * )git_oid_dup(result); + } + if (result != NULL) { + to = GitOid::New((void *)result); + } else { + to = Null(); + } + return scope.Close(to); } -void GitReference::OidAfterWork(uv_work_t* req) { + +/** + * @return {String} result + */ +Handle GitReference::SymbolicTarget(const Arguments& args) { HandleScope scope; - OidBaton *baton = static_cast(req->data); + + + const char * result = git_reference_symbolic_target( + ObjectWrap::Unwrap(args.This())->GetValue() + ); - if (success(baton->error, baton->callback)) { - Handle oid = GitOid::constructor_template->NewInstance(); - GitOid *oidInstance = ObjectWrap::Unwrap(oid); - oidInstance->SetValue(*const_cast(baton->rawOid)); + Handle to; + to = String::New(result); + return scope.Close(to); +} +/** + * @return {Number} result + */ +Handle GitReference::Type(const Arguments& args) { + HandleScope scope; + + + git_ref_t result = git_reference_type( + ObjectWrap::Unwrap(args.This())->GetValue() + ); + + Handle to; + to = Number::New(result); + return scope.Close(to); +} + +/** + * @return {String} result + */ +Handle GitReference::Name(const Arguments& args) { + HandleScope scope; + + + const char * result = git_reference_name( + ObjectWrap::Unwrap(args.This())->GetValue() + ); + + Handle to; + to = String::New(result); + return scope.Close(to); +} + +/** + * @param {Reference} callback + */ +Handle GitReference::Resolve(const Arguments& args) { + HandleScope scope; + + if (args.Length() == 0 || !args[0]->IsFunction()) { + return ThrowException(Exception::Error(String::New("Callback is required and must be a Function."))); + } + + ResolveBaton* baton = new ResolveBaton; + baton->error_code = GIT_OK; + baton->error = NULL; + baton->request.data = baton; + baton->refReference = Persistent::New(args.This()); + baton->ref = ObjectWrap::Unwrap(args.This())->GetValue(); + baton->callback = Persistent::New(Local::Cast(args[0])); + + uv_queue_work(uv_default_loop(), &baton->request, ResolveWork, (uv_after_work_cb)ResolveAfterWork); + + return Undefined(); +} + +void GitReference::ResolveWork(uv_work_t *req) { + ResolveBaton *baton = static_cast(req->data); + int result = git_reference_resolve( + &baton->out, + baton->ref + ); + baton->error_code = result; + if (result != GIT_OK) { + baton->error = giterr_last(); + } +} + +void GitReference::ResolveAfterWork(uv_work_t *req) { + HandleScope scope; + ResolveBaton *baton = static_cast(req->data); + + TryCatch try_catch; + if (baton->error_code == GIT_OK) { + Handle to; + if (baton->out != NULL) { + to = GitReference::New((void *)baton->out); + } else { + to = Null(); + } + Handle result = to; Handle argv[2] = { Local::New(Null()), - oid + result }; - - TryCatch try_catch; baton->callback->Call(Context::GetCurrent()->Global(), 2, argv); - if (try_catch.HasCaught()) { - node::FatalException(try_catch); + } else { + if (baton->error) { + Handle argv[1] = { + Exception::Error(String::New(baton->error->message)) + }; + baton->callback->Call(Context::GetCurrent()->Global(), 1, argv); + } else { + baton->callback->Call(Context::GetCurrent()->Global(), 0, NULL); } + } + + if (try_catch.HasCaught()) { + node::FatalException(try_catch); } + baton->refReference.Dispose(); + baton->callback.Dispose(); + delete baton; +} - delete req; +/** + * @param {String} target + * @return {Reference} out + */ +Handle GitReference::SetSymbolicTarget(const Arguments& args) { + HandleScope scope; + if (args.Length() == 0 || !args[0]->IsString()) { + return ThrowException(Exception::Error(String::New("String target is required."))); + } + + git_reference *out = NULL; + const char * from_target; + String::Utf8Value target(args[0]->ToString()); + from_target = strdup(*target); + + int result = git_reference_symbolic_set_target( + &out + , ObjectWrap::Unwrap(args.This())->GetValue() + , from_target + ); + free((void *)from_target); + if (result != GIT_OK) { + if (giterr_last()) { + return ThrowException(Exception::Error(String::New(giterr_last()->message))); + } else { + return ThrowException(Exception::Error(String::New("Unkown Error"))); + } + } + + Handle to; + if (out != NULL) { + to = GitReference::New((void *)out); + } else { + to = Null(); + } + return scope.Close(to); } -Handle GitReference::Lookup(const Arguments& args) { +/** + * @param {Oid} id + * @return {Reference} out + */ +Handle GitReference::setTarget(const Arguments& args) { HandleScope scope; + if (args.Length() == 0 || !args[0]->IsObject()) { + return ThrowException(Exception::Error(String::New("Oid id is required."))); + } - if(args.Length() == 0 || !args[0]->IsObject()) { - return ThrowException(Exception::Error(String::New("Repo is required and must be a Object."))); + git_reference *out = NULL; + const git_oid * from_id; + from_id = ObjectWrap::Unwrap(args[0]->ToObject())->GetValue(); + + int result = git_reference_set_target( + &out + , ObjectWrap::Unwrap(args.This())->GetValue() + , from_id + ); + if (result != GIT_OK) { + if (giterr_last()) { + return ThrowException(Exception::Error(String::New(giterr_last()->message))); + } else { + return ThrowException(Exception::Error(String::New("Unkown Error"))); + } } - if(args.Length() == 1 || !args[1]->IsString()) { - return ThrowException(Exception::Error(String::New("Name is required and must be a String."))); + Handle to; + if (out != NULL) { + to = GitReference::New((void *)out); + } else { + to = Null(); } + return scope.Close(to); +} - if(args.Length() == 2 || !args[2]->IsFunction()) { +/** + * @param {String} new_name + * @param {Number} force + * @param {Reference} callback + */ +Handle GitReference::Rename(const Arguments& args) { + HandleScope scope; + if (args.Length() == 0 || !args[0]->IsString()) { + return ThrowException(Exception::Error(String::New("String new_name is required."))); + } + if (args.Length() == 1 || !args[1]->IsInt32()) { + return ThrowException(Exception::Error(String::New("Number force is required."))); + } + + if (args.Length() == 2 || !args[2]->IsFunction()) { return ThrowException(Exception::Error(String::New("Callback is required and must be a Function."))); } - LookupBaton *baton = new LookupBaton; + RenameBaton* baton = new RenameBaton; + baton->error_code = GIT_OK; + baton->error = NULL; baton->request.data = baton; - baton->ref = ObjectWrap::Unwrap(args.This()); - baton->ref->Ref(); + baton->refReference = Persistent::New(args.This()); + baton->ref = ObjectWrap::Unwrap(args.This())->GetValue(); + baton->new_nameReference = Persistent::New(args[0]); + const char * from_new_name; + String::Utf8Value new_name(args[0]->ToString()); + from_new_name = strdup(*new_name); + baton->new_name = from_new_name; + baton->forceReference = Persistent::New(args[1]); + int from_force; + from_force = (int) args[1]->ToInt32()->Value(); + baton->force = from_force; + baton->callback = Persistent::New(Local::Cast(args[2])); + + uv_queue_work(uv_default_loop(), &baton->request, RenameWork, (uv_after_work_cb)RenameAfterWork); + + return Undefined(); +} + +void GitReference::RenameWork(uv_work_t *req) { + RenameBaton *baton = static_cast(req->data); + int result = git_reference_rename( + &baton->out, + baton->ref, + baton->new_name, + baton->force + ); + baton->error_code = result; + if (result != GIT_OK) { + baton->error = giterr_last(); + } +} + +void GitReference::RenameAfterWork(uv_work_t *req) { + HandleScope scope; + RenameBaton *baton = static_cast(req->data); + + TryCatch try_catch; + if (baton->error_code == GIT_OK) { + Handle to; + if (baton->out != NULL) { + to = GitReference::New((void *)baton->out); + } else { + to = Null(); + } + Handle result = to; + Handle argv[2] = { + Local::New(Null()), + result + }; + baton->callback->Call(Context::GetCurrent()->Global(), 2, argv); + } else { + if (baton->error) { + Handle argv[1] = { + Exception::Error(String::New(baton->error->message)) + }; + baton->callback->Call(Context::GetCurrent()->Global(), 1, argv); + } else { + baton->callback->Call(Context::GetCurrent()->Global(), 0, NULL); + } + } + + if (try_catch.HasCaught()) { + node::FatalException(try_catch); + } + baton->refReference.Dispose(); + baton->new_nameReference.Dispose(); + baton->forceReference.Dispose(); + baton->callback.Dispose(); + free((void *)baton->new_name); + delete baton; +} + +/** + */ +Handle GitReference::Delete(const Arguments& args) { + HandleScope scope; + + if (args.Length() == 0 || !args[0]->IsFunction()) { + return ThrowException(Exception::Error(String::New("Callback is required and must be a Function."))); + } + + DeleteBaton* baton = new DeleteBaton; + baton->error_code = GIT_OK; baton->error = NULL; - baton->rawRepo = ObjectWrap::Unwrap(args[0]->ToObject())->GetValue(); - baton->name = stringArgToString(args[1]->ToString()); - baton->callback = Persistent::New(Local::Cast(args[2])); + baton->request.data = baton; + baton->refReference = Persistent::New(args.This()); + baton->ref = ObjectWrap::Unwrap(args.This())->GetValue(); + baton->callback = Persistent::New(Local::Cast(args[0])); - uv_queue_work(uv_default_loop(), &baton->request, LookupWork, (uv_after_work_cb)LookupAfterWork); + uv_queue_work(uv_default_loop(), &baton->request, DeleteWork, (uv_after_work_cb)DeleteAfterWork); return Undefined(); } -void GitReference::LookupWork(uv_work_t *req) { - LookupBaton *baton = static_cast(req->data); - baton->rawRef = NULL; - int returnCode = git_reference_lookup(&baton->rawRef, baton->rawRepo, baton->name.c_str()); - if (returnCode != GIT_OK) { +void GitReference::DeleteWork(uv_work_t *req) { + DeleteBaton *baton = static_cast(req->data); + int result = git_reference_delete( + baton->ref + ); + baton->error_code = result; + if (result != GIT_OK) { baton->error = giterr_last(); } } -void GitReference::LookupAfterWork(uv_work_t *req) { - HandleScope scope; - LookupBaton *baton = static_cast(req->data); - if (success(baton->error, baton->callback)) { - baton->ref->SetValue(baton->rawRef); +void GitReference::DeleteAfterWork(uv_work_t *req) { + HandleScope scope; + DeleteBaton *baton = static_cast(req->data); + TryCatch try_catch; + if (baton->error_code == GIT_OK) { + Handle result = Local::New(Undefined()); Handle argv[2] = { Local::New(Null()), - baton->ref->handle_ + result }; - - TryCatch try_catch; baton->callback->Call(Context::GetCurrent()->Global(), 2, argv); - if (try_catch.HasCaught()) { - node::FatalException(try_catch); + } else { + if (baton->error) { + Handle argv[1] = { + Exception::Error(String::New(baton->error->message)) + }; + baton->callback->Call(Context::GetCurrent()->Global(), 1, argv); + } else { + baton->callback->Call(Context::GetCurrent()->Global(), 0, NULL); } + } + + if (try_catch.HasCaught()) { + node::FatalException(try_catch); } + baton->refReference.Dispose(); + baton->callback.Dispose(); + delete baton; +} - baton->ref->Unref(); - delete req; +/** + */ +Handle GitReference::IsBranch(const Arguments& args) { + HandleScope scope; + + + int result = git_reference_is_branch( + ObjectWrap::Unwrap(args.This())->GetValue() + ); + if (result != GIT_OK) { + if (giterr_last()) { + return ThrowException(Exception::Error(String::New(giterr_last()->message))); + } else { + return ThrowException(Exception::Error(String::New("Unkown Error"))); + } + } + + return Undefined(); +} + +/** + */ +Handle GitReference::IsRemote(const Arguments& args) { + HandleScope scope; + + + int result = git_reference_is_remote( + ObjectWrap::Unwrap(args.This())->GetValue() + ); + if (result != GIT_OK) { + if (giterr_last()) { + return ThrowException(Exception::Error(String::New(giterr_last()->message))); + } else { + return ThrowException(Exception::Error(String::New("Unkown Error"))); + } + } + + return Undefined(); +} + +/** + * @param {Number} type + * @return {Object} out + */ +Handle GitReference::Peel(const Arguments& args) { + HandleScope scope; + if (args.Length() == 0 || !args[0]->IsInt32()) { + return ThrowException(Exception::Error(String::New("Number type is required."))); + } + + git_object *out = NULL; + git_otype from_type; + from_type = (git_otype) args[0]->ToInt32()->Value(); + + int result = git_reference_peel( + &out + , ObjectWrap::Unwrap(args.This())->GetValue() + , from_type + ); + if (result != GIT_OK) { + if (giterr_last()) { + return ThrowException(Exception::Error(String::New(giterr_last()->message))); + } else { + return ThrowException(Exception::Error(String::New("Unkown Error"))); + } + } + + Handle to; + if (out != NULL) { + to = GitObject::New((void *)out); + } else { + to = Null(); + } + return scope.Close(to); +} + +/** + * @param {String} refname + */ +Handle GitReference::IsValidName(const Arguments& args) { + HandleScope scope; + if (args.Length() == 0 || !args[0]->IsString()) { + return ThrowException(Exception::Error(String::New("String refname is required."))); + } + + const char * from_refname; + String::Utf8Value refname(args[0]->ToString()); + from_refname = strdup(*refname); + + int result = git_reference_is_valid_name( + from_refname + ); + free((void *)from_refname); + if (result != GIT_OK) { + if (giterr_last()) { + return ThrowException(Exception::Error(String::New(giterr_last()->message))); + } else { + return ThrowException(Exception::Error(String::New("Unkown Error"))); + } + } + + return Undefined(); } Persistent GitReference::constructor_template; diff --git a/src/remote.cc b/src/remote.cc new file mode 100644 index 000000000..3445111a0 --- /dev/null +++ b/src/remote.cc @@ -0,0 +1,597 @@ +/** + * This code is auto-generated; unless you know what you're doing, do not modify! + **/ +#include +#include +#include + +#include "git2.h" + +#include "../include/functions/copy.h" + +#include "../include/remote.h" +#include "git2/net.h" + +using namespace v8; +using namespace node; + +GitRemote::GitRemote(git_remote *raw) { + this->raw = raw; +} + +GitRemote::~GitRemote() { + git_remote_free(this->raw); +} + +void GitRemote::Initialize(Handle target) { + HandleScope scope; + + Local tpl = FunctionTemplate::New(New); + + tpl->InstanceTemplate()->SetInternalFieldCount(1); + tpl->SetClassName(String::NewSymbol("Remote")); + + NODE_SET_PROTOTYPE_METHOD(tpl, "name", Name); + NODE_SET_PROTOTYPE_METHOD(tpl, "url", Url); + NODE_SET_PROTOTYPE_METHOD(tpl, "pushUrl", PushUrl); + NODE_SET_PROTOTYPE_METHOD(tpl, "setUrl", SetUrl); + NODE_SET_PROTOTYPE_METHOD(tpl, "setPushUrl", SetPushUrl); + NODE_SET_PROTOTYPE_METHOD(tpl, "connect", Connect); + NODE_SET_PROTOTYPE_METHOD(tpl, "download", Download); + NODE_SET_PROTOTYPE_METHOD(tpl, "connected", Connected); + NODE_SET_PROTOTYPE_METHOD(tpl, "stop", Stop); + NODE_SET_PROTOTYPE_METHOD(tpl, "disconnect", Disconnect); + NODE_SET_PROTOTYPE_METHOD(tpl, "updateTips", UpdateTips); + NODE_SET_METHOD(tpl, "validUrl", ValidUrl); + NODE_SET_METHOD(tpl, "supportedUrl", SupportedUrl); + NODE_SET_PROTOTYPE_METHOD(tpl, "checkCert", CheckCert); + NODE_SET_PROTOTYPE_METHOD(tpl, "updateFetchhead", UpdateFetchhead); + NODE_SET_PROTOTYPE_METHOD(tpl, "setUpdateFetchhead", SetUpdateFetchhead); + NODE_SET_METHOD(tpl, "isValidName", IsValidName); + + + constructor_template = Persistent::New(tpl->GetFunction()); + target->Set(String::NewSymbol("Remote"), constructor_template); +} + +Handle GitRemote::New(const Arguments& args) { + HandleScope scope; + + if (args.Length() == 0 || !args[0]->IsExternal()) { + return ThrowException(Exception::Error(String::New("git_remote is required."))); + } + + GitRemote* object = new GitRemote((git_remote *) External::Unwrap(args[0])); + object->Wrap(args.This()); + + return scope.Close(args.This()); +} + +Handle GitRemote::New(void *raw) { + HandleScope scope; + Handle argv[1] = { External::New((void *)raw) }; + return scope.Close(GitRemote::constructor_template->NewInstance(1, argv)); +} + +git_remote *GitRemote::GetValue() { + return this->raw; +} + + +/** + * @return {String} result + */ +Handle GitRemote::Name(const Arguments& args) { + HandleScope scope; + + + const char * result = git_remote_name( + ObjectWrap::Unwrap(args.This())->GetValue() + ); + + Handle to; + to = String::New(result); + return scope.Close(to); +} + +/** + * @return {String} result + */ +Handle GitRemote::Url(const Arguments& args) { + HandleScope scope; + + + const char * result = git_remote_url( + ObjectWrap::Unwrap(args.This())->GetValue() + ); + + Handle to; + to = String::New(result); + return scope.Close(to); +} + +/** + * @return {String} result + */ +Handle GitRemote::PushUrl(const Arguments& args) { + HandleScope scope; + + + const char * result = git_remote_pushurl( + ObjectWrap::Unwrap(args.This())->GetValue() + ); + + Handle to; + to = String::New(result); + return scope.Close(to); +} + +/** + * @param {String} url + */ +Handle GitRemote::SetUrl(const Arguments& args) { + HandleScope scope; + if (args.Length() == 0 || !args[0]->IsString()) { + return ThrowException(Exception::Error(String::New("String url is required."))); + } + + const char* from_url; + String::Utf8Value url(args[0]->ToString()); + from_url = strdup(*url); + + int result = git_remote_set_url( + ObjectWrap::Unwrap(args.This())->GetValue() + , from_url + ); + free((void *)from_url); + if (result != GIT_OK) { + if (giterr_last()) { + return ThrowException(Exception::Error(String::New(giterr_last()->message))); + } else { + return ThrowException(Exception::Error(String::New("Unkown Error"))); + } + } + + return Undefined(); +} + +/** + * @param {String} url + */ +Handle GitRemote::SetPushUrl(const Arguments& args) { + HandleScope scope; + if (args.Length() == 0 || !args[0]->IsString()) { + return ThrowException(Exception::Error(String::New("String url is required."))); + } + + const char* from_url; + String::Utf8Value url(args[0]->ToString()); + from_url = strdup(*url); + + int result = git_remote_set_pushurl( + ObjectWrap::Unwrap(args.This())->GetValue() + , from_url + ); + free((void *)from_url); + if (result != GIT_OK) { + if (giterr_last()) { + return ThrowException(Exception::Error(String::New(giterr_last()->message))); + } else { + return ThrowException(Exception::Error(String::New("Unkown Error"))); + } + } + + return Undefined(); +} + +/** + * @param {Number} direction + */ +Handle GitRemote::Connect(const Arguments& args) { + HandleScope scope; + if (args.Length() == 0 || !args[0]->IsNumber()) { + return ThrowException(Exception::Error(String::New("Number direction is required."))); + } + + if (args.Length() == 1 || !args[1]->IsFunction()) { + return ThrowException(Exception::Error(String::New("Callback is required and must be a Function."))); + } + + ConnectBaton* baton = new ConnectBaton; + baton->error_code = GIT_OK; + baton->error = NULL; + baton->request.data = baton; + baton->remoteReference = Persistent::New(args.This()); + baton->remote = ObjectWrap::Unwrap(args.This())->GetValue(); + baton->directionReference = Persistent::New(args[0]); + git_direction from_direction; + from_direction = (git_direction) args[0]->ToNumber()->Value(); + baton->direction = from_direction; + baton->callback = Persistent::New(Local::Cast(args[1])); + + uv_queue_work(uv_default_loop(), &baton->request, ConnectWork, (uv_after_work_cb)ConnectAfterWork); + + return Undefined(); +} + +void GitRemote::ConnectWork(uv_work_t *req) { + ConnectBaton *baton = static_cast(req->data); + int result = git_remote_connect( + baton->remote, + baton->direction + ); + baton->error_code = result; + if (result != GIT_OK) { + baton->error = giterr_last(); + } +} + +void GitRemote::ConnectAfterWork(uv_work_t *req) { + HandleScope scope; + ConnectBaton *baton = static_cast(req->data); + + TryCatch try_catch; + if (baton->error_code == GIT_OK) { + Handle result = Local::New(Undefined()); + Handle argv[2] = { + Local::New(Null()), + result + }; + baton->callback->Call(Context::GetCurrent()->Global(), 2, argv); + } else { + if (baton->error) { + Handle argv[1] = { + Exception::Error(String::New(baton->error->message)) + }; + baton->callback->Call(Context::GetCurrent()->Global(), 1, argv); + } else { + baton->callback->Call(Context::GetCurrent()->Global(), 0, NULL); + } + } + + if (try_catch.HasCaught()) { + node::FatalException(try_catch); + } + baton->remoteReference.Dispose(); + baton->directionReference.Dispose(); + baton->callback.Dispose(); + delete baton; +} + +/** + * @param {Function} progress_cb + * @param {void} payload + */ +Handle GitRemote::Download(const Arguments& args) { + HandleScope scope; + + if (args.Length() == 1 || !args[1]->IsFunction()) { + return ThrowException(Exception::Error(String::New("Callback is required and must be a Function."))); + } + + DownloadBaton* baton = new DownloadBaton; + baton->error_code = GIT_OK; + baton->error = NULL; + baton->request.data = baton; + baton->remoteReference = Persistent::New(args.This()); + baton->remote = ObjectWrap::Unwrap(args.This())->GetValue(); + baton->progress_cbReference = Persistent::New(args[0]); + git_transfer_progress_callback from_progress_cb; + if (args[0]->IsFunction()) { + Persistent::New(Local::Cast(args[0])); + } else { + from_progress_cb = NULL; + } + baton->progress_cb = from_progress_cb; + baton->payloadReference = Persistent::New(args[1]); + baton->callback = Persistent::New(Local::Cast(args[1])); + + uv_queue_work(uv_default_loop(), &baton->request, DownloadWork, (uv_after_work_cb)DownloadAfterWork); + + return Undefined(); +} + +void GitRemote::DownloadWork(uv_work_t *req) { + DownloadBaton *baton = static_cast(req->data); + int result = git_remote_download( + baton->remote, + baton->progress_cb, + baton->payload + ); + baton->error_code = result; + if (result != GIT_OK) { + baton->error = giterr_last(); + } +} + +void GitRemote::DownloadAfterWork(uv_work_t *req) { + HandleScope scope; + DownloadBaton *baton = static_cast(req->data); + + TryCatch try_catch; + if (baton->error_code == GIT_OK) { + Handle result = Local::New(Undefined()); + Handle argv[2] = { + Local::New(Null()), + result + }; + baton->callback->Call(Context::GetCurrent()->Global(), 2, argv); + } else { + if (baton->error) { + Handle argv[1] = { + Exception::Error(String::New(baton->error->message)) + }; + baton->callback->Call(Context::GetCurrent()->Global(), 1, argv); + } else { + baton->callback->Call(Context::GetCurrent()->Global(), 0, NULL); + } + } + + if (try_catch.HasCaught()) { + node::FatalException(try_catch); + } + baton->remoteReference.Dispose(); + baton->progress_cbReference.Dispose(); + baton->payloadReference.Dispose(); + baton->callback.Dispose(); + delete baton; +} + +/** + */ +Handle GitRemote::Connected(const Arguments& args) { + HandleScope scope; + + + int result = git_remote_connected( + ObjectWrap::Unwrap(args.This())->GetValue() + ); + if (result != GIT_OK) { + if (giterr_last()) { + return ThrowException(Exception::Error(String::New(giterr_last()->message))); + } else { + return ThrowException(Exception::Error(String::New("Unkown Error"))); + } + } + + return Undefined(); +} + +/** + */ +Handle GitRemote::Stop(const Arguments& args) { + HandleScope scope; + + + git_remote_stop( + ObjectWrap::Unwrap(args.This())->GetValue() + ); + + return Undefined(); +} + +/** + */ +Handle GitRemote::Disconnect(const Arguments& args) { + HandleScope scope; + + if (args.Length() == 0 || !args[0]->IsFunction()) { + return ThrowException(Exception::Error(String::New("Callback is required and must be a Function."))); + } + + DisconnectBaton* baton = new DisconnectBaton; + baton->error_code = GIT_OK; + baton->error = NULL; + baton->request.data = baton; + baton->remoteReference = Persistent::New(args.This()); + baton->remote = ObjectWrap::Unwrap(args.This())->GetValue(); + baton->callback = Persistent::New(Local::Cast(args[0])); + + uv_queue_work(uv_default_loop(), &baton->request, DisconnectWork, (uv_after_work_cb)DisconnectAfterWork); + + return Undefined(); +} + +void GitRemote::DisconnectWork(uv_work_t *req) { + DisconnectBaton *baton = static_cast(req->data); + git_remote_disconnect( + baton->remote + ); +} + +void GitRemote::DisconnectAfterWork(uv_work_t *req) { + HandleScope scope; + DisconnectBaton *baton = static_cast(req->data); + + TryCatch try_catch; + if (baton->error_code == GIT_OK) { + Handle result = Local::New(Undefined()); + Handle argv[2] = { + Local::New(Null()), + result + }; + baton->callback->Call(Context::GetCurrent()->Global(), 2, argv); + } else { + if (baton->error) { + Handle argv[1] = { + Exception::Error(String::New(baton->error->message)) + }; + baton->callback->Call(Context::GetCurrent()->Global(), 1, argv); + } else { + baton->callback->Call(Context::GetCurrent()->Global(), 0, NULL); + } + } + + if (try_catch.HasCaught()) { + node::FatalException(try_catch); + } + baton->remoteReference.Dispose(); + baton->callback.Dispose(); + delete baton; +} + +/** + */ +Handle GitRemote::UpdateTips(const Arguments& args) { + HandleScope scope; + + + int result = git_remote_update_tips( + ObjectWrap::Unwrap(args.This())->GetValue() + ); + if (result != GIT_OK) { + if (giterr_last()) { + return ThrowException(Exception::Error(String::New(giterr_last()->message))); + } else { + return ThrowException(Exception::Error(String::New("Unkown Error"))); + } + } + + return Undefined(); +} + +/** + * @param {String} url + */ +Handle GitRemote::ValidUrl(const Arguments& args) { + HandleScope scope; + if (args.Length() == 0 || !args[0]->IsString()) { + return ThrowException(Exception::Error(String::New("String url is required."))); + } + + const char * from_url; + String::Utf8Value url(args[0]->ToString()); + from_url = strdup(*url); + + int result = git_remote_valid_url( + from_url + ); + free((void *)from_url); + if (result != GIT_OK) { + if (giterr_last()) { + return ThrowException(Exception::Error(String::New(giterr_last()->message))); + } else { + return ThrowException(Exception::Error(String::New("Unkown Error"))); + } + } + + return Undefined(); +} + +/** + * @param {String} url + */ +Handle GitRemote::SupportedUrl(const Arguments& args) { + HandleScope scope; + if (args.Length() == 0 || !args[0]->IsString()) { + return ThrowException(Exception::Error(String::New("String url is required."))); + } + + const char* from_url; + String::Utf8Value url(args[0]->ToString()); + from_url = strdup(*url); + + int result = git_remote_supported_url( + from_url + ); + free((void *)from_url); + if (result != GIT_OK) { + if (giterr_last()) { + return ThrowException(Exception::Error(String::New(giterr_last()->message))); + } else { + return ThrowException(Exception::Error(String::New("Unkown Error"))); + } + } + + return Undefined(); +} + +/** + * @param {Number} check + */ +Handle GitRemote::CheckCert(const Arguments& args) { + HandleScope scope; + if (args.Length() == 0 || !args[0]->IsInt32()) { + return ThrowException(Exception::Error(String::New("Number check is required."))); + } + + int from_check; + from_check = (int) args[0]->ToInt32()->Value(); + + git_remote_check_cert( + ObjectWrap::Unwrap(args.This())->GetValue() + , from_check + ); + + return Undefined(); +} + +/** + */ +Handle GitRemote::UpdateFetchhead(const Arguments& args) { + HandleScope scope; + + + int result = git_remote_update_fetchhead( + ObjectWrap::Unwrap(args.This())->GetValue() + ); + if (result != GIT_OK) { + if (giterr_last()) { + return ThrowException(Exception::Error(String::New(giterr_last()->message))); + } else { + return ThrowException(Exception::Error(String::New("Unkown Error"))); + } + } + + return Undefined(); +} + +/** + * @param {Number} value + */ +Handle GitRemote::SetUpdateFetchhead(const Arguments& args) { + HandleScope scope; + if (args.Length() == 0 || !args[0]->IsInt32()) { + return ThrowException(Exception::Error(String::New("Number value is required."))); + } + + int from_value; + from_value = (int) args[0]->ToInt32()->Value(); + + git_remote_set_update_fetchhead( + ObjectWrap::Unwrap(args.This())->GetValue() + , from_value + ); + + return Undefined(); +} + +/** + * @param {String} remote_name + */ +Handle GitRemote::IsValidName(const Arguments& args) { + HandleScope scope; + if (args.Length() == 0 || !args[0]->IsString()) { + return ThrowException(Exception::Error(String::New("String remote_name is required."))); + } + + const char * from_remote_name; + String::Utf8Value remote_name(args[0]->ToString()); + from_remote_name = strdup(*remote_name); + + int result = git_remote_is_valid_name( + from_remote_name + ); + free((void *)from_remote_name); + if (result != GIT_OK) { + if (giterr_last()) { + return ThrowException(Exception::Error(String::New(giterr_last()->message))); + } else { + return ThrowException(Exception::Error(String::New("Unkown Error"))); + } + } + + return Undefined(); +} + +Persistent GitRemote::constructor_template; diff --git a/src/repo.cc b/src/repo.cc index 6644803a4..98e598050 100755 --- a/src/repo.cc +++ b/src/repo.cc @@ -1,25 +1,44 @@ /** - * Copyright (c) 2011, Tim Branyen @tbranyen - * @author Michael Robinson @codeofinterest - * - * Dual licensed under the MIT and GPL licenses. - */ - + * This code is auto-generated; unless you know what you're doing, do not modify! + **/ #include #include +#include #include "git2.h" +#include "../include/functions/copy.h" + #include "../include/repo.h" +#include "../include/oid.h" #include "../include/commit.h" -#include "../include/error.h" - -#include "../include/functions/string.h" +#include "../include/blob.h" +#include "../include/object.h" +#include "../include/reference.h" +#include "../include/submodule.h" +#include "../include/refdb.h" +#include "../include/revwalk.h" +#include "../include/tag.h" +#include "../include/signature.h" +#include "../include/tree.h" +#include "../include/odb.h" +#include "../include/index.h" +#include "../include/remote.h" +#include "../include/clone_options.h" +#include "node_buffer.h" using namespace v8; using namespace node; -void GitRepo::Initialize(Handle target) { +GitRepo::GitRepo(git_repository *raw) { + this->raw = raw; +} + +GitRepo::~GitRepo() { + git_repository_free(this->raw); +} + +void GitRepo::Initialize(Handle target) { HandleScope scope; Local tpl = FunctionTemplate::New(New); @@ -27,59 +46,89 @@ void GitRepo::Initialize(Handle target) { tpl->InstanceTemplate()->SetInternalFieldCount(1); tpl->SetClassName(String::NewSymbol("Repo")); - NODE_SET_PROTOTYPE_METHOD(tpl, "open", Open); - NODE_SET_PROTOTYPE_METHOD(tpl, "free", Free); - NODE_SET_PROTOTYPE_METHOD(tpl, "init", Init); + NODE_SET_METHOD(tpl, "open", Open); + NODE_SET_METHOD(tpl, "init", Init); + NODE_SET_PROTOTYPE_METHOD(tpl, "path", Path); + NODE_SET_PROTOTYPE_METHOD(tpl, "workdir", Workdir); + NODE_SET_PROTOTYPE_METHOD(tpl, "odb", Odb); + NODE_SET_PROTOTYPE_METHOD(tpl, "openIndex", openIndex); + NODE_SET_PROTOTYPE_METHOD(tpl, "getBlob", GetBlob); + NODE_SET_PROTOTYPE_METHOD(tpl, "getCommit", GetCommit); + NODE_SET_PROTOTYPE_METHOD(tpl, "createCommit", CreateCommit); + NODE_SET_PROTOTYPE_METHOD(tpl, "getObject", GetObject); + NODE_SET_PROTOTYPE_METHOD(tpl, "getReference", GetReference); + NODE_SET_PROTOTYPE_METHOD(tpl, "createSymbolicReference", CreateSymbolicReference); + NODE_SET_PROTOTYPE_METHOD(tpl, "createReference", CreateReference); + NODE_SET_PROTOTYPE_METHOD(tpl, "addRemote", AddRemote); + NODE_SET_PROTOTYPE_METHOD(tpl, "createRevWalk", CreateRevWalk); + NODE_SET_PROTOTYPE_METHOD(tpl, "getSubmodule", GetSubmodule); + NODE_SET_PROTOTYPE_METHOD(tpl, "addSubmodule", AddSubmodule); + NODE_SET_PROTOTYPE_METHOD(tpl, "getTag", GetTag); + NODE_SET_PROTOTYPE_METHOD(tpl, "createTag", CreateTag); + NODE_SET_METHOD(tpl, "createLightweightTag", CreateLightweightTag); + NODE_SET_PROTOTYPE_METHOD(tpl, "getTree", GetTree); + NODE_SET_METHOD(tpl, "reloadSubmodules", ReloadSubmodules); + NODE_SET_PROTOTYPE_METHOD(tpl, "delete", Delete); + NODE_SET_PROTOTYPE_METHOD(tpl, "getReferences", GetReferences); + NODE_SET_PROTOTYPE_METHOD(tpl, "createBlobFromBuffer", CreateBlobFromBuffer); + NODE_SET_PROTOTYPE_METHOD(tpl, "createBlobFromFile", CreateBlobFromFile); + NODE_SET_PROTOTYPE_METHOD(tpl, "getRemotes", GetRemotes); + NODE_SET_METHOD(tpl, "clone", Clone); + NODE_SET_PROTOTYPE_METHOD(tpl, "getRemote", GetRemote); + constructor_template = Persistent::New(tpl->GetFunction()); target->Set(String::NewSymbol("Repo"), constructor_template); } -git_repository* GitRepo::GetValue() { - return this->repo; -} -void GitRepo::SetValue(git_repository* repo) { - this->repo = repo; -} - Handle GitRepo::New(const Arguments& args) { HandleScope scope; - GitRepo *repo = new GitRepo(); - repo->Wrap(args.This()); + if (args.Length() == 0 || !args[0]->IsExternal()) { + return ThrowException(Exception::Error(String::New("git_repository is required."))); + } + + GitRepo* object = new GitRepo((git_repository *) External::Unwrap(args[0])); + object->Wrap(args.This()); return scope.Close(args.This()); } -Handle GitRepo::Free(const Arguments& args) { +Handle GitRepo::New(void *raw) { HandleScope scope; + Handle argv[1] = { External::New((void *)raw) }; + return scope.Close(GitRepo::constructor_template->NewInstance(1, argv)); +} - GitRepo *repo = ObjectWrap::Unwrap(args.This()); - git_repository_free(repo->repo); - - return scope.Close( Undefined() ); +git_repository *GitRepo::GetValue() { + return this->raw; } +/** + * @param {String} path + * @param {Repository} callback + */ Handle GitRepo::Open(const Arguments& args) { HandleScope scope; - - if(args.Length() == 0 || !args[0]->IsString()) { - return ThrowException(Exception::Error(String::New("Path is required and must be a String."))); + if (args.Length() == 0 || !args[0]->IsString()) { + return ThrowException(Exception::Error(String::New("String path is required."))); } - if(args.Length() == 1 || !args[1]->IsFunction()) { + if (args.Length() == 1 || !args[1]->IsFunction()) { return ThrowException(Exception::Error(String::New("Callback is required and must be a Function."))); } - OpenBaton *baton = new OpenBaton; - baton->request.data = baton; + OpenBaton* baton = new OpenBaton; + baton->error_code = GIT_OK; baton->error = NULL; - baton->path = stringArgToString(args[0]->ToString());; - baton->repo = ObjectWrap::Unwrap(args.This()); - baton->callback = Persistent::New(Handle::Cast(args[1])); - - baton->repo->Ref(); + baton->request.data = baton; + baton->pathReference = Persistent::New(args[0]); + const char * from_path; + String::Utf8Value path(args[0]->ToString()); + from_path = strdup(*path); + baton->path = from_path; + baton->callback = Persistent::New(Local::Cast(args[1])); uv_queue_work(uv_default_loop(), &baton->request, OpenWork, (uv_after_work_cb)OpenAfterWork); @@ -88,105 +137,2130 @@ Handle GitRepo::Open(const Arguments& args) { void GitRepo::OpenWork(uv_work_t *req) { OpenBaton *baton = static_cast(req->data); - - int returnCode = git_repository_open(&baton->rawRepo, baton->path.c_str()); - if (returnCode != GIT_OK) { + int result = git_repository_open( + &baton->out, + baton->path + ); + baton->error_code = result; + if (result != GIT_OK) { baton->error = giterr_last(); } } void GitRepo::OpenAfterWork(uv_work_t *req) { HandleScope scope; - OpenBaton *baton = static_cast(req->data); - if (baton->error) { - Local argv[1] = { - GitError::WrapError(baton->error) + TryCatch try_catch; + if (baton->error_code == GIT_OK) { + Handle to; + if (baton->out != NULL) { + to = GitRepo::New((void *)baton->out); + } else { + to = Null(); + } + Handle result = to; + Handle argv[2] = { + Local::New(Null()), + result }; - - TryCatch try_catch; - baton->callback->Call(Context::GetCurrent()->Global(), 1, argv); - if (try_catch.HasCaught()) { - node::FatalException(try_catch); - } + baton->callback->Call(Context::GetCurrent()->Global(), 2, argv); } else { + if (baton->error) { + Handle argv[1] = { + Exception::Error(String::New(baton->error->message)) + }; + baton->callback->Call(Context::GetCurrent()->Global(), 1, argv); + } else { + baton->callback->Call(Context::GetCurrent()->Global(), 0, NULL); + } + } + + if (try_catch.HasCaught()) { + node::FatalException(try_catch); + } + baton->pathReference.Dispose(); + baton->callback.Dispose(); + free((void *)baton->path); + delete baton; +} + +/** + * @param {String} path + * @param {Boolean} is_bare + * @param {Repository} callback + */ +Handle GitRepo::Init(const Arguments& args) { + HandleScope scope; + if (args.Length() == 0 || !args[0]->IsString()) { + return ThrowException(Exception::Error(String::New("String path is required."))); + } + if (args.Length() == 1 || !args[1]->IsBoolean()) { + return ThrowException(Exception::Error(String::New("Boolean is_bare is required."))); + } + + if (args.Length() == 2 || !args[2]->IsFunction()) { + return ThrowException(Exception::Error(String::New("Callback is required and must be a Function."))); + } + + InitBaton* baton = new InitBaton; + baton->error_code = GIT_OK; + baton->error = NULL; + baton->request.data = baton; + baton->pathReference = Persistent::New(args[0]); + const char * from_path; + String::Utf8Value path(args[0]->ToString()); + from_path = strdup(*path); + baton->path = from_path; + baton->is_bareReference = Persistent::New(args[1]); + unsigned from_is_bare; + from_is_bare = (unsigned) args[1]->ToBoolean()->Value(); + baton->is_bare = from_is_bare; + baton->callback = Persistent::New(Local::Cast(args[2])); + + uv_queue_work(uv_default_loop(), &baton->request, InitWork, (uv_after_work_cb)InitAfterWork); + + return Undefined(); +} + +void GitRepo::InitWork(uv_work_t *req) { + InitBaton *baton = static_cast(req->data); + int result = git_repository_init( + &baton->out, + baton->path, + baton->is_bare + ); + baton->error_code = result; + if (result != GIT_OK) { + baton->error = giterr_last(); + } +} - baton->repo->SetValue(baton->rawRepo); +void GitRepo::InitAfterWork(uv_work_t *req) { + HandleScope scope; + InitBaton *baton = static_cast(req->data); + TryCatch try_catch; + if (baton->error_code == GIT_OK) { + Handle to; + if (baton->out != NULL) { + to = GitRepo::New((void *)baton->out); + } else { + to = Null(); + } + Handle result = to; Handle argv[2] = { Local::New(Null()), - baton->repo->handle_ + result }; - - TryCatch try_catch; baton->callback->Call(Context::GetCurrent()->Global(), 2, argv); - if (try_catch.HasCaught()) { - node::FatalException(try_catch); + } else { + if (baton->error) { + Handle argv[1] = { + Exception::Error(String::New(baton->error->message)) + }; + baton->callback->Call(Context::GetCurrent()->Global(), 1, argv); + } else { + baton->callback->Call(Context::GetCurrent()->Global(), 0, NULL); } + } + + if (try_catch.HasCaught()) { + node::FatalException(try_catch); } - delete req; - baton->repo->Unref(); + baton->pathReference.Dispose(); + baton->is_bareReference.Dispose(); + baton->callback.Dispose(); + free((void *)baton->path); + delete baton; } -Handle GitRepo::Init(const Arguments& args) { +/** + * @return {String} result + */ +Handle GitRepo::Path(const Arguments& args) { + HandleScope scope; + + + const char * result = git_repository_path( + ObjectWrap::Unwrap(args.This())->GetValue() + ); + + Handle to; + to = String::New(result); + return scope.Close(to); +} + +/** + * @return {String} result + */ +Handle GitRepo::Workdir(const Arguments& args) { + HandleScope scope; + + + const char * result = git_repository_workdir( + ObjectWrap::Unwrap(args.This())->GetValue() + ); + + Handle to; + to = String::New(result); + return scope.Close(to); +} + +/** + * @return {Odb} out + */ +Handle GitRepo::Odb(const Arguments& args) { HandleScope scope; + + git_odb *out = NULL; - if(args.Length() == 0 || !args[0]->IsString()) { - return ThrowException(Exception::Error(String::New("path is required and must be a String."))); + int result = git_repository_odb( + &out + , ObjectWrap::Unwrap(args.This())->GetValue() + ); + if (result != GIT_OK) { + if (giterr_last()) { + return ThrowException(Exception::Error(String::New(giterr_last()->message))); + } else { + return ThrowException(Exception::Error(String::New("Unkown Error"))); + } } - if(args.Length() == 1 || !args[1]->IsBoolean()) { - return ThrowException(Exception::Error(String::New("is_bare is required and must be a Boolean."))); + Handle to; + if (out != NULL) { + to = GitOdb::New((void *)out); + } else { + to = Null(); } + return scope.Close(to); +} - if(args.Length() == 2 || !args[2]->IsFunction()) { +/** + * @param {Index} callback + */ +Handle GitRepo::openIndex(const Arguments& args) { + HandleScope scope; + + if (args.Length() == 0 || !args[0]->IsFunction()) { return ThrowException(Exception::Error(String::New("Callback is required and must be a Function."))); } - InitBaton *baton = new InitBaton; + openIndexBaton* baton = new openIndexBaton; + baton->error_code = GIT_OK; + baton->error = NULL; baton->request.data = baton; + baton->repoReference = Persistent::New(args.This()); + baton->repo = ObjectWrap::Unwrap(args.This())->GetValue(); + baton->callback = Persistent::New(Local::Cast(args[0])); + + uv_queue_work(uv_default_loop(), &baton->request, openIndexWork, (uv_after_work_cb)openIndexAfterWork); + + return Undefined(); +} + +void GitRepo::openIndexWork(uv_work_t *req) { + openIndexBaton *baton = static_cast(req->data); + int result = git_repository_index( + &baton->out, + baton->repo + ); + baton->error_code = result; + if (result != GIT_OK) { + baton->error = giterr_last(); + } +} + +void GitRepo::openIndexAfterWork(uv_work_t *req) { + HandleScope scope; + openIndexBaton *baton = static_cast(req->data); + + TryCatch try_catch; + if (baton->error_code == GIT_OK) { + Handle to; + if (baton->out != NULL) { + to = GitIndex::New((void *)baton->out); + } else { + to = Null(); + } + Handle result = to; + Handle argv[2] = { + Local::New(Null()), + result + }; + baton->callback->Call(Context::GetCurrent()->Global(), 2, argv); + } else { + if (baton->error) { + Handle argv[1] = { + Exception::Error(String::New(baton->error->message)) + }; + baton->callback->Call(Context::GetCurrent()->Global(), 1, argv); + } else { + baton->callback->Call(Context::GetCurrent()->Global(), 0, NULL); + } + } + + if (try_catch.HasCaught()) { + node::FatalException(try_catch); + } + baton->repoReference.Dispose(); + baton->callback.Dispose(); + delete baton; +} + +/** + * @param {Oid} id + * @param {Blob} callback + */ +Handle GitRepo::GetBlob(const Arguments& args) { + HandleScope scope; + if (args.Length() == 0 || !args[0]->IsObject()) { + return ThrowException(Exception::Error(String::New("Oid id is required."))); + } + + if (args.Length() == 1 || !args[1]->IsFunction()) { + return ThrowException(Exception::Error(String::New("Callback is required and must be a Function."))); + } + + GetBlobBaton* baton = new GetBlobBaton; + baton->error_code = GIT_OK; baton->error = NULL; - baton->repo = ObjectWrap::Unwrap(args.This()); - baton->repo->Ref(); - baton->rawRepo = baton->repo->GetValue(); - baton->path = stringArgToString(args[0]->ToString());; - baton->isBare = args[1]->ToBoolean()->Value(); - baton->callback = Persistent::New(Local::Cast(args[2])); + baton->request.data = baton; + baton->repoReference = Persistent::New(args.This()); + baton->repo = ObjectWrap::Unwrap(args.This())->GetValue(); + baton->idReference = Persistent::New(args[0]); + const git_oid * from_id; + from_id = ObjectWrap::Unwrap(args[0]->ToObject())->GetValue(); + baton->id = from_id; + baton->callback = Persistent::New(Local::Cast(args[1])); - uv_queue_work(uv_default_loop(), &baton->request, InitWork, (uv_after_work_cb)InitAfterWork); + uv_queue_work(uv_default_loop(), &baton->request, GetBlobWork, (uv_after_work_cb)GetBlobAfterWork); return Undefined(); } -void GitRepo::InitWork(uv_work_t *req) { - InitBaton *baton = static_cast(req->data); +void GitRepo::GetBlobWork(uv_work_t *req) { + GetBlobBaton *baton = static_cast(req->data); + int result = git_blob_lookup( + &baton->blob, + baton->repo, + baton->id + ); + baton->error_code = result; + if (result != GIT_OK) { + baton->error = giterr_last(); + } +} + +void GitRepo::GetBlobAfterWork(uv_work_t *req) { + HandleScope scope; + GetBlobBaton *baton = static_cast(req->data); + + TryCatch try_catch; + if (baton->error_code == GIT_OK) { + Handle to; + if (baton->blob != NULL) { + to = GitBlob::New((void *)baton->blob); + } else { + to = Null(); + } + Handle result = to; + Handle argv[2] = { + Local::New(Null()), + result + }; + baton->callback->Call(Context::GetCurrent()->Global(), 2, argv); + } else { + if (baton->error) { + Handle argv[1] = { + Exception::Error(String::New(baton->error->message)) + }; + baton->callback->Call(Context::GetCurrent()->Global(), 1, argv); + } else { + baton->callback->Call(Context::GetCurrent()->Global(), 0, NULL); + } + } + + if (try_catch.HasCaught()) { + node::FatalException(try_catch); + } + baton->repoReference.Dispose(); + baton->idReference.Dispose(); + baton->callback.Dispose(); + delete baton; +} + +/** + * @param {Oid} id + * @param {Commit} callback + */ +Handle GitRepo::GetCommit(const Arguments& args) { + HandleScope scope; + if (args.Length() == 0 || !args[0]->IsObject()) { + return ThrowException(Exception::Error(String::New("Oid id is required."))); + } + + if (args.Length() == 1 || !args[1]->IsFunction()) { + return ThrowException(Exception::Error(String::New("Callback is required and must be a Function."))); + } + + GetCommitBaton* baton = new GetCommitBaton; + baton->error_code = GIT_OK; + baton->error = NULL; + baton->request.data = baton; + baton->repoReference = Persistent::New(args.This()); + baton->repo = ObjectWrap::Unwrap(args.This())->GetValue(); + baton->idReference = Persistent::New(args[0]); + const git_oid * from_id; + from_id = ObjectWrap::Unwrap(args[0]->ToObject())->GetValue(); + baton->id = from_id; + baton->callback = Persistent::New(Local::Cast(args[1])); + + uv_queue_work(uv_default_loop(), &baton->request, GetCommitWork, (uv_after_work_cb)GetCommitAfterWork); + + return Undefined(); +} - int returnCode = git_repository_init(&baton->rawRepo, baton->path.c_str(), baton->isBare); - if (returnCode != GIT_OK) { +void GitRepo::GetCommitWork(uv_work_t *req) { + GetCommitBaton *baton = static_cast(req->data); + int result = git_commit_lookup( + &baton->commit, + baton->repo, + baton->id + ); + baton->error_code = result; + if (result != GIT_OK) { baton->error = giterr_last(); } } -void GitRepo::InitAfterWork(uv_work_t *req) { +void GitRepo::GetCommitAfterWork(uv_work_t *req) { HandleScope scope; + GetCommitBaton *baton = static_cast(req->data); - InitBaton *baton = static_cast(req->data); + TryCatch try_catch; + if (baton->error_code == GIT_OK) { + Handle to; + if (baton->commit != NULL) { + to = GitCommit::New((void *)baton->commit); + } else { + to = Null(); + } + Handle result = to; + Handle argv[2] = { + Local::New(Null()), + result + }; + baton->callback->Call(Context::GetCurrent()->Global(), 2, argv); + } else { + if (baton->error) { + Handle argv[1] = { + Exception::Error(String::New(baton->error->message)) + }; + baton->callback->Call(Context::GetCurrent()->Global(), 1, argv); + } else { + baton->callback->Call(Context::GetCurrent()->Global(), 0, NULL); + } + } + + if (try_catch.HasCaught()) { + node::FatalException(try_catch); + } + baton->repoReference.Dispose(); + baton->idReference.Dispose(); + baton->callback.Dispose(); + delete baton; +} + +/** + * @param {String} update_ref + * @param {Signature} author + * @param {Signature} committer + * @param {String} message_encoding + * @param {String} message + * @param {Tree} tree + * @param {Number} parent_count + * @param {Array} parents + * @param {Oid} callback + */ +Handle GitRepo::CreateCommit(const Arguments& args) { + HandleScope scope; + if (args.Length() == 1 || !args[1]->IsObject()) { + return ThrowException(Exception::Error(String::New("Signature author is required."))); + } + if (args.Length() == 2 || !args[2]->IsObject()) { + return ThrowException(Exception::Error(String::New("Signature committer is required."))); + } + if (args.Length() == 4 || !args[4]->IsString()) { + return ThrowException(Exception::Error(String::New("String message is required."))); + } + if (args.Length() == 5 || !args[5]->IsObject()) { + return ThrowException(Exception::Error(String::New("Tree tree is required."))); + } + if (args.Length() == 6 || !args[6]->IsInt32()) { + return ThrowException(Exception::Error(String::New("Number parent_count is required."))); + } + if (args.Length() == 7 || !args[7]->IsObject()) { + return ThrowException(Exception::Error(String::New("Array parents is required."))); + } + + if (args.Length() == 8 || !args[8]->IsFunction()) { + return ThrowException(Exception::Error(String::New("Callback is required and must be a Function."))); + } + + CreateCommitBaton* baton = new CreateCommitBaton; + baton->error_code = GIT_OK; + baton->error = NULL; + baton->request.data = baton; + baton->id = (git_oid *)malloc(sizeof(git_oid )); + baton->repoReference = Persistent::New(args.This()); + baton->repo = ObjectWrap::Unwrap(args.This())->GetValue(); + baton->update_refReference = Persistent::New(args[0]); + const char * from_update_ref; + if (args[0]->IsString()) { + String::Utf8Value update_ref(args[0]->ToString()); + from_update_ref = strdup(*update_ref); + } else { + from_update_ref = NULL; + } + baton->update_ref = from_update_ref; + baton->authorReference = Persistent::New(args[1]); + const git_signature * from_author; + from_author = ObjectWrap::Unwrap(args[1]->ToObject())->GetValue(); + baton->author = from_author; + baton->committerReference = Persistent::New(args[2]); + const git_signature * from_committer; + from_committer = ObjectWrap::Unwrap(args[2]->ToObject())->GetValue(); + baton->committer = from_committer; + baton->message_encodingReference = Persistent::New(args[3]); + const char * from_message_encoding; + if (args[3]->IsString()) { + String::Utf8Value message_encoding(args[3]->ToString()); + from_message_encoding = strdup(*message_encoding); + } else { + from_message_encoding = NULL; + } + baton->message_encoding = from_message_encoding; + baton->messageReference = Persistent::New(args[4]); + const char * from_message; + String::Utf8Value message(args[4]->ToString()); + from_message = strdup(*message); + baton->message = from_message; + baton->treeReference = Persistent::New(args[5]); + const git_tree * from_tree; + from_tree = ObjectWrap::Unwrap(args[5]->ToObject())->GetValue(); + baton->tree = from_tree; + baton->parent_countReference = Persistent::New(args[6]); + int from_parent_count; + from_parent_count = (int) args[6]->ToInt32()->Value(); + baton->parent_count = from_parent_count; + baton->parentsReference = Persistent::New(args[7]); + const git_commit ** from_parents; + Array *tmp_parents = Array::Cast(*args[7]); + from_parents = (const git_commit **)malloc(tmp_parents->Length() * sizeof(const git_commit *)); + for (unsigned int i = 0; i < tmp_parents->Length(); i++) { + + from_parents[i] = ObjectWrap::Unwrap(tmp_parents->Get(Number::New(static_cast(i)))->ToObject())->GetValue(); + } + baton->parents = from_parents; + baton->callback = Persistent::New(Local::Cast(args[8])); + + uv_queue_work(uv_default_loop(), &baton->request, CreateCommitWork, (uv_after_work_cb)CreateCommitAfterWork); + + return Undefined(); +} + +void GitRepo::CreateCommitWork(uv_work_t *req) { + CreateCommitBaton *baton = static_cast(req->data); + int result = git_commit_create( + baton->id, + baton->repo, + baton->update_ref, + baton->author, + baton->committer, + baton->message_encoding, + baton->message, + baton->tree, + baton->parent_count, + baton->parents + ); + baton->error_code = result; + if (result != GIT_OK) { + baton->error = giterr_last(); + } +} + +void GitRepo::CreateCommitAfterWork(uv_work_t *req) { + HandleScope scope; + CreateCommitBaton *baton = static_cast(req->data); - Local argv[1]; - if (baton->error) { - argv[0] = GitError::WrapError(baton->error); + TryCatch try_catch; + if (baton->error_code == GIT_OK) { + Handle to; + if (baton->id != NULL) { + to = GitOid::New((void *)baton->id); + } else { + to = Null(); + } + Handle result = to; + Handle argv[2] = { + Local::New(Null()), + result + }; + baton->callback->Call(Context::GetCurrent()->Global(), 2, argv); } else { - argv[0] = Local::New(Null()); + if (baton->error) { + Handle argv[1] = { + Exception::Error(String::New(baton->error->message)) + }; + baton->callback->Call(Context::GetCurrent()->Global(), 1, argv); + } else { + baton->callback->Call(Context::GetCurrent()->Global(), 0, NULL); + } + free(baton->id); + } + + if (try_catch.HasCaught()) { + node::FatalException(try_catch); + } + baton->repoReference.Dispose(); + baton->update_refReference.Dispose(); + baton->authorReference.Dispose(); + baton->committerReference.Dispose(); + baton->message_encodingReference.Dispose(); + baton->messageReference.Dispose(); + baton->treeReference.Dispose(); + baton->parent_countReference.Dispose(); + baton->parentsReference.Dispose(); + baton->callback.Dispose(); + free((void *)baton->update_ref); + free((void *)baton->message_encoding); + free((void *)baton->message); + free((void *)baton->parents); + delete baton; +} + +/** + * @param {Oid} id + * @param {Number} type + * @param {Object} callback + */ +Handle GitRepo::GetObject(const Arguments& args) { + HandleScope scope; + if (args.Length() == 0 || !args[0]->IsObject()) { + return ThrowException(Exception::Error(String::New("Oid id is required."))); + } + if (args.Length() == 1 || !args[1]->IsInt32()) { + return ThrowException(Exception::Error(String::New("Number type is required."))); + } + + if (args.Length() == 2 || !args[2]->IsFunction()) { + return ThrowException(Exception::Error(String::New("Callback is required and must be a Function."))); + } + + GetObjectBaton* baton = new GetObjectBaton; + baton->error_code = GIT_OK; + baton->error = NULL; + baton->request.data = baton; + baton->repoReference = Persistent::New(args.This()); + baton->repo = ObjectWrap::Unwrap(args.This())->GetValue(); + baton->idReference = Persistent::New(args[0]); + const git_oid * from_id; + from_id = ObjectWrap::Unwrap(args[0]->ToObject())->GetValue(); + baton->id = from_id; + baton->typeReference = Persistent::New(args[1]); + git_otype from_type; + from_type = (git_otype) args[1]->ToInt32()->Value(); + baton->type = from_type; + baton->callback = Persistent::New(Local::Cast(args[2])); + + uv_queue_work(uv_default_loop(), &baton->request, GetObjectWork, (uv_after_work_cb)GetObjectAfterWork); + + return Undefined(); +} + +void GitRepo::GetObjectWork(uv_work_t *req) { + GetObjectBaton *baton = static_cast(req->data); + int result = git_object_lookup( + &baton->object, + baton->repo, + baton->id, + baton->type + ); + baton->error_code = result; + if (result != GIT_OK) { + baton->error = giterr_last(); } +} + +void GitRepo::GetObjectAfterWork(uv_work_t *req) { + HandleScope scope; + GetObjectBaton *baton = static_cast(req->data); TryCatch try_catch; - baton->callback->Call(Context::GetCurrent()->Global(), 1, argv); + if (baton->error_code == GIT_OK) { + Handle to; + if (baton->object != NULL) { + to = GitObject::New((void *)baton->object); + } else { + to = Null(); + } + Handle result = to; + Handle argv[2] = { + Local::New(Null()), + result + }; + baton->callback->Call(Context::GetCurrent()->Global(), 2, argv); + } else { + if (baton->error) { + Handle argv[1] = { + Exception::Error(String::New(baton->error->message)) + }; + baton->callback->Call(Context::GetCurrent()->Global(), 1, argv); + } else { + baton->callback->Call(Context::GetCurrent()->Global(), 0, NULL); + } + } + if (try_catch.HasCaught()) { - node::FatalException(try_catch); + node::FatalException(try_catch); + } + baton->repoReference.Dispose(); + baton->idReference.Dispose(); + baton->typeReference.Dispose(); + baton->callback.Dispose(); + delete baton; +} + +/** + * @param {String} name + * @param {Reference} callback + */ +Handle GitRepo::GetReference(const Arguments& args) { + HandleScope scope; + if (args.Length() == 0 || !args[0]->IsString()) { + return ThrowException(Exception::Error(String::New("String name is required."))); + } + + if (args.Length() == 1 || !args[1]->IsFunction()) { + return ThrowException(Exception::Error(String::New("Callback is required and must be a Function."))); + } + + GetReferenceBaton* baton = new GetReferenceBaton; + baton->error_code = GIT_OK; + baton->error = NULL; + baton->request.data = baton; + baton->repoReference = Persistent::New(args.This()); + baton->repo = ObjectWrap::Unwrap(args.This())->GetValue(); + baton->nameReference = Persistent::New(args[0]); + const char * from_name; + String::Utf8Value name(args[0]->ToString()); + from_name = strdup(*name); + baton->name = from_name; + baton->callback = Persistent::New(Local::Cast(args[1])); + + uv_queue_work(uv_default_loop(), &baton->request, GetReferenceWork, (uv_after_work_cb)GetReferenceAfterWork); + + return Undefined(); +} + +void GitRepo::GetReferenceWork(uv_work_t *req) { + GetReferenceBaton *baton = static_cast(req->data); + int result = git_reference_lookup( + &baton->out, + baton->repo, + baton->name + ); + baton->error_code = result; + if (result != GIT_OK) { + baton->error = giterr_last(); + } +} + +void GitRepo::GetReferenceAfterWork(uv_work_t *req) { + HandleScope scope; + GetReferenceBaton *baton = static_cast(req->data); + + TryCatch try_catch; + if (baton->error_code == GIT_OK) { + Handle to; + if (baton->out != NULL) { + to = GitReference::New((void *)baton->out); + } else { + to = Null(); + } + Handle result = to; + Handle argv[2] = { + Local::New(Null()), + result + }; + baton->callback->Call(Context::GetCurrent()->Global(), 2, argv); + } else { + if (baton->error) { + Handle argv[1] = { + Exception::Error(String::New(baton->error->message)) + }; + baton->callback->Call(Context::GetCurrent()->Global(), 1, argv); + } else { + baton->callback->Call(Context::GetCurrent()->Global(), 0, NULL); + } + } + + if (try_catch.HasCaught()) { + node::FatalException(try_catch); + } + baton->repoReference.Dispose(); + baton->nameReference.Dispose(); + baton->callback.Dispose(); + free((void *)baton->name); + delete baton; +} + +/** + * @param {String} name + * @param {String} target + * @param {Number} force + * @return {Reference} out + */ +Handle GitRepo::CreateSymbolicReference(const Arguments& args) { + HandleScope scope; + if (args.Length() == 0 || !args[0]->IsString()) { + return ThrowException(Exception::Error(String::New("String name is required."))); + } + if (args.Length() == 1 || !args[1]->IsString()) { + return ThrowException(Exception::Error(String::New("String target is required."))); + } + if (args.Length() == 2 || !args[2]->IsInt32()) { + return ThrowException(Exception::Error(String::New("Number force is required."))); + } + + git_reference *out = NULL; + const char * from_name; + String::Utf8Value name(args[0]->ToString()); + from_name = strdup(*name); + const char * from_target; + String::Utf8Value target(args[1]->ToString()); + from_target = strdup(*target); + int from_force; + from_force = (int) args[2]->ToInt32()->Value(); + + int result = git_reference_symbolic_create( + &out + , ObjectWrap::Unwrap(args.This())->GetValue() + , from_name + , from_target + , from_force + ); + free((void *)from_name); + free((void *)from_target); + if (result != GIT_OK) { + if (giterr_last()) { + return ThrowException(Exception::Error(String::New(giterr_last()->message))); + } else { + return ThrowException(Exception::Error(String::New("Unkown Error"))); + } + } + + Handle to; + if (out != NULL) { + to = GitReference::New((void *)out); + } else { + to = Null(); + } + return scope.Close(to); +} + +/** + * @param {String} name + * @param {Oid} id + * @param {Number} force + * @return {Reference} out + */ +Handle GitRepo::CreateReference(const Arguments& args) { + HandleScope scope; + if (args.Length() == 0 || !args[0]->IsString()) { + return ThrowException(Exception::Error(String::New("String name is required."))); + } + if (args.Length() == 1 || !args[1]->IsObject()) { + return ThrowException(Exception::Error(String::New("Oid id is required."))); + } + if (args.Length() == 2 || !args[2]->IsInt32()) { + return ThrowException(Exception::Error(String::New("Number force is required."))); + } + + git_reference *out = NULL; + const char * from_name; + String::Utf8Value name(args[0]->ToString()); + from_name = strdup(*name); + const git_oid * from_id; + from_id = ObjectWrap::Unwrap(args[1]->ToObject())->GetValue(); + int from_force; + from_force = (int) args[2]->ToInt32()->Value(); + + int result = git_reference_create( + &out + , ObjectWrap::Unwrap(args.This())->GetValue() + , from_name + , from_id + , from_force + ); + free((void *)from_name); + if (result != GIT_OK) { + if (giterr_last()) { + return ThrowException(Exception::Error(String::New(giterr_last()->message))); + } else { + return ThrowException(Exception::Error(String::New("Unkown Error"))); + } + } + + Handle to; + if (out != NULL) { + to = GitReference::New((void *)out); + } else { + to = Null(); + } + return scope.Close(to); +} + +/** + * @param {String} name + * @param {String} url + * @param {Remote} callback + */ +Handle GitRepo::AddRemote(const Arguments& args) { + HandleScope scope; + if (args.Length() == 0 || !args[0]->IsString()) { + return ThrowException(Exception::Error(String::New("String name is required."))); + } + if (args.Length() == 1 || !args[1]->IsString()) { + return ThrowException(Exception::Error(String::New("String url is required."))); + } + + if (args.Length() == 2 || !args[2]->IsFunction()) { + return ThrowException(Exception::Error(String::New("Callback is required and must be a Function."))); + } + + AddRemoteBaton* baton = new AddRemoteBaton; + baton->error_code = GIT_OK; + baton->error = NULL; + baton->request.data = baton; + baton->repoReference = Persistent::New(args.This()); + baton->repo = ObjectWrap::Unwrap(args.This())->GetValue(); + baton->nameReference = Persistent::New(args[0]); + const char * from_name; + String::Utf8Value name(args[0]->ToString()); + from_name = strdup(*name); + baton->name = from_name; + baton->urlReference = Persistent::New(args[1]); + const char * from_url; + String::Utf8Value url(args[1]->ToString()); + from_url = strdup(*url); + baton->url = from_url; + baton->callback = Persistent::New(Local::Cast(args[2])); + + uv_queue_work(uv_default_loop(), &baton->request, AddRemoteWork, (uv_after_work_cb)AddRemoteAfterWork); + + return Undefined(); +} + +void GitRepo::AddRemoteWork(uv_work_t *req) { + AddRemoteBaton *baton = static_cast(req->data); + int result = git_remote_create( + &baton->out, + baton->repo, + baton->name, + baton->url + ); + baton->error_code = result; + if (result != GIT_OK) { + baton->error = giterr_last(); + } +} + +void GitRepo::AddRemoteAfterWork(uv_work_t *req) { + HandleScope scope; + AddRemoteBaton *baton = static_cast(req->data); + + TryCatch try_catch; + if (baton->error_code == GIT_OK) { + Handle to; + if (baton->out != NULL) { + to = GitRemote::New((void *)baton->out); + } else { + to = Null(); + } + Handle result = to; + Handle argv[2] = { + Local::New(Null()), + result + }; + baton->callback->Call(Context::GetCurrent()->Global(), 2, argv); + } else { + if (baton->error) { + Handle argv[1] = { + Exception::Error(String::New(baton->error->message)) + }; + baton->callback->Call(Context::GetCurrent()->Global(), 1, argv); + } else { + baton->callback->Call(Context::GetCurrent()->Global(), 0, NULL); + } + } + + if (try_catch.HasCaught()) { + node::FatalException(try_catch); + } + baton->repoReference.Dispose(); + baton->nameReference.Dispose(); + baton->urlReference.Dispose(); + baton->callback.Dispose(); + free((void *)baton->name); + free((void *)baton->url); + delete baton; +} + +/** + * @return {RevWalk} out + */ +Handle GitRepo::CreateRevWalk(const Arguments& args) { + HandleScope scope; + + git_revwalk *out = NULL; + + int result = git_revwalk_new( + &out + , ObjectWrap::Unwrap(args.This())->GetValue() + ); + if (result != GIT_OK) { + if (giterr_last()) { + return ThrowException(Exception::Error(String::New(giterr_last()->message))); + } else { + return ThrowException(Exception::Error(String::New("Unkown Error"))); + } + } + + Handle to; + if (out != NULL) { + to = GitRevWalk::New((void *)out); + } else { + to = Null(); + } + return scope.Close(to); +} + +/** + * @param {String} name + * @return {Submodule} submodule + */ +Handle GitRepo::GetSubmodule(const Arguments& args) { + HandleScope scope; + if (args.Length() == 0 || !args[0]->IsString()) { + return ThrowException(Exception::Error(String::New("String name is required."))); + } + + git_submodule *submodule = NULL; + const char * from_name; + String::Utf8Value name(args[0]->ToString()); + from_name = strdup(*name); + + int result = git_submodule_lookup( + &submodule + , ObjectWrap::Unwrap(args.This())->GetValue() + , from_name + ); + free((void *)from_name); + if (result != GIT_OK) { + if (giterr_last()) { + return ThrowException(Exception::Error(String::New(giterr_last()->message))); + } else { + return ThrowException(Exception::Error(String::New("Unkown Error"))); + } + } + + Handle to; + if (submodule != NULL) { + to = GitSubmodule::New((void *)submodule); + } else { + to = Null(); + } + return scope.Close(to); +} + +/** + * @param {String} url + * @param {String} path + * @param {Number} use_gitlink + * @return {Submodule} submodule + */ +Handle GitRepo::AddSubmodule(const Arguments& args) { + HandleScope scope; + if (args.Length() == 0 || !args[0]->IsString()) { + return ThrowException(Exception::Error(String::New("String url is required."))); + } + if (args.Length() == 1 || !args[1]->IsString()) { + return ThrowException(Exception::Error(String::New("String path is required."))); + } + if (args.Length() == 2 || !args[2]->IsInt32()) { + return ThrowException(Exception::Error(String::New("Number use_gitlink is required."))); + } + + git_submodule *submodule = NULL; + const char * from_url; + String::Utf8Value url(args[0]->ToString()); + from_url = strdup(*url); + const char * from_path; + String::Utf8Value path(args[1]->ToString()); + from_path = strdup(*path); + int from_use_gitlink; + from_use_gitlink = (int) args[2]->ToInt32()->Value(); + + int result = git_submodule_add_setup( + &submodule + , ObjectWrap::Unwrap(args.This())->GetValue() + , from_url + , from_path + , from_use_gitlink + ); + free((void *)from_url); + free((void *)from_path); + if (result != GIT_OK) { + if (giterr_last()) { + return ThrowException(Exception::Error(String::New(giterr_last()->message))); + } else { + return ThrowException(Exception::Error(String::New("Unkown Error"))); + } + } + + Handle to; + if (submodule != NULL) { + to = GitSubmodule::New((void *)submodule); + } else { + to = Null(); + } + return scope.Close(to); +} + +/** + * @param {Oid} id + * @param {Tag} callback + */ +Handle GitRepo::GetTag(const Arguments& args) { + HandleScope scope; + if (args.Length() == 0 || !args[0]->IsObject()) { + return ThrowException(Exception::Error(String::New("Oid id is required."))); + } + + if (args.Length() == 1 || !args[1]->IsFunction()) { + return ThrowException(Exception::Error(String::New("Callback is required and must be a Function."))); + } + + GetTagBaton* baton = new GetTagBaton; + baton->error_code = GIT_OK; + baton->error = NULL; + baton->request.data = baton; + baton->repoReference = Persistent::New(args.This()); + baton->repo = ObjectWrap::Unwrap(args.This())->GetValue(); + baton->idReference = Persistent::New(args[0]); + const git_oid * from_id; + from_id = ObjectWrap::Unwrap(args[0]->ToObject())->GetValue(); + baton->id = from_id; + baton->callback = Persistent::New(Local::Cast(args[1])); + + uv_queue_work(uv_default_loop(), &baton->request, GetTagWork, (uv_after_work_cb)GetTagAfterWork); + + return Undefined(); +} + +void GitRepo::GetTagWork(uv_work_t *req) { + GetTagBaton *baton = static_cast(req->data); + int result = git_tag_lookup( + &baton->out, + baton->repo, + baton->id + ); + baton->error_code = result; + if (result != GIT_OK) { + baton->error = giterr_last(); + } +} + +void GitRepo::GetTagAfterWork(uv_work_t *req) { + HandleScope scope; + GetTagBaton *baton = static_cast(req->data); + + TryCatch try_catch; + if (baton->error_code == GIT_OK) { + Handle to; + if (baton->out != NULL) { + to = GitTag::New((void *)baton->out); + } else { + to = Null(); + } + Handle result = to; + Handle argv[2] = { + Local::New(Null()), + result + }; + baton->callback->Call(Context::GetCurrent()->Global(), 2, argv); + } else { + if (baton->error) { + Handle argv[1] = { + Exception::Error(String::New(baton->error->message)) + }; + baton->callback->Call(Context::GetCurrent()->Global(), 1, argv); + } else { + baton->callback->Call(Context::GetCurrent()->Global(), 0, NULL); + } + } + + if (try_catch.HasCaught()) { + node::FatalException(try_catch); + } + baton->repoReference.Dispose(); + baton->idReference.Dispose(); + baton->callback.Dispose(); + delete baton; +} + +/** + * @param {String} tag_name + * @param {Object} target + * @param {Signature} tagger + * @param {String} message + * @param {Number} force + * @param {Oid} callback + */ +Handle GitRepo::CreateTag(const Arguments& args) { + HandleScope scope; + if (args.Length() == 0 || !args[0]->IsString()) { + return ThrowException(Exception::Error(String::New("String tag_name is required."))); + } + if (args.Length() == 1 || !args[1]->IsObject()) { + return ThrowException(Exception::Error(String::New("Object target is required."))); + } + if (args.Length() == 2 || !args[2]->IsObject()) { + return ThrowException(Exception::Error(String::New("Signature tagger is required."))); + } + if (args.Length() == 3 || !args[3]->IsString()) { + return ThrowException(Exception::Error(String::New("String message is required."))); + } + if (args.Length() == 4 || !args[4]->IsInt32()) { + return ThrowException(Exception::Error(String::New("Number force is required."))); + } + + if (args.Length() == 5 || !args[5]->IsFunction()) { + return ThrowException(Exception::Error(String::New("Callback is required and must be a Function."))); + } + + CreateTagBaton* baton = new CreateTagBaton; + baton->error_code = GIT_OK; + baton->error = NULL; + baton->request.data = baton; + baton->oid = (git_oid *)malloc(sizeof(git_oid )); + baton->repoReference = Persistent::New(args.This()); + baton->repo = ObjectWrap::Unwrap(args.This())->GetValue(); + baton->tag_nameReference = Persistent::New(args[0]); + const char * from_tag_name; + String::Utf8Value tag_name(args[0]->ToString()); + from_tag_name = strdup(*tag_name); + baton->tag_name = from_tag_name; + baton->targetReference = Persistent::New(args[1]); + const git_object * from_target; + from_target = ObjectWrap::Unwrap(args[1]->ToObject())->GetValue(); + baton->target = from_target; + baton->taggerReference = Persistent::New(args[2]); + const git_signature * from_tagger; + from_tagger = ObjectWrap::Unwrap(args[2]->ToObject())->GetValue(); + baton->tagger = from_tagger; + baton->messageReference = Persistent::New(args[3]); + const char * from_message; + String::Utf8Value message(args[3]->ToString()); + from_message = strdup(*message); + baton->message = from_message; + baton->forceReference = Persistent::New(args[4]); + int from_force; + from_force = (int) args[4]->ToInt32()->Value(); + baton->force = from_force; + baton->callback = Persistent::New(Local::Cast(args[5])); + + uv_queue_work(uv_default_loop(), &baton->request, CreateTagWork, (uv_after_work_cb)CreateTagAfterWork); + + return Undefined(); +} + +void GitRepo::CreateTagWork(uv_work_t *req) { + CreateTagBaton *baton = static_cast(req->data); + int result = git_tag_create( + baton->oid, + baton->repo, + baton->tag_name, + baton->target, + baton->tagger, + baton->message, + baton->force + ); + baton->error_code = result; + if (result != GIT_OK) { + baton->error = giterr_last(); + } +} + +void GitRepo::CreateTagAfterWork(uv_work_t *req) { + HandleScope scope; + CreateTagBaton *baton = static_cast(req->data); + + TryCatch try_catch; + if (baton->error_code == GIT_OK) { + Handle to; + if (baton->oid != NULL) { + to = GitOid::New((void *)baton->oid); + } else { + to = Null(); + } + Handle result = to; + Handle argv[2] = { + Local::New(Null()), + result + }; + baton->callback->Call(Context::GetCurrent()->Global(), 2, argv); + } else { + if (baton->error) { + Handle argv[1] = { + Exception::Error(String::New(baton->error->message)) + }; + baton->callback->Call(Context::GetCurrent()->Global(), 1, argv); + } else { + baton->callback->Call(Context::GetCurrent()->Global(), 0, NULL); + } + free(baton->oid); + } + + if (try_catch.HasCaught()) { + node::FatalException(try_catch); + } + baton->repoReference.Dispose(); + baton->tag_nameReference.Dispose(); + baton->targetReference.Dispose(); + baton->taggerReference.Dispose(); + baton->messageReference.Dispose(); + baton->forceReference.Dispose(); + baton->callback.Dispose(); + free((void *)baton->tag_name); + free((void *)baton->message); + delete baton; +} + +/** + * @param {String} tag_name + * @param {Object} target + * @param {Number} force + * @param {Oid} callback + */ +Handle GitRepo::CreateLightweightTag(const Arguments& args) { + HandleScope scope; + if (args.Length() == 0 || !args[0]->IsString()) { + return ThrowException(Exception::Error(String::New("String tag_name is required."))); + } + if (args.Length() == 1 || !args[1]->IsObject()) { + return ThrowException(Exception::Error(String::New("Object target is required."))); + } + if (args.Length() == 2 || !args[2]->IsInt32()) { + return ThrowException(Exception::Error(String::New("Number force is required."))); + } + + if (args.Length() == 3 || !args[3]->IsFunction()) { + return ThrowException(Exception::Error(String::New("Callback is required and must be a Function."))); + } + + CreateLightweightTagBaton* baton = new CreateLightweightTagBaton; + baton->error_code = GIT_OK; + baton->error = NULL; + baton->request.data = baton; + baton->oid = (git_oid *)malloc(sizeof(git_oid )); + baton->repoReference = Persistent::New(args.This()); + baton->repo = ObjectWrap::Unwrap(args.This())->GetValue(); + baton->tag_nameReference = Persistent::New(args[0]); + const char * from_tag_name; + String::Utf8Value tag_name(args[0]->ToString()); + from_tag_name = strdup(*tag_name); + baton->tag_name = from_tag_name; + baton->targetReference = Persistent::New(args[1]); + const git_object * from_target; + from_target = ObjectWrap::Unwrap(args[1]->ToObject())->GetValue(); + baton->target = from_target; + baton->forceReference = Persistent::New(args[2]); + int from_force; + from_force = (int) args[2]->ToInt32()->Value(); + baton->force = from_force; + baton->callback = Persistent::New(Local::Cast(args[3])); + + uv_queue_work(uv_default_loop(), &baton->request, CreateLightweightTagWork, (uv_after_work_cb)CreateLightweightTagAfterWork); + + return Undefined(); +} + +void GitRepo::CreateLightweightTagWork(uv_work_t *req) { + CreateLightweightTagBaton *baton = static_cast(req->data); + int result = git_tag_create_lightweight( + baton->oid, + baton->repo, + baton->tag_name, + baton->target, + baton->force + ); + baton->error_code = result; + if (result != GIT_OK) { + baton->error = giterr_last(); + } +} + +void GitRepo::CreateLightweightTagAfterWork(uv_work_t *req) { + HandleScope scope; + CreateLightweightTagBaton *baton = static_cast(req->data); + + TryCatch try_catch; + if (baton->error_code == GIT_OK) { + Handle to; + if (baton->oid != NULL) { + to = GitOid::New((void *)baton->oid); + } else { + to = Null(); + } + Handle result = to; + Handle argv[2] = { + Local::New(Null()), + result + }; + baton->callback->Call(Context::GetCurrent()->Global(), 2, argv); + } else { + if (baton->error) { + Handle argv[1] = { + Exception::Error(String::New(baton->error->message)) + }; + baton->callback->Call(Context::GetCurrent()->Global(), 1, argv); + } else { + baton->callback->Call(Context::GetCurrent()->Global(), 0, NULL); + } + free(baton->oid); + } + + if (try_catch.HasCaught()) { + node::FatalException(try_catch); + } + baton->repoReference.Dispose(); + baton->tag_nameReference.Dispose(); + baton->targetReference.Dispose(); + baton->forceReference.Dispose(); + baton->callback.Dispose(); + free((void *)baton->tag_name); + delete baton; +} + +/** + * @param {Oid} id + * @param {Tree} callback + */ +Handle GitRepo::GetTree(const Arguments& args) { + HandleScope scope; + if (args.Length() == 0 || !args[0]->IsObject()) { + return ThrowException(Exception::Error(String::New("Oid id is required."))); + } + + if (args.Length() == 1 || !args[1]->IsFunction()) { + return ThrowException(Exception::Error(String::New("Callback is required and must be a Function."))); + } + + GetTreeBaton* baton = new GetTreeBaton; + baton->error_code = GIT_OK; + baton->error = NULL; + baton->request.data = baton; + baton->repoReference = Persistent::New(args.This()); + baton->repo = ObjectWrap::Unwrap(args.This())->GetValue(); + baton->idReference = Persistent::New(args[0]); + const git_oid * from_id; + from_id = ObjectWrap::Unwrap(args[0]->ToObject())->GetValue(); + baton->id = from_id; + baton->callback = Persistent::New(Local::Cast(args[1])); + + uv_queue_work(uv_default_loop(), &baton->request, GetTreeWork, (uv_after_work_cb)GetTreeAfterWork); + + return Undefined(); +} + +void GitRepo::GetTreeWork(uv_work_t *req) { + GetTreeBaton *baton = static_cast(req->data); + int result = git_tree_lookup( + &baton->out, + baton->repo, + baton->id + ); + baton->error_code = result; + if (result != GIT_OK) { + baton->error = giterr_last(); + } +} + +void GitRepo::GetTreeAfterWork(uv_work_t *req) { + HandleScope scope; + GetTreeBaton *baton = static_cast(req->data); + + TryCatch try_catch; + if (baton->error_code == GIT_OK) { + Handle to; + if (baton->out != NULL) { + to = GitTree::New((void *)baton->out); + } else { + to = Null(); + } + Handle result = to; + Handle argv[2] = { + Local::New(Null()), + result + }; + baton->callback->Call(Context::GetCurrent()->Global(), 2, argv); + } else { + if (baton->error) { + Handle argv[1] = { + Exception::Error(String::New(baton->error->message)) + }; + baton->callback->Call(Context::GetCurrent()->Global(), 1, argv); + } else { + baton->callback->Call(Context::GetCurrent()->Global(), 0, NULL); + } + } + + if (try_catch.HasCaught()) { + node::FatalException(try_catch); + } + baton->repoReference.Dispose(); + baton->idReference.Dispose(); + baton->callback.Dispose(); + delete baton; +} + +/** + */ +Handle GitRepo::ReloadSubmodules(const Arguments& args) { + HandleScope scope; + + if (args.Length() == 0 || !args[0]->IsFunction()) { + return ThrowException(Exception::Error(String::New("Callback is required and must be a Function."))); + } + + ReloadSubmodulesBaton* baton = new ReloadSubmodulesBaton; + baton->error_code = GIT_OK; + baton->error = NULL; + baton->request.data = baton; + baton->repoReference = Persistent::New(args.This()); + baton->repo = ObjectWrap::Unwrap(args.This())->GetValue(); + baton->callback = Persistent::New(Local::Cast(args[0])); + + uv_queue_work(uv_default_loop(), &baton->request, ReloadSubmodulesWork, (uv_after_work_cb)ReloadSubmodulesAfterWork); + + return Undefined(); +} + +void GitRepo::ReloadSubmodulesWork(uv_work_t *req) { + ReloadSubmodulesBaton *baton = static_cast(req->data); + int result = git_submodule_reload_all( + baton->repo + ); + baton->error_code = result; + if (result != GIT_OK) { + baton->error = giterr_last(); + } +} + +void GitRepo::ReloadSubmodulesAfterWork(uv_work_t *req) { + HandleScope scope; + ReloadSubmodulesBaton *baton = static_cast(req->data); + + TryCatch try_catch; + if (baton->error_code == GIT_OK) { + Handle result = Local::New(Undefined()); + Handle argv[2] = { + Local::New(Null()), + result + }; + baton->callback->Call(Context::GetCurrent()->Global(), 2, argv); + } else { + if (baton->error) { + Handle argv[1] = { + Exception::Error(String::New(baton->error->message)) + }; + baton->callback->Call(Context::GetCurrent()->Global(), 1, argv); + } else { + baton->callback->Call(Context::GetCurrent()->Global(), 0, NULL); + } + } + + if (try_catch.HasCaught()) { + node::FatalException(try_catch); + } + baton->repoReference.Dispose(); + baton->callback.Dispose(); + delete baton; +} + +/** + * @param {String} tag_name + */ +Handle GitRepo::Delete(const Arguments& args) { + HandleScope scope; + if (args.Length() == 0 || !args[0]->IsString()) { + return ThrowException(Exception::Error(String::New("String tag_name is required."))); + } + + if (args.Length() == 1 || !args[1]->IsFunction()) { + return ThrowException(Exception::Error(String::New("Callback is required and must be a Function."))); + } + + DeleteBaton* baton = new DeleteBaton; + baton->error_code = GIT_OK; + baton->error = NULL; + baton->request.data = baton; + baton->repoReference = Persistent::New(args.This()); + baton->repo = ObjectWrap::Unwrap(args.This())->GetValue(); + baton->tag_nameReference = Persistent::New(args[0]); + const char * from_tag_name; + String::Utf8Value tag_name(args[0]->ToString()); + from_tag_name = strdup(*tag_name); + baton->tag_name = from_tag_name; + baton->callback = Persistent::New(Local::Cast(args[1])); + + uv_queue_work(uv_default_loop(), &baton->request, DeleteWork, (uv_after_work_cb)DeleteAfterWork); + + return Undefined(); +} + +void GitRepo::DeleteWork(uv_work_t *req) { + DeleteBaton *baton = static_cast(req->data); + int result = git_tag_delete( + baton->repo, + baton->tag_name + ); + baton->error_code = result; + if (result != GIT_OK) { + baton->error = giterr_last(); + } +} + +void GitRepo::DeleteAfterWork(uv_work_t *req) { + HandleScope scope; + DeleteBaton *baton = static_cast(req->data); + + TryCatch try_catch; + if (baton->error_code == GIT_OK) { + Handle result = Local::New(Undefined()); + Handle argv[2] = { + Local::New(Null()), + result + }; + baton->callback->Call(Context::GetCurrent()->Global(), 2, argv); + } else { + if (baton->error) { + Handle argv[1] = { + Exception::Error(String::New(baton->error->message)) + }; + baton->callback->Call(Context::GetCurrent()->Global(), 1, argv); + } else { + baton->callback->Call(Context::GetCurrent()->Global(), 0, NULL); + } + } + + if (try_catch.HasCaught()) { + node::FatalException(try_catch); + } + baton->repoReference.Dispose(); + baton->tag_nameReference.Dispose(); + baton->callback.Dispose(); + free((void *)baton->tag_name); + delete baton; +} + +/** + * @param {Number} list_flags + * @param {Array} callback + */ +Handle GitRepo::GetReferences(const Arguments& args) { + HandleScope scope; + + if (args.Length() == 1 || !args[1]->IsFunction()) { + return ThrowException(Exception::Error(String::New("Callback is required and must be a Function."))); + } + + GetReferencesBaton* baton = new GetReferencesBaton; + baton->error_code = GIT_OK; + baton->error = NULL; + baton->request.data = baton; + baton->array = (git_strarray *)malloc(sizeof(git_strarray )); + baton->repoReference = Persistent::New(args.This()); + baton->repo = ObjectWrap::Unwrap(args.This())->GetValue(); + baton->list_flagsReference = Persistent::New(args[0]); + unsigned int from_list_flags; + if (args[0]->IsUint32()) { + from_list_flags = (unsigned int) args[0]->ToUint32()->Value(); + } else { + from_list_flags = NULL; + } + baton->list_flags = from_list_flags; + baton->callback = Persistent::New(Local::Cast(args[1])); + + uv_queue_work(uv_default_loop(), &baton->request, GetReferencesWork, (uv_after_work_cb)GetReferencesAfterWork); + + return Undefined(); +} + +void GitRepo::GetReferencesWork(uv_work_t *req) { + GetReferencesBaton *baton = static_cast(req->data); + int result = git_reference_list( + baton->array, + baton->repo, + baton->list_flags + ); + baton->error_code = result; + if (result != GIT_OK) { + baton->error = giterr_last(); + } +} + +void GitRepo::GetReferencesAfterWork(uv_work_t *req) { + HandleScope scope; + GetReferencesBaton *baton = static_cast(req->data); + + TryCatch try_catch; + if (baton->error_code == GIT_OK) { + Handle to; + + Local tmpArray = Array::New(baton->array->count); + for (unsigned int i = 0; i < baton->array->count; i++) { + tmpArray->Set(Number::New(i), String::New(baton->array->strings[i])); + } + to = tmpArray; + Handle result = to; + Handle argv[2] = { + Local::New(Null()), + result + }; + baton->callback->Call(Context::GetCurrent()->Global(), 2, argv); + } else { + if (baton->error) { + Handle argv[1] = { + Exception::Error(String::New(baton->error->message)) + }; + baton->callback->Call(Context::GetCurrent()->Global(), 1, argv); + } else { + baton->callback->Call(Context::GetCurrent()->Global(), 0, NULL); + } + free(baton->array); + } + + if (try_catch.HasCaught()) { + node::FatalException(try_catch); + } + baton->repoReference.Dispose(); + baton->list_flagsReference.Dispose(); + baton->callback.Dispose(); + + git_strarray_free(baton->array); + delete baton; +} + +/** + * @param {Buffer} buffer + * @param {Number} len + * @param {Oid} callback + */ +Handle GitRepo::CreateBlobFromBuffer(const Arguments& args) { + HandleScope scope; + if (args.Length() == 0 || !args[0]->IsObject()) { + return ThrowException(Exception::Error(String::New("Buffer buffer is required."))); + } + if (args.Length() == 1 || !args[1]->IsNumber()) { + return ThrowException(Exception::Error(String::New("Number len is required."))); + } + + if (args.Length() == 2 || !args[2]->IsFunction()) { + return ThrowException(Exception::Error(String::New("Callback is required and must be a Function."))); + } + + CreateBlobFromBufferBaton* baton = new CreateBlobFromBufferBaton; + baton->error_code = GIT_OK; + baton->error = NULL; + baton->request.data = baton; + baton->oid = (git_oid *)malloc(sizeof(git_oid )); + baton->repoReference = Persistent::New(args.This()); + baton->repo = ObjectWrap::Unwrap(args.This())->GetValue(); + baton->bufferReference = Persistent::New(args[0]); + const void * from_buffer; + from_buffer = Buffer::Data(args[0]->ToObject()); + baton->buffer = from_buffer; + baton->lenReference = Persistent::New(args[1]); + size_t from_len; + from_len = (size_t) args[1]->ToNumber()->Value(); + baton->len = from_len; + baton->callback = Persistent::New(Local::Cast(args[2])); + + uv_queue_work(uv_default_loop(), &baton->request, CreateBlobFromBufferWork, (uv_after_work_cb)CreateBlobFromBufferAfterWork); + + return Undefined(); +} + +void GitRepo::CreateBlobFromBufferWork(uv_work_t *req) { + CreateBlobFromBufferBaton *baton = static_cast(req->data); + int result = git_blob_create_frombuffer( + baton->oid, + baton->repo, + baton->buffer, + baton->len + ); + baton->error_code = result; + if (result != GIT_OK) { + baton->error = giterr_last(); + } +} + +void GitRepo::CreateBlobFromBufferAfterWork(uv_work_t *req) { + HandleScope scope; + CreateBlobFromBufferBaton *baton = static_cast(req->data); + + TryCatch try_catch; + if (baton->error_code == GIT_OK) { + Handle to; + if (baton->oid != NULL) { + to = GitOid::New((void *)baton->oid); + } else { + to = Null(); + } + Handle result = to; + Handle argv[2] = { + Local::New(Null()), + result + }; + baton->callback->Call(Context::GetCurrent()->Global(), 2, argv); + } else { + if (baton->error) { + Handle argv[1] = { + Exception::Error(String::New(baton->error->message)) + }; + baton->callback->Call(Context::GetCurrent()->Global(), 1, argv); + } else { + baton->callback->Call(Context::GetCurrent()->Global(), 0, NULL); + } + free(baton->oid); + } + + if (try_catch.HasCaught()) { + node::FatalException(try_catch); + } + baton->repoReference.Dispose(); + baton->bufferReference.Dispose(); + baton->lenReference.Dispose(); + baton->callback.Dispose(); + delete baton; +} + +/** + * @param {String} path + * @param {Oid} callback + */ +Handle GitRepo::CreateBlobFromFile(const Arguments& args) { + HandleScope scope; + if (args.Length() == 0 || !args[0]->IsString()) { + return ThrowException(Exception::Error(String::New("String path is required."))); + } + + if (args.Length() == 1 || !args[1]->IsFunction()) { + return ThrowException(Exception::Error(String::New("Callback is required and must be a Function."))); + } + + CreateBlobFromFileBaton* baton = new CreateBlobFromFileBaton; + baton->error_code = GIT_OK; + baton->error = NULL; + baton->request.data = baton; + baton->id = (git_oid *)malloc(sizeof(git_oid )); + baton->repoReference = Persistent::New(args.This()); + baton->repo = ObjectWrap::Unwrap(args.This())->GetValue(); + baton->pathReference = Persistent::New(args[0]); + const char * from_path; + String::Utf8Value path(args[0]->ToString()); + from_path = strdup(*path); + baton->path = from_path; + baton->callback = Persistent::New(Local::Cast(args[1])); + + uv_queue_work(uv_default_loop(), &baton->request, CreateBlobFromFileWork, (uv_after_work_cb)CreateBlobFromFileAfterWork); + + return Undefined(); +} + +void GitRepo::CreateBlobFromFileWork(uv_work_t *req) { + CreateBlobFromFileBaton *baton = static_cast(req->data); + int result = git_blob_create_fromdisk( + baton->id, + baton->repo, + baton->path + ); + baton->error_code = result; + if (result != GIT_OK) { + baton->error = giterr_last(); + } +} + +void GitRepo::CreateBlobFromFileAfterWork(uv_work_t *req) { + HandleScope scope; + CreateBlobFromFileBaton *baton = static_cast(req->data); + + TryCatch try_catch; + if (baton->error_code == GIT_OK) { + Handle to; + if (baton->id != NULL) { + to = GitOid::New((void *)baton->id); + } else { + to = Null(); + } + Handle result = to; + Handle argv[2] = { + Local::New(Null()), + result + }; + baton->callback->Call(Context::GetCurrent()->Global(), 2, argv); + } else { + if (baton->error) { + Handle argv[1] = { + Exception::Error(String::New(baton->error->message)) + }; + baton->callback->Call(Context::GetCurrent()->Global(), 1, argv); + } else { + baton->callback->Call(Context::GetCurrent()->Global(), 0, NULL); + } + free(baton->id); + } + + if (try_catch.HasCaught()) { + node::FatalException(try_catch); + } + baton->repoReference.Dispose(); + baton->pathReference.Dispose(); + baton->callback.Dispose(); + free((void *)baton->path); + delete baton; +} + +/** + * @param {Array} callback + */ +Handle GitRepo::GetRemotes(const Arguments& args) { + HandleScope scope; + + if (args.Length() == 0 || !args[0]->IsFunction()) { + return ThrowException(Exception::Error(String::New("Callback is required and must be a Function."))); + } + + GetRemotesBaton* baton = new GetRemotesBaton; + baton->error_code = GIT_OK; + baton->error = NULL; + baton->request.data = baton; + baton->out = (git_strarray *)malloc(sizeof(git_strarray )); + baton->repoReference = Persistent::New(args.This()); + baton->repo = ObjectWrap::Unwrap(args.This())->GetValue(); + baton->callback = Persistent::New(Local::Cast(args[0])); + + uv_queue_work(uv_default_loop(), &baton->request, GetRemotesWork, (uv_after_work_cb)GetRemotesAfterWork); + + return Undefined(); +} + +void GitRepo::GetRemotesWork(uv_work_t *req) { + GetRemotesBaton *baton = static_cast(req->data); + int result = git_remote_list( + baton->out, + baton->repo + ); + baton->error_code = result; + if (result != GIT_OK) { + baton->error = giterr_last(); + } +} + +void GitRepo::GetRemotesAfterWork(uv_work_t *req) { + HandleScope scope; + GetRemotesBaton *baton = static_cast(req->data); + + TryCatch try_catch; + if (baton->error_code == GIT_OK) { + Handle to; + + Local tmpArray = Array::New(baton->out->count); + for (unsigned int i = 0; i < baton->out->count; i++) { + tmpArray->Set(Number::New(i), String::New(baton->out->strings[i])); + } + to = tmpArray; + Handle result = to; + Handle argv[2] = { + Local::New(Null()), + result + }; + baton->callback->Call(Context::GetCurrent()->Global(), 2, argv); + } else { + if (baton->error) { + Handle argv[1] = { + Exception::Error(String::New(baton->error->message)) + }; + baton->callback->Call(Context::GetCurrent()->Global(), 1, argv); + } else { + baton->callback->Call(Context::GetCurrent()->Global(), 0, NULL); + } + free(baton->out); + } + + if (try_catch.HasCaught()) { + node::FatalException(try_catch); + } + baton->repoReference.Dispose(); + baton->callback.Dispose(); + + git_strarray_free(baton->out); + delete baton; +} + +/** + * @param {String} url + * @param {String} local_path + * @param {CloneOptions} options + * @param {Repository} callback + */ +Handle GitRepo::Clone(const Arguments& args) { + HandleScope scope; + if (args.Length() == 0 || !args[0]->IsString()) { + return ThrowException(Exception::Error(String::New("String url is required."))); + } + if (args.Length() == 1 || !args[1]->IsString()) { + return ThrowException(Exception::Error(String::New("String local_path is required."))); + } + + if (args.Length() == 3 || !args[3]->IsFunction()) { + return ThrowException(Exception::Error(String::New("Callback is required and must be a Function."))); + } + + CloneBaton* baton = new CloneBaton; + baton->error_code = GIT_OK; + baton->error = NULL; + baton->request.data = baton; + baton->urlReference = Persistent::New(args[0]); + const char * from_url; + String::Utf8Value url(args[0]->ToString()); + from_url = strdup(*url); + baton->url = from_url; + baton->local_pathReference = Persistent::New(args[1]); + const char * from_local_path; + String::Utf8Value local_path(args[1]->ToString()); + from_local_path = strdup(*local_path); + baton->local_path = from_local_path; + baton->optionsReference = Persistent::New(args[2]); + const git_clone_options * from_options; + if (args[2]->IsObject()) { + from_options = ObjectWrap::Unwrap(args[2]->ToObject())->GetValue(); + } else { + from_options = NULL; + } + baton->options = from_options; + baton->callback = Persistent::New(Local::Cast(args[3])); + + uv_queue_work(uv_default_loop(), &baton->request, CloneWork, (uv_after_work_cb)CloneAfterWork); + + return Undefined(); +} + +void GitRepo::CloneWork(uv_work_t *req) { + CloneBaton *baton = static_cast(req->data); + int result = git_clone( + &baton->out, + baton->url, + baton->local_path, + baton->options + ); + baton->error_code = result; + if (result != GIT_OK) { + baton->error = giterr_last(); + } +} + +void GitRepo::CloneAfterWork(uv_work_t *req) { + HandleScope scope; + CloneBaton *baton = static_cast(req->data); + + TryCatch try_catch; + if (baton->error_code == GIT_OK) { + Handle to; + if (baton->out != NULL) { + to = GitRepo::New((void *)baton->out); + } else { + to = Null(); + } + Handle result = to; + Handle argv[2] = { + Local::New(Null()), + result + }; + baton->callback->Call(Context::GetCurrent()->Global(), 2, argv); + } else { + if (baton->error) { + Handle argv[1] = { + Exception::Error(String::New(baton->error->message)) + }; + baton->callback->Call(Context::GetCurrent()->Global(), 1, argv); + } else { + baton->callback->Call(Context::GetCurrent()->Global(), 0, NULL); + } + } + + if (try_catch.HasCaught()) { + node::FatalException(try_catch); + } + baton->urlReference.Dispose(); + baton->local_pathReference.Dispose(); + baton->optionsReference.Dispose(); + baton->callback.Dispose(); + free((void *)baton->url); + free((void *)baton->local_path); + delete baton; +} + +/** + * @param {String} name + * @return {Remote} out + */ +Handle GitRepo::GetRemote(const Arguments& args) { + HandleScope scope; + if (args.Length() == 0 || !args[0]->IsString()) { + return ThrowException(Exception::Error(String::New("String name is required."))); + } + + git_remote *out = NULL; + const char * from_name; + String::Utf8Value name(args[0]->ToString()); + from_name = strdup(*name); + + int result = git_remote_load( + &out + , ObjectWrap::Unwrap(args.This())->GetValue() + , from_name + ); + free((void *)from_name); + if (result != GIT_OK) { + if (giterr_last()) { + return ThrowException(Exception::Error(String::New(giterr_last()->message))); + } else { + return ThrowException(Exception::Error(String::New("Unkown Error"))); + } + } + + Handle to; + if (out != NULL) { + to = GitRemote::New((void *)out); + } else { + to = Null(); } - delete req; - baton->repo->Unref(); + return scope.Close(to); } Persistent GitRepo::constructor_template; diff --git a/src/revwalk.cc b/src/revwalk.cc index c8817bfde..ec5ff3c5d 100755 --- a/src/revwalk.cc +++ b/src/revwalk.cc @@ -1,26 +1,30 @@ -/* - * Copyright 2011, Tim Branyen @tbranyen - * @author Michael Robinson @codeofinterest - * - * Dual licensed under the MIT and GPL licenses. - */ - +/** + * This code is auto-generated; unless you know what you're doing, do not modify! + **/ #include #include +#include #include "git2.h" +#include "../include/functions/copy.h" + #include "../include/revwalk.h" +#include "../include/oid.h" #include "../include/repo.h" -#include "../include/commit.h" -#include "../include/error.h" - -#include "../include/functions/utilities.h" using namespace v8; using namespace node; -void GitRevWalk::Initialize(Handle target) { +GitRevWalk::GitRevWalk(git_revwalk *raw) { + this->raw = raw; +} + +GitRevWalk::~GitRevWalk() { + git_revwalk_free(this->raw); +} + +void GitRevWalk::Initialize(Handle target) { HandleScope scope; Local tpl = FunctionTemplate::New(New); @@ -28,230 +32,732 @@ void GitRevWalk::Initialize(Handle target) { tpl->InstanceTemplate()->SetInternalFieldCount(1); tpl->SetClassName(String::NewSymbol("RevWalk")); - NODE_SET_PROTOTYPE_METHOD(tpl, "allocate", Allocate); NODE_SET_PROTOTYPE_METHOD(tpl, "reset", Reset); NODE_SET_PROTOTYPE_METHOD(tpl, "push", Push); + NODE_SET_PROTOTYPE_METHOD(tpl, "pushGlob", PushGlob); + NODE_SET_PROTOTYPE_METHOD(tpl, "pushHead", PushHead); + NODE_SET_PROTOTYPE_METHOD(tpl, "hide", Hide); + NODE_SET_PROTOTYPE_METHOD(tpl, "hideGlob", HideGlob); + NODE_SET_PROTOTYPE_METHOD(tpl, "hideHead", HideHead); + NODE_SET_PROTOTYPE_METHOD(tpl, "pushRef", PushRef); + NODE_SET_PROTOTYPE_METHOD(tpl, "hideRef", HideRef); NODE_SET_PROTOTYPE_METHOD(tpl, "next", Next); - NODE_SET_PROTOTYPE_METHOD(tpl, "free", Free); - - // Local sort = Object::New(); + NODE_SET_PROTOTYPE_METHOD(tpl, "sorting", Sorting); - // sort->Set(String::New("NONE"), Integer::New(0)); - // sort->Set(String::New("TOPOLOGICAL"), Integer::New(1)); - // sort->Set(String::New("TIME"), Integer::New(2)); - // sort->Set(String::New("REVERSE"), Integer::New(4)); - - // tpl->Set(String::New("sort"), sort); constructor_template = Persistent::New(tpl->GetFunction()); target->Set(String::NewSymbol("RevWalk"), constructor_template); } -git_revwalk* GitRevWalk::GetValue() { - return this->revwalk; -} -void GitRevWalk::SetValue(git_revwalk* revwalk) { - this->revwalk = revwalk; +Handle GitRevWalk::New(const Arguments& args) { + HandleScope scope; + + if (args.Length() == 0 || !args[0]->IsExternal()) { + return ThrowException(Exception::Error(String::New("git_revwalk is required."))); + } + + GitRevWalk* object = new GitRevWalk((git_revwalk *) External::Unwrap(args[0])); + object->Wrap(args.This()); + + return scope.Close(args.This()); } -git_repository* GitRevWalk::GetRepo() { - return this->repo; + +Handle GitRevWalk::New(void *raw) { + HandleScope scope; + Handle argv[1] = { External::New((void *)raw) }; + return scope.Close(GitRevWalk::constructor_template->NewInstance(1, argv)); } -void GitRevWalk::SetRepo(git_repository* repo) { - this->repo = repo; + +git_revwalk *GitRevWalk::GetValue() { + return this->raw; } -Handle GitRevWalk::Free(const Arguments& args) { - HandleScope scope; - GitRevWalk *revwalk = ObjectWrap::Unwrap(args.This()); +/** + */ +Handle GitRevWalk::Reset(const Arguments& args) { + HandleScope scope; + - git_revwalk_free(revwalk->revwalk); + git_revwalk_reset( + ObjectWrap::Unwrap(args.This())->GetValue() + ); return Undefined(); } -Handle GitRevWalk::New(const Arguments& args) { +/** + * @param {Oid} id + */ +Handle GitRevWalk::Push(const Arguments& args) { HandleScope scope; + if (args.Length() == 0 || !args[0]->IsObject()) { + return ThrowException(Exception::Error(String::New("Oid id is required."))); + } - GitRevWalk *revwalk = new GitRevWalk(); - if(args.Length() == 0 || !args[0]->IsObject()) { - return ThrowException(Exception::Error(String::New("Repo is required and must be an Object."))); + if (args.Length() == 1 || !args[1]->IsFunction()) { + return ThrowException(Exception::Error(String::New("Callback is required and must be a Function."))); } - GitRepo *repo = ObjectWrap::Unwrap(args[0]->ToObject()); - revwalk->SetRepo(repo->GetValue()); + PushBaton* baton = new PushBaton; + baton->error_code = GIT_OK; + baton->error = NULL; + baton->request.data = baton; + baton->walkReference = Persistent::New(args.This()); + baton->walk = ObjectWrap::Unwrap(args.This())->GetValue(); + baton->idReference = Persistent::New(args[0]); + const git_oid * from_id; + from_id = ObjectWrap::Unwrap(args[0]->ToObject())->GetValue(); + baton->id = from_id; + baton->callback = Persistent::New(Local::Cast(args[1])); - revwalk->Wrap(args.This()); + uv_queue_work(uv_default_loop(), &baton->request, PushWork, (uv_after_work_cb)PushAfterWork); - return scope.Close(args.This()); + return Undefined(); } -Handle GitRevWalk::Reset(const Arguments& args) { +void GitRevWalk::PushWork(uv_work_t *req) { + PushBaton *baton = static_cast(req->data); + int result = git_revwalk_push( + baton->walk, + baton->id + ); + baton->error_code = result; + if (result != GIT_OK) { + baton->error = giterr_last(); + } +} + +void GitRevWalk::PushAfterWork(uv_work_t *req) { HandleScope scope; + PushBaton *baton = static_cast(req->data); - GitRevWalk *revwalk = ObjectWrap::Unwrap(args.This()); - git_revwalk_reset(revwalk->revwalk); + TryCatch try_catch; + if (baton->error_code == GIT_OK) { + Handle result = Local::New(Undefined()); + Handle argv[2] = { + Local::New(Null()), + result + }; + baton->callback->Call(Context::GetCurrent()->Global(), 2, argv); + } else { + if (baton->error) { + Handle argv[1] = { + Exception::Error(String::New(baton->error->message)) + }; + baton->callback->Call(Context::GetCurrent()->Global(), 1, argv); + } else { + baton->callback->Call(Context::GetCurrent()->Global(), 0, NULL); + } + } - return Undefined(); + if (try_catch.HasCaught()) { + node::FatalException(try_catch); + } + baton->walkReference.Dispose(); + baton->idReference.Dispose(); + baton->callback.Dispose(); + delete baton; } -Handle GitRevWalk::Allocate(const Arguments& args) { +/** + * @param {String} glob + */ +Handle GitRevWalk::PushGlob(const Arguments& args) { HandleScope scope; + if (args.Length() == 0 || !args[0]->IsString()) { + return ThrowException(Exception::Error(String::New("String glob is required."))); + } - if(args.Length() == 0 || !args[0]->IsFunction()) { + if (args.Length() == 1 || !args[1]->IsFunction()) { return ThrowException(Exception::Error(String::New("Callback is required and must be a Function."))); } - AllocateBaton *baton = new AllocateBaton; + PushGlobBaton* baton = new PushGlobBaton; + baton->error_code = GIT_OK; + baton->error = NULL; baton->request.data = baton; + baton->walkReference = Persistent::New(args.This()); + baton->walk = ObjectWrap::Unwrap(args.This())->GetValue(); + baton->globReference = Persistent::New(args[0]); + const char * from_glob; + String::Utf8Value glob(args[0]->ToString()); + from_glob = strdup(*glob); + baton->glob = from_glob; + baton->callback = Persistent::New(Local::Cast(args[1])); + + uv_queue_work(uv_default_loop(), &baton->request, PushGlobWork, (uv_after_work_cb)PushGlobAfterWork); + + return Undefined(); +} + +void GitRevWalk::PushGlobWork(uv_work_t *req) { + PushGlobBaton *baton = static_cast(req->data); + int result = git_revwalk_push_glob( + baton->walk, + baton->glob + ); + baton->error_code = result; + if (result != GIT_OK) { + baton->error = giterr_last(); + } +} + +void GitRevWalk::PushGlobAfterWork(uv_work_t *req) { + HandleScope scope; + PushGlobBaton *baton = static_cast(req->data); + + TryCatch try_catch; + if (baton->error_code == GIT_OK) { + Handle result = Local::New(Undefined()); + Handle argv[2] = { + Local::New(Null()), + result + }; + baton->callback->Call(Context::GetCurrent()->Global(), 2, argv); + } else { + if (baton->error) { + Handle argv[1] = { + Exception::Error(String::New(baton->error->message)) + }; + baton->callback->Call(Context::GetCurrent()->Global(), 1, argv); + } else { + baton->callback->Call(Context::GetCurrent()->Global(), 0, NULL); + } + } + + if (try_catch.HasCaught()) { + node::FatalException(try_catch); + } + baton->walkReference.Dispose(); + baton->globReference.Dispose(); + baton->callback.Dispose(); + free((void *)baton->glob); + delete baton; +} + +/** + */ +Handle GitRevWalk::PushHead(const Arguments& args) { + HandleScope scope; + + if (args.Length() == 0 || !args[0]->IsFunction()) { + return ThrowException(Exception::Error(String::New("Callback is required and must be a Function."))); + } + + PushHeadBaton* baton = new PushHeadBaton; + baton->error_code = GIT_OK; baton->error = NULL; - baton->revwalk = ObjectWrap::Unwrap(args.This()); - baton->rawRevwalk = NULL; - baton->rawRepo = baton->revwalk->GetRepo(); + baton->request.data = baton; + baton->walkReference = Persistent::New(args.This()); + baton->walk = ObjectWrap::Unwrap(args.This())->GetValue(); baton->callback = Persistent::New(Local::Cast(args[0])); - uv_queue_work(uv_default_loop(), &baton->request, AllocateWork, (uv_after_work_cb)AllocateAfterWork); + uv_queue_work(uv_default_loop(), &baton->request, PushHeadWork, (uv_after_work_cb)PushHeadAfterWork); return Undefined(); } -void GitRevWalk::AllocateWork(uv_work_t *req) { - AllocateBaton *baton = static_cast(req->data); - int returnCode = git_revwalk_new(&baton->rawRevwalk, baton->rawRepo); - if (returnCode != GIT_OK) { +void GitRevWalk::PushHeadWork(uv_work_t *req) { + PushHeadBaton *baton = static_cast(req->data); + int result = git_revwalk_push_head( + baton->walk + ); + baton->error_code = result; + if (result != GIT_OK) { baton->error = giterr_last(); } } -void GitRevWalk::AllocateAfterWork(uv_work_t *req) { +void GitRevWalk::PushHeadAfterWork(uv_work_t *req) { HandleScope scope; - AllocateBaton *baton = static_cast(req->data); + PushHeadBaton *baton = static_cast(req->data); + TryCatch try_catch; + if (baton->error_code == GIT_OK) { + Handle result = Local::New(Undefined()); + Handle argv[2] = { + Local::New(Null()), + result + }; + baton->callback->Call(Context::GetCurrent()->Global(), 2, argv); + } else { + if (baton->error) { + Handle argv[1] = { + Exception::Error(String::New(baton->error->message)) + }; + baton->callback->Call(Context::GetCurrent()->Global(), 1, argv); + } else { + baton->callback->Call(Context::GetCurrent()->Global(), 0, NULL); + } + } - if (success(baton->error, baton->callback)) { + if (try_catch.HasCaught()) { + node::FatalException(try_catch); + } + baton->walkReference.Dispose(); + baton->callback.Dispose(); + delete baton; +} - baton->revwalk->SetValue(baton->rawRevwalk); +/** + * @param {Oid} commit_id + */ +Handle GitRevWalk::Hide(const Arguments& args) { + HandleScope scope; + if (args.Length() == 0 || !args[0]->IsObject()) { + return ThrowException(Exception::Error(String::New("Oid commit_id is required."))); + } + + if (args.Length() == 1 || !args[1]->IsFunction()) { + return ThrowException(Exception::Error(String::New("Callback is required and must be a Function."))); + } + + HideBaton* baton = new HideBaton; + baton->error_code = GIT_OK; + baton->error = NULL; + baton->request.data = baton; + baton->walkReference = Persistent::New(args.This()); + baton->walk = ObjectWrap::Unwrap(args.This())->GetValue(); + baton->commit_idReference = Persistent::New(args[0]); + const git_oid * from_commit_id; + from_commit_id = ObjectWrap::Unwrap(args[0]->ToObject())->GetValue(); + baton->commit_id = from_commit_id; + baton->callback = Persistent::New(Local::Cast(args[1])); + + uv_queue_work(uv_default_loop(), &baton->request, HideWork, (uv_after_work_cb)HideAfterWork); + return Undefined(); +} + +void GitRevWalk::HideWork(uv_work_t *req) { + HideBaton *baton = static_cast(req->data); + int result = git_revwalk_hide( + baton->walk, + baton->commit_id + ); + baton->error_code = result; + if (result != GIT_OK) { + baton->error = giterr_last(); + } +} + +void GitRevWalk::HideAfterWork(uv_work_t *req) { + HandleScope scope; + HideBaton *baton = static_cast(req->data); + + TryCatch try_catch; + if (baton->error_code == GIT_OK) { + Handle result = Local::New(Undefined()); Handle argv[2] = { Local::New(Null()), - baton->revwalk->handle_ + result }; - - TryCatch try_catch; baton->callback->Call(Context::GetCurrent()->Global(), 2, argv); - if (try_catch.HasCaught()) { - node::FatalException(try_catch); + } else { + if (baton->error) { + Handle argv[1] = { + Exception::Error(String::New(baton->error->message)) + }; + baton->callback->Call(Context::GetCurrent()->Global(), 1, argv); + } else { + baton->callback->Call(Context::GetCurrent()->Global(), 0, NULL); } + } + + if (try_catch.HasCaught()) { + node::FatalException(try_catch); } - delete req; + baton->walkReference.Dispose(); + baton->commit_idReference.Dispose(); + baton->callback.Dispose(); + delete baton; } -Handle GitRevWalk::Push(const Arguments& args) { +/** + * @param {String} glob + */ +Handle GitRevWalk::HideGlob(const Arguments& args) { HandleScope scope; - - if(args.Length() == 0 || !args[0]->IsObject()) { - return ThrowException(Exception::Error(String::New("Oid is required and must be an Object."))); + if (args.Length() == 0 || !args[0]->IsString()) { + return ThrowException(Exception::Error(String::New("String glob is required."))); } - if(args.Length() == 1 || !args[1]->IsFunction()) { + if (args.Length() == 1 || !args[1]->IsFunction()) { return ThrowException(Exception::Error(String::New("Callback is required and must be a Function."))); } - PushBaton* baton = new PushBaton; - + HideGlobBaton* baton = new HideGlobBaton; + baton->error_code = GIT_OK; + baton->error = NULL; baton->request.data = baton; + baton->walkReference = Persistent::New(args.This()); + baton->walk = ObjectWrap::Unwrap(args.This())->GetValue(); + baton->globReference = Persistent::New(args[0]); + const char * from_glob; + String::Utf8Value glob(args[0]->ToString()); + from_glob = strdup(*glob); + baton->glob = from_glob; + baton->callback = Persistent::New(Local::Cast(args[1])); + + uv_queue_work(uv_default_loop(), &baton->request, HideGlobWork, (uv_after_work_cb)HideGlobAfterWork); + + return Undefined(); +} + +void GitRevWalk::HideGlobWork(uv_work_t *req) { + HideGlobBaton *baton = static_cast(req->data); + int result = git_revwalk_hide_glob( + baton->walk, + baton->glob + ); + baton->error_code = result; + if (result != GIT_OK) { + baton->error = giterr_last(); + } +} + +void GitRevWalk::HideGlobAfterWork(uv_work_t *req) { + HandleScope scope; + HideGlobBaton *baton = static_cast(req->data); + + TryCatch try_catch; + if (baton->error_code == GIT_OK) { + Handle result = Local::New(Undefined()); + Handle argv[2] = { + Local::New(Null()), + result + }; + baton->callback->Call(Context::GetCurrent()->Global(), 2, argv); + } else { + if (baton->error) { + Handle argv[1] = { + Exception::Error(String::New(baton->error->message)) + }; + baton->callback->Call(Context::GetCurrent()->Global(), 1, argv); + } else { + baton->callback->Call(Context::GetCurrent()->Global(), 0, NULL); + } + } + + if (try_catch.HasCaught()) { + node::FatalException(try_catch); + } + baton->walkReference.Dispose(); + baton->globReference.Dispose(); + baton->callback.Dispose(); + free((void *)baton->glob); + delete baton; +} + +/** + */ +Handle GitRevWalk::HideHead(const Arguments& args) { + HandleScope scope; + + if (args.Length() == 0 || !args[0]->IsFunction()) { + return ThrowException(Exception::Error(String::New("Callback is required and must be a Function."))); + } + + HideHeadBaton* baton = new HideHeadBaton; + baton->error_code = GIT_OK; baton->error = NULL; - baton->rawRevwalk = ObjectWrap::Unwrap(args.This())->GetValue(); - baton->rawOid = ObjectWrap::Unwrap(args[0]->ToObject())->GetValue(); - baton->callback = Persistent::New(Local::Cast(args[1])); + baton->request.data = baton; + baton->walkReference = Persistent::New(args.This()); + baton->walk = ObjectWrap::Unwrap(args.This())->GetValue(); + baton->callback = Persistent::New(Local::Cast(args[0])); - uv_queue_work(uv_default_loop(), &baton->request, PushWork, (uv_after_work_cb)PushAfterWork); + uv_queue_work(uv_default_loop(), &baton->request, HideHeadWork, (uv_after_work_cb)HideHeadAfterWork); return Undefined(); } -void GitRevWalk::PushWork(uv_work_t *req) { - PushBaton *baton = static_cast(req->data); - git_revwalk_sorting(baton->rawRevwalk, GIT_SORT_TIME | GIT_SORT_REVERSE); +void GitRevWalk::HideHeadWork(uv_work_t *req) { + HideHeadBaton *baton = static_cast(req->data); + int result = git_revwalk_hide_head( + baton->walk + ); + baton->error_code = result; + if (result != GIT_OK) { + baton->error = giterr_last(); + } +} - int returnCode = git_revwalk_push(baton->rawRevwalk, &baton->rawOid); - if (returnCode) { +void GitRevWalk::HideHeadAfterWork(uv_work_t *req) { + HandleScope scope; + HideHeadBaton *baton = static_cast(req->data); + + TryCatch try_catch; + if (baton->error_code == GIT_OK) { + Handle result = Local::New(Undefined()); + Handle argv[2] = { + Local::New(Null()), + result + }; + baton->callback->Call(Context::GetCurrent()->Global(), 2, argv); + } else { + if (baton->error) { + Handle argv[1] = { + Exception::Error(String::New(baton->error->message)) + }; + baton->callback->Call(Context::GetCurrent()->Global(), 1, argv); + } else { + baton->callback->Call(Context::GetCurrent()->Global(), 0, NULL); + } + } + + if (try_catch.HasCaught()) { + node::FatalException(try_catch); + } + baton->walkReference.Dispose(); + baton->callback.Dispose(); + delete baton; +} + +/** + * @param {String} refname + */ +Handle GitRevWalk::PushRef(const Arguments& args) { + HandleScope scope; + if (args.Length() == 0 || !args[0]->IsString()) { + return ThrowException(Exception::Error(String::New("String refname is required."))); + } + + if (args.Length() == 1 || !args[1]->IsFunction()) { + return ThrowException(Exception::Error(String::New("Callback is required and must be a Function."))); + } + + PushRefBaton* baton = new PushRefBaton; + baton->error_code = GIT_OK; + baton->error = NULL; + baton->request.data = baton; + baton->walkReference = Persistent::New(args.This()); + baton->walk = ObjectWrap::Unwrap(args.This())->GetValue(); + baton->refnameReference = Persistent::New(args[0]); + const char * from_refname; + String::Utf8Value refname(args[0]->ToString()); + from_refname = strdup(*refname); + baton->refname = from_refname; + baton->callback = Persistent::New(Local::Cast(args[1])); + + uv_queue_work(uv_default_loop(), &baton->request, PushRefWork, (uv_after_work_cb)PushRefAfterWork); + + return Undefined(); +} + +void GitRevWalk::PushRefWork(uv_work_t *req) { + PushRefBaton *baton = static_cast(req->data); + int result = git_revwalk_push_ref( + baton->walk, + baton->refname + ); + baton->error_code = result; + if (result != GIT_OK) { baton->error = giterr_last(); } } -void GitRevWalk::PushAfterWork(uv_work_t *req) { + +void GitRevWalk::PushRefAfterWork(uv_work_t *req) { HandleScope scope; - PushBaton *baton = static_cast(req->data); + PushRefBaton *baton = static_cast(req->data); - Local argv[1]; - if (baton->error) { - argv[0] = GitError::WrapError(baton->error); + TryCatch try_catch; + if (baton->error_code == GIT_OK) { + Handle result = Local::New(Undefined()); + Handle argv[2] = { + Local::New(Null()), + result + }; + baton->callback->Call(Context::GetCurrent()->Global(), 2, argv); } else { - argv[0] = Local::New(Null()); + if (baton->error) { + Handle argv[1] = { + Exception::Error(String::New(baton->error->message)) + }; + baton->callback->Call(Context::GetCurrent()->Global(), 1, argv); + } else { + baton->callback->Call(Context::GetCurrent()->Global(), 0, NULL); + } + } + + if (try_catch.HasCaught()) { + node::FatalException(try_catch); + } + baton->walkReference.Dispose(); + baton->refnameReference.Dispose(); + baton->callback.Dispose(); + free((void *)baton->refname); + delete baton; +} + +/** + * @param {String} refname + */ +Handle GitRevWalk::HideRef(const Arguments& args) { + HandleScope scope; + if (args.Length() == 0 || !args[0]->IsString()) { + return ThrowException(Exception::Error(String::New("String refname is required."))); + } + + if (args.Length() == 1 || !args[1]->IsFunction()) { + return ThrowException(Exception::Error(String::New("Callback is required and must be a Function."))); + } + + HideRefBaton* baton = new HideRefBaton; + baton->error_code = GIT_OK; + baton->error = NULL; + baton->request.data = baton; + baton->walkReference = Persistent::New(args.This()); + baton->walk = ObjectWrap::Unwrap(args.This())->GetValue(); + baton->refnameReference = Persistent::New(args[0]); + const char * from_refname; + String::Utf8Value refname(args[0]->ToString()); + from_refname = strdup(*refname); + baton->refname = from_refname; + baton->callback = Persistent::New(Local::Cast(args[1])); + + uv_queue_work(uv_default_loop(), &baton->request, HideRefWork, (uv_after_work_cb)HideRefAfterWork); + + return Undefined(); +} + +void GitRevWalk::HideRefWork(uv_work_t *req) { + HideRefBaton *baton = static_cast(req->data); + int result = git_revwalk_hide_ref( + baton->walk, + baton->refname + ); + baton->error_code = result; + if (result != GIT_OK) { + baton->error = giterr_last(); } +} + +void GitRevWalk::HideRefAfterWork(uv_work_t *req) { + HandleScope scope; + HideRefBaton *baton = static_cast(req->data); TryCatch try_catch; - baton->callback->Call(Context::GetCurrent()->Global(), 1, argv); + if (baton->error_code == GIT_OK) { + Handle result = Local::New(Undefined()); + Handle argv[2] = { + Local::New(Null()), + result + }; + baton->callback->Call(Context::GetCurrent()->Global(), 2, argv); + } else { + if (baton->error) { + Handle argv[1] = { + Exception::Error(String::New(baton->error->message)) + }; + baton->callback->Call(Context::GetCurrent()->Global(), 1, argv); + } else { + baton->callback->Call(Context::GetCurrent()->Global(), 0, NULL); + } + } + if (try_catch.HasCaught()) { - node::FatalException(try_catch); + node::FatalException(try_catch); } - delete req; + baton->walkReference.Dispose(); + baton->refnameReference.Dispose(); + baton->callback.Dispose(); + free((void *)baton->refname); + delete baton; } +/** + * @param {Oid} callback + */ Handle GitRevWalk::Next(const Arguments& args) { HandleScope scope; - - if(args.Length() == 0 || !args[0]->IsFunction()) { + + if (args.Length() == 0 || !args[0]->IsFunction()) { return ThrowException(Exception::Error(String::New("Callback is required and must be a Function."))); } NextBaton* baton = new NextBaton; - - baton->request.data = baton; + baton->error_code = GIT_OK; baton->error = NULL; - baton->rawRevwalk = ObjectWrap::Unwrap(args.This())->GetValue(); - baton->walkOver = false; + baton->request.data = baton; + baton->out = (git_oid *)malloc(sizeof(git_oid )); + baton->walkReference = Persistent::New(args.This()); + baton->walk = ObjectWrap::Unwrap(args.This())->GetValue(); baton->callback = Persistent::New(Local::Cast(args[0])); uv_queue_work(uv_default_loop(), &baton->request, NextWork, (uv_after_work_cb)NextAfterWork); return Undefined(); } + void GitRevWalk::NextWork(uv_work_t *req) { NextBaton *baton = static_cast(req->data); - - int returnCode = git_revwalk_next(&baton->rawOid, baton->rawRevwalk); - if (returnCode != GIT_OK) { - if (returnCode == GIT_ITEROVER) { - baton->walkOver = true; - } else { - git_revwalk_reset(baton->rawRevwalk); - baton->error = giterr_last(); - } + int result = git_revwalk_next( + baton->out, + baton->walk + ); + baton->error_code = result; + if (result != GIT_OK) { + baton->error = giterr_last(); } } + void GitRevWalk::NextAfterWork(uv_work_t *req) { HandleScope scope; NextBaton *baton = static_cast(req->data); - if (success(baton->error, baton->callback)) { - Local oid = GitOid::constructor_template->NewInstance(); - GitOid *oidInstance = ObjectWrap::Unwrap(oid); - oidInstance->SetValue(baton->rawOid); - - Local argv[3] = { + TryCatch try_catch; + if (baton->error_code == GIT_OK) { + Handle to; + if (baton->out != NULL) { + to = GitOid::New((void *)baton->out); + } else { + to = Null(); + } + Handle result = to; + Handle argv[2] = { Local::New(Null()), - oid, - Local::New(Boolean::New(baton->walkOver)) + result }; - - TryCatch try_catch; - baton->callback->Call(Context::GetCurrent()->Global(), 3, argv); - if(try_catch.HasCaught()) { - FatalException(try_catch); + baton->callback->Call(Context::GetCurrent()->Global(), 2, argv); + } else { + if (baton->error) { + Handle argv[1] = { + Exception::Error(String::New(baton->error->message)) + }; + baton->callback->Call(Context::GetCurrent()->Global(), 1, argv); + } else { + baton->callback->Call(Context::GetCurrent()->Global(), 0, NULL); } + free(baton->out); + } + + if (try_catch.HasCaught()) { + node::FatalException(try_catch); } - delete req; + baton->walkReference.Dispose(); + baton->callback.Dispose(); + delete baton; +} + +/** + * @param {Number} sort_mode + */ +Handle GitRevWalk::Sorting(const Arguments& args) { + HandleScope scope; + if (args.Length() == 0 || !args[0]->IsUint32()) { + return ThrowException(Exception::Error(String::New("Number sort_mode is required."))); + } + + unsigned int from_sort_mode; + from_sort_mode = (unsigned int) args[0]->ToUint32()->Value(); + + git_revwalk_sorting( + ObjectWrap::Unwrap(args.This())->GetValue() + , from_sort_mode + ); + + return Undefined(); } Persistent GitRevWalk::constructor_template; diff --git a/src/signature.cc b/src/signature.cc index 49b775403..de0d84051 100755 --- a/src/signature.cc +++ b/src/signature.cc @@ -1,90 +1,215 @@ -/* - * Copyright 2013, Tim Branyen @tbranyen - * @author Michael Robinson @codeofinterest - * - * Dual licensed under the MIT and GPL licenses. - */ - +/** + * This code is auto-generated; unless you know what you're doing, do not modify! + **/ #include #include +#include #include "git2.h" -#include "../include/repo.h" +#include "../include/functions/copy.h" + #include "../include/signature.h" +#include "../include/time.h" using namespace v8; using namespace node; +GitSignature::GitSignature(git_signature *raw) { + this->raw = raw; +} + +GitSignature::~GitSignature() { + git_signature_free(this->raw); +} + void GitSignature::Initialize(Handle target) { + HandleScope scope; + Local tpl = FunctionTemplate::New(New); tpl->InstanceTemplate()->SetInternalFieldCount(1); tpl->SetClassName(String::NewSymbol("Signature")); - NODE_SET_PROTOTYPE_METHOD(tpl, "duplicate", Duplicate); + NODE_SET_METHOD(tpl, "create", Create); + NODE_SET_METHOD(tpl, "now", Now); + NODE_SET_PROTOTYPE_METHOD(tpl, "name", Name); NODE_SET_PROTOTYPE_METHOD(tpl, "email", Email); - - NODE_SET_PROTOTYPE_METHOD(tpl, "free", Free); + NODE_SET_PROTOTYPE_METHOD(tpl, "time", Time); constructor_template = Persistent::New(tpl->GetFunction()); target->Set(String::NewSymbol("Signature"), constructor_template); } -git_signature* GitSignature::GetValue() { - return this->signature; -} - -void GitSignature::SetValue(git_signature* signature) { - this->signature = signature; -} - Handle GitSignature::New(const Arguments& args) { HandleScope scope; - GitSignature *signature = new GitSignature(); - signature->Wrap(args.This()); + if (args.Length() == 0 || !args[0]->IsExternal()) { + return ThrowException(Exception::Error(String::New("git_signature is required."))); + } + + GitSignature* object = new GitSignature((git_signature *) External::Unwrap(args[0])); + object->Wrap(args.This()); return scope.Close(args.This()); } -Handle GitSignature::Free(const Arguments& args) { +Handle GitSignature::New(void *raw) { HandleScope scope; - - GitSignature *signature = ObjectWrap::Unwrap(args.This()); - git_signature_free(signature->signature); - signature->signature = NULL; - - return Undefined(); + Handle argv[1] = { External::New((void *)raw) }; + return scope.Close(GitSignature::constructor_template->NewInstance(1, argv)); } -Handle GitSignature::Duplicate(const Arguments& args) { - HandleScope scope; +git_signature *GitSignature::GetValue() { + return this->raw; +} - Local duplicateSignature = GitSignature::constructor_template->NewInstance(); - GitSignature *duplicateSignatureInstance = ObjectWrap::Unwrap(duplicateSignature); - GitSignature* signature = ObjectWrap::Unwrap(args.This()); - duplicateSignatureInstance->SetValue(git_signature_dup(signature->GetValue())); +/** + * @param {String} name + * @param {String} email + * @param {Number} time + * @param {Number} offset + * @return {Signature} out + */ +Handle GitSignature::Create(const Arguments& args) { + HandleScope scope; + if (args.Length() == 0 || !args[0]->IsString()) { + return ThrowException(Exception::Error(String::New("String name is required."))); + } + if (args.Length() == 1 || !args[1]->IsString()) { + return ThrowException(Exception::Error(String::New("String email is required."))); + } + if (args.Length() == 2 || !args[2]->IsInt32()) { + return ThrowException(Exception::Error(String::New("Number time is required."))); + } + if (args.Length() == 3 || !args[3]->IsInt32()) { + return ThrowException(Exception::Error(String::New("Number offset is required."))); + } + + git_signature *out = NULL; + const char * from_name; + String::Utf8Value name(args[0]->ToString()); + from_name = strdup(*name); + const char * from_email; + String::Utf8Value email(args[1]->ToString()); + from_email = strdup(*email); + git_time_t from_time; + from_time = (git_time_t) args[2]->ToInt32()->Value(); + int from_offset; + from_offset = (int) args[3]->ToInt32()->Value(); + + int result = git_signature_new( + &out + , from_name + , from_email + , from_time + , from_offset + ); + free((void *)from_name); + free((void *)from_email); + if (result != GIT_OK) { + if (giterr_last()) { + return ThrowException(Exception::Error(String::New(giterr_last()->message))); + } else { + return ThrowException(Exception::Error(String::New("Unkown Error"))); + } + } + + Handle to; + if (out != NULL) { + to = GitSignature::New((void *)out); + } else { + to = Null(); + } + return scope.Close(to); +} - return duplicateSignature; +/** + * @param {String} name + * @param {String} email + * @return {Signature} out + */ +Handle GitSignature::Now(const Arguments& args) { + HandleScope scope; + if (args.Length() == 0 || !args[0]->IsString()) { + return ThrowException(Exception::Error(String::New("String name is required."))); + } + if (args.Length() == 1 || !args[1]->IsString()) { + return ThrowException(Exception::Error(String::New("String email is required."))); + } + + git_signature *out = NULL; + const char * from_name; + String::Utf8Value name(args[0]->ToString()); + from_name = strdup(*name); + const char * from_email; + String::Utf8Value email(args[1]->ToString()); + from_email = strdup(*email); + + int result = git_signature_now( + &out + , from_name + , from_email + ); + free((void *)from_name); + free((void *)from_email); + if (result != GIT_OK) { + if (giterr_last()) { + return ThrowException(Exception::Error(String::New(giterr_last()->message))); + } else { + return ThrowException(Exception::Error(String::New("Unkown Error"))); + } + } + + Handle to; + if (out != NULL) { + to = GitSignature::New((void *)out); + } else { + to = Null(); + } + return scope.Close(to); } Handle GitSignature::Name(const Arguments& args) { HandleScope scope; + Handle to; - GitSignature *signature = ObjectWrap::Unwrap(args.This()); + const char * name = + ObjectWrap::Unwrap(args.This())->GetValue()->name; - return scope.Close(String::New(signature->GetValue()->name)); + to = String::New(name); + return scope.Close(to); } Handle GitSignature::Email(const Arguments& args) { HandleScope scope; + Handle to; - GitSignature *signature = ObjectWrap::Unwrap(args.This()); + const char * email = + ObjectWrap::Unwrap(args.This())->GetValue()->email; - return scope.Close(String::New(signature->GetValue()->email)); + to = String::New(email); + return scope.Close(to); +} + +Handle GitSignature::Time(const Arguments& args) { + HandleScope scope; + Handle to; + + git_time *when = + &ObjectWrap::Unwrap(args.This())->GetValue()->when; + + if (when != NULL) { + when = (git_time *)git_time_dup(when); + } + if (when != NULL) { + to = GitTime::New((void *)when); + } else { + to = Null(); + } + return scope.Close(to); } Persistent GitSignature::constructor_template; diff --git a/src/submodule.cc b/src/submodule.cc new file mode 100644 index 000000000..d6b968a0b --- /dev/null +++ b/src/submodule.cc @@ -0,0 +1,752 @@ +/** + * This code is auto-generated; unless you know what you're doing, do not modify! + **/ +#include +#include +#include + +#include "git2.h" + +#include "../include/functions/copy.h" + +#include "../include/submodule.h" +#include "../include/oid.h" +#include "../include/repo.h" + +using namespace v8; +using namespace node; + +GitSubmodule::GitSubmodule(git_submodule *raw) { + this->raw = raw; +} + +GitSubmodule::~GitSubmodule() { + free(this->raw); +} + +void GitSubmodule::Initialize(Handle target) { + HandleScope scope; + + Local tpl = FunctionTemplate::New(New); + + tpl->InstanceTemplate()->SetInternalFieldCount(1); + tpl->SetClassName(String::NewSymbol("Submodule")); + + NODE_SET_PROTOTYPE_METHOD(tpl, "addFinalize", AddFinalize); + NODE_SET_PROTOTYPE_METHOD(tpl, "addToIndex", AddToIndex); + NODE_SET_PROTOTYPE_METHOD(tpl, "save", Save); + NODE_SET_PROTOTYPE_METHOD(tpl, "name", Name); + NODE_SET_PROTOTYPE_METHOD(tpl, "path", Path); + NODE_SET_PROTOTYPE_METHOD(tpl, "url", Url); + NODE_SET_PROTOTYPE_METHOD(tpl, "setUrl", SetUrl); + NODE_SET_PROTOTYPE_METHOD(tpl, "indexId", IndexId); + NODE_SET_PROTOTYPE_METHOD(tpl, "headId", HeadId); + NODE_SET_PROTOTYPE_METHOD(tpl, "init", Init); + NODE_SET_PROTOTYPE_METHOD(tpl, "sync", Sync); + NODE_SET_PROTOTYPE_METHOD(tpl, "open", Open); + NODE_SET_PROTOTYPE_METHOD(tpl, "reload", Reload); + NODE_SET_PROTOTYPE_METHOD(tpl, "status", Status); + + + constructor_template = Persistent::New(tpl->GetFunction()); + target->Set(String::NewSymbol("Submodule"), constructor_template); +} + +Handle GitSubmodule::New(const Arguments& args) { + HandleScope scope; + + if (args.Length() == 0 || !args[0]->IsExternal()) { + return ThrowException(Exception::Error(String::New("git_submodule is required."))); + } + + GitSubmodule* object = new GitSubmodule((git_submodule *) External::Unwrap(args[0])); + object->Wrap(args.This()); + + return scope.Close(args.This()); +} + +Handle GitSubmodule::New(void *raw) { + HandleScope scope; + Handle argv[1] = { External::New((void *)raw) }; + return scope.Close(GitSubmodule::constructor_template->NewInstance(1, argv)); +} + +git_submodule *GitSubmodule::GetValue() { + return this->raw; +} + + +/** + */ +Handle GitSubmodule::AddFinalize(const Arguments& args) { + HandleScope scope; + + if (args.Length() == 0 || !args[0]->IsFunction()) { + return ThrowException(Exception::Error(String::New("Callback is required and must be a Function."))); + } + + AddFinalizeBaton* baton = new AddFinalizeBaton; + baton->error_code = GIT_OK; + baton->error = NULL; + baton->request.data = baton; + baton->submoduleReference = Persistent::New(args.This()); + baton->submodule = ObjectWrap::Unwrap(args.This())->GetValue(); + baton->callback = Persistent::New(Local::Cast(args[0])); + + uv_queue_work(uv_default_loop(), &baton->request, AddFinalizeWork, (uv_after_work_cb)AddFinalizeAfterWork); + + return Undefined(); +} + +void GitSubmodule::AddFinalizeWork(uv_work_t *req) { + AddFinalizeBaton *baton = static_cast(req->data); + int result = git_submodule_add_finalize( + baton->submodule + ); + baton->error_code = result; + if (result != GIT_OK) { + baton->error = giterr_last(); + } +} + +void GitSubmodule::AddFinalizeAfterWork(uv_work_t *req) { + HandleScope scope; + AddFinalizeBaton *baton = static_cast(req->data); + + TryCatch try_catch; + if (baton->error_code == GIT_OK) { + Handle result = Local::New(Undefined()); + Handle argv[2] = { + Local::New(Null()), + result + }; + baton->callback->Call(Context::GetCurrent()->Global(), 2, argv); + } else { + if (baton->error) { + Handle argv[1] = { + Exception::Error(String::New(baton->error->message)) + }; + baton->callback->Call(Context::GetCurrent()->Global(), 1, argv); + } else { + baton->callback->Call(Context::GetCurrent()->Global(), 0, NULL); + } + } + + if (try_catch.HasCaught()) { + node::FatalException(try_catch); + } + baton->submoduleReference.Dispose(); + baton->callback.Dispose(); + delete baton; +} + +/** + * @param {Number} write_index + */ +Handle GitSubmodule::AddToIndex(const Arguments& args) { + HandleScope scope; + if (args.Length() == 0 || !args[0]->IsInt32()) { + return ThrowException(Exception::Error(String::New("Number write_index is required."))); + } + + if (args.Length() == 1 || !args[1]->IsFunction()) { + return ThrowException(Exception::Error(String::New("Callback is required and must be a Function."))); + } + + AddToIndexBaton* baton = new AddToIndexBaton; + baton->error_code = GIT_OK; + baton->error = NULL; + baton->request.data = baton; + baton->submoduleReference = Persistent::New(args.This()); + baton->submodule = ObjectWrap::Unwrap(args.This())->GetValue(); + baton->write_indexReference = Persistent::New(args[0]); + int from_write_index; + from_write_index = (int) args[0]->ToInt32()->Value(); + baton->write_index = from_write_index; + baton->callback = Persistent::New(Local::Cast(args[1])); + + uv_queue_work(uv_default_loop(), &baton->request, AddToIndexWork, (uv_after_work_cb)AddToIndexAfterWork); + + return Undefined(); +} + +void GitSubmodule::AddToIndexWork(uv_work_t *req) { + AddToIndexBaton *baton = static_cast(req->data); + int result = git_submodule_add_to_index( + baton->submodule, + baton->write_index + ); + baton->error_code = result; + if (result != GIT_OK) { + baton->error = giterr_last(); + } +} + +void GitSubmodule::AddToIndexAfterWork(uv_work_t *req) { + HandleScope scope; + AddToIndexBaton *baton = static_cast(req->data); + + TryCatch try_catch; + if (baton->error_code == GIT_OK) { + Handle result = Local::New(Undefined()); + Handle argv[2] = { + Local::New(Null()), + result + }; + baton->callback->Call(Context::GetCurrent()->Global(), 2, argv); + } else { + if (baton->error) { + Handle argv[1] = { + Exception::Error(String::New(baton->error->message)) + }; + baton->callback->Call(Context::GetCurrent()->Global(), 1, argv); + } else { + baton->callback->Call(Context::GetCurrent()->Global(), 0, NULL); + } + } + + if (try_catch.HasCaught()) { + node::FatalException(try_catch); + } + baton->submoduleReference.Dispose(); + baton->write_indexReference.Dispose(); + baton->callback.Dispose(); + delete baton; +} + +/** + */ +Handle GitSubmodule::Save(const Arguments& args) { + HandleScope scope; + + if (args.Length() == 0 || !args[0]->IsFunction()) { + return ThrowException(Exception::Error(String::New("Callback is required and must be a Function."))); + } + + SaveBaton* baton = new SaveBaton; + baton->error_code = GIT_OK; + baton->error = NULL; + baton->request.data = baton; + baton->submoduleReference = Persistent::New(args.This()); + baton->submodule = ObjectWrap::Unwrap(args.This())->GetValue(); + baton->callback = Persistent::New(Local::Cast(args[0])); + + uv_queue_work(uv_default_loop(), &baton->request, SaveWork, (uv_after_work_cb)SaveAfterWork); + + return Undefined(); +} + +void GitSubmodule::SaveWork(uv_work_t *req) { + SaveBaton *baton = static_cast(req->data); + int result = git_submodule_save( + baton->submodule + ); + baton->error_code = result; + if (result != GIT_OK) { + baton->error = giterr_last(); + } +} + +void GitSubmodule::SaveAfterWork(uv_work_t *req) { + HandleScope scope; + SaveBaton *baton = static_cast(req->data); + + TryCatch try_catch; + if (baton->error_code == GIT_OK) { + Handle result = Local::New(Undefined()); + Handle argv[2] = { + Local::New(Null()), + result + }; + baton->callback->Call(Context::GetCurrent()->Global(), 2, argv); + } else { + if (baton->error) { + Handle argv[1] = { + Exception::Error(String::New(baton->error->message)) + }; + baton->callback->Call(Context::GetCurrent()->Global(), 1, argv); + } else { + baton->callback->Call(Context::GetCurrent()->Global(), 0, NULL); + } + } + + if (try_catch.HasCaught()) { + node::FatalException(try_catch); + } + baton->submoduleReference.Dispose(); + baton->callback.Dispose(); + delete baton; +} + +/** + * @return {String} result + */ +Handle GitSubmodule::Name(const Arguments& args) { + HandleScope scope; + + + const char * result = git_submodule_name( + ObjectWrap::Unwrap(args.This())->GetValue() + ); + + Handle to; + to = String::New(result); + return scope.Close(to); +} + +/** + * @return {String} result + */ +Handle GitSubmodule::Path(const Arguments& args) { + HandleScope scope; + + + const char * result = git_submodule_path( + ObjectWrap::Unwrap(args.This())->GetValue() + ); + + Handle to; + to = String::New(result); + return scope.Close(to); +} + +/** + * @return {String} result + */ +Handle GitSubmodule::Url(const Arguments& args) { + HandleScope scope; + + + const char * result = git_submodule_url( + ObjectWrap::Unwrap(args.This())->GetValue() + ); + + Handle to; + to = String::New(result); + return scope.Close(to); +} + +/** + * @param {String} url + */ +Handle GitSubmodule::SetUrl(const Arguments& args) { + HandleScope scope; + if (args.Length() == 0 || !args[0]->IsString()) { + return ThrowException(Exception::Error(String::New("String url is required."))); + } + + const char * from_url; + String::Utf8Value url(args[0]->ToString()); + from_url = strdup(*url); + + int result = git_submodule_set_url( + ObjectWrap::Unwrap(args.This())->GetValue() + , from_url + ); + free((void *)from_url); + if (result != GIT_OK) { + if (giterr_last()) { + return ThrowException(Exception::Error(String::New(giterr_last()->message))); + } else { + return ThrowException(Exception::Error(String::New("Unkown Error"))); + } + } + + return Undefined(); +} + +/** + * @return {Oid} result + */ +Handle GitSubmodule::IndexId(const Arguments& args) { + HandleScope scope; + + + const git_oid * result = git_submodule_index_id( + ObjectWrap::Unwrap(args.This())->GetValue() + ); + + Handle to; + if (result != NULL) { + result = (const git_oid * )git_oid_dup(result); + } + if (result != NULL) { + to = GitOid::New((void *)result); + } else { + to = Null(); + } + return scope.Close(to); +} + +/** + * @return {Oid} result + */ +Handle GitSubmodule::HeadId(const Arguments& args) { + HandleScope scope; + + + const git_oid * result = git_submodule_head_id( + ObjectWrap::Unwrap(args.This())->GetValue() + ); + + Handle to; + if (result != NULL) { + result = (const git_oid * )git_oid_dup(result); + } + if (result != NULL) { + to = GitOid::New((void *)result); + } else { + to = Null(); + } + return scope.Close(to); +} + +/** + * @param {Number} overwrite + */ +Handle GitSubmodule::Init(const Arguments& args) { + HandleScope scope; + if (args.Length() == 0 || !args[0]->IsInt32()) { + return ThrowException(Exception::Error(String::New("Number overwrite is required."))); + } + + if (args.Length() == 1 || !args[1]->IsFunction()) { + return ThrowException(Exception::Error(String::New("Callback is required and must be a Function."))); + } + + InitBaton* baton = new InitBaton; + baton->error_code = GIT_OK; + baton->error = NULL; + baton->request.data = baton; + baton->submoduleReference = Persistent::New(args.This()); + baton->submodule = ObjectWrap::Unwrap(args.This())->GetValue(); + baton->overwriteReference = Persistent::New(args[0]); + int from_overwrite; + from_overwrite = (int) args[0]->ToInt32()->Value(); + baton->overwrite = from_overwrite; + baton->callback = Persistent::New(Local::Cast(args[1])); + + uv_queue_work(uv_default_loop(), &baton->request, InitWork, (uv_after_work_cb)InitAfterWork); + + return Undefined(); +} + +void GitSubmodule::InitWork(uv_work_t *req) { + InitBaton *baton = static_cast(req->data); + int result = git_submodule_init( + baton->submodule, + baton->overwrite + ); + baton->error_code = result; + if (result != GIT_OK) { + baton->error = giterr_last(); + } +} + +void GitSubmodule::InitAfterWork(uv_work_t *req) { + HandleScope scope; + InitBaton *baton = static_cast(req->data); + + TryCatch try_catch; + if (baton->error_code == GIT_OK) { + Handle result = Local::New(Undefined()); + Handle argv[2] = { + Local::New(Null()), + result + }; + baton->callback->Call(Context::GetCurrent()->Global(), 2, argv); + } else { + if (baton->error) { + Handle argv[1] = { + Exception::Error(String::New(baton->error->message)) + }; + baton->callback->Call(Context::GetCurrent()->Global(), 1, argv); + } else { + baton->callback->Call(Context::GetCurrent()->Global(), 0, NULL); + } + } + + if (try_catch.HasCaught()) { + node::FatalException(try_catch); + } + baton->submoduleReference.Dispose(); + baton->overwriteReference.Dispose(); + baton->callback.Dispose(); + delete baton; +} + +/** + */ +Handle GitSubmodule::Sync(const Arguments& args) { + HandleScope scope; + + if (args.Length() == 0 || !args[0]->IsFunction()) { + return ThrowException(Exception::Error(String::New("Callback is required and must be a Function."))); + } + + SyncBaton* baton = new SyncBaton; + baton->error_code = GIT_OK; + baton->error = NULL; + baton->request.data = baton; + baton->submoduleReference = Persistent::New(args.This()); + baton->submodule = ObjectWrap::Unwrap(args.This())->GetValue(); + baton->callback = Persistent::New(Local::Cast(args[0])); + + uv_queue_work(uv_default_loop(), &baton->request, SyncWork, (uv_after_work_cb)SyncAfterWork); + + return Undefined(); +} + +void GitSubmodule::SyncWork(uv_work_t *req) { + SyncBaton *baton = static_cast(req->data); + int result = git_submodule_sync( + baton->submodule + ); + baton->error_code = result; + if (result != GIT_OK) { + baton->error = giterr_last(); + } +} + +void GitSubmodule::SyncAfterWork(uv_work_t *req) { + HandleScope scope; + SyncBaton *baton = static_cast(req->data); + + TryCatch try_catch; + if (baton->error_code == GIT_OK) { + Handle result = Local::New(Undefined()); + Handle argv[2] = { + Local::New(Null()), + result + }; + baton->callback->Call(Context::GetCurrent()->Global(), 2, argv); + } else { + if (baton->error) { + Handle argv[1] = { + Exception::Error(String::New(baton->error->message)) + }; + baton->callback->Call(Context::GetCurrent()->Global(), 1, argv); + } else { + baton->callback->Call(Context::GetCurrent()->Global(), 0, NULL); + } + } + + if (try_catch.HasCaught()) { + node::FatalException(try_catch); + } + baton->submoduleReference.Dispose(); + baton->callback.Dispose(); + delete baton; +} + +/** + * @param {Repository} callback + */ +Handle GitSubmodule::Open(const Arguments& args) { + HandleScope scope; + + if (args.Length() == 0 || !args[0]->IsFunction()) { + return ThrowException(Exception::Error(String::New("Callback is required and must be a Function."))); + } + + OpenBaton* baton = new OpenBaton; + baton->error_code = GIT_OK; + baton->error = NULL; + baton->request.data = baton; + baton->submoduleReference = Persistent::New(args.This()); + baton->submodule = ObjectWrap::Unwrap(args.This())->GetValue(); + baton->callback = Persistent::New(Local::Cast(args[0])); + + uv_queue_work(uv_default_loop(), &baton->request, OpenWork, (uv_after_work_cb)OpenAfterWork); + + return Undefined(); +} + +void GitSubmodule::OpenWork(uv_work_t *req) { + OpenBaton *baton = static_cast(req->data); + int result = git_submodule_open( + &baton->repo, + baton->submodule + ); + baton->error_code = result; + if (result != GIT_OK) { + baton->error = giterr_last(); + } +} + +void GitSubmodule::OpenAfterWork(uv_work_t *req) { + HandleScope scope; + OpenBaton *baton = static_cast(req->data); + + TryCatch try_catch; + if (baton->error_code == GIT_OK) { + Handle to; + if (baton->repo != NULL) { + to = GitRepo::New((void *)baton->repo); + } else { + to = Null(); + } + Handle result = to; + Handle argv[2] = { + Local::New(Null()), + result + }; + baton->callback->Call(Context::GetCurrent()->Global(), 2, argv); + } else { + if (baton->error) { + Handle argv[1] = { + Exception::Error(String::New(baton->error->message)) + }; + baton->callback->Call(Context::GetCurrent()->Global(), 1, argv); + } else { + baton->callback->Call(Context::GetCurrent()->Global(), 0, NULL); + } + } + + if (try_catch.HasCaught()) { + node::FatalException(try_catch); + } + baton->submoduleReference.Dispose(); + baton->callback.Dispose(); + delete baton; +} + +/** + */ +Handle GitSubmodule::Reload(const Arguments& args) { + HandleScope scope; + + if (args.Length() == 0 || !args[0]->IsFunction()) { + return ThrowException(Exception::Error(String::New("Callback is required and must be a Function."))); + } + + ReloadBaton* baton = new ReloadBaton; + baton->error_code = GIT_OK; + baton->error = NULL; + baton->request.data = baton; + baton->submoduleReference = Persistent::New(args.This()); + baton->submodule = ObjectWrap::Unwrap(args.This())->GetValue(); + baton->callback = Persistent::New(Local::Cast(args[0])); + + uv_queue_work(uv_default_loop(), &baton->request, ReloadWork, (uv_after_work_cb)ReloadAfterWork); + + return Undefined(); +} + +void GitSubmodule::ReloadWork(uv_work_t *req) { + ReloadBaton *baton = static_cast(req->data); + int result = git_submodule_reload( + baton->submodule + ); + baton->error_code = result; + if (result != GIT_OK) { + baton->error = giterr_last(); + } +} + +void GitSubmodule::ReloadAfterWork(uv_work_t *req) { + HandleScope scope; + ReloadBaton *baton = static_cast(req->data); + + TryCatch try_catch; + if (baton->error_code == GIT_OK) { + Handle result = Local::New(Undefined()); + Handle argv[2] = { + Local::New(Null()), + result + }; + baton->callback->Call(Context::GetCurrent()->Global(), 2, argv); + } else { + if (baton->error) { + Handle argv[1] = { + Exception::Error(String::New(baton->error->message)) + }; + baton->callback->Call(Context::GetCurrent()->Global(), 1, argv); + } else { + baton->callback->Call(Context::GetCurrent()->Global(), 0, NULL); + } + } + + if (try_catch.HasCaught()) { + node::FatalException(try_catch); + } + baton->submoduleReference.Dispose(); + baton->callback.Dispose(); + delete baton; +} + +/** + * @param {Number} status + */ +Handle GitSubmodule::Status(const Arguments& args) { + HandleScope scope; + if (args.Length() == 0 || !args[0]->IsInt32()) { + return ThrowException(Exception::Error(String::New("Number status is required."))); + } + + if (args.Length() == 1 || !args[1]->IsFunction()) { + return ThrowException(Exception::Error(String::New("Callback is required and must be a Function."))); + } + + StatusBaton* baton = new StatusBaton; + baton->error_code = GIT_OK; + baton->error = NULL; + baton->request.data = baton; + baton->statusReference = Persistent::New(args[0]); + unsigned int * from_status; + from_status = (unsigned int *) args[0]->ToInt32()->Value(); + baton->status = from_status; + baton->submoduleReference = Persistent::New(args.This()); + baton->submodule = ObjectWrap::Unwrap(args.This())->GetValue(); + baton->callback = Persistent::New(Local::Cast(args[1])); + + uv_queue_work(uv_default_loop(), &baton->request, StatusWork, (uv_after_work_cb)StatusAfterWork); + + return Undefined(); +} + +void GitSubmodule::StatusWork(uv_work_t *req) { + StatusBaton *baton = static_cast(req->data); + int result = git_submodule_status( + baton->status, + baton->submodule + ); + baton->error_code = result; + if (result != GIT_OK) { + baton->error = giterr_last(); + } +} + +void GitSubmodule::StatusAfterWork(uv_work_t *req) { + HandleScope scope; + StatusBaton *baton = static_cast(req->data); + + TryCatch try_catch; + if (baton->error_code == GIT_OK) { + Handle result = Local::New(Undefined()); + Handle argv[2] = { + Local::New(Null()), + result + }; + baton->callback->Call(Context::GetCurrent()->Global(), 2, argv); + } else { + if (baton->error) { + Handle argv[1] = { + Exception::Error(String::New(baton->error->message)) + }; + baton->callback->Call(Context::GetCurrent()->Global(), 1, argv); + } else { + baton->callback->Call(Context::GetCurrent()->Global(), 0, NULL); + } + } + + if (try_catch.HasCaught()) { + node::FatalException(try_catch); + } + baton->statusReference.Dispose(); + baton->submoduleReference.Dispose(); + baton->callback.Dispose(); + delete baton; +} + +Persistent GitSubmodule::constructor_template; diff --git a/src/tag.cc b/src/tag.cc new file mode 100644 index 000000000..a0443dbb6 --- /dev/null +++ b/src/tag.cc @@ -0,0 +1,299 @@ +/** + * This code is auto-generated; unless you know what you're doing, do not modify! + **/ +#include +#include +#include + +#include "git2.h" + +#include "../include/functions/copy.h" + +#include "../include/tag.h" +#include "../include/oid.h" +#include "../include/repo.h" +#include "../include/object.h" +#include "../include/signature.h" + +using namespace v8; +using namespace node; + +GitTag::GitTag(git_tag *raw) { + this->raw = raw; +} + +GitTag::~GitTag() { + git_tag_free(this->raw); +} + +void GitTag::Initialize(Handle target) { + HandleScope scope; + + Local tpl = FunctionTemplate::New(New); + + tpl->InstanceTemplate()->SetInternalFieldCount(1); + tpl->SetClassName(String::NewSymbol("Tag")); + + NODE_SET_PROTOTYPE_METHOD(tpl, "oid", Oid); + NODE_SET_PROTOTYPE_METHOD(tpl, "getTarget", GetTarget); + NODE_SET_PROTOTYPE_METHOD(tpl, "targetId", TargetId); + NODE_SET_PROTOTYPE_METHOD(tpl, "targetType", TargetType); + NODE_SET_PROTOTYPE_METHOD(tpl, "name", Name); + NODE_SET_PROTOTYPE_METHOD(tpl, "tagger", Tagger); + NODE_SET_PROTOTYPE_METHOD(tpl, "message", Message); + NODE_SET_PROTOTYPE_METHOD(tpl, "peel", Peel); + + + constructor_template = Persistent::New(tpl->GetFunction()); + target->Set(String::NewSymbol("Tag"), constructor_template); +} + +Handle GitTag::New(const Arguments& args) { + HandleScope scope; + + if (args.Length() == 0 || !args[0]->IsExternal()) { + return ThrowException(Exception::Error(String::New("git_tag is required."))); + } + + GitTag* object = new GitTag((git_tag *) External::Unwrap(args[0])); + object->Wrap(args.This()); + + return scope.Close(args.This()); +} + +Handle GitTag::New(void *raw) { + HandleScope scope; + Handle argv[1] = { External::New((void *)raw) }; + return scope.Close(GitTag::constructor_template->NewInstance(1, argv)); +} + +git_tag *GitTag::GetValue() { + return this->raw; +} + + +/** + * @return {Oid} result + */ +Handle GitTag::Oid(const Arguments& args) { + HandleScope scope; + + + const git_oid * result = git_tag_id( + ObjectWrap::Unwrap(args.This())->GetValue() + ); + + Handle to; + if (result != NULL) { + result = (const git_oid * )git_oid_dup(result); + } + if (result != NULL) { + to = GitOid::New((void *)result); + } else { + to = Null(); + } + return scope.Close(to); +} + +/** + * @param {Object} callback + */ +Handle GitTag::GetTarget(const Arguments& args) { + HandleScope scope; + + if (args.Length() == 0 || !args[0]->IsFunction()) { + return ThrowException(Exception::Error(String::New("Callback is required and must be a Function."))); + } + + GetTargetBaton* baton = new GetTargetBaton; + baton->error_code = GIT_OK; + baton->error = NULL; + baton->request.data = baton; + baton->tagReference = Persistent::New(args.This()); + baton->tag = ObjectWrap::Unwrap(args.This())->GetValue(); + baton->callback = Persistent::New(Local::Cast(args[0])); + + uv_queue_work(uv_default_loop(), &baton->request, GetTargetWork, (uv_after_work_cb)GetTargetAfterWork); + + return Undefined(); +} + +void GitTag::GetTargetWork(uv_work_t *req) { + GetTargetBaton *baton = static_cast(req->data); + int result = git_tag_target( + &baton->target_out, + baton->tag + ); + baton->error_code = result; + if (result != GIT_OK) { + baton->error = giterr_last(); + } +} + +void GitTag::GetTargetAfterWork(uv_work_t *req) { + HandleScope scope; + GetTargetBaton *baton = static_cast(req->data); + + TryCatch try_catch; + if (baton->error_code == GIT_OK) { + Handle to; + if (baton->target_out != NULL) { + to = GitObject::New((void *)baton->target_out); + } else { + to = Null(); + } + Handle result = to; + Handle argv[2] = { + Local::New(Null()), + result + }; + baton->callback->Call(Context::GetCurrent()->Global(), 2, argv); + } else { + if (baton->error) { + Handle argv[1] = { + Exception::Error(String::New(baton->error->message)) + }; + baton->callback->Call(Context::GetCurrent()->Global(), 1, argv); + } else { + baton->callback->Call(Context::GetCurrent()->Global(), 0, NULL); + } + } + + if (try_catch.HasCaught()) { + node::FatalException(try_catch); + } + baton->tagReference.Dispose(); + baton->callback.Dispose(); + delete baton; +} + +/** + * @return {Oid} result + */ +Handle GitTag::TargetId(const Arguments& args) { + HandleScope scope; + + + const git_oid * result = git_tag_target_id( + ObjectWrap::Unwrap(args.This())->GetValue() + ); + + Handle to; + if (result != NULL) { + result = (const git_oid * )git_oid_dup(result); + } + if (result != NULL) { + to = GitOid::New((void *)result); + } else { + to = Null(); + } + return scope.Close(to); +} + +/** + * @return {Number} result + */ +Handle GitTag::TargetType(const Arguments& args) { + HandleScope scope; + + + git_otype result = git_tag_target_type( + ObjectWrap::Unwrap(args.This())->GetValue() + ); + + Handle to; + to = Int32::New(result); + return scope.Close(to); +} + +/** + * @return {String} result + */ +Handle GitTag::Name(const Arguments& args) { + HandleScope scope; + + + const char * result = git_tag_name( + ObjectWrap::Unwrap(args.This())->GetValue() + ); + + Handle to; + to = String::New(result); + return scope.Close(to); +} + +/** + * @return {Signature} result + */ +Handle GitTag::Tagger(const Arguments& args) { + HandleScope scope; + + + const git_signature * result = git_tag_tagger( + ObjectWrap::Unwrap(args.This())->GetValue() + ); + + Handle to; + if (result != NULL) { + result = (const git_signature * )git_signature_dup(result); + } + if (result != NULL) { + to = GitSignature::New((void *)result); + } else { + to = Null(); + } + return scope.Close(to); +} + +/** + * @return {String} result + */ +Handle GitTag::Message(const Arguments& args) { + HandleScope scope; + + + const char * result = git_tag_message( + ObjectWrap::Unwrap(args.This())->GetValue() + ); + + Handle to; + to = String::New(result); + return scope.Close(to); +} + +/** + * @param {Tag} tag + * @return {Object} tag_target_out + */ +Handle GitTag::Peel(const Arguments& args) { + HandleScope scope; + if (args.Length() == 0 || !args[0]->IsObject()) { + return ThrowException(Exception::Error(String::New("Tag tag is required."))); + } + + git_object *tag_target_out = NULL; + const git_tag * from_tag; + from_tag = ObjectWrap::Unwrap(args[0]->ToObject())->GetValue(); + + int result = git_tag_peel( + &tag_target_out + , from_tag + ); + if (result != GIT_OK) { + if (giterr_last()) { + return ThrowException(Exception::Error(String::New(giterr_last()->message))); + } else { + return ThrowException(Exception::Error(String::New("Unkown Error"))); + } + } + + Handle to; + if (tag_target_out != NULL) { + to = GitObject::New((void *)tag_target_out); + } else { + to = Null(); + } + return scope.Close(to); +} + +Persistent GitTag::constructor_template; diff --git a/src/threads.cc b/src/threads.cc index 847e38e3a..020600206 100755 --- a/src/threads.cc +++ b/src/threads.cc @@ -1,54 +1,59 @@ -/* - * Copyright 2011, Tim Branyen @tbranyen - * @author Michael Robinson @codeofinterest - * - * Dual licensed under the MIT and GPL licenses. - */ - -#include +/** + * This code is auto-generated; unless you know what you're doing, do not modify! + **/ #include #include +#include #include "git2.h" +#include "../include/functions/copy.h" + #include "../include/threads.h" -#include "../include/error.h" using namespace v8; using namespace node; -void GitThreads::Initialize(Handle target) { +void GitThreads::Initialize(Handle target) { HandleScope scope; - Local tpl = FunctionTemplate::New(New); - - tpl->InstanceTemplate()->SetInternalFieldCount(1); - tpl->SetClassName(String::NewSymbol("Threads")); + Persistent object = Persistent::New(Object::New()); - NODE_SET_PROTOTYPE_METHOD(tpl, "init", Init); + object->Set(String::NewSymbol("init"), FunctionTemplate::New(Init)->GetFunction()); + object->Set(String::NewSymbol("shutdown"), FunctionTemplate::New(Shutdown)->GetFunction()); - constructor_template = Persistent::New(tpl->GetFunction()); - target->Set(String::NewSymbol("Threads"), constructor_template); + target->Set(String::NewSymbol("Threads"), object); } -Handle GitThreads::New(const Arguments& args) { - HandleScope scope; - - GitThreads *threads = new GitThreads(); - threads->Wrap(args.This()); +/** + */ +Handle GitThreads::Init(const Arguments& args) { + HandleScope scope; + + + int result = git_threads_init( + ); + if (result != GIT_OK) { + if (giterr_last()) { + return ThrowException(Exception::Error(String::New(giterr_last()->message))); + } else { + return ThrowException(Exception::Error(String::New("Unkown Error"))); + } + } - return scope.Close(args.This()); + return Undefined(); } -Handle GitThreads::Init(const Arguments& args) { +/** + */ +Handle GitThreads::Shutdown(const Arguments& args) { HandleScope scope; + - int returnCode = git_threads_init(); - if (returnCode) { - return GitError::WrapError(giterr_last()); - } - return True(); + git_threads_shutdown( + ); + + return Undefined(); } -Persistent GitThreads::constructor_template; diff --git a/src/time.cc b/src/time.cc new file mode 100644 index 000000000..b03a49c84 --- /dev/null +++ b/src/time.cc @@ -0,0 +1,87 @@ +/** + * This code is auto-generated; unless you know what you're doing, do not modify! + **/ +#include +#include +#include + +#include "git2.h" + +#include "../include/functions/copy.h" + +#include "../include/time.h" + +using namespace v8; +using namespace node; + +GitTime::GitTime(git_time *raw) { + this->raw = raw; +} + +GitTime::~GitTime() { + free(this->raw); +} + +void GitTime::Initialize(Handle target) { + HandleScope scope; + + Local tpl = FunctionTemplate::New(New); + + tpl->InstanceTemplate()->SetInternalFieldCount(1); + tpl->SetClassName(String::NewSymbol("Time")); + + + NODE_SET_PROTOTYPE_METHOD(tpl, "time", Time); + NODE_SET_PROTOTYPE_METHOD(tpl, "offset", Offset); + + constructor_template = Persistent::New(tpl->GetFunction()); + target->Set(String::NewSymbol("Time"), constructor_template); +} + +Handle GitTime::New(const Arguments& args) { + HandleScope scope; + + if (args.Length() == 0 || !args[0]->IsExternal()) { + return ThrowException(Exception::Error(String::New("git_time is required."))); + } + + GitTime* object = new GitTime((git_time *) External::Unwrap(args[0])); + object->Wrap(args.This()); + + return scope.Close(args.This()); +} + +Handle GitTime::New(void *raw) { + HandleScope scope; + Handle argv[1] = { External::New((void *)raw) }; + return scope.Close(GitTime::constructor_template->NewInstance(1, argv)); +} + +git_time *GitTime::GetValue() { + return this->raw; +} + + +Handle GitTime::Time(const Arguments& args) { + HandleScope scope; + Handle to; + + git_time_t time = + ObjectWrap::Unwrap(args.This())->GetValue()->time; + + to = Integer::New(time); + return scope.Close(to); +} + +Handle GitTime::Offset(const Arguments& args) { + HandleScope scope; + Handle to; + + int offset = + ObjectWrap::Unwrap(args.This())->GetValue()->offset; + + to = Int32::New(offset); + return scope.Close(to); +} + +Persistent GitTime::constructor_template; diff --git a/src/tree.cc b/src/tree.cc index 915164e36..3e8eaa888 100755 --- a/src/tree.cc +++ b/src/tree.cc @@ -1,31 +1,35 @@ -/* - * Copyright 2013, Tim Branyen @tbranyen - * @author Michael Robinson @codeofinterest - * - * Dual licensed under the MIT and GPL licenses. - */ - +/** + * This code is auto-generated; unless you know what you're doing, do not modify! + **/ #include #include -#include +#include -#include "cvv8/v8-convert.hpp" #include "git2.h" +#include "../include/functions/copy.h" + +#include "../include/tree.h" #include "../include/repo.h" #include "../include/oid.h" -#include "../include/tree.h" #include "../include/tree_entry.h" -#include "../include/error.h" - -#include "../include/functions/string.h" -#include "../include/functions/utilities.h" +#include "../include/diff_list.h" +#include "../include/diff_options.h" +#include "../include/tree_builder.h" +#include "../include/index.h" using namespace v8; using namespace node; -using namespace cvv8; -void GitTree::Initialize (Handle target) { +GitTree::GitTree(git_tree *raw) { + this->raw = raw; +} + +GitTree::~GitTree() { + git_tree_free(this->raw); +} + +void GitTree::Initialize(Handle target) { HandleScope scope; Local tpl = FunctionTemplate::New(New); @@ -33,294 +37,585 @@ void GitTree::Initialize (Handle target) { tpl->InstanceTemplate()->SetInternalFieldCount(1); tpl->SetClassName(String::NewSymbol("Tree")); - NODE_SET_PROTOTYPE_METHOD(tpl, "lookup", Lookup); - NODE_SET_PROTOTYPE_METHOD(tpl, "walk", Walk); - NODE_SET_PROTOTYPE_METHOD(tpl, "entryByPath", EntryByPath); + NODE_SET_PROTOTYPE_METHOD(tpl, "oid", Oid); + NODE_SET_PROTOTYPE_METHOD(tpl, "size", Size); + NODE_SET_PROTOTYPE_METHOD(tpl, "entryByName", EntryByName); + NODE_SET_PROTOTYPE_METHOD(tpl, "entryByIndex", EntryByIndex); + NODE_SET_PROTOTYPE_METHOD(tpl, "entryByOid", EntryByOid); + NODE_SET_PROTOTYPE_METHOD(tpl, "getEntry", GetEntry); + NODE_SET_PROTOTYPE_METHOD(tpl, "builder", Builder); + NODE_SET_PROTOTYPE_METHOD(tpl, "diffTree", DiffTree); + NODE_SET_PROTOTYPE_METHOD(tpl, "diffIndex", DiffIndex); + NODE_SET_PROTOTYPE_METHOD(tpl, "diffWorkDir", DiffWorkDir); + constructor_template = Persistent::New(tpl->GetFunction()); target->Set(String::NewSymbol("Tree"), constructor_template); } -git_tree* GitTree::GetValue() { - return this->tree; +Handle GitTree::New(const Arguments& args) { + HandleScope scope; + + if (args.Length() == 0 || !args[0]->IsExternal()) { + return ThrowException(Exception::Error(String::New("git_tree is required."))); + } + + GitTree* object = new GitTree((git_tree *) External::Unwrap(args[0])); + object->Wrap(args.This()); + + return scope.Close(args.This()); +} + +Handle GitTree::New(void *raw) { + HandleScope scope; + Handle argv[1] = { External::New((void *)raw) }; + return scope.Close(GitTree::constructor_template->NewInstance(1, argv)); } -void GitTree::SetValue(git_tree* tree) { - this->tree = tree; + +git_tree *GitTree::GetValue() { + return this->raw; } -Handle GitTree::New(const Arguments& args) { + +/** + * @return {Oid} result + */ +Handle GitTree::Oid(const Arguments& args) { HandleScope scope; + - GitTree *tree = new GitTree(); + const git_oid * result = git_tree_id( + ObjectWrap::Unwrap(args.This())->GetValue() + ); - tree->Wrap(args.This()); + Handle to; + if (result != NULL) { + result = (const git_oid * )git_oid_dup(result); + } + if (result != NULL) { + to = GitOid::New((void *)result); + } else { + to = Null(); + } + return scope.Close(to); +} - return scope.Close(args.This()); +/** + * @return {Number} result + */ +Handle GitTree::Size(const Arguments& args) { + HandleScope scope; + + + size_t result = git_tree_entrycount( + ObjectWrap::Unwrap(args.This())->GetValue() + ); + + Handle to; + to = Uint32::New(result); + return scope.Close(to); +} + +/** + * @param {String} filename + * @return {TreeEntry} result + */ +Handle GitTree::EntryByName(const Arguments& args) { + HandleScope scope; + if (args.Length() == 0 || !args[0]->IsString()) { + return ThrowException(Exception::Error(String::New("String filename is required."))); + } + + const char * from_filename; + String::Utf8Value filename(args[0]->ToString()); + from_filename = strdup(*filename); + + const git_tree_entry * result = git_tree_entry_byname( + ObjectWrap::Unwrap(args.This())->GetValue() + , from_filename + ); + free((void *)from_filename); + + Handle to; + if (result != NULL) { + result = (const git_tree_entry * )git_tree_entry_dup(result); + } + if (result != NULL) { + to = GitTreeEntry::New((void *)result); + } else { + to = Null(); + } + return scope.Close(to); } -Handle GitTree::Lookup(const Arguments& args) { +/** + * @param {Number} idx + * @return {TreeEntry} result + */ +Handle GitTree::EntryByIndex(const Arguments& args) { HandleScope scope; + if (args.Length() == 0 || !args[0]->IsUint32()) { + return ThrowException(Exception::Error(String::New("Number idx is required."))); + } - if(args.Length() == 0 || !args[0]->IsObject()) { - return ThrowException(Exception::Error(String::New("Oid is required and must be a Object."))); + size_t from_idx; + from_idx = (size_t) args[0]->ToUint32()->Value(); + + const git_tree_entry * result = git_tree_entry_byindex( + ObjectWrap::Unwrap(args.This())->GetValue() + , from_idx + ); + + Handle to; + if (result != NULL) { + result = (const git_tree_entry * )git_tree_entry_dup(result); } + if (result != NULL) { + to = GitTreeEntry::New((void *)result); + } else { + to = Null(); + } + return scope.Close(to); +} + +/** + * @param {Oid} oid + * @return {TreeEntry} result + */ +Handle GitTree::EntryByOid(const Arguments& args) { + HandleScope scope; + if (args.Length() == 0 || !args[0]->IsObject()) { + return ThrowException(Exception::Error(String::New("Oid oid is required."))); + } + + const git_oid * from_oid; + from_oid = ObjectWrap::Unwrap(args[0]->ToObject())->GetValue(); + + const git_tree_entry * result = git_tree_entry_byoid( + ObjectWrap::Unwrap(args.This())->GetValue() + , from_oid + ); + + Handle to; + if (result != NULL) { + result = (const git_tree_entry * )git_tree_entry_dup(result); + } + if (result != NULL) { + to = GitTreeEntry::New((void *)result); + } else { + to = Null(); + } + return scope.Close(to); +} - if(args.Length() == 1 || !args[1]->IsObject()) { - return ThrowException(Exception::Error(String::New("Repository is required and must be a Object."))); +/** + * @param {String} path + * @param {TreeEntry} callback + */ +Handle GitTree::GetEntry(const Arguments& args) { + HandleScope scope; + if (args.Length() == 0 || !args[0]->IsString()) { + return ThrowException(Exception::Error(String::New("String path is required."))); } - if(args.Length() == 2 || !args[2]->IsFunction()) { + if (args.Length() == 1 || !args[1]->IsFunction()) { return ThrowException(Exception::Error(String::New("Callback is required and must be a Function."))); } - LookupBaton* baton = new LookupBaton; - baton->request.data = baton; + GetEntryBaton* baton = new GetEntryBaton; + baton->error_code = GIT_OK; baton->error = NULL; - baton->rawTree = ObjectWrap::Unwrap(args.This())->GetValue(); - baton->rawOid = ObjectWrap::Unwrap(args[0]->ToObject())->GetValue(); - baton->rawRepo = ObjectWrap::Unwrap(args[1]->ToObject())->GetValue(); - baton->callback = Persistent::New(Local::Cast(args[2])); + baton->request.data = baton; + baton->rootReference = Persistent::New(args.This()); + baton->root = ObjectWrap::Unwrap(args.This())->GetValue(); + baton->pathReference = Persistent::New(args[0]); + const char * from_path; + String::Utf8Value path(args[0]->ToString()); + from_path = strdup(*path); + baton->path = from_path; + baton->callback = Persistent::New(Local::Cast(args[1])); - uv_queue_work(uv_default_loop(), &baton->request, LookupWork, (uv_after_work_cb)LookupAfterWork); + uv_queue_work(uv_default_loop(), &baton->request, GetEntryWork, (uv_after_work_cb)GetEntryAfterWork); return Undefined(); } -void GitTree::LookupWork(uv_work_t* req) { - LookupBaton* baton = static_cast(req->data); - int returnCode = git_tree_lookup(&baton->rawTree, baton->rawRepo, &baton->rawOid); - if (returnCode != GIT_OK) { +void GitTree::GetEntryWork(uv_work_t *req) { + GetEntryBaton *baton = static_cast(req->data); + int result = git_tree_entry_bypath( + &baton->out, + baton->root, + baton->path + ); + baton->error_code = result; + if (result != GIT_OK) { baton->error = giterr_last(); } } -void GitTree::LookupAfterWork(uv_work_t* req) { - HandleScope scope; - LookupBaton* baton = static_cast(req->data); - if (success(baton->error, baton->callback)) { - Local tree = GitTree::constructor_template->NewInstance(); - GitTree *treeInstance = ObjectWrap::Unwrap(tree); - treeInstance->SetValue(baton->rawTree); +void GitTree::GetEntryAfterWork(uv_work_t *req) { + HandleScope scope; + GetEntryBaton *baton = static_cast(req->data); + TryCatch try_catch; + if (baton->error_code == GIT_OK) { + Handle to; + if (baton->out != NULL) { + to = GitTreeEntry::New((void *)baton->out); + } else { + to = Null(); + } + Handle result = to; Handle argv[2] = { Local::New(Null()), - tree + result }; - - TryCatch try_catch; baton->callback->Call(Context::GetCurrent()->Global(), 2, argv); - if (try_catch.HasCaught()) { - node::FatalException(try_catch); + } else { + if (baton->error) { + Handle argv[1] = { + Exception::Error(String::New(baton->error->message)) + }; + baton->callback->Call(Context::GetCurrent()->Global(), 1, argv); + } else { + baton->callback->Call(Context::GetCurrent()->Global(), 0, NULL); } + } + + if (try_catch.HasCaught()) { + node::FatalException(try_catch); } - delete req; + baton->rootReference.Dispose(); + baton->pathReference.Dispose(); + baton->callback.Dispose(); + free((void *)baton->path); + delete baton; } -Handle GitTree::Walk(const Arguments& args) { +/** + * @return {TreeBuilder} out + */ +Handle GitTree::Builder(const Arguments& args) { HandleScope scope; - - GitTree* tree = ObjectWrap::Unwrap(args.This()); - - if (tree->GetValue() == NULL) { - return ThrowException(Exception::Error(String::New("No tree list to Walk."))); + + git_treebuilder *out = NULL; + + int result = git_treebuilder_create( + &out + , ObjectWrap::Unwrap(args.This())->GetValue() + ); + if (result != GIT_OK) { + if (giterr_last()) { + return ThrowException(Exception::Error(String::New(giterr_last()->message))); + } else { + return ThrowException(Exception::Error(String::New("Unkown Error"))); + } } - if(args.Length() == 0 || !args[0]->IsBoolean()) { - return ThrowException(Exception::Error(String::New("Blobs only flag is required and must be a Boolean."))); + Handle to; + if (out != NULL) { + to = GitTreeBuilder::New((void *)out); + } else { + to = Null(); } + return scope.Close(to); +} - if(args.Length() == 1 || !args[1]->IsFunction()) { - return ThrowException(Exception::Error(String::New("Entry callback is required and must be a Function."))); +/** + * @param {Repository} repo + * @param {Tree} new_tree + * @param {DiffOptions} opts + * @param {DiffList} callback + */ +Handle GitTree::DiffTree(const Arguments& args) { + HandleScope scope; + if (args.Length() == 0 || !args[0]->IsObject()) { + return ThrowException(Exception::Error(String::New("Repository repo is required."))); } - - if(args.Length() == 2 || !args[2]->IsFunction()) { - return ThrowException(Exception::Error(String::New("End callback is required and must be a Function."))); + if (args.Length() == 1 || !args[1]->IsObject()) { + return ThrowException(Exception::Error(String::New("Tree new_tree is required."))); } - WalkBaton* baton = new WalkBaton; - uv_async_init(uv_default_loop(), &baton->asyncEntry, WalkWorkSendEntry); - uv_async_init(uv_default_loop(), &baton->asyncEnd, WalkWorkSendEnd); - - uv_mutex_init(&baton->mutex); + if (args.Length() == 3 || !args[3]->IsFunction()) { + return ThrowException(Exception::Error(String::New("Callback is required and must be a Function."))); + } - baton->rawTree = tree->GetValue(); + DiffTreeBaton* baton = new DiffTreeBaton; + baton->error_code = GIT_OK; baton->error = NULL; - baton->blobsOnly = CastFromJS(args[0]->ToBoolean()); - baton->entryCallback = Persistent::New(Local::Cast(args[1])); - baton->endCallback = Persistent::New(Local::Cast(args[2])); + baton->request.data = baton; + baton->repoReference = Persistent::New(args[0]); + git_repository * from_repo; + from_repo = ObjectWrap::Unwrap(args[0]->ToObject())->GetValue(); + baton->repo = from_repo; + baton->old_treeReference = Persistent::New(args.This()); + baton->old_tree = ObjectWrap::Unwrap(args.This())->GetValue(); + baton->new_treeReference = Persistent::New(args[1]); + git_tree * from_new_tree; + from_new_tree = ObjectWrap::Unwrap(args[1]->ToObject())->GetValue(); + baton->new_tree = from_new_tree; + baton->optsReference = Persistent::New(args[2]); + const git_diff_options * from_opts; + if (args[2]->IsObject()) { + from_opts = ObjectWrap::Unwrap(args[2]->ToObject())->GetValue(); + } else { + from_opts = NULL; + } + baton->opts = from_opts; + baton->callback = Persistent::New(Local::Cast(args[3])); - uv_thread_create(&baton->threadId, WalkWork, baton); + uv_queue_work(uv_default_loop(), &baton->request, DiffTreeWork, (uv_after_work_cb)DiffTreeAfterWork); return Undefined(); } -void GitTree::WalkWork(void* payload) { - WalkBaton *baton = static_cast(payload); - int returnCode = git_tree_walk(baton->rawTree, GIT_TREEWALK_PRE, WalkWorkEntry, payload); - if (returnCode != GIT_OK) { +void GitTree::DiffTreeWork(uv_work_t *req) { + DiffTreeBaton *baton = static_cast(req->data); + int result = git_diff_tree_to_tree( + &baton->diff, + baton->repo, + baton->old_tree, + baton->new_tree, + baton->opts + ); + baton->error_code = result; + if (result != GIT_OK) { baton->error = giterr_last(); - baton->asyncEnd.data = baton; - uv_async_send(&baton->asyncEnd); - return; } - - baton->asyncEntry.data = baton; - uv_async_send(&baton->asyncEntry); - - baton->asyncEnd.data = baton; - uv_async_send(&baton->asyncEnd); } -int GitTree::WalkWorkEntry(const char* root, const git_tree_entry* entry, - void* payload) { - WalkBaton *baton = static_cast(payload); - uv_mutex_lock(&baton->mutex); - - if (!baton->blobsOnly) { - - GitTree::WalkEntry* walkEntry = new WalkEntry; - walkEntry->rawEntry = git_tree_entry_dup(entry); - walkEntry->root = root; - baton->rawTreeEntries.push_back(walkEntry); +void GitTree::DiffTreeAfterWork(uv_work_t *req) { + HandleScope scope; + DiffTreeBaton *baton = static_cast(req->data); + TryCatch try_catch; + if (baton->error_code == GIT_OK) { + Handle to; + if (baton->diff != NULL) { + to = GitDiffList::New((void *)baton->diff); } else { - git_tree_entry* rawEntry = git_tree_entry_dup(entry); - git_filemode_t fileMode = git_tree_entry_filemode(rawEntry); - - if (fileMode == GIT_FILEMODE_BLOB || - fileMode == GIT_FILEMODE_BLOB_EXECUTABLE) { - - GitTree::WalkEntry* walkEntry = new WalkEntry; - walkEntry->rawEntry = rawEntry; - walkEntry->root = root; - baton->rawTreeEntries.push_back(walkEntry); - } + to = Null(); } + Handle result = to; + Handle argv[2] = { + Local::New(Null()), + result + }; + baton->callback->Call(Context::GetCurrent()->Global(), 2, argv); + } else { + if (baton->error) { + Handle argv[1] = { + Exception::Error(String::New(baton->error->message)) + }; + baton->callback->Call(Context::GetCurrent()->Global(), 1, argv); + } else { + baton->callback->Call(Context::GetCurrent()->Global(), 0, NULL); + } + } - uv_mutex_unlock(&baton->mutex); - - if ((unsigned int)baton->rawTreeEntries.size() == (unsigned int)GitTree::WALK_ENTRY_SEND_THRESHOLD) { - baton->asyncEntry.data = baton; - uv_async_send(&baton->asyncEntry); + if (try_catch.HasCaught()) { + node::FatalException(try_catch); } - - return GIT_OK; + baton->repoReference.Dispose(); + baton->old_treeReference.Dispose(); + baton->new_treeReference.Dispose(); + baton->optsReference.Dispose(); + baton->callback.Dispose(); + delete baton; } -void GitTree::WalkWorkSendEntry(uv_async_t *handle, int status /*UNUSED*/) { - HandleScope scope; - - WalkBaton *baton = static_cast(handle->data); - - uv_mutex_lock(&baton->mutex); - if (success(baton->error, baton->entryCallback)) { - - std::vector > treeEntries; - - for(std::vector::iterator treeEntriesIterator = baton->rawTreeEntries.begin(); treeEntriesIterator != baton->rawTreeEntries.end(); ++treeEntriesIterator) { - WalkEntry* walkEntry = (*treeEntriesIterator); - - Local entry = GitTreeEntry::constructor_template->NewInstance(); - GitTreeEntry *entryInstance = ObjectWrap::Unwrap(entry); - entryInstance->SetValue(walkEntry->rawEntry); - entryInstance->SetRoot(walkEntry->root); +/** + * @param {Repository} repo + * @param {Index} index + * @param {DiffOptions} opts + * @param {DiffList} callback + */ +Handle GitTree::DiffIndex(const Arguments& args) { + HandleScope scope; + if (args.Length() == 0 || !args[0]->IsObject()) { + return ThrowException(Exception::Error(String::New("Repository repo is required."))); + } + if (args.Length() == 1 || !args[1]->IsObject()) { + return ThrowException(Exception::Error(String::New("Index index is required."))); + } + if (args.Length() == 2 || !args[2]->IsObject()) { + return ThrowException(Exception::Error(String::New("DiffOptions opts is required."))); + } - treeEntries.push_back(entry); - } + if (args.Length() == 3 || !args[3]->IsFunction()) { + return ThrowException(Exception::Error(String::New("Callback is required and must be a Function."))); + } - baton->rawTreeEntries.clear(); + DiffIndexBaton* baton = new DiffIndexBaton; + baton->error_code = GIT_OK; + baton->error = NULL; + baton->request.data = baton; + baton->repoReference = Persistent::New(args[0]); + git_repository * from_repo; + from_repo = ObjectWrap::Unwrap(args[0]->ToObject())->GetValue(); + baton->repo = from_repo; + baton->old_treeReference = Persistent::New(args.This()); + baton->old_tree = ObjectWrap::Unwrap(args.This())->GetValue(); + baton->indexReference = Persistent::New(args[1]); + git_index * from_index; + from_index = ObjectWrap::Unwrap(args[1]->ToObject())->GetValue(); + baton->index = from_index; + baton->optsReference = Persistent::New(args[2]); + const git_diff_options * from_opts; + from_opts = ObjectWrap::Unwrap(args[2]->ToObject())->GetValue(); + baton->opts = from_opts; + baton->callback = Persistent::New(Local::Cast(args[3])); + + uv_queue_work(uv_default_loop(), &baton->request, DiffIndexWork, (uv_after_work_cb)DiffIndexAfterWork); - Handle argv[2] = { - Local::New(Null()), - CastToJS(treeEntries) - }; + return Undefined(); +} - TryCatch try_catch; - baton->entryCallback->Call(Context::GetCurrent()->Global(), 2, argv); - if (try_catch.HasCaught()) { - node::FatalException(try_catch); - } +void GitTree::DiffIndexWork(uv_work_t *req) { + DiffIndexBaton *baton = static_cast(req->data); + int result = git_diff_tree_to_index( + &baton->diff, + baton->repo, + baton->old_tree, + baton->index, + baton->opts + ); + baton->error_code = result; + if (result != GIT_OK) { + baton->error = giterr_last(); } - uv_mutex_unlock(&baton->mutex); } -void GitTree::WalkWorkSendEnd(uv_async_t *handle, int status /*UNUSED*/) { - WalkBaton *baton = static_cast(handle->data); - uv_mutex_destroy(&baton->mutex); - uv_close((uv_handle_t*) &baton->asyncEnd, NULL); - uv_close((uv_handle_t*) &baton->asyncEntry, NULL); +void GitTree::DiffIndexAfterWork(uv_work_t *req) { + HandleScope scope; + DiffIndexBaton *baton = static_cast(req->data); - Local argv[1]; - if (baton->error) { - argv[0] = GitError::WrapError(baton->error); + TryCatch try_catch; + if (baton->error_code == GIT_OK) { + Handle to; + if (baton->diff != NULL) { + to = GitDiffList::New((void *)baton->diff); } else { - argv[0] = Local::New(Null()); + to = Null(); } + Handle result = to; + Handle argv[2] = { + Local::New(Null()), + result + }; + baton->callback->Call(Context::GetCurrent()->Global(), 2, argv); + } else { + if (baton->error) { + Handle argv[1] = { + Exception::Error(String::New(baton->error->message)) + }; + baton->callback->Call(Context::GetCurrent()->Global(), 1, argv); + } else { + baton->callback->Call(Context::GetCurrent()->Global(), 0, NULL); + } + } - TryCatch try_catch; - baton->endCallback->Call(Context::GetCurrent()->Global(), 1, argv); if (try_catch.HasCaught()) { - node::FatalException(try_catch); + node::FatalException(try_catch); } + baton->repoReference.Dispose(); + baton->old_treeReference.Dispose(); + baton->indexReference.Dispose(); + baton->optsReference.Dispose(); + baton->callback.Dispose(); + delete baton; } -Handle GitTree::EntryByPath(const Arguments& args) { +/** + * @param {Repository} repo + * @param {DiffOptions} opts + * @param {DiffList} callback + */ +Handle GitTree::DiffWorkDir(const Arguments& args) { HandleScope scope; - - if(args.Length() == 0 || !args[0]->IsString()) { - return ThrowException(Exception::Error(String::New("Path is required and must be a String."))); + if (args.Length() == 0 || !args[0]->IsObject()) { + return ThrowException(Exception::Error(String::New("Repository repo is required."))); + } + if (args.Length() == 1 || !args[1]->IsObject()) { + return ThrowException(Exception::Error(String::New("DiffOptions opts is required."))); } - if(args.Length() == 1 || !args[1]->IsFunction()) { + if (args.Length() == 2 || !args[2]->IsFunction()) { return ThrowException(Exception::Error(String::New("Callback is required and must be a Function."))); } - EntryByPathBaton *baton = new EntryByPathBaton; - baton->request.data = baton; + DiffWorkDirBaton* baton = new DiffWorkDirBaton; + baton->error_code = GIT_OK; baton->error = NULL; - baton->rawEntry = NULL; - - GitTree *tree = ObjectWrap::Unwrap(args.This()); - tree->Ref(); - - baton->rawTree = tree->GetValue(); - baton->path = stringArgToString(args[0]->ToString()); - baton->callback = Persistent::New(Local::Cast(args[1])); - - uv_queue_work(uv_default_loop(), &baton->request, EntryByPathWork, (uv_after_work_cb)EntryByPathAfterWork); + baton->request.data = baton; + baton->repoReference = Persistent::New(args[0]); + git_repository * from_repo; + from_repo = ObjectWrap::Unwrap(args[0]->ToObject())->GetValue(); + baton->repo = from_repo; + baton->old_treeReference = Persistent::New(args.This()); + baton->old_tree = ObjectWrap::Unwrap(args.This())->GetValue(); + baton->optsReference = Persistent::New(args[1]); + const git_diff_options * from_opts; + from_opts = ObjectWrap::Unwrap(args[1]->ToObject())->GetValue(); + baton->opts = from_opts; + baton->callback = Persistent::New(Local::Cast(args[2])); + + uv_queue_work(uv_default_loop(), &baton->request, DiffWorkDirWork, (uv_after_work_cb)DiffWorkDirAfterWork); return Undefined(); } -void GitTree::EntryByPathWork(uv_work_t *req) { - EntryByPathBaton *baton = static_cast(req->data); - int returnCode = git_tree_entry_bypath(&baton->rawEntry, baton->rawTree, baton->path.c_str()); - if (returnCode != GIT_OK) { +void GitTree::DiffWorkDirWork(uv_work_t *req) { + DiffWorkDirBaton *baton = static_cast(req->data); + int result = git_diff_tree_to_workdir( + &baton->diff, + baton->repo, + baton->old_tree, + baton->opts + ); + baton->error_code = result; + if (result != GIT_OK) { baton->error = giterr_last(); } } -void GitTree::EntryByPathAfterWork(uv_work_t *req) { - HandleScope scope; - EntryByPathBaton *baton = static_cast(req->data); - if (success(baton->error, baton->callback)) { - Local entry = GitTreeEntry::constructor_template->NewInstance(); - GitTreeEntry *entryInstance = ObjectWrap::Unwrap(entry); - entryInstance->SetValue(baton->rawEntry); - entryInstance->SetRoot(baton->path.substr(0, baton->path.find_last_of("\\/"))); +void GitTree::DiffWorkDirAfterWork(uv_work_t *req) { + HandleScope scope; + DiffWorkDirBaton *baton = static_cast(req->data); + TryCatch try_catch; + if (baton->error_code == GIT_OK) { + Handle to; + if (baton->diff != NULL) { + to = GitDiffList::New((void *)baton->diff); + } else { + to = Null(); + } + Handle result = to; Handle argv[2] = { Local::New(Null()), - entry + result }; - - TryCatch try_catch; baton->callback->Call(Context::GetCurrent()->Global(), 2, argv); - if (try_catch.HasCaught()) { - node::FatalException(try_catch); + } else { + if (baton->error) { + Handle argv[1] = { + Exception::Error(String::New(baton->error->message)) + }; + baton->callback->Call(Context::GetCurrent()->Global(), 1, argv); + } else { + baton->callback->Call(Context::GetCurrent()->Global(), 0, NULL); } + } + + if (try_catch.HasCaught()) { + node::FatalException(try_catch); } - delete req; + baton->repoReference.Dispose(); + baton->old_treeReference.Dispose(); + baton->optsReference.Dispose(); + baton->callback.Dispose(); + delete baton; } Persistent GitTree::constructor_template; diff --git a/src/tree_builder.cc b/src/tree_builder.cc new file mode 100644 index 000000000..798f8098a --- /dev/null +++ b/src/tree_builder.cc @@ -0,0 +1,348 @@ +/** + * This code is auto-generated; unless you know what you're doing, do not modify! + **/ +#include +#include +#include + +#include "git2.h" + +#include "../include/functions/copy.h" + +#include "../include/tree_builder.h" +#include "../include/repo.h" +#include "../include/oid.h" +#include "../include/tree_entry.h" +#include "../include/tree.h" +#include "../include/diff_list.h" +#include "../include/diff_options.h" +#include "../include/index.h" + +using namespace v8; +using namespace node; + +GitTreeBuilder::GitTreeBuilder(git_treebuilder *raw) { + this->raw = raw; +} + +GitTreeBuilder::~GitTreeBuilder() { + git_treebuilder_free(this->raw); +} + +void GitTreeBuilder::Initialize(Handle target) { + HandleScope scope; + + Local tpl = FunctionTemplate::New(New); + + tpl->InstanceTemplate()->SetInternalFieldCount(1); + tpl->SetClassName(String::NewSymbol("TreeBuilder")); + + NODE_SET_METHOD(tpl, "create", Create); + NODE_SET_PROTOTYPE_METHOD(tpl, "clear", Clear); + NODE_SET_METHOD(tpl, "size", Size); + NODE_SET_PROTOTYPE_METHOD(tpl, "get", Get); + NODE_SET_PROTOTYPE_METHOD(tpl, "insert", Insert); + NODE_SET_PROTOTYPE_METHOD(tpl, "gitTreebuilderRemove", GitTreebuilderRemove); + NODE_SET_PROTOTYPE_METHOD(tpl, "write", Write); + + + constructor_template = Persistent::New(tpl->GetFunction()); + target->Set(String::NewSymbol("TreeBuilder"), constructor_template); +} + +Handle GitTreeBuilder::New(const Arguments& args) { + HandleScope scope; + + if (args.Length() == 0 || !args[0]->IsExternal()) { + return ThrowException(Exception::Error(String::New("git_treebuilder is required."))); + } + + GitTreeBuilder* object = new GitTreeBuilder((git_treebuilder *) External::Unwrap(args[0])); + object->Wrap(args.This()); + + return scope.Close(args.This()); +} + +Handle GitTreeBuilder::New(void *raw) { + HandleScope scope; + Handle argv[1] = { External::New((void *)raw) }; + return scope.Close(GitTreeBuilder::constructor_template->NewInstance(1, argv)); +} + +git_treebuilder *GitTreeBuilder::GetValue() { + return this->raw; +} + + +/** + * @param {Tree} source + * @return {TreeBuilder} out + */ +Handle GitTreeBuilder::Create(const Arguments& args) { + HandleScope scope; + + git_treebuilder *out = NULL; + const git_tree * from_source; + if (args[0]->IsObject()) { + from_source = ObjectWrap::Unwrap(args[0]->ToObject())->GetValue(); + } else { + from_source = NULL; + } + + int result = git_treebuilder_create( + &out + , from_source + ); + if (result != GIT_OK) { + if (giterr_last()) { + return ThrowException(Exception::Error(String::New(giterr_last()->message))); + } else { + return ThrowException(Exception::Error(String::New("Unkown Error"))); + } + } + + Handle to; + if (out != NULL) { + to = GitTreeBuilder::New((void *)out); + } else { + to = Null(); + } + return scope.Close(to); +} + +/** + * @param {TreeBuilder} bld + */ +Handle GitTreeBuilder::Clear(const Arguments& args) { + HandleScope scope; + if (args.Length() == 0 || !args[0]->IsObject()) { + return ThrowException(Exception::Error(String::New("TreeBuilder bld is required."))); + } + + git_treebuilder * from_bld; + from_bld = ObjectWrap::Unwrap(args[0]->ToObject())->GetValue(); + + git_treebuilder_clear( + from_bld + ); + + return Undefined(); +} + +/** + * @return {Number} result + */ +Handle GitTreeBuilder::Size(const Arguments& args) { + HandleScope scope; + + + unsigned int result = git_treebuilder_entrycount( + ObjectWrap::Unwrap(args.This())->GetValue() + ); + + Handle to; + to = Uint32::New(result); + return scope.Close(to); +} + +/** + * @param {String} filename + * @return {TreeEntry} result + */ +Handle GitTreeBuilder::Get(const Arguments& args) { + HandleScope scope; + if (args.Length() == 0 || !args[0]->IsString()) { + return ThrowException(Exception::Error(String::New("String filename is required."))); + } + + const char * from_filename; + String::Utf8Value filename(args[0]->ToString()); + from_filename = strdup(*filename); + + const git_tree_entry * result = git_treebuilder_get( + ObjectWrap::Unwrap(args.This())->GetValue() + , from_filename + ); + free((void *)from_filename); + + Handle to; + if (result != NULL) { + result = (const git_tree_entry * )git_tree_entry_dup(result); + } + if (result != NULL) { + to = GitTreeEntry::New((void *)result); + } else { + to = Null(); + } + return scope.Close(to); +} + +/** + * @param {String} filename + * @param {Oid} id + * @param {Number} filemode + * @return {TreeEntry} out + */ +Handle GitTreeBuilder::Insert(const Arguments& args) { + HandleScope scope; + if (args.Length() == 0 || !args[0]->IsString()) { + return ThrowException(Exception::Error(String::New("String filename is required."))); + } + if (args.Length() == 1 || !args[1]->IsObject()) { + return ThrowException(Exception::Error(String::New("Oid id is required."))); + } + if (args.Length() == 2 || !args[2]->IsNumber()) { + return ThrowException(Exception::Error(String::New("Number filemode is required."))); + } + + const git_tree_entry *out = NULL; + const char * from_filename; + String::Utf8Value filename(args[0]->ToString()); + from_filename = strdup(*filename); + const git_oid * from_id; + from_id = ObjectWrap::Unwrap(args[1]->ToObject())->GetValue(); + git_filemode_t from_filemode; + from_filemode = (git_filemode_t) args[2]->ToNumber()->Value(); + + int result = git_treebuilder_insert( + &out + , ObjectWrap::Unwrap(args.This())->GetValue() + , from_filename + , from_id + , from_filemode + ); + free((void *)from_filename); + if (result != GIT_OK) { + if (giterr_last()) { + return ThrowException(Exception::Error(String::New(giterr_last()->message))); + } else { + return ThrowException(Exception::Error(String::New("Unkown Error"))); + } + } + + Handle to; + if (out != NULL) { + out = (const git_tree_entry * )git_tree_entry_dup(out); + } + if (out != NULL) { + to = GitTreeEntry::New((void *)out); + } else { + to = Null(); + } + return scope.Close(to); +} + +/** + * @param {String} filename + */ +Handle GitTreeBuilder::GitTreebuilderRemove(const Arguments& args) { + HandleScope scope; + if (args.Length() == 0 || !args[0]->IsString()) { + return ThrowException(Exception::Error(String::New("String filename is required."))); + } + + const char * from_filename; + String::Utf8Value filename(args[0]->ToString()); + from_filename = strdup(*filename); + + int result = git_treebuilder_remove( + ObjectWrap::Unwrap(args.This())->GetValue() + , from_filename + ); + free((void *)from_filename); + if (result != GIT_OK) { + if (giterr_last()) { + return ThrowException(Exception::Error(String::New(giterr_last()->message))); + } else { + return ThrowException(Exception::Error(String::New("Unkown Error"))); + } + } + + return Undefined(); +} + +/** + * @param {Repository} repo + * @param {Oid} callback + */ +Handle GitTreeBuilder::Write(const Arguments& args) { + HandleScope scope; + if (args.Length() == 0 || !args[0]->IsObject()) { + return ThrowException(Exception::Error(String::New("Repository repo is required."))); + } + + if (args.Length() == 1 || !args[1]->IsFunction()) { + return ThrowException(Exception::Error(String::New("Callback is required and must be a Function."))); + } + + WriteBaton* baton = new WriteBaton; + baton->error_code = GIT_OK; + baton->error = NULL; + baton->request.data = baton; + baton->id = (git_oid *)malloc(sizeof(git_oid )); + baton->repoReference = Persistent::New(args[0]); + git_repository * from_repo; + from_repo = ObjectWrap::Unwrap(args[0]->ToObject())->GetValue(); + baton->repo = from_repo; + baton->bldReference = Persistent::New(args.This()); + baton->bld = ObjectWrap::Unwrap(args.This())->GetValue(); + baton->callback = Persistent::New(Local::Cast(args[1])); + + uv_queue_work(uv_default_loop(), &baton->request, WriteWork, (uv_after_work_cb)WriteAfterWork); + + return Undefined(); +} + +void GitTreeBuilder::WriteWork(uv_work_t *req) { + WriteBaton *baton = static_cast(req->data); + int result = git_treebuilder_write( + baton->id, + baton->repo, + baton->bld + ); + baton->error_code = result; + if (result != GIT_OK) { + baton->error = giterr_last(); + } +} + +void GitTreeBuilder::WriteAfterWork(uv_work_t *req) { + HandleScope scope; + WriteBaton *baton = static_cast(req->data); + + TryCatch try_catch; + if (baton->error_code == GIT_OK) { + Handle to; + if (baton->id != NULL) { + to = GitOid::New((void *)baton->id); + } else { + to = Null(); + } + Handle result = to; + Handle argv[2] = { + Local::New(Null()), + result + }; + baton->callback->Call(Context::GetCurrent()->Global(), 2, argv); + } else { + if (baton->error) { + Handle argv[1] = { + Exception::Error(String::New(baton->error->message)) + }; + baton->callback->Call(Context::GetCurrent()->Global(), 1, argv); + } else { + baton->callback->Call(Context::GetCurrent()->Global(), 0, NULL); + } + free(baton->id); + } + + if (try_catch.HasCaught()) { + node::FatalException(try_catch); + } + baton->repoReference.Dispose(); + baton->bldReference.Dispose(); + baton->callback.Dispose(); + delete baton; +} + +Persistent GitTreeBuilder::constructor_template; diff --git a/src/tree_entry.cc b/src/tree_entry.cc index 78578cb4c..a2f4aa7a6 100755 --- a/src/tree_entry.cc +++ b/src/tree_entry.cc @@ -1,281 +1,224 @@ -/* - * Copyright 2013, Tim Branyen @tbranyen - * @author Michael Robinson @codeofinterest - * - * Dual licensed under the MIT and GPL licenses. - */ - +/** + * This code is auto-generated; unless you know what you're doing, do not modify! + **/ #include #include - -#include "cvv8/v8-convert.hpp" +#include #include "git2.h" -#include "../include/repo.h" -#include "../include/blob.h" -#include "../include/tree.h" -#include "../include/oid.h" -#include "../include/tree_entry.h" -#include "../include/error.h" +#include "../include/functions/copy.h" -#include "../include/functions/utilities.h" +#include "../include/tree_entry.h" +#include "../include/oid.h" +#include "../include/repo.h" +#include "../include/object.h" using namespace v8; using namespace node; -using namespace cvv8; -namespace cvv8 { - template <> - struct NativeToJS : NativeToJS {}; +GitTreeEntry::GitTreeEntry(git_tree_entry *raw) { + this->raw = raw; +} + +GitTreeEntry::~GitTreeEntry() { + git_tree_entry_free(this->raw); } void GitTreeEntry::Initialize(Handle target) { + HandleScope scope; + Local tpl = FunctionTemplate::New(New); tpl->InstanceTemplate()->SetInternalFieldCount(1); tpl->SetClassName(String::NewSymbol("TreeEntry")); NODE_SET_PROTOTYPE_METHOD(tpl, "name", Name); - NODE_SET_PROTOTYPE_METHOD(tpl, "root", Root); - NODE_SET_PROTOTYPE_METHOD(tpl, "fileMode", FileMode); NODE_SET_PROTOTYPE_METHOD(tpl, "oid", Oid); - NODE_SET_PROTOTYPE_METHOD(tpl, "toBlob", ToBlob); - - // Add libgit2 file modes to entry object - Local libgit2FileModes = Object::New(); + NODE_SET_PROTOTYPE_METHOD(tpl, "type", Type); + NODE_SET_PROTOTYPE_METHOD(tpl, "filemode", filemode); + NODE_SET_PROTOTYPE_METHOD(tpl, "getObject", GetObject); - libgit2FileModes->Set(String::NewSymbol("GIT_FILEMODE_NEW"), CastToJS(GIT_FILEMODE_NEW), ReadOnly); - libgit2FileModes->Set(String::NewSymbol("GIT_FILEMODE_TREE"), CastToJS(GIT_FILEMODE_TREE), ReadOnly); - libgit2FileModes->Set(String::NewSymbol("GIT_FILEMODE_BLOB"), CastToJS(GIT_FILEMODE_BLOB), ReadOnly); - libgit2FileModes->Set(String::NewSymbol("GIT_FILEMODE_BLOB_EXECUTABLE"), CastToJS(GIT_FILEMODE_BLOB_EXECUTABLE), ReadOnly); - libgit2FileModes->Set(String::NewSymbol("GIT_FILEMODE_LINK"), CastToJS(GIT_FILEMODE_LINK), ReadOnly); - libgit2FileModes->Set(String::NewSymbol("GIT_FILEMODE_COMMIT"), CastToJS(GIT_FILEMODE_COMMIT), ReadOnly); constructor_template = Persistent::New(tpl->GetFunction()); - constructor_template->Set(String::NewSymbol("fileModes"), libgit2FileModes, ReadOnly); target->Set(String::NewSymbol("TreeEntry"), constructor_template); } -git_tree_entry* GitTreeEntry::GetValue() { - return this->entry; -} -void GitTreeEntry::SetValue(git_tree_entry* entry) { - this->entry = entry; -} -void GitTreeEntry::SetRoot(std::string root) { - this->root = root; -} -std::string GitTreeEntry::GetRoot() { - return this->root; -} - Handle GitTreeEntry::New(const Arguments& args) { HandleScope scope; - GitTreeEntry *entry = new GitTreeEntry(); - - entry->Wrap(args.This()); - - return scope.Close(args.This()); -} - -Handle GitTreeEntry::Root(const Arguments& args) { - HandleScope scope; - - if(args.Length() == 0 || !args[0]->IsFunction()) { - return ThrowException(Exception::Error(String::New("Callback is required and must be a Function."))); + if (args.Length() == 0 || !args[0]->IsExternal()) { + return ThrowException(Exception::Error(String::New("git_tree_entry is required."))); } - GitTreeEntry *entry = ObjectWrap::Unwrap(args.This()); - - Handle argv[2] = { - Local::New(Null()), - String::New(entry->GetRoot().c_str()) - }; - - TryCatch try_catch; - Local::Cast(args[0])->Call(Context::GetCurrent()->Global(), 2, argv); - if (try_catch.HasCaught()) { - node::FatalException(try_catch); - } + GitTreeEntry* object = new GitTreeEntry((git_tree_entry *) External::Unwrap(args[0])); + object->Wrap(args.This()); - return Undefined(); + return scope.Close(args.This()); } -Handle GitTreeEntry::Name(const Arguments& args) { +Handle GitTreeEntry::New(void *raw) { HandleScope scope; - - if(args.Length() == 0 || !args[0]->IsFunction()) { - return ThrowException(Exception::Error(String::New("Callback is required and must be a Function."))); - } - - NameBaton *baton = new NameBaton; - baton->request.data = baton; - - GitTreeEntry *treeEntry = ObjectWrap::Unwrap(args.This()); - baton->rawEntry = treeEntry->GetValue(); - baton->callback = Persistent::New(Local::Cast(args[0])); - - uv_queue_work(uv_default_loop(), &baton->request, NameWork, (uv_after_work_cb)NameAfterWork); - - return Undefined(); + Handle argv[1] = { External::New((void *)raw) }; + return scope.Close(GitTreeEntry::constructor_template->NewInstance(1, argv)); } -void GitTreeEntry::NameWork(uv_work_t* req) { - NameBaton *baton = static_cast(req->data); - baton->name = git_tree_entry_name(baton->rawEntry); +git_tree_entry *GitTreeEntry::GetValue() { + return this->raw; } -void GitTreeEntry::NameAfterWork(uv_work_t* req) { - HandleScope scope; - NameBaton *baton = static_cast(req->data); - Handle argv[2] = { - Local::New(Null()), - String::New(baton->name) - }; - TryCatch try_catch; - baton->callback->Call(Context::GetCurrent()->Global(), 2, argv); - if (try_catch.HasCaught()) { - node::FatalException(try_catch); - } - delete req; -} - -Handle GitTreeEntry::FileMode(const Arguments& args) { +/** + * @return {String} result + */ +Handle GitTreeEntry::Name(const Arguments& args) { HandleScope scope; + - if(args.Length() == 0 || !args[0]->IsFunction()) { - return ThrowException(Exception::Error(String::New("Callback is required and must be a Function."))); - } - - FileModeBaton *baton = new FileModeBaton; - baton->request.data = baton; - baton->rawEntry = ObjectWrap::Unwrap(args.This())->GetValue(); - baton->callback = Persistent::New(Local::Cast(args[0])); - - uv_queue_work(uv_default_loop(), &baton->request, FileModeWork, (uv_after_work_cb)FileModeAfterWork); + const char * result = git_tree_entry_name( + ObjectWrap::Unwrap(args.This())->GetValue() + ); - return Undefined(); + Handle to; + to = String::New(result); + return scope.Close(to); } -void GitTreeEntry::FileModeWork(uv_work_t* req) { - FileModeBaton *baton = static_cast(req->data); - baton->fileMode = git_tree_entry_filemode(baton->rawEntry); -} -void GitTreeEntry::FileModeAfterWork(uv_work_t* req) { +/** + * @return {Oid} result + */ +Handle GitTreeEntry::Oid(const Arguments& args) { HandleScope scope; - FileModeBaton *baton = static_cast(req->data); + - Handle argv[2] = { - Local::New(Null()), - Integer::New(baton->fileMode) - }; + const git_oid * result = git_tree_entry_id( + ObjectWrap::Unwrap(args.This())->GetValue() + ); - TryCatch try_catch; - baton->callback->Call(Context::GetCurrent()->Global(), 2, argv); - if (try_catch.HasCaught()) { - node::FatalException(try_catch); + Handle to; + if (result != NULL) { + result = (const git_oid * )git_oid_dup(result); } - delete req; + if (result != NULL) { + to = GitOid::New((void *)result); + } else { + to = Null(); + } + return scope.Close(to); } -Handle GitTreeEntry::Oid(const Arguments& args) { +/** + * @return {Number} result + */ +Handle GitTreeEntry::Type(const Arguments& args) { HandleScope scope; + - if(args.Length() == 0 || !args[0]->IsFunction()) { - return ThrowException(Exception::Error(String::New("Callback is required and must be a Function."))); - } + git_otype result = git_tree_entry_type( + ObjectWrap::Unwrap(args.This())->GetValue() + ); - OidBaton* baton = new OidBaton; - baton->request.data = baton; - baton->rawEntry = ObjectWrap::Unwrap(args.This())->GetValue(); - baton->callback = Persistent::New(Local::Cast(args[0])); - - uv_queue_work(uv_default_loop(), &baton->request, OidWork, (uv_after_work_cb)OidAfterWork); - - return Undefined(); + Handle to; + to = Number::New(result); + return scope.Close(to); } -void GitTreeEntry::OidWork(uv_work_t* req) { - OidBaton *baton = static_cast(req->data); - baton->rawOid = git_tree_entry_id(const_cast(baton->rawEntry)); -} -void GitTreeEntry::OidAfterWork(uv_work_t* req) { +/** + * @return {Number} result + */ +Handle GitTreeEntry::filemode(const Arguments& args) { HandleScope scope; - OidBaton *baton = static_cast(req->data); - - Handle oid = GitOid::constructor_template->NewInstance(); - GitOid* oidInstance = ObjectWrap::Unwrap(oid); - oidInstance->SetValue(*const_cast(baton->rawOid)); + - Handle argv[2] = { - Local::New(Null()), - oid - }; + git_filemode_t result = git_tree_entry_filemode( + ObjectWrap::Unwrap(args.This())->GetValue() + ); - TryCatch try_catch; - baton->callback->Call(Context::GetCurrent()->Global(), 2, argv); - if (try_catch.HasCaught()) { - node::FatalException(try_catch); - } - delete req; + Handle to; + to = Number::New(result); + return scope.Close(to); } -Handle GitTreeEntry::ToBlob(const Arguments& args) { +/** + * @param {Repository} repo + * @param {Object} callback + */ +Handle GitTreeEntry::GetObject(const Arguments& args) { HandleScope scope; - - if(args.Length() == 0 || !args[0]->IsObject()) { - return ThrowException(Exception::Error(String::New("Repository is required and must be an Object."))); + if (args.Length() == 0 || !args[0]->IsObject()) { + return ThrowException(Exception::Error(String::New("Repository repo is required."))); } - if(args.Length() == 1 || !args[1]->IsFunction()) { + if (args.Length() == 1 || !args[1]->IsFunction()) { return ThrowException(Exception::Error(String::New("Callback is required and must be a Function."))); } - ToBlobBaton* baton = new ToBlobBaton; - baton->request.data = baton; + GetObjectBaton* baton = new GetObjectBaton; + baton->error_code = GIT_OK; baton->error = NULL; - baton->rawRepo = ObjectWrap::Unwrap(args[0]->ToObject())->GetValue(); - baton->rawEntry = ObjectWrap::Unwrap(args.This())->GetValue(); - baton->rawBlob = NULL; + baton->request.data = baton; + baton->repoReference = Persistent::New(args[0]); + git_repository * from_repo; + from_repo = ObjectWrap::Unwrap(args[0]->ToObject())->GetValue(); + baton->repo = from_repo; + baton->entryReference = Persistent::New(args.This()); + baton->entry = ObjectWrap::Unwrap(args.This())->GetValue(); baton->callback = Persistent::New(Local::Cast(args[1])); - uv_queue_work(uv_default_loop(), &baton->request, ToBlobWork, (uv_after_work_cb)ToBlobAfterWork); + uv_queue_work(uv_default_loop(), &baton->request, GetObjectWork, (uv_after_work_cb)GetObjectAfterWork); return Undefined(); } -void GitTreeEntry::ToBlobWork(uv_work_t *req) { - ToBlobBaton* baton = static_cast(req->data); - int returnCode = git_tree_entry_to_object((git_object**)&baton->rawBlob, baton->rawRepo, baton->rawEntry); - if (returnCode != GIT_OK) { +void GitTreeEntry::GetObjectWork(uv_work_t *req) { + GetObjectBaton *baton = static_cast(req->data); + int result = git_tree_entry_to_object( + &baton->object_out, + baton->repo, + baton->entry + ); + baton->error_code = result; + if (result != GIT_OK) { baton->error = giterr_last(); } } -void GitTreeEntry::ToBlobAfterWork(uv_work_t *req) { - HandleScope scope; - ToBlobBaton* baton = static_cast(req->data); - if (success(baton->error, baton->callback)) { - Handle blob = GitBlob::constructor_template->NewInstance(); - GitBlob *blobInstance = ObjectWrap::Unwrap(blob); - blobInstance->SetValue(baton->rawBlob); +void GitTreeEntry::GetObjectAfterWork(uv_work_t *req) { + HandleScope scope; + GetObjectBaton *baton = static_cast(req->data); + TryCatch try_catch; + if (baton->error_code == GIT_OK) { + Handle to; + if (baton->object_out != NULL) { + to = GitObject::New((void *)baton->object_out); + } else { + to = Null(); + } + Handle result = to; Handle argv[2] = { Local::New(Null()), - blob + result }; - - TryCatch try_catch; baton->callback->Call(Context::GetCurrent()->Global(), 2, argv); - if (try_catch.HasCaught()) { - node::FatalException(try_catch); + } else { + if (baton->error) { + Handle argv[1] = { + Exception::Error(String::New(baton->error->message)) + }; + baton->callback->Call(Context::GetCurrent()->Global(), 1, argv); + } else { + baton->callback->Call(Context::GetCurrent()->Global(), 0, NULL); } + } + + if (try_catch.HasCaught()) { + node::FatalException(try_catch); } - delete req; + baton->repoReference.Dispose(); + baton->entryReference.Dispose(); + baton->callback.Dispose(); + delete baton; } Persistent GitTreeEntry::constructor_template; - diff --git a/src/wrapper.cc b/src/wrapper.cc new file mode 100644 index 000000000..d513cb5ad --- /dev/null +++ b/src/wrapper.cc @@ -0,0 +1,77 @@ +/** + * This code is auto-generated; unless you know what you're doing, do not modify! + **/ +#include +#include +#include + +#include "../include/wrapper.h" +#include "node_buffer.h" + +using namespace v8; +using namespace node; + +Wrapper::Wrapper(void *raw) { + this->raw = raw; +} + +void Wrapper::Initialize(Handle target) { + HandleScope scope; + + Local tpl = FunctionTemplate::New(New); + + tpl->InstanceTemplate()->SetInternalFieldCount(1); + tpl->SetClassName(String::NewSymbol("Wrapper")); + + NODE_SET_PROTOTYPE_METHOD(tpl, "toBuffer", ToBuffer); + + constructor_template = Persistent::New(tpl->GetFunction()); + target->Set(String::NewSymbol("Wrapper"), constructor_template); +} + +Handle Wrapper::New(const Arguments& args) { + HandleScope scope; + + if (args.Length() == 0 || !args[0]->IsExternal()) { + return ThrowException(Exception::Error(String::New("void * is required."))); + } + + Wrapper* object = new Wrapper(External::Unwrap(args[0])); + object->Wrap(args.This()); + + return scope.Close(args.This()); +} + +Handle Wrapper::New(void *raw) { + HandleScope scope; + + Handle argv[1] = { External::New((void *)raw) }; + return scope.Close(Wrapper::constructor_template->NewInstance(1, argv)); +} + +void *Wrapper::GetValue() { + return this->raw; +} + +Handle Wrapper::ToBuffer(const Arguments& args) { + HandleScope scope; + + if(args.Length() == 0 || !args[0]->IsNumber()) { + return ThrowException(Exception::Error(String::New("Number is required."))); + } + + int len = args[0]->ToNumber()->Value(); + + Local bufferConstructor = Local::Cast( + Context::GetCurrent()->Global()->Get(String::New("Buffer"))); + + Handle constructorArgs[1] = { Integer::New(len) }; + Local nodeBuffer = bufferConstructor->NewInstance(1, constructorArgs); + + memcpy(node::Buffer::Data(nodeBuffer), ObjectWrap::Unwrap(args.This())->GetValue(), len); + + return scope.Close(nodeBuffer); +} + + +Persistent Wrapper::constructor_template; diff --git a/templates/asyncFunction.cc.ejs b/templates/asyncFunction.cc.ejs new file mode 100644 index 000000000..1a4c98347 --- /dev/null +++ b/templates/asyncFunction.cc.ejs @@ -0,0 +1,138 @@ +/** +<% include doc.cc.ejs -%> + */ +Handle <%- cppClassName %>::<%- functionInfo.cppFunctionName %>(const Arguments& args) { + HandleScope scope; + <% var jsArg; -%> + <% include guardArguments.cc.ejs -%> + + if (args.Length() == <%- jsArg %> || !args[<%- jsArg %>]->IsFunction()) { + return ThrowException(Exception::Error(String::New("Callback is required and must be a Function."))); + } + + <%- functionInfo.cppFunctionName %>Baton* baton = new <%- functionInfo.cppFunctionName %>Baton; + baton->error_code = GIT_OK; + baton->error = NULL; + baton->request.data = baton; +<% + for (var cArg = 0, jsArg = 0; cArg < functionInfo.args.length; cArg++) { + var arg = functionInfo.args[cArg]; +-%> +<% if (!arg.isReturn) { -%> +<% if (arg.isSelf) { -%> + baton-><%- arg.name %>Reference = Persistent::New(args.This()); + baton-><%- arg.name %> = ObjectWrap::Unwrap<<%- cppClassName %>>(args.This())->GetValue(); +<% } else { -%> + baton-><%- arg.name %>Reference = Persistent::New(args[<%- jsArg %>]); + <% include convertFromV8.cc.ejs -%> + <% if (!arg.isPayload) { -%> + baton-><%- arg.name %> = from_<%- arg.name %>; + <% } -%> +<% } -%> +<% if (!(arg.isReturn || arg.isSelf || arg.isPayload)) jsArg++; -%> +<% } else { -%> +<% if (arg.shouldAlloc) { -%> + baton-><%- arg.name %> = (<%- arg.cType %>)malloc(sizeof(<%- arg.cType.replace('*', '') %>)); +<% } else { -%> +<% } -%> +<% } -%> +<% } -%> + baton->callback = Persistent::New(Local::Cast(args[<%- jsArg %>])); + + uv_queue_work(uv_default_loop(), &baton->request, <%- functionInfo.cppFunctionName %>Work, (uv_after_work_cb)<%- functionInfo.cppFunctionName %>AfterWork); + + return Undefined(); +} + +void <%- cppClassName %>::<%- functionInfo.cppFunctionName %>Work(uv_work_t *req) { + <%- functionInfo.cppFunctionName %>Baton *baton = static_cast<<%- functionInfo.cppFunctionName %>Baton *>(req->data); + <% if (functionInfo.return.cType != "void" || functionInfo.return.isErrorCode) { %><%- functionInfo.return.cType %> result = <% } %><%- functionInfo.cFunctionName %>( +<% + for (var i = 0; i < functionInfo.args.length; i++) { + var arg = functionInfo.args[i]; +-%> + <% if (arg.isReturn && /\*\*/.test(arg.cType)) { %>&<% } %>baton-><%- arg.name %><% if (i < functionInfo.args.length - 1) { %>, <% } %> +<% } -%> + ); +<% if (functionInfo.return.isErrorCode) { -%> + baton->error_code = result; + if (result != GIT_OK) { + baton->error = giterr_last(); + } +<% } else if (functionInfo.return.cType != "void") { -%> + baton->result = result; +<% } -%> +} + +void <%- cppClassName %>::<%- functionInfo.cppFunctionName %>AfterWork(uv_work_t *req) { + HandleScope scope; + <%- functionInfo.cppFunctionName %>Baton *baton = static_cast<<%- functionInfo.cppFunctionName %>Baton *>(req->data); + + TryCatch try_catch; + if (baton->error_code == GIT_OK) { +<% if (!returns.length) { -%> + Handle result = Local::New(Undefined()); +<% } else if (returns.length == 1) { -%> +<% var to = {}; to.__proto__ = returns[0]; to.name = "baton->" + to.name; -%> + Handle to; + <% include convertToV8.cc.ejs -%> + Handle result = to; +<% } else { -%> + Handle result = Object::New(); + Handle to; +<% + for (r in returns) { + var to = returns[r]; +-%> + <% include convertToV8.cc.ejs -%> + result->Set(String::NewSymbol("<%- to.jsName || to.name %>"), to); +<% } -%> +<% } -%> + Handle argv[2] = { + Local::New(Null()), + result + }; + baton->callback->Call(Context::GetCurrent()->Global(), 2, argv); + } else { + if (baton->error) { + Handle argv[1] = { + Exception::Error(String::New(baton->error->message)) + }; + baton->callback->Call(Context::GetCurrent()->Global(), 1, argv); + } else { + baton->callback->Call(Context::GetCurrent()->Global(), 0, NULL); + } + <% + for (var i = 0; i < functionInfo.args.length; i++) { + var arg = functionInfo.args[i]; + if (!arg.shouldAlloc) continue; + -%> + free(baton-><%= arg.name %>); + <% } -%> + } + + if (try_catch.HasCaught()) { + node::FatalException(try_catch); + } +<% + for (var i = 0, j = 0; i < functionInfo.args.length; i++) { + var arg = functionInfo.args[i]; + if (arg.isReturn) continue; +-%> + baton-><%- arg.name %>Reference.Dispose(); +<% } -%> + baton->callback.Dispose(); +<% + for (var i = 0; i < functionInfo.args.length; i++) { + var arg = functionInfo.args[i]; +-%> +<% if (['String', 'Array'].indexOf(arg.cppClassName) > -1) { -%> +<% if (arg.freeFunctionName) { %> + <%- arg.freeFunctionName %>(baton-><%- arg.name %>); +<% } else { -%> + free((void *)baton-><%- arg.name %>); +<% } -%> +<% } -%> +<% } -%> + delete baton; +} diff --git a/templates/class.cc.ejs b/templates/class.cc.ejs new file mode 100644 index 000000000..1ddc9d618 --- /dev/null +++ b/templates/class.cc.ejs @@ -0,0 +1,148 @@ +<% + function isV8Value(cppClassName) { + return ["Boolean", "Number", "String", "Integer", "Int32", "Uint32", "Date", "Function"].indexOf(cppClassName) > -1; + } + + function cppClassName2v8ValueClassName(cppClassName) { + if (isV8Value(cppClassName)) + return cppClassName; + else + return 'Object'; + } +-%> +/** + * This code is auto-generated; unless you know what you're doing, do not modify! + **/ +#include +#include +#include + +#include "git2.h" + +#include "../include/functions/copy.h" + +#include "../include/<%= filename %>" +<% if (typeof dependencies != 'undefined') { -%> +<% for (d in dependencies) { -%> +#include "<%- dependencies[d] %>" +<% } -%> +<% } -%> + +using namespace v8; +using namespace node; + +<% if (typeof cType != 'undefined') { -%> +<%- cppClassName %>::<%- cppClassName %>(<%- cType %> *raw) { + this->raw = raw; +} + +<%- cppClassName %>::~<%- cppClassName %>() { +<% if (typeof freeFunctionName != 'undefined') { -%> + <%- freeFunctionName %>(this->raw); +<% } -%> +} + +void <%- cppClassName %>::Initialize(Handle target) { + HandleScope scope; + + Local tpl = FunctionTemplate::New(New); + + tpl->InstanceTemplate()->SetInternalFieldCount(1); + tpl->SetClassName(String::NewSymbol("<%- jsClassName %>")); + +<% if (typeof functions != 'undefined') { -%> +<% + for (var i in functions) { + var functionInfo = functions[i]; + if (functionInfo.ignore) continue; +-%> +<% if (functionInfo.isPrototypeMethod) { -%> + NODE_SET_PROTOTYPE_METHOD(tpl, "<%- functionInfo.jsFunctionName %>", <%- functionInfo.cppFunctionName %>); +<% } else { -%> + NODE_SET_METHOD(tpl, "<%- functionInfo.jsFunctionName %>", <%- functionInfo.cppFunctionName %>); +<% } -%> +<% } -%> +<% } -%> + +<% if (typeof fields != 'undefined') { -%> +<% + for (var i in fields) { + var fieldInfo = fields[i]; + if (fieldInfo.ignore) continue; +-%> + NODE_SET_PROTOTYPE_METHOD(tpl, "<%- fieldInfo.jsFunctionName %>", <%- fieldInfo.cppFunctionName %>); +<% } -%> +<% } -%> + + constructor_template = Persistent::New(tpl->GetFunction()); + target->Set(String::NewSymbol("<%- jsClassName %>"), constructor_template); +} + +Handle <%- cppClassName %>::New(const Arguments& args) { + HandleScope scope; + + if (args.Length() == 0 || !args[0]->IsExternal()) { + return ThrowException(Exception::Error(String::New("<%= cType %> is required."))); + } + + <%- cppClassName %>* object = new <%- cppClassName %>((<%= cType%> *) External::Unwrap(args[0])); + object->Wrap(args.This()); + + return scope.Close(args.This()); +} + +Handle <%- cppClassName %>::New(void *raw) { + HandleScope scope; + Handle argv[1] = { External::New((void *)raw) }; + return scope.Close(<%- cppClassName %>::constructor_template->NewInstance(1, argv)); +} + +<%- cType %> *<%- cppClassName %>::GetValue() { + return this->raw; +} +<% } else { -%> +void <%- cppClassName %>::Initialize(Handle target) { + HandleScope scope; + + Persistent object = Persistent::New(Object::New()); + +<% if (typeof functions != 'undefined') { -%> +<% + for (var i in functions) { + var functionInfo = functions[i]; + if (functionInfo.ignore) continue; +-%> + object->Set(String::NewSymbol("<%- functionInfo.jsFunctionName %>"), FunctionTemplate::New(<%- functionInfo.cppFunctionName %>)->GetFunction()); +<% } -%> +<% } -%> + + target->Set(String::NewSymbol("<%- jsClassName %>"), object); +} +<% } -%> + +<% if (typeof functions != 'undefined') { -%> +<% + for (var i in functions) { + var functionInfo = functions[i]; + if (functionInfo.ignore) continue; + + var returns = []; + for (var i = 0; i < functionInfo.args.length; i++) { + var arg = functionInfo.args[i]; + if (arg.isReturn) returns.push(arg); + } + if (!returns.length && !functionInfo.return.isErrorCode && functionInfo.return.cType != "void") returns.push(functionInfo.return); +-%> + +<% if (functionInfo.isAsync) { -%> +<% include templates/asyncFunction.cc.ejs -%> +<% } else { -%> +<% include templates/syncFunction.cc.ejs -%> +<% } -%> +<% } -%> +<% } -%> +<% include templates/fields.cc.ejs -%> + +<% if (typeof cType != 'undefined') { -%> +Persistent <%- cppClassName %>::constructor_template; +<% } -%> diff --git a/templates/convertFromV8.cc.ejs b/templates/convertFromV8.cc.ejs new file mode 100644 index 000000000..9d26d998f --- /dev/null +++ b/templates/convertFromV8.cc.ejs @@ -0,0 +1,32 @@ +<% if (!arg.isPayload) { -%> + <%- arg.cType %> from_<%- arg.name %>; + <% if (arg.isOptional) { -%> + if (args[<%- jsArg %>]->Is<%- cppClassName2v8ValueClassName(arg.cppClassName) %>()) { + <% } -%> + <% if (arg.cppClassName == 'String') { -%> + String::Utf8Value <%- arg.name %>(args[<%- jsArg %>]->ToString()); + from_<%- arg.name %> = strdup(*<%- arg.name %>); + <% } else if (arg.cppClassName == 'Array') { -%> + Array *tmp_<%- arg.name %> = Array::Cast(*args[<%- jsArg %>]); + from_<%- arg.name %> = (<%- arg.cType %>)malloc(tmp_<%- arg.name %>->Length() * sizeof(<%- arg.cType.replace('**', '*') %>)); + for (unsigned int i = 0; i < tmp_<%- arg.name %>->Length(); i++) { + <% + // FIXME: should recursively call convertFromv8. + %> + from_<%- arg.name %>[i] = ObjectWrap::Unwrap<<%- arg.arrayElementCppClassName %>>(tmp_<%- arg.name %>->Get(Number::New(static_cast(i)))->ToObject())->GetValue(); + } + <% } else if (arg.cppClassName == "Function") { -%> + Persistent::New(Local::Cast(args[<%- jsArg %>])); + <% } else if (arg.cppClassName == 'Buffer') { -%> + from_<%- arg.name %> = Buffer::Data(args[<%- jsArg %>]->ToObject()); + <% } else if (isV8Value(arg.cppClassName)) { -%> + from_<%- arg.name %> = (<%- arg.cType %>) args[<%- jsArg %>]->To<%- arg.cppClassName %>()->Value(); + <% } else { -%> + from_<%- arg.name %> = ObjectWrap::Unwrap<<%- arg.cppClassName %>>(args[<%- jsArg %>]->ToObject())->GetValue(); + <% } -%> + <% if (arg.isOptional) { -%> + } else { + from_<%- arg.name %> = NULL; + } + <% } -%> +<% } -%> \ No newline at end of file diff --git a/templates/convertToV8.cc.ejs b/templates/convertToV8.cc.ejs new file mode 100644 index 000000000..9918d948d --- /dev/null +++ b/templates/convertToV8.cc.ejs @@ -0,0 +1,35 @@ +<% toName = to.name || 'result' -%> +<% if (to.cppClassName == "String") { -%> +<% if (typeof to.size != 'undefined') { -%> + to = String::New(<%- toName %>, <%- to.size %>); +<% } else { -%> + to = String::New(<%- toName %>); +<% } -%> +<% if (to.freeFunctionName) { -%> + <%- to.freeFunctionName %>(<%- toName %>); +<% } -%> +<% } else if (isV8Value(to.cppClassName)) { -%> + to = <%- to.cppClassName %>::New(<%- toName %>); +<% } else if (to.cppClassName == "External") { -%> + to = External::New((void *)<%- toName %>); +<% } else if (to.cppClassName == 'Array') { -%> +<% + // FIXME this is not general purpose enough. +%> + Local tmpArray = Array::New(<%- toName %>-><%- to.size %>); + for (unsigned int i = 0; i < <%- toName %>-><%- to.size %>; i++) { + tmpArray->Set(Number::New(i), String::New(<%- toName %>-><%- to.key %>[i])); + } + to = tmpArray; +<% } else { -%> +<% if (to.copy) { -%> + if (<%- toName %> != NULL) { + <%- toName %> = (<%- to.cType.replace('**', '*') %> <% if (!/\*/.test(to.cType)) {%>*<% } %>)<%- to.copy %>(<%- toName %>); + } +<% } -%> + if (<%- toName %> != NULL) { + to = <%- to.cppClassName %>::New((void *)<%- toName %>); + } else { + to = Null(); + } +<% } -%> diff --git a/templates/doc.cc.ejs b/templates/doc.cc.ejs new file mode 100644 index 000000000..44ca0979a --- /dev/null +++ b/templates/doc.cc.ejs @@ -0,0 +1,14 @@ +<% + for (var i = 0; i < functionInfo.args.length; i++) { + var arg = functionInfo.args[i]; + if (arg.isReturn || arg.isSelf) continue; +-%> + * @param {<%- arg.jsClassName %>} <%- arg.name %> +<% } -%> +<% for (var r = 0; r < returns.length; r++) { -%> +<% if (functionInfo.isAsync) { -%> + * @param {<%- returns[r].jsClassName || returns[r].cppClassName %>} callback +<% } else { -%> + * @return {<%- returns[r].jsClassName || returns[r].cppClassName %>} <%- returns[r].name || 'result' %> +<% } -%> +<% } -%> diff --git a/templates/fields.cc.ejs b/templates/fields.cc.ejs new file mode 100644 index 000000000..44c8fcb57 --- /dev/null +++ b/templates/fields.cc.ejs @@ -0,0 +1,20 @@ +<% if (typeof fields != 'undefined') { -%> +<% + for (var i in fields) { + var fieldInfo = fields[i]; + if (fieldInfo.ignore) continue; +-%> + +Handle <%- cppClassName %>::<%- fieldInfo.cppFunctionName %>(const Arguments& args) { + HandleScope scope; + <% var to = fieldInfo; -%> + Handle to; + + <%- fieldInfo.cType %> <% if (!isV8Value(fieldInfo.cppClassName)) { %>*<% } %><%- fieldInfo.name %> = + <% if (!isV8Value(fieldInfo.cppClassName)) { %>&<% } %>ObjectWrap::Unwrap<<%- cppClassName %>>(args.This())->GetValue()-><%- fieldInfo.name %>; + + <% include convertToV8.cc.ejs -%> + return scope.Close(to); +} +<% } -%> +<% } -%> diff --git a/templates/guardArguments.cc.ejs b/templates/guardArguments.cc.ejs new file mode 100644 index 000000000..a238d32e9 --- /dev/null +++ b/templates/guardArguments.cc.ejs @@ -0,0 +1,13 @@ +<% + var cArg = 0; + for (cArg = 0, jsArg = 0; cArg < functionInfo.args.length; cArg++) { + var arg = functionInfo.args[cArg]; + if (arg.isReturn || arg.isSelf || arg.isPayload) continue; +-%> +<% if (!arg.isOptional) { -%> + if (args.Length() == <%- jsArg %> || !args[<%- jsArg %>]->Is<%- cppClassName2v8ValueClassName(arg.cppClassName) %>()) { + return ThrowException(Exception::Error(String::New("<%- arg.jsClassName %> <%- arg.name %> is required."))); + } +<% } -%> +<% jsArg++; -%> +<% } -%> diff --git a/templates/header.h.ejs b/templates/header.h.ejs new file mode 100644 index 000000000..1a31a7fe7 --- /dev/null +++ b/templates/header.h.ejs @@ -0,0 +1,83 @@ +/** + * This code is auto-generated; unless you know what you're doing, do not modify! + **/ + +#ifndef <%- cppClassName.toUpperCase() %>_H +#define <%- cppClassName.toUpperCase() %>_H + +#include +#include +#include + +#include "git2.h" + +using namespace node; +using namespace v8; + +class <%- cppClassName %> : public ObjectWrap { + public: + + static Persistent constructor_template; + static void Initialize (Handle target); + +<% if (typeof cType != 'undefined') { -%> + <%- cType %> *GetValue(); + + static Handle New(void *raw); +<% } -%> + + private: +<% if (typeof cType != 'undefined') { -%> + <%- cppClassName %>(<%- cType %> *raw); + ~<%- cppClassName %>(); +<% } -%> + + static Handle New(const Arguments& args); + +<% if (typeof fields != 'undefined') { -%> +<% + for (var i in fields) { + var fieldInfo = fields[i]; + if (fieldInfo.ignore) continue; +-%> + static Handle <%- fieldInfo.cppFunctionName %>(const Arguments& args); +<% } -%> +<% } -%> + +<% if (typeof functions != 'undefined') { -%> +<% + for (var i in functions) { + var functionInfo = functions[i]; + if (functionInfo.ignore) continue; +-%> + static Handle <%- functionInfo.cppFunctionName %>(const Arguments& args); +<% if (functionInfo.isAsync) { -%> + static void <%- functionInfo.cppFunctionName %>Work(uv_work_t* req); + static void <%- functionInfo.cppFunctionName %>AfterWork(uv_work_t* req); + + struct <%- functionInfo.cppFunctionName %>Baton { + uv_work_t request; + int error_code; + const git_error* error; +<% + for (var i = 0; i < functionInfo.args.length; i++) { + var arg = functionInfo.args[i]; +-%> +<% if (arg.isReturn) { -%> + <%- arg.cType.replace('**', '*') %> <%- arg.name %>; +<% } else { -%> + Persistent <%- arg.name %>Reference; + <%- arg.cType %> <%- arg.name %>; +<% } -%> +<% } -%> + Persistent callback; + }; +<% } -%> +<% } -%> +<% } -%> +<% if (typeof cType != 'undefined') { -%> + <%- cType %> *raw; +<% } -%> +}; + +#endif diff --git a/templates/syncFunction.cc.ejs b/templates/syncFunction.cc.ejs new file mode 100644 index 000000000..599fe4a49 --- /dev/null +++ b/templates/syncFunction.cc.ejs @@ -0,0 +1,95 @@ +/** +<% include doc.cc.ejs -%> + */ +Handle <%- cppClassName %>::<%- functionInfo.cppFunctionName %>(const Arguments& args) { + HandleScope scope; + <% include guardArguments.cc.ejs -%> + +<% + for (var i = 0; i < functionInfo.args.length; i++) { + var arg = functionInfo.args[i]; + if (!arg.isReturn) continue; +-%> +<% if (arg.shouldAlloc) { -%> + <%- arg.cType %><%- arg.name %> = (<%- arg.cType %>)malloc(sizeof(<%- arg.cType.replace('*', '') %>)); +<% } else { -%> + <%- arg.cType.replace('*', '') %><%- arg.name %> = NULL; +<% } -%> +<% } -%> +<% + for (var cArg = 0, jsArg = 0; cArg < functionInfo.args.length; cArg++) { + var arg = functionInfo.args[cArg]; + if (arg.isSelf || arg.isReturn || arg.isPayload) continue; +-%> +<% include convertFromV8.cc.ejs -%> +<% jsArg++; -%> +<% } %> + <% if (returns.length || functionInfo.return.isErrorCode) { %><%- functionInfo.return.cType %> result = <% } %><%- functionInfo.cFunctionName %>( +<% + for (var cArg = 0, jsArg = 0; cArg < functionInfo.args.length; cArg++) { + var arg = functionInfo.args[cArg]; +-%> + <% if (cArg > 0) { %>, <% } -%><% if (arg.isReturn && !arg.shouldAlloc) { %>&<% } -%> +<% if (arg.isSelf) { -%> +ObjectWrap::Unwrap<<%- cppClassName %>>(args.This())->GetValue() +<% } else if (arg.isReturn) { -%> +<%- arg.name %> +<% } else { -%> +from_<%- arg.name %> +<% } -%> +<% + if (!(arg.isReturn || arg.isSelf)) jsArg++; + } +-%> + ); +<% + for (var i = 0; i < functionInfo.args.length; i++) { + var arg = functionInfo.args[i]; + if (arg.isSelf || arg.isReturn) continue; +-%> +<% if (['String', 'Array'].indexOf(arg.cppClassName) > -1) { -%> +<% if (arg.freeFunctionName) { %> + <%- arg.freeFunctionName %>(from_<%- arg.name %>); +<% } else { -%> + free((void *)from_<%- arg.name %>); +<% } -%> +<% } -%> +<% } -%> +<% if (functionInfo.return.isErrorCode) { -%> + if (result != GIT_OK) { +<% + for (var i = 0; i < functionInfo.args.length; i++) { + var arg = functionInfo.args[i]; + if (!arg.shouldAlloc) continue; +-%> + free(<%= arg.name %>); +<% } -%> + if (giterr_last()) { + return ThrowException(Exception::Error(String::New(giterr_last()->message))); + } else { + return ThrowException(Exception::Error(String::New("Unkown Error"))); + } + } +<% } -%> + +<% if (!returns.length) { -%> + return Undefined(); +<% } else if (returns.length == 1) { -%> +<% var to = returns[0]; -%> + Handle to; + <% include convertToV8.cc.ejs -%> + return scope.Close(to); +<% } else { -%> + Handle toReturn = Object::New(); + Handle to; +<% + for (r in returns) { + var to = returns[r]; +-%> + <% include convertToV8.cc.ejs -%> + toReturn->Set(String::NewSymbol("<%- to.jsName || to.name %>"), to); + +<% } -%> + return scope.Close(toReturn); +<% } -%> +} diff --git a/test/blob.js b/test/blob.js new file mode 100644 index 000000000..b79adb69b --- /dev/null +++ b/test/blob.js @@ -0,0 +1,13 @@ +var git = require('../'), + path = require('path'); + +exports.content = function(test) { + var testOid = git.Oid.fromString('111dd657329797f6165f52f5085f61ac976dcf04'); + test.expect(1); + git.Repo.open(path.resolve('../.git'), function(err, repo) { + repo.getBlob(testOid, function(err, blob) { + test.equals(blob.toString().slice(0, 7), "@import"); + test.done(); + }); + }); +}; diff --git a/test/commit.js b/test/commit.js new file mode 100644 index 000000000..16515cd45 --- /dev/null +++ b/test/commit.js @@ -0,0 +1,242 @@ +var git = require('../'), + rimraf = require('rimraf'), + fs = require( 'fs' ); + +var historyCountKnownSHA = 'fce88902e66c72b5b93e75bdb5ae717038b221f6'; + +exports.message = function(test) { + test.expect(2); + git.Repo.open('../.git', function(error, repository) { + repository.getCommit(historyCountKnownSHA, function(error, commit) { + var message = commit.message(); + test.equals(error, null, 'There should be no error'); + test.equals(message, 'Update README.md', 'Message should match expected value'); + test.done(); + }); + }); +}; + +exports.sha = function(test) { + test.expect(2); + git.Repo.open('../.git', function(error, repository) { + repository.getCommit(historyCountKnownSHA, function(error, commit) { + var sha = commit.sha(); + test.equals(error, null, 'There should be no error'); + test.equals(sha, historyCountKnownSHA, 'SHA should match expected value'); + test.done(); + }); + }); +}; + +exports.time = function(test) { + test.expect(2); + git.Repo.open('../.git', function(error, repository) { + repository.getCommit(historyCountKnownSHA, function(error, commit) { + var time = commit.timeMs(); + test.equals(error, null, 'There should be no error'); + test.equals(time, 1362012884000, 'Time should match expected value'); + test.done(); + }); + }); +}; + +exports.date = function(test) { + test.expect(2); + git.Repo.open('../.git', function(error, repository) { + repository.getCommit(historyCountKnownSHA, function(error, commit) { + var date = commit.date(); + test.equals(error, null, 'There should be no error'); + test.equals(date.getTime(), 1362012884000, 'Date should match expected value'); + test.done(); + }); + }); +}; + +exports.offset = function(test) { + test.expect(2); + git.Repo.open('../.git', function(error, repository) { + repository.getCommit(historyCountKnownSHA, function(error, commit) { + var offset = commit.offset(); + test.equals(error, null, 'There should be no error'); + test.equals(offset, 780, 'Offset should match expected value'); + test.done(); + }); + }); +}; + +exports.author = function(test) { + test.expect(2); + git.Repo.open('../.git', function(error, repository) { + repository.getCommit(historyCountKnownSHA, function(error, commit) { + var author = commit.author(); + test.equals(error, null, 'There should be no error'); + test.notEqual(author, null, 'Author should not be null'); + test.done(); + }); + }); +}; + +exports.authorName = function(test) { + test.expect(1); + git.Repo.open('../.git', function(error, repository) { + repository.getCommit(historyCountKnownSHA, function(error, commit) { + var author = commit.author(); + var name = author.name(); + test.equals(name, 'Michael Robinson', 'The author name should match expected value'); + test.done(); + }); + }); +}; + +exports.authorEmail = function(test) { + test.expect(1); + git.Repo.open('../.git', function(error, repository) { + repository.getCommit(historyCountKnownSHA, function(error, commit) { + var author = commit.author(); + var email = author.email(); + test.equals(email, 'mike@panmedia.co.nz', 'The author email should match expected value'); + test.done(); + }); + }); +}; + +exports.committerName = function(test) { + test.expect(1); + git.Repo.open('../.git', function(error, repository) { + repository.getCommit(historyCountKnownSHA, function(error, commit) { + var committer = commit.committer(); + var name = committer.name(); + test.equals(name, 'Michael Robinson', 'The author name should match expected value'); + test.done(); + }); + }); +}; + +exports.committerEmail = function(test) { + test.expect(1); + git.Repo.open('../.git', function(error, repository) { + repository.getCommit(historyCountKnownSHA, function(error, commit) { + var committer = commit.committer(); + var email = committer.email(); + test.equals(email, 'mike@panmedia.co.nz', 'The committer email should match expected value'); + test.done(); + }); + }); +}; + +/** + * Test that improper commit ID's result in an error message + */ +exports.improperCommitId = function(test) { + test.expect(1); + git.Repo.open('../.git', function(error, repository) { + repository.getCommit('not a proper commit sha', function(error, commit) { + test.notEqual(error, null, 'Error should occur'); + test.done(); + }); + }); +}; + +/** + * Test that retreiving walking a given commit's history works as expected. + */ +exports.history = function(test) { + test.expect(4); + git.Repo.open('../.git', function(error, repository) { + repository.getCommit(historyCountKnownSHA, function(error, commit) { + test.equals(null, error, 'Getting latest branch commit should not error'); + var historyCount = 0; + var expectedHistoryCount = 364; + commit.history().on('commit', function(commit) { + historyCount++; + }).on('end', function(commits) { + test.equals(null, error, 'There should be no errors'); + test.equals(historyCount, expectedHistoryCount); + test.equals(commits.length, expectedHistoryCount); + test.done(); + }).on('error', function(error) { + test.equals(null, error, 'There should be no errors'); + test.ok(false, 'There should be no errors'); + }).start(); + }); + }); +}; + +/** + * Test that retreiving master branch's HEAD commit works as expected. + */ +exports.masterHead = function(test) { + test.expect(1); + git.Repo.open('../.git', function(error, repository) { + repository.getBranch('master', function(error, branch) { + var sha = branch.sha(); + repository.getCommit(sha, function(error, commit) { + test.equals(error, null, 'Getting latest branch commit should not error'); + test.done(); + }); + }); + }); +}; + +/** + * Test that retreiving parent works as expected. + * + * @param {Object} test + */ +exports.parents = function(test) { + test.expect(3); + git.Repo.open('../.git', function(error, repository) { + repository.getCommit(historyCountKnownSHA, function(error, commit) { + commit.getParents(function(error, parents) { + test.equals(parents.length, 1, 'Commit should have exactly one parent'); + var sha = parents[0].sha(); + test.equals(error, null, 'Getting parent SHA should not error'); + test.equals(sha, 'ecfd36c80a3e9081f200dfda2391acadb56dac27', 'Parent SHA should match expected value'); + test.done(); + }); + }); + }); +}; + +/** + * Test that retrieving and walking a commit's tree works as expected. + */ +exports.tree = function(test) { + test.expect(2); + git.Repo.open('../.git', function(error, repository) { + repository.getCommit(historyCountKnownSHA, function(error, commit) { + test.equals(error, null, 'Getting latest branch commit should not error'); + + var commitTreeEntryCount = 0; + var expectedCommitTreeEntryCount = 198; + commit.getTree(function(error, tree) { + tree.walk().on('entry', function(entry) { + commitTreeEntryCount++; + }).on('end', function(error, entries) { + test.equals(commitTreeEntryCount, expectedCommitTreeEntryCount, 'Commit tree entry count does not match expected'); + test.done(); + }).start(); + }); + }); + }); +}; + +/** + * Test that getDiff works as expected. + */ +exports.getDiff = function(test) { + test.expect(1); + git.Repo.open('../.git', function(error, repository) { + repository.getCommit(historyCountKnownSHA, function(error, commit) { + commit.getDiff(function(error, diff) { + test.equals(diff.length, 1, 'Should be one item in parents diff trees'); + test.done(); + }); + }); + }); +}; + +process.on('uncaughtException', function(err) { + console.log(err.stack); +}); + diff --git a/test/convenience-commit.js b/test/convenience-commit.js deleted file mode 100644 index 663ffe99d..000000000 --- a/test/convenience-commit.js +++ /dev/null @@ -1,289 +0,0 @@ -var git = require('../'), - rimraf = require('rimraf'), - fs = require( 'fs' ); - -var historyCountKnownSHA = 'fce88902e66c72b5b93e75bdb5ae717038b221f6'; - -// Helper functions -var helper = { - // Test if obj is a true function - testFunction: function(test, obj, label) { - // The object reports itself as a function - test(typeof obj, 'function', label + ' reports as a function.'); - // This ensures the repo is actually a derivative of the Function [[Class]] - test(toString.call(obj), '[object Function]', label + ' [[Class]] is of type function.'); - }, - // Test code and handle exception thrown - testException: function(test, fun, label) { - try { - fun(); - test(false, label); - } - catch (ex) { - test(true, label); - } - } -}; - -/** - * Test that the commit object is present. - */ -exports.method = function(test){ - test.expect(2); - helper.testFunction(test.equals, git.commit, 'Commmit'); - test.done(); -}; - -exports.message = function(test) { - test.expect(3); - git.repo('../.git', function(error, repository) { - repository.commit(historyCountKnownSHA, function(error, commit) { - commit.message(function(error, message) { - test.equals(error, null, 'There should be no error'); - test.notEqual(message, null, 'Message should not be null'); - test.equals(message, 'Update README.md', 'Message should match expected value'); - test.done(); - }); - }); - }); -}; - -exports.sha = function(test) { - test.expect(3); - git.repo('../.git', function(error, repository) { - repository.commit(historyCountKnownSHA, function(error, commit) { - commit.sha(function(error, sha) { - test.equals(error, null, 'There should be no error'); - test.notEqual(sha, null, 'SHA should not be null'); - test.equals(sha, historyCountKnownSHA, 'SHA should match expected value'); - test.done(); - }); - }); - }); -}; - -exports.time = function(test) { - test.expect(3); - git.repo('../.git', function(error, repository) { - repository.commit(historyCountKnownSHA, function(error, commit) { - commit.time(function(error, time) { - test.equals(error, null, 'There should be no error'); - test.notEqual(time, null, 'Time should not be null'); - test.equals(time, 1362012884000, 'Time should match expected value'); - test.done(); - }); - }); - }); -}; - -exports.date = function(test) { - test.expect(4); - git.repo('../.git', function(error, repository) { - repository.commit(historyCountKnownSHA, function(error, commit) { - commit.date(function(error, date) { - test.equals(error, null, 'There should be no error'); - test.notEqual(date, null, 'Date should not be null'); - test.equal(date instanceof Date, true, 'Date should be a date object'); - test.equals(date.getTime(), 1362012884000, 'Date should match expected value'); - test.done(); - }); - }); - }); -}; - -exports.offset = function(test) { - test.expect(3); - git.repo('../.git', function(error, repository) { - repository.commit(historyCountKnownSHA, function(error, commit) { - commit.offset(function(error, offset) { - test.equals(error, null, 'There should be no error'); - test.notEqual(offset, null, 'Offset should not be null'); - test.equals(offset, 780, 'Offset should match expected value'); - test.done(); - }); - }); - }); -}; - -exports.author = function(test) { - test.expect(2); - git.repo('../.git', function(error, repository) { - repository.commit(historyCountKnownSHA, function(error, commit) { - commit.author(function(error, author) { - test.equals(error, null, 'There should be no error'); - test.notEqual(author, null, 'Author should not be null'); - test.done(); - }); - }); - }); -}; - -exports.authorName = function(test) { - test.expect(1); - git.repo('../.git', function(error, repository) { - repository.commit(historyCountKnownSHA, function(error, commit) { - commit.author(function commitAuthor(error, author) { - author.name(function authorName(error, name) { - test.equals(name, 'Michael Robinson', 'The author name should match expected value'); - test.done(); - }); - }); - }); - }); -}; - -exports.authorEmail = function(test) { - test.expect(1); - git.repo('../.git', function(error, repository) { - repository.commit(historyCountKnownSHA, function(error, commit) { - commit.author(function commitAuthor(error, author) { - author.email(function authorName(error, email) { - test.equals(email, 'mike@panmedia.co.nz', 'The author email should match expected value'); - test.done(); - }); - }); - }); - }); -}; - -exports.committerName = function(test) { - test.expect(1); - git.repo('../.git', function(error, repository) { - repository.commit(historyCountKnownSHA, function(error, commit) { - commit.committer(function commitCommitter(error, committer) { - committer.name(function committerName(error, name) { - test.equals(name, 'Michael Robinson', 'The author name should match expected value'); - test.done(); - }); - }); - }); - }); -}; - -exports.committerEmail = function(test) { - test.expect(1); - git.repo('../.git', function(error, repository) { - repository.commit(historyCountKnownSHA, function(error, commit) { - commit.committer(function commitCommitter(error, committer) { - committer.email(function committerName(error, email) { - test.equals(email, 'mike@panmedia.co.nz', 'The committer email should match expected value'); - test.done(); - }); - }); - }); - }); -}; - -/** - * Test that improper commit ID's result in an error message - */ -exports.improperCommitId = function(test) { - test.expect(1); - git.repo('../.git', function(error, repository) { - repository.commit('not a proper commit sha', function(error, commit) { - test.notEqual(error, null, 'Error should occur'); - test.done(); - }); - }); -}; - -/** - * Test that retreiving walking a given commit's history works as expected. - */ -exports.history = function(test) { - test.expect(368); - git.repo('../.git', function(error, repository) { - repository.commit(historyCountKnownSHA, function(error, commit) { - test.equals(null, error, 'Getting latest branch commit should not error'); - var historyCount = 0; - var expectedHistoryCount = 364; - commit.history().on('commit', function(error, commit) { - test.equals(null, error, 'There should be no errors'); - historyCount++; - }).on('end', function(error, commits) { - test.equals(null, error, 'There should be no errors'); - test.equals(historyCount, expectedHistoryCount, 'Manual count does not match expected'); - test.equals(commits.length, expectedHistoryCount, '"end" count does not match expected'); - test.done(); - }); - }); - }); -}; - -/** - * Test that retreiving master branch's HEAD commit works as expected. - */ -exports.masterHead = function(test) { - test.expect(2); - git.repo('../.git', function(error, repository) { - repository.branch('master', function(error, branch) { - test.equals(error, null, 'Getting branch should not error'); - branch.sha(function(error, sha) { - repository.commit(sha, function(error, commit) { - test.equals(error, null, 'Getting latest branch commit should not error'); - test.done(); - }); - }); - }); - }); -}; - -/** - * Test that retreiving parent works as expected. - * - * @param {Object} test - */ -exports.parents = function(test) { - test.expect(3); - git.repo('../.git', function(error, repository) { - repository.commit(historyCountKnownSHA, function(error, commit) { - commit.parents(function(error, parents) { - test.equals(parents.length, 1, 'Commit should have exactly one parent'); - parents[0].sha(function parentSha(error, sha) { - test.equals(error, null, 'Getting parent SHA should not error'); - test.equals(sha, 'ecfd36c80a3e9081f200dfda2391acadb56dac27', 'Parent SHA should match expected value'); - test.done(); - }); - }); - }); - }); -}; - -/** - * Test that retrieving and walking a commit's tree works as expected. - */ -exports.tree = function(test) { - test.expect(2); - git.repo('../.git', function(error, repository) { - repository.commit(historyCountKnownSHA, function(error, commit) { - test.equals(error, null, 'Getting latest branch commit should not error'); - - var commitTreeEntryCount = 0; - var expectedCommitTreeEntryCount = 198; - - commit.tree(function commitTree(error, tree) { - tree.walk().on('entry', function(error, entry) { - commitTreeEntryCount++; - }).on('end', function(error, entries) { - test.equals(commitTreeEntryCount, expectedCommitTreeEntryCount, 'Commit tree entry count does not match expected'); - test.done(); - }); - }); - }); - }); -}; - -/** - * Test that parentsDiffTrees works as expected. - */ -exports.parentsDiffTrees = function(test) { - test.expect(1); - git.repo('../.git', function(error, repository) { - repository.commit(historyCountKnownSHA, function(error, commit) { - commit.parentsDiffTrees(function(error, parentsDiffTrees) { - test.equals(parentsDiffTrees.length, 1, 'Should be one item in parents diff trees'); - test.done(); - }); - }); - }); -}; diff --git a/test/convenience-difflist.js b/test/convenience-difflist.js deleted file mode 100644 index c010691c1..000000000 --- a/test/convenience-difflist.js +++ /dev/null @@ -1,124 +0,0 @@ -var git = require('../'), - rimraf = require('rimraf'), - fs = require( 'fs' ); - -var historyCountKnownSHA = 'fce88902e66c72b5b93e75bdb5ae717038b221f6'; - -// Helper functions -var helper = { - // Test if obj is a true function - testFunction: function(test, obj, label) { - // The object reports itself as a function - test(typeof obj, 'function', label + ' reports as a function.'); - // This ensures the repo is actually a derivative of the Function [[Class]] - test(toString.call(obj), '[object Function]', label + ' [[Class]] is of type function.'); - }, - // Test code and handle exception thrown - testException: function(test, fun, label) { - try { - fun(); - test(false, label); - } - catch (ex) { - test(true, label); - } - } -}; - -/** - * Test that the commit object is present. - */ -exports.method = function(test){ - test.expect(2); - helper.testFunction(test.equals, git.diffList, 'DiffList'); - test.done(); -}; - -/** - * Test that retreiving parent works as expected. - * - * @param {Object} test - */ -exports.walkingDiffs = function(test) { - test.expect(15); - git.repo('../.git', function(error, repository) { - repository.commit(historyCountKnownSHA, function(error, commit) { - commit.parents(function(error, parents) { - parents[0].sha(function(error, parentSha) { - (new git.diffList(commit.rawRepo)).treeToTree(parentSha, historyCountKnownSHA, function(error, diffList) { - test.equal(null, error, 'Should not error'); - diffList.walk().on('delta', function(error, delta) { - test.equal(null, error, 'Should not error'); - test.equal(delta.oldFile.path, 'README.md', 'Old file path should match expected'); - test.equal(delta.newFile.path, 'README.md', 'New file path should match expected'); - test.equal(delta.content.length, 5, 'Content array should be of known length'); - test.equal(delta.status, diffList.deltaTypes.GIT_DELTA_MODIFIED, 'Status should be known type'); - test.equal(delta.content[0].lineOrigin, diffList.lineOriginTypes.GIT_DIFF_LINE_CONTEXT, 'First content item should be context'); - test.equal(delta.content[1].lineOrigin, diffList.lineOriginTypes.GIT_DIFF_LINE_CONTEXT, 'Second content item should be context'); - test.equal(delta.content[2].lineOrigin, diffList.lineOriginTypes.GIT_DIFF_LINE_CONTEXT, 'Third content item should be context'); - - var oldContent = '__Before submitting a pull request, please ensure both unit tests and lint checks pass.__\n'; - test.equal(delta.content[3].content, oldContent, 'Old content should match known value'); - test.equal(delta.content[3].lineOrigin, diffList.lineOriginTypes.GIT_DIFF_LINE_DELETION, 'Fourth content item should be deletion'); - test.equal(delta.content[3].contentLength, 90, 'Fourth content length should match known value'); - - var newContent = '__Before submitting a pull request, please ensure both that you\'ve added unit tests to cover your shiny new code, and that all unit tests and lint checks pass.__\n'; - test.equal(delta.content[4].content, newContent, 'New content should match known value'); - test.equal(delta.content[4].lineOrigin, diffList.lineOriginTypes.GIT_DIFF_LINE_ADDITION, 'Fifth content item should be addition'); - test.equal(delta.content[4].contentLength, 162, 'Fifth content length should match known value'); - test.done(); - }); - }); - }); - }); - }); - }); -}; - -exports.walkingEnd = function(test) { - test.expect(2); - git.repo('../.git', function(error, repository) { - repository.commit(historyCountKnownSHA, function(error, commit) { - commit.parents(function(error, parents) { - parents[0].sha(function(error, parentSha) { - (new git.diffList(commit.rawRepo)).treeToTree(parentSha, historyCountKnownSHA, function(error, diffList) { - diffList.walk().on('end', function(error, diffs) { - test.equal(null, error, 'Should not error'); - test.equal(diffs.length, 1, 'Diffs array should be of known length'); - test.done(); - }); - }); - }); - }); - }); - }); -}; - -exports.deltaTypes = function(test) { - test.expect(9); - var diffList = new git.diffList((new git.repo()).rawRepo); - test.equal(diffList.deltaTypes.GIT_DELTA_UNMODIFIED, git.raw.DiffList.deltaTypes.GIT_DELTA_UNMODIFIED, 'GIT_DELTA_UNMODIFIED delta type should match expected value'); - test.equal(diffList.deltaTypes.GIT_DELTA_ADDED, git.raw.DiffList.deltaTypes.GIT_DELTA_ADDED, 'GIT_DELTA_ADDED delta type should match expected value'); - test.equal(diffList.deltaTypes.GIT_DELTA_DELETED, git.raw.DiffList.deltaTypes.GIT_DELTA_DELETED, 'GIT_DELTA_DELETED delta type should match expected value'); - test.equal(diffList.deltaTypes.GIT_DELTA_MODIFIED, git.raw.DiffList.deltaTypes.GIT_DELTA_MODIFIED, 'GIT_DELTA_MODIFIED delta type should match expected value'); - test.equal(diffList.deltaTypes.GIT_DELTA_RENAMED, git.raw.DiffList.deltaTypes.GIT_DELTA_RENAMED, 'GIT_DELTA_RENAMED delta type should match expected value'); - test.equal(diffList.deltaTypes.GIT_DELTA_COPIED, git.raw.DiffList.deltaTypes.GIT_DELTA_COPIED, 'GIT_DELTA_COPIED delta type should match expected value'); - test.equal(diffList.deltaTypes.GIT_DELTA_IGNORED, git.raw.DiffList.deltaTypes.GIT_DELTA_IGNORED, 'GIT_DELTA_IGNORED delta type should match expected value'); - test.equal(diffList.deltaTypes.GIT_DELTA_UNTRACKED, git.raw.DiffList.deltaTypes.GIT_DELTA_UNTRACKED, 'GIT_DELTA_UNTRACKED delta type should match expected value'); - test.equal(diffList.deltaTypes.GIT_DELTA_TYPECHANGE, git.raw.DiffList.deltaTypes.GIT_DELTA_TYPECHANGE, 'GIT_DELTA_TYPECHANGE delta type should match expected value'); - test.done(); -}; - -exports.lineOriginTypes = function(test) { - test.expect(8); - var diffList = new git.diffList((new git.repo()).rawRepo); - test.equal(diffList.lineOriginTypes.GIT_DIFF_LINE_CONTEXT, git.raw.DiffList.lineOriginTypes.GIT_DIFF_LINE_CONTEXT, 'GIT_DIFF_LINE_CONTEXT line origin type should match expected value'); - test.equal(diffList.lineOriginTypes.GIT_DIFF_LINE_ADDITION, git.raw.DiffList.lineOriginTypes.GIT_DIFF_LINE_ADDITION, 'GIT_DIFF_LINE_ADDITION line origin type should match expected value'); - test.equal(diffList.lineOriginTypes.GIT_DIFF_LINE_DELETION, git.raw.DiffList.lineOriginTypes.GIT_DIFF_LINE_DELETION, 'GIT_DIFF_LINE_DELETION line origin type should match expected value'); - test.equal(diffList.lineOriginTypes.GIT_DIFF_LINE_ADD_EOFNL, git.raw.DiffList.lineOriginTypes.GIT_DIFF_LINE_ADD_EOFNL, 'GIT_DIFF_LINE_ADD_EOFNL line origin type should match expected value'); - test.equal(diffList.lineOriginTypes.GIT_DIFF_LINE_DEL_EOFNL, git.raw.DiffList.lineOriginTypes.GIT_DIFF_LINE_DEL_EOFNL, 'GIT_DIFF_LINE_DEL_EOFNL line origin type should match expected value'); - test.equal(diffList.lineOriginTypes.GIT_DIFF_LINE_FILE_HDR, git.raw.DiffList.lineOriginTypes.GIT_DIFF_LINE_FILE_HDR, 'GIT_DIFF_LINE_FILE_HDR line origin type should match expected value'); - test.equal(diffList.lineOriginTypes.GIT_DIFF_LINE_HUNK_HDR, git.raw.DiffList.lineOriginTypes.GIT_DIFF_LINE_HUNK_HDR, 'GIT_DIFF_LINE_HUNK_HDR line origin type should match expected value'); - test.equal(diffList.lineOriginTypes.GIT_DIFF_LINE_BINARY, git.raw.DiffList.lineOriginTypes.GIT_DIFF_LINE_BINARY, 'GIT_DIFF_LINE_BINARY line origin type should match expected value'); - test.done(); -}; diff --git a/test/convenience-entry.js b/test/convenience-entry.js deleted file mode 100644 index f24068a7a..000000000 --- a/test/convenience-entry.js +++ /dev/null @@ -1,123 +0,0 @@ -var git = require('../'); - -var sha = '5716e9757886eaf38d51c86b192258c960d9cfea'; - -var getEntry = function(path, callback) { - git.repo('../.git', function(error, repo) { - repo.commit(sha, function(error, commit) { - commit.file(path, function(error, entry) { - callback(error, entry); - }); - }); - }); -}; - -exports.missingFile = function(test) { - test.expect(1); - - getEntry('test/convenience-entry.js', function(error, entry) { - test.notEqual(error, null, 'Missing file should error'); - test.done(); - }); -}; - -exports.sha = function(test) { - test.expect(1); - getEntry('README.md', function(error, entry) { - entry.sha(function(error, sha) { - test.equal(sha, '6cb45ba5d32532bf0d1310dc31ca4f20f59964bc', 'Entry SHA should match expected value'); - test.done(); - }); - }); -}; - -exports.isFile = function(test) { - test.expect(2); - getEntry('README.md', function(error, entry) { - entry.isFile(function(error, isFile) { - test.equal(isFile, true, 'Entry is a file'); - getEntry('example', function(error, entry) { - entry.isFile(function(error, isFile) { - test.equal(isFile, false, 'Entry is a directory'); - test.done(); - }); - }); - }); - }); -}; - -exports.isDirectory = function(test) { - test.expect(2); - getEntry('example', function(error, entry) { - entry.isFile(function(error, isFile) { - test.equal(isFile, false, 'Entry is a directory'); - getEntry('README.md', function(error, entry) { - entry.isFile(function(error, isFile) { - test.equal(isFile, true, 'Entry is a file'); - test.done(); - }); - }); - }); - }); -}; - -exports.name = function(test) { - test.expect(2); - getEntry('test/raw-commit.js', function(error, entry) { - test.equal(error, null, 'Should not error'); - entry.name(function(error, name) { - test.equal(name, 'raw-commit.js', 'Name should match expected value'); - test.done(); - }); - }); -}; - -exports.root = function(test) { - test.expect(1); - getEntry('test/raw-commit.js', function(error, entry) { - entry.root(function(error, root) { - test.equal(root, 'test', 'Root should match expected value'); - test.done(); - }); - }); -}; - -exports.path = function(test) { - test.expect(1); - getEntry('test/raw-commit.js', function(error, entry) { - entry.path(function(error, path) { - test.equal(path, 'test/raw-commit.js', 'Path should match expected value'); - test.done(); - }); - }); -}; - -exports.content = function(test) { - test.expect(1); - getEntry('test/raw-commit.js', function(error, entry) { - entry.content(function(error, content) { - test.equal(content.length, 2736, 'Content length should match expected value'); - test.done(); - }); - }); -}; - -exports.toBlob = function(test) { - test.expect(1); - getEntry('test/raw-commit.js', function(error, entry) { - entry.toBlob(function(error, blob) { - test.equal(blob instanceof git.blob, true, 'Expected instance of Blob'); - test.done(); - }); - }); -}; - -exports.tree = function(test) { - test.expect(1); - getEntry('test', function(error, entry) { - entry.tree(function(error, tree) { - test.equal(tree instanceof git.tree, true, 'Expected instance of Tree'); - test.done(); - }); - }); -}; diff --git a/test/convenience-error.js b/test/convenience-error.js deleted file mode 100644 index 38393dffa..000000000 --- a/test/convenience-error.js +++ /dev/null @@ -1,85 +0,0 @@ -var git = require('../'), - rimraf = require('rimraf'), - fs = require( 'fs' ); - -// Helper functions -var helper = { - // Test if obj is a true function - testFunction: function(test, obj, label) { - // The object reports itself as a function - test(typeof obj, 'function', label + ' reports as a function.'); - // This ensures the repo is actually a derivative of the Function [[Class]] - test(toString.call(obj), '[object Function]', label + ' [[Class]] is of type function.'); - }, - // Test code and handle exception thrown - testException: function(test, fun, label) { - try { - fun(); - test(false, label); - } - catch (ex) { - test(true, label); - } - } -}; - -/** - * Test that the error object is present. - * - * @param {Object} test - */ -exports.method = function(test){ - test.expect(2); - helper.testFunction(test.equals, git.error, 'Error'); - test.done(); -}; - -exports.codes = function(test) { - test.expect(14); - var error = new git.error(); - test.equal(error.codes.GITERR_NOMEMORY, git.raw.Error.codes.GITERR_NOMEMORY, 'GITERR_NOMEMORY code should match expected value'); - test.equal(error.codes.GITERR_OS, git.raw.Error.codes.GITERR_OS, 'GITERR_OS code should match expected value'); - test.equal(error.codes.GITERR_INVALID, git.raw.Error.codes.GITERR_INVALID, 'GITERR_INVALID code should match expected value'); - test.equal(error.codes.GITERR_REFERENCE, git.raw.Error.codes.GITERR_REFERENCE, 'GITERR_REFERENCE code should match expected value'); - test.equal(error.codes.GITERR_ZLIB, git.raw.Error.codes.GITERR_ZLIB, 'GITERR_ZLIB code should match expected value'); - test.equal(error.codes.GITERR_REPOSITORY, git.raw.Error.codes.GITERR_REPOSITORY, 'GITERR_REPOSITORY code should match expected value'); - test.equal(error.codes.GITERR_CONFIG, git.raw.Error.codes.GITERR_CONFIG, 'GITERR_CONFIG code should match expected value'); - test.equal(error.codes.GITERR_REGEX, git.raw.Error.codes.GITERR_REGEX, 'GITERR_REGEX code should match expected value'); - test.equal(error.codes.GITERR_ODB, git.raw.Error.codes.GITERR_ODB, 'GITERR_ODB code should match expected value'); - test.equal(error.codes.GITERR_INDEX, git.raw.Error.codes.GITERR_INDEX, 'GITERR_INDEX code should match expected value'); - test.equal(error.codes.GITERR_OBJECT, git.raw.Error.codes.GITERR_OBJECT, 'GITERR_OBJECT code should match expected value'); - test.equal(error.codes.GITERR_NET, git.raw.Error.codes.GITERR_NET, 'GITERR_NET code should match expected value'); - test.equal(error.codes.GITERR_TAG, git.raw.Error.codes.GITERR_TAG, 'GITERR_TAG code should match expected value'); - test.equal(error.codes.GITERR_TREE, git.raw.Error.codes.GITERR_TREE, 'GITERR_TREE code should match expected value'); - test.done(); -}; - -exports.returnCodes = function(test) { - test.expect(8); - var error = new git.error(); - test.equal(error.returnCodes.GIT_OK, git.raw.Error.returnCodes.GIT_OK, 'GIT_OK return code should match expected value'); - test.equal(error.returnCodes.GIT_ERROR, git.raw.Error.returnCodes.GIT_ERROR, 'GIT_ERROR return code should match expected value'); - test.equal(error.returnCodes.GIT_ENOTFOUND, git.raw.Error.returnCodes.GIT_ENOTFOUND, 'GIT_ENOTFOUND return code should match expected value'); - test.equal(error.returnCodes.GIT_EEXISTS, git.raw.Error.returnCodes.GIT_EEXISTS, 'GIT_EEXISTS return code should match expected value'); - test.equal(error.returnCodes.GIT_EAMBIGUOUS, git.raw.Error.returnCodes.GIT_EAMBIGUOUS, 'GIT_EAMBIGUOUS return code should match expected value'); - test.equal(error.returnCodes.GIT_EBUFS, git.raw.Error.returnCodes.GIT_EBUFS, 'GIT_EBUFS return code should match expected value'); - test.equal(error.returnCodes.GIT_PASSTHROUGH, git.raw.Error.returnCodes.GIT_PASSTHROUGH, 'GIT_PASSTHROUGH return code should match expected value'); - test.equal(error.returnCodes.GIT_ITEROVER, git.raw.Error.returnCodes.GIT_ITEROVER, 'GIT_ITEROVER return code should match expected value'); - test.done(); -}; - -/** - * Test that - * - * @param {Object} test - */ -exports.improperCommitId = function(test) { - test.expect(1); - git.repo('../.git', function(error, repository) { - repository.commit('not a proper commit sha', function(error, commit) { - test.notEqual(error.code, git.error.GIT_SUCCESS, 'Attempting to get commit by invalid SHA should error'); - test.done(); - }); - }); -}; - diff --git a/test/convenience-oid.js b/test/convenience-oid.js deleted file mode 100644 index 91f359370..000000000 --- a/test/convenience-oid.js +++ /dev/null @@ -1,49 +0,0 @@ -var git = require('../'); - -// Helper functions -var helper = { - // Test if obj is a true function - testFunction: function(test, obj, label) { - // The object reports itself as a function - test(typeof obj, 'function', label + ' reports as a function.'); - // This ensures the repo is actually a derivative of the Function [[Class]] - test(toString.call(obj), '[object Function]', label + ' [[Class]] is of type function.'); - }, - // Test code and handle exception thrown - testException: function(test, fun, label) { - try { - fun(); - test(false, label); - } - catch (ex) { - test(true, label); - } - } -}; - -exports.method = function(test){ - test.expect(2); - helper.testFunction(test.equals, git.commit, 'Oid'); - test.done(); -}; - -var knownSha = 'fce88902e66c72b5b93e75bdb5ae717038b221f6'; - -exports.fromString = function(test) { - test.expect(1); - (new git.oid()).fromString(knownSha, function(error, oid) { - test.equal(error, null, 'Should not error'); - test.done(); - }); -}; - -exports.sha = function(test) { - test.expect(2); - (new git.oid()).fromString(knownSha, function(error, oid) { - oid.sha(function(error, sha) { - test.equal(error, null, 'Should not error'); - test.equal(sha, knownSha, 'SHA should match known value'); - test.done(); - }); - }); -}; diff --git a/test/convenience-repo.js b/test/convenience-repo.js deleted file mode 100644 index d01f7ec72..000000000 --- a/test/convenience-repo.js +++ /dev/null @@ -1,85 +0,0 @@ -var git = require('../'), - rimraf = require('rimraf'), - fs = require( 'fs' ); - -// Helper functions -var helper = { - // Test if obj is a true function - testFunction: function(test, obj, label) { - // The object reports itself as a function - test(typeof obj, 'function', label + ' reports as a function.'); - // This ensures the repo is actually a derivative of the Function [[Class]] - test(toString.call(obj), '[object Function]', label + ' [[Class]] is of type function.'); - }, - // Test code and handle exception thrown - testException: function(test, fun, label) { - try { - fun(); - test(false, label); - } catch (ex) { - test(true, label); - } - } -}; - -/** - * Repo - * Ensure the repo method can handle opening repositories with async/sync - * signatures properly. - */ -exports.method = function(test){ - test.expect(5); - - helper.testFunction(test.equals, git.repo, 'Repo'); - - // Test callback argument existence - helper.testException(test.ok, function() { - git.repo('some/path'); - }, 'Throw an exception if no callback'); - - // Test invalid repository - git.repo('/etc/hosts', function(error, repository) { - test.equals(error.code, error.codes.GITERR_REPOSITORY, error.message, 'Invalid repository error code'); - - // Test valid repository - git.repo('../.git', function(error, repository) { - test.equals(null, error, 'Valid repository error code'); - test.done(); - }); - }); -}; - -/** - * Ensure repo doesn't attempt to open missing directories - */ -exports.nonexistentDirectory = function(test) { - test.expect(2); - git.repo('/surely/this/directory/does/not/exist/on/this/machine', function(error, repository) { - test.notEqual(error, null, 'Attempting to open a nonexistent directory should error'); - test.equals(repository, null, 'Non existent directory should result in null repository'); - test.done(); - }); -}; - -/** - * Ensure the init method can create repositories at the destination path and - * can create either bare/non-bare. - */ -exports.init = function(test) { - test.expect(2); - - // Cleanup, remove test repo directory - if it exists - rimraf('./test.git', function() { - // Create bare repo and test for creation - git.repo().init('./test.git', true, function(error, path, isBare) { - test.equals(null, error, 'Successfully created bare repository'); - // Verify repo exists - git.repo('./test.git', function(error, path, repo) { - test.equals(null, error, 'Valid repository created'); - - // Cleanup, remove test repo directory - rimraf('./test.git', test.done); - }); - }); - }); -}; diff --git a/test/convenience-tree.js b/test/convenience-tree.js deleted file mode 100644 index 813fa3d8c..000000000 --- a/test/convenience-tree.js +++ /dev/null @@ -1,27 +0,0 @@ -var git = require('../'), - rimraf = require('rimraf'), - fs = require('fs'); - -var sha = '5716e9757886eaf38d51c86b192258c960d9cfea'; -var fileCount = 512; // Number of blob & blob executabless - -exports.walk = function(test) { - test.expect(515); - - git.repo('../.git', function(error, repo) { - repo.commit(sha, function(error, commit) { - var entryCount = 0; - commit.tree(function(error, tree) { - tree.walk().on('entry', function(error, index, entry) { - test.equals(error, null, 'There should be no error'); - entryCount++; - }).on('end', function(error, entries) { - test.equals(error, null, 'There should be no error'); - test.equals(entryCount, fileCount, 'The manual tree entry count and the "end" tree entry count do not match'); - test.equals(entries.length, fileCount, 'The end entries count and the manual entry count do not match'); - test.done(); - }); - }); - }); - }); -}; diff --git a/test/difflist.js b/test/difflist.js new file mode 100644 index 000000000..6815e2d82 --- /dev/null +++ b/test/difflist.js @@ -0,0 +1,49 @@ +var git = require('../'), + rimraf = require('rimraf'), + fs = require( 'fs' ); + +var historyCountKnownSHA = 'fce88902e66c72b5b93e75bdb5ae717038b221f6'; + +/** + * Test that retreiving parent works as expected. + * + * @param {Object} test + */ +exports.walkingDiffs = function(test) { + test.expect(16); + git.Repo.open('../.git', function(error, repository) { + repository.getCommit(historyCountKnownSHA, function(error, commit) { + commit.getDiff(function(error, diffList) { + test.equal(null, error, 'Should not error'); + + diffList[0].patches().forEach(function(patch) { + test.equal(null, error, 'Should not error'); + + test.equal(patch.oldFile().path(), 'README.md', 'Old file path should match expected'); + test.equal(patch.newFile().path(), 'README.md', 'New file path should match expected'); + test.equal(patch.size(), 1, 'Content array should be of known length'); + test.ok(patch.isModified(), 'Status should be known type'); + + var hunk = patch.hunks()[0]; + test.equal(hunk.size(), 5, 'Content array should be of known length'); + var lines = hunk.lines(); + + test.equal(lines[0].lineOrigin, git.DiffList.LineOrigin.Context, 'First content item should be context'); + test.equal(lines[1].lineOrigin, git.DiffList.LineOrigin.Context, 'Second content item should be context'); + test.equal(lines[2].lineOrigin, git.DiffList.LineOrigin.Context, 'Third content item should be context'); + + var oldContent = '__Before submitting a pull request, please ensure both unit tests and lint checks pass.__\n'; + test.equal(lines[3].content, oldContent, 'Old content should match known value'); + test.equal(lines[3].lineOrigin, git.DiffList.LineOrigin.Deletion, 'Fourth content item should be deletion'); + test.equal(lines[3].length, 90, 'Fourth content length should match known value'); + + var newContent = '__Before submitting a pull request, please ensure both that you\'ve added unit tests to cover your shiny new code, and that all unit tests and lint checks pass.__\n'; + test.equal(lines[4].content, newContent, 'New content should match known value'); + test.equal(lines[4].lineOrigin, git.DiffList.LineOrigin.Addition, 'Fifth content item should be addition'); + test.equal(lines[4].length, 162, 'Fifth content length should match known value'); + test.done(); + }); + }); + }); + }); +}; diff --git a/test/npm-debug.log b/test/npm-debug.log new file mode 100644 index 000000000..b7d4604cd --- /dev/null +++ b/test/npm-debug.log @@ -0,0 +1,19 @@ +0 info it worked if it ends with ok +1 verbose cli [ 'node', '/usr/local/bin/npm', 'run-script', 'gen' ] +2 info using npm@1.2.28 +3 info using node@v0.10.10 +4 verbose read json /Users/nkallen/Workspace/nodegit/test/package.json +5 error Error: ENOENT, open '/Users/nkallen/Workspace/nodegit/test/package.json' +6 error If you need help, you may report this log at: +6 error +6 error or email it to: +6 error +7 error System Darwin 12.3.0 +8 error command "node" "/usr/local/bin/npm" "run-script" "gen" +9 error cwd /Users/nkallen/Workspace/nodegit/test +10 error node -v v0.10.10 +11 error npm -v 1.2.28 +12 error path /Users/nkallen/Workspace/nodegit/test/package.json +13 error code ENOENT +14 error errno 34 +15 verbose exit [ 34, true ] diff --git a/test/oid.js b/test/oid.js new file mode 100644 index 000000000..3ce3d48d1 --- /dev/null +++ b/test/oid.js @@ -0,0 +1,10 @@ +var git = require('../'); + +var knownSha = 'fce88902e66c72b5b93e75bdb5ae717038b221f6'; + +exports.fromStringAndSha = function(test) { + test.expect(1); + var oid = git.Oid.fromString(knownSha); + test.equal(oid.sha(), knownSha, 'SHA should match known value'); + test.done(); +}; diff --git a/test/raw-blob.js b/test/raw-blob.js deleted file mode 100644 index 583c5bb14..000000000 --- a/test/raw-blob.js +++ /dev/null @@ -1,120 +0,0 @@ -var git = require('../').raw, - path = require('path'), - rimraf = require('rimraf'); - -var testRepo = new git.Repo(); - -var helper = { - // Test if obj is a true function - testFunction: function(test, obj, label) { - // The object reports itself as a function - test(typeof obj, 'function', label +' reports as a function.'); - // This ensures the repo is actually a derivative of the Function [[Class]] - test(toString.call(obj), '[object Function]', label +' [[Class]] is of type function.'); - }, - // Test code and handle exception thrown - testException: function(test, fun, label) { - try { - fun(); - test(false, label); - } - catch (ex) { - test(true, label); - } - } -}; - -/** - * Blob constructor - */ -exports.constructor = function(test){ - test.expect(3); - helper.testFunction(test.equals, git.Blob, 'Blob'); - test.ok(new git.Blob() instanceof git.Blob, 'Invocation returns an instance of Blob'); - test.done(); -}; - -// Blob::Lookup -exports.lookup = function(test) { - var testOid = new git.Oid(), - testRef = new git.Reference(testRepo), - testBlob = new git.Blob(); - - test.expect(5); - - // Test for function - helper.testFunction(test.equals, testBlob.lookup, 'Blob::Lookup'); - - // Test repo argument existence - helper.testException(test.ok, function() { - testBlob.lookup(); - }, 'Throw an exception if no repo Object'); - - // Test Oid argument existence - helper.testException(test.ok, function() { - testBlob.lookup(testRepo); - }, 'Throw an exception if no oid Object'); - - // Test Callback argument existence - helper.testException(test.ok, function() { - testBlob.lookup(testRepo, testOid); - }, 'Throw an exception if no callback Object'); - - testRepo.open(path.resolve('../.git'), function() { - // @todo actually lookup - test.done(); - }); -}; - -// Blob::RawContent -exports.rawContent = function(test) { - var testOid = new git.Oid(), - testBlob = new git.Blob(), - testCommit = new git.Commit(); - - test.expect(2); - - // Test for function - helper.testFunction(test.equals, testBlob.rawContent, 'Blob::RawContent'); - - test.done(); -}; - -// Blob::Free -exports.free = function(test) { - var testOid = new git.Oid(), - testBlob = new git.Blob(); - - test.expect(2); - - // Test for function - helper.testFunction(test.equals, testBlob.free, 'Blob::Free'); - - test.done(); -}; - -// Blob::CreateFromFile -exports.createFromFile = function(test) { - var testOid = new git.Oid(), - testBlob = new git.Blob(); - - test.expect(2); - - // Test for function - helper.testFunction(test.equals, testBlob.createFromFile, 'Blob::CreateFromFile'); - - test.done(); -}; - -// Blob::CreateFromBuffer -exports.createFromBuffer = function(test) { - var testOid = new git.Oid(), - testBlob = new git.Blob(); - - test.expect(2); - - // Test for function - helper.testFunction(test.equals, testBlob.createFromBuffer, 'Blob::CreateFromBuffer'); - - test.done(); -}; diff --git a/test/raw-commit.js b/test/raw-commit.js deleted file mode 100644 index 058ed52eb..000000000 --- a/test/raw-commit.js +++ /dev/null @@ -1,86 +0,0 @@ -var git = require('../').raw; - -var testRepo = new git.Repo(); - -var helper = { - // Test if obj is a true function - testFunction: function(test, obj, label) { - // The object reports itself as a function - test(typeof obj, 'function', label +' reports as a function.'); - // This ensures the repo is actually a derivative of the Function [[Class]] - test(toString.call(obj), '[object Function]', label +' [[Class]] is of type function.'); - }, - // Test code and handle exception thrown - testException: function(test, fun, label) { - try { - fun(); - test(false, label); - } - catch (ex) { - test(true, label); - } - } -}; - -/** - * Commit - */ -exports.constructor = function(test){ - test.expect(3); - - // Test for function - helper.testFunction(test.equals, git.Commit, 'Commit'); - - testRepo.open('../.git', function(err) { - // Ensure we get an instance of Commit - test.ok(new git.Commit(testRepo) instanceof git.Commit, 'Invocation returns an instance of Commit'); - - test.done(); - }); -}; - -/** - * Commit::Lookup - */ -exports.lookup = function(test) { - test.expect(7); - - var testOid = new git.Oid(), - testCommit = new git.Commit(); - - // Test for function - helper.testFunction(test.equals, testCommit.lookup, 'Commit::Lookup'); - - testOid.fromString('cb09e99e91d41705197e0fb60823fdc7df776691', function(error, testOid) { - - // Test repo argument existence - helper.testException(test.ok, function() { - testCommit.lookup(); - }, 'Throw an exception if no repo'); - - // Test oid argument existence - helper.testException(test.ok, function() { - testCommit.lookup(testRepo); - }, 'Throw an exception if no oid'); - - // Test callback argument existence - helper.testException(test.ok, function() { - testCommit.lookup(testOid); - }, 'Throw an exception if no callback'); - - // Test that all arguments result correctly - helper.testException(test.ifError, function() { - testCommit.lookup(testRepo, testOid, function() {}); - }, 'No exception is thrown with proper arguments'); - - testRepo.open('../.git', function() { - // Test valid commit - testOid.fromString('cb76e3c030ab29db332aff3b297dc39451a84762', function(error, testOid) { - testCommit.lookup(testRepo, testOid, function(err) { - test.equal(null, err, 'Valid commit'); - test.done(); - }); - }); - }); - }); -}; diff --git a/test/raw-error.js b/test/raw-error.js deleted file mode 100644 index 3c23a4244..000000000 --- a/test/raw-error.js +++ /dev/null @@ -1,67 +0,0 @@ -var git = require('../').raw, - rimraf = require('rimraf'); - -// Helper functions -var helper = { - // Test if obj is a true function - testFunction: function(test, obj, label) { - // The object reports itself as a function - test(typeof obj, 'function', label +' reports as a function.'); - // This ensures the repo is actually a derivative of the Function [[Class]] - test(toString.call(obj), '[object Function]', label +' [[Class]] is of type function.'); - }, - // Test code and handle exception thrown - testException: function(test, fun, label) { - try { - fun(); - test(false, label); - } - catch (ex) { - test(true, label); - } - } -}; - -// Error -exports.constructor = function(test){ - test.expect(3); - - // Test for function - helper.testFunction(test.equals, git.Error, 'Error'); - - // Ensure we get an instance of Error - test.ok(new git.Error() instanceof git.Error, 'Invocation returns an instance of Error'); - - test.done(); -}; - -exports.codes = function(test) { - test.expect(23); - - test.equals(git.Error.returnCodes.GIT_OK, 0, 'GIT_OK should equal 0'), - test.equals(git.Error.returnCodes.GIT_ERROR, -1, 'GIT_ERROR should equal -1'), - test.equals(git.Error.returnCodes.GIT_ENOTFOUND, -3, 'GIT_ENOTFOUND should equal -3'), - test.equals(git.Error.returnCodes.GIT_EEXISTS, -4, 'GIT_EEXISTS should equal -4'), - test.equals(git.Error.returnCodes.GIT_EAMBIGUOUS, -5, 'GIT_EAMBIGUOUS should equal -5'), - test.equals(git.Error.returnCodes.GIT_EBUFS, -6, 'GIT_EBUFS should equal -6'), - test.equals(git.Error.returnCodes.GIT_PASSTHROUGH, -30, 'GIT_PASSTHROUGH should equal -30'), - test.equals(git.Error.returnCodes.GIT_ITEROVER, -31, 'GIT_ITEROVER should equal -31'), - - test.equals(git.Error.codes.GITERR_NOMEMORY, 0, 'GITERR_NOMEMORY should equal 0'); - test.equals(git.Error.codes.GITERR_OS, 1, 'GITERR_OS should equal 1'); - test.equals(git.Error.codes.GITERR_INVALID, 2, 'GITERR_INVALID should equal 2'); - test.equals(git.Error.codes.GITERR_REFERENCE, 3, 'GITERR_REFERENCE should equal 3'); - test.equals(git.Error.codes.GITERR_ZLIB, 4, 'GITERR_ZLIB should equal 4'); - test.equals(git.Error.codes.GITERR_REPOSITORY, 5, 'GITERR_REPOSITORY should equal 5'); - test.equals(git.Error.codes.GITERR_CONFIG, 6, 'GITERR_CONFIG should equal 6'); - test.equals(git.Error.codes.GITERR_REGEX, 7, 'GITERR_REGEX should equal 7'); - test.equals(git.Error.codes.GITERR_ODB, 8, 'GITERR_ODB should equal 8'); - test.equals(git.Error.codes.GITERR_INDEX, 9, 'GITERR_INDEX should equal 9'); - test.equals(git.Error.codes.GITERR_OBJECT, 10, 'GITERR_OBJECT should equal 10'); - test.equals(git.Error.codes.GITERR_NET, 11, 'GITERR_NET should equal 11'); - test.equals(git.Error.codes.GITERR_TAG, 12, 'GITERR_TAG should equal 12'); - test.equals(git.Error.codes.GITERR_TREE, 13, 'GITERR_TREE should equal 13'); - test.equals(git.Error.codes.GITERR_INDEXER, 14, 'GITERR_INDEXER should equal 14'); - - test.done(); -}; diff --git a/test/raw-oid.js b/test/raw-oid.js deleted file mode 100644 index 126a6fd31..000000000 --- a/test/raw-oid.js +++ /dev/null @@ -1,82 +0,0 @@ -var git = require('../').raw, - rimraf = require('rimraf'); - -// Helper functions -var helper = { - // Test if obj is a true function - testFunction: function(test, obj, label) { - // The object reports itself as a function - test(typeof obj, 'function', label +' reports as a function.'); - // This ensures the repo is actually a derivative of the Function [[Class]] - test(toString.call(obj), '[object Function]', label +' [[Class]] is of type function.'); - }, - // Test code and handle exception thrown - testException: function(test, fun, label) { - try { - fun(); - test(false, label); - } - catch (ex) { - test(true, label); - } - } -}; - -// Oid -exports.constructor = function(test){ - test.expect(3); - - // Test for function - helper.testFunction(test.equals, git.Oid, 'Oid'); - - // Ensure we get an instance of Oid - test.ok(new git.Oid() instanceof git.Oid, 'Invocation returns an instance of Oid'); - - test.done(); -}; - -// Oid::FromString -exports.fromString = function(test) { - test.expect(6); - - var testOid = new git.Oid(); - - // Test for function - helper.testFunction(test.equals, testOid.fromString, 'Oid::FromString'); - - // Test path argument existence - helper.testException(test.ok, function() { - testOid.fromString(); - }, 'Throw an exception if no hex String'); - - // Test that both arguments result correctly - helper.testException(test.ifError, function() { - testOid.fromString("somestr", function() {}); - }, 'No exception is thrown with proper arguments'); - - // Test invalid hex id string - testOid.fromString('1392DLFJIOS', function(error, oid) { - test.notEqual(null, error, 'Invalid hex id String'); - testOid.fromString('1810DFF58D8A660512D4832E740F692884338CCD', function(error, oid) { - // Test valid hex id string - test.equal(null, error, 'Valid hex id String'); - test.done(); - }); - }); -}; - -// Oid::Sha -exports.sha = function(test) { - test.expect(3); - var testOid = new git.Oid(); - - // Test for function - helper.testFunction(test.equals, testOid.sha, 'Oid::Sha'); - - // Test valid hex id string - var sha = '1810DFF58D8A660512D4832E740F692884338CCD'; - testOid.fromString(sha, function(error, rawOid) { - test.equals(sha, testOid.sha().toUpperCase(), 'Valid hex id String'); - test.done(); - }); -}; diff --git a/test/raw-reference.js b/test/raw-reference.js deleted file mode 100644 index e20662f60..000000000 --- a/test/raw-reference.js +++ /dev/null @@ -1,83 +0,0 @@ -var git = require('../').raw, - rimraf = require('rimraf'); - -// Helper functions -var helper = { - // Test if obj is a true function - testFunction: function(test, obj, label) { - // The object reports itself as a function - test(typeof obj, 'function', label +' reports as a function.'); - // This ensures the repo is actually a derivative of the Function [[Class]] - test(toString.call(obj), '[object Function]', label +' [[Class]] is of type function.'); - }, - // Test code and handle exception thrown - testException: function(test, fun, label) { - try { - fun(); - test(false, label); - } - catch (ex) { - test(true, label); - } - } -}; - -// Ref -exports.constructor = function(test){ - test.expect(3); - - // Test for function - helper.testFunction(test.equals, git.Reference, 'Reference'); - - // Ensure we get an instance of Ref - test.ok(new git.Reference() instanceof git.Reference, 'Invocation returns an instance of Ref'); - - test.done(); -}; - -// Ref::Lookup -exports.lookup = function(test) { - - var testRepo = new git.Repo(), - master = new git.Reference(); - - test.expect(5); - - // Test for function - helper.testFunction(test.equals, master.lookup, 'Ref::Lookup'); - - // Test repo argument existence - helper.testException(test.ok, function() { - master.lookup(); - }, 'Throw an exception if no repo'); - - // Test name argument existence - helper.testException(test.ok, function() { - master.lookup(testRepo); - }, 'Throw an exception if no name'); - - // Test callback argument existence - helper.testException(test.ok, function() { - master.lookup(testRepo, 'refs/heads/master'); - }, 'Throw an exception if no callback'); - - // Cleanup, remove test repo directory - if it exists - rimraf('./test.git', function() { - // // Create bare repo and test for creation - // testRepo.init('./test.git', true, function(err, path, is_bare) { - // test.equals(0, err, 'Successfully created bare repository'); - // // Verify repo exists - // testRepo.open('./test.git', function(err, path) { - // test.equals(0, err, 'Valid repository created'); - // test.equals(true, is_bare, 'Returns valid is_bare value'); - - // testRepo.free(); - - // // Cleanup, remove test repo directory - // rimraf('./test.git', function() { - test.done(); - // }); - // }); - // }); - }); -}; diff --git a/test/raw-repo.js b/test/raw-repo.js deleted file mode 100644 index b6c475e21..000000000 --- a/test/raw-repo.js +++ /dev/null @@ -1,126 +0,0 @@ -var git = require('../').raw, - rimraf = require('rimraf'), - path = require('path'), - fs = require('fs'); - -// Helper functions -var helper = { - // Test if obj is a true function - testFunction: function(test, obj, label) { - // The object reports itself as a function - test(typeof obj, 'function', label +' reports as a function.'); - // This ensures the repo is actually a derivative of the Function [[Class]] - test(toString.call(obj), '[object Function]', label +' [[Class]] is of type function.'); - }, - // Test code and handle exception thrown - testException: function(test, fun, label) { - try { - fun(); - test(false, label); - } - catch (ex) { - test(true, label); - } - } -}; - -// Repo -exports.constructor = function(test){ - test.expect(3); - - // Test for function - helper.testFunction(test.equals, git.Repo, 'Repo'); - - // Ensure we get an instance of Repo - test.ok(new git.Repo() instanceof git.Repo, 'Invocation returns an instance of Repo'); - - test.done(); -}; - -// Repo::Open -exports.open = function(test) { - var testRepo = new git.Repo(); - - test.expect(6); - - // Test for function - helper.testFunction(test.equals, testRepo.open, 'Repo::Open'); - - // Test path argument existence - helper.testException(test.ok, function() { - testRepo.open(); - }, 'Throw an exception if no path'); - - // Test callback argument existence - helper.testException(test.ok, function() { - testRepo.open('some/path'); - }, 'Throw an exception if no callback'); - - // Test invalid repository - testRepo.open('/etc/hosts', function(error) { - test.equals(git.Error.codes.GIT_ERROR, error.klass, 'Invalid repository error code'); - - // Test valid repository - testRepo.open(path.resolve('../.git'), function(error) { - test.equals(null, error, 'Valid repository error code'); - test.done(); - }); - }); -}; - -// TODO: Figure out how write unit tests for free -// Repo::Free -exports.free = function(test) { - var testRepo = new git.Repo(); - - test.expect(2); - - // Test for function - helper.testFunction(test.equals, testRepo.free, 'Repo::Free'); - - test.done(); -}; - -// Repo::Init -exports.init = function(test) { - var testRepo = new git.Repo(); - - test.expect(7); - - // Test for function - helper.testFunction(test.equals, testRepo.init, 'Repo::Init'); - - // Test path argument existence - helper.testException(test.ok, function() { - testRepo.init(); - }, 'Throw an exception if no path'); - - // Test is_bare argument existence - helper.testException(test.ok, function() { - testRepo.init("some/path"); - }, 'Throw an exception if no is_bare'); - - // Test callback argument existence - helper.testException(test.ok, function() { - testRepo.init("some/path", true); - }, 'Throw an exception if no callback'); - - // Cleanup, remove test repo directory - if it exists - rimraf('./test.git', function() { - // Create bare repo and test for creation - testRepo.init('./test.git', true, function(error, path, is_bare) { - test.equals(null, error, 'Successfully created bare repository'); - // Verify repo exists - testRepo.open('./test.git', function(error, path) { - test.equals(null, error, 'Valid repository created'); - - testRepo.free(); - - // Cleanup, remove test repo directory - rimraf('./test.git', function() { - test.done(); - }); - }); - }); - }); -}; diff --git a/test/reference.js b/test/reference.js new file mode 100644 index 000000000..f7e2bb1f2 --- /dev/null +++ b/test/reference.js @@ -0,0 +1,14 @@ +var git = require('../'), + rimraf = require('rimraf'); + +// Ref::Lookup +exports.lookup = function(test) { + test.expect(1); + + git.Repo.open('../.git', function(error, repo) { + repo.getReference('refs/heads/master', function(error, reference) { + test.ok(reference instanceof git.Reference); + test.done(); + }); + }); +}; diff --git a/test/repo.js b/test/repo.js new file mode 100644 index 000000000..886dee035 --- /dev/null +++ b/test/repo.js @@ -0,0 +1,57 @@ +var git = require('../'), + rimraf = require('rimraf'), + fs = require( 'fs' ); + +/** + * Repo + * Ensure the repo method can handle opening repositories with async/sync + * signatures properly. + */ +exports.open = function(test){ + test.expect(2); + + // Test invalid repository + git.Repo.open('../templates', function(error, repository) { + test.equals(error.message, "Could not find repository from '../templates'"); + + // Test valid repository + git.Repo.open('../.git', function(error, repository) { + test.equals(null, error, 'Valid repository error code'); + test.done(); + }); + }); +}; + +/** + * Ensure repo doesn't attempt to open missing directories + */ +exports.nonexistentDirectory = function(test) { + test.expect(2); + git.Repo.open('/surely/this/directory/does/not/exist/on/this/machine', function(error, repository) { + test.notEqual(error, null, 'Attempting to open a nonexistent directory should error'); + test.equals(repository, null, 'Non existent directory should result in null repository'); + test.done(); + }); +}; + +/** + * Ensure the init method can create repositories at the destination path and + * can create either bare/non-bare. + */ +exports.init = function(test) { + test.expect(2); + // Cleanup, remove test repo directory - if it exists + rimraf('./test.git', function() { + // Create bare repo and test for creation + git.Repo.init('./test.git', true, function(error, path, isBare) { + test.equals(null, error, 'Successfully created bare repository'); + // Verify repo exists + git.Repo.open('./test.git', function(error, path, repo) { + test.equals(null, error, 'Valid repository created'); + + // Cleanup, remove test repo directory + rimraf('./test.git', test.done); + }); + }); + }); +}; diff --git a/test/raw-revwalk.js b/test/revwalk.js similarity index 62% rename from test/raw-revwalk.js rename to test/revwalk.js index e7338fa32..469f18b51 100644 --- a/test/raw-revwalk.js +++ b/test/revwalk.js @@ -2,8 +2,6 @@ var git = require('../').raw, path = require('path'), rimraf = require('rimraf'); -var testRepo = new git.Repo(); - // Helper functions var helper = { // Test if obj is a true function @@ -24,19 +22,3 @@ var helper = { } } }; - -/** - * RevWalk - */ -exports.constructor = function(test){ - test.expect(3); - - // Test for function - helper.testFunction(test.equals, git.RevWalk, 'RevWalk'); - - // Ensure we get an instance of Oid - testRepo.open('../.git', function(error, repository) { - test.ok(new git.RevWalk(repository) instanceof git.RevWalk, 'Invocation returns an instance of RevWalk'); - test.done(); - }); -}; diff --git a/test/tree.js b/test/tree.js new file mode 100644 index 000000000..7bb73329f --- /dev/null +++ b/test/tree.js @@ -0,0 +1,62 @@ +var git = require('../'), + rimraf = require('rimraf'), + fs = require('fs'); + +var sha = '5716e9757886eaf38d51c86b192258c960d9cfea'; +var fileCount = 512; // Number of blob & blob executabless + +exports.walk = function(test) { + test.expect(515); + + git.Repo.open('../.git', function(error, repo) { + repo.getCommit(sha, function(error, commit) { + var entryCount = 0; + commit.getTree(function(error, tree) { + tree.walk().on('entry', function(index, entry) { + test.equals(error, null, 'There should be no error'); + entryCount++; + }).on('end', function(errors, entries) { + test.equals(errors, null, 'There should be no error'); + test.equals(entryCount, fileCount, 'The manual tree entry count and the "end" tree entry count do not match'); + test.equals(entries.length, fileCount, 'The end entries count and the manual entry count do not match'); + test.done(); + }).start(); + }); + }); + }); +}; + +exports.insert = function(test) { + test.expect(1); + + git.Repo.open('../.git', function(error, repo) { + repo.getCommit('1e7bc7fba93aabc8c76ebea41918f9ad892141ed', function(error, commit) { + commit.getTree(function(error, tree) { + var text = "this is a file\n", + buffer = new Buffer(text); + repo.createBlobFromBuffer(buffer, function(error, blobId) { + var builder = tree.builder(); + builder.insert("lib/baz/bar.txt", blobId, git.TreeEntry.FileMode.Blob); + builder.write(function(error, treeId) { + repo.getTree(treeId, function(error, tree) { + var author = git.Signature.create("Scott Chacon", "schacon@gmail.com", 123456789, 60), + committer = git.Signature.create("Scott A Chacon", "scott@github.com", 987654321, 90); + repo.createCommit(null, author, committer, "message", tree, [commit], function(error, commitId) { + repo.getCommit(commitId, function(error, commit) { + commit.getTree(function(error, tree) { + tree.getEntry('lib/baz/bar.txt', function(error, entry) { + entry.getBlob(function(error, blob) { + test.equals(blob.toString(), text); + test.done(); + }); + }); + }); + }); + }); + }); + }); + }); + }); + }); + }); +}; diff --git a/test/tree_entry.js b/test/tree_entry.js new file mode 100644 index 000000000..4ee9b1338 --- /dev/null +++ b/test/tree_entry.js @@ -0,0 +1,83 @@ +var git = require('../'); + +var sha = '5716e9757886eaf38d51c86b192258c960d9cfea'; + +var getEntry = function(path, callback) { + git.Repo.open('../.git', function(error, repo) { + repo.getCommit(sha, function(error, commit) { + commit.getEntry(path, callback); + }); + }); +}; + +exports.missingFile = function(test) { + test.expect(1); + + getEntry('test/convenience-entry.js', function(error, entry) { + test.notEqual(error, null, 'Missing file should error'); + test.done(); + }); +}; + +exports.sha = function(test) { + test.expect(1); + getEntry('README.md', function(error, entry) { + var sha = entry.sha(); + test.equal(sha, '6cb45ba5d32532bf0d1310dc31ca4f20f59964bc', 'Entry SHA should match expected value'); + test.done(); + }); +}; + +exports.isFile = function(test) { + test.expect(2); + getEntry('README.md', function(error, entry) { + var isFile = entry.isFile(); + test.equal(isFile, true, 'Entry is a file'); + getEntry('example', function(error, entry) { + var isFile = entry.isFile(); + test.equal(isFile, false, 'Entry is a directory'); + test.done(); + }); + }); +}; + +exports.isDirectory = function(test) { + test.expect(2); + getEntry('example', function(error, entry) { + test.equal(entry.isFile(), false, 'Entry is a directory'); + getEntry('README.md', function(error, entry) { + test.equal(entry.isFile(), true, 'Entry is a file'); + test.done(); + }); + }); +}; + +exports.name = function(test) { + test.expect(2); + getEntry('test/raw-commit.js', function(error, entry) { + test.equal(error, null, 'Should not error'); + var name = entry.name(); + test.equal(name, 'raw-commit.js', 'Name should match expected value'); + test.done(); + }); +}; + +exports.getBlob = function(test) { + test.expect(1); + getEntry('test/raw-commit.js', function(error, entry) { + entry.getBlob(function(error, blob) { + test.equal(blob.size(), 2736, 'Content length should match expected value'); + test.done(); + }); + }); +}; + +exports.getTree = function(test) { + test.expect(1); + getEntry('test', function(error, entry) { + entry.getTree(function(error, tree) { + test.equal(tree instanceof git.Tree, true, 'Expected instance of Tree'); + test.done(); + }); + }); +}; diff --git a/test/utilities.js b/test/utilities.js deleted file mode 100644 index 06f9714f3..000000000 --- a/test/utilities.js +++ /dev/null @@ -1,23 +0,0 @@ -var git = require('../'), - utilities = require('../lib/utilities'); - -exports.successNoError = function(test){ - test.expect(0); - - if (utilities.success(null, function() { })) { - test.done(); - } -}; - -/** - * Test whether success function calls callback with error - */ -exports.successError = function(test){ - test.expect(3); - utilities.success(new git.error('Message', git.raw.Error.codes.GITERR_INVALID), function(error) { - test.notEqual(error, null, 'Error should not be null'); - test.equal(error.code, git.raw.Error.codes.GITERR_INVALID, 'Error code should match input'); - test.equal(error.message, 'Message', 'Error message should match input'); - test.done(); - }); -}; diff --git a/util/hint-check.js b/util/hint-check.js index 54091ff8b..ab71ac549 100644 --- a/util/hint-check.js +++ b/util/hint-check.js @@ -1,49 +1,22 @@ -var nodejshint = require( './nodejshint.js' ).test, +var nodejshint = require('./nodejshint.js').test, + fs = require('fs'), + path = require('path'); -files = [ - // Test convenience api - 'lib/blob.js' -, 'lib/commit.js' -, 'lib/error.js' -, 'lib/index.js' -, 'lib/object.js' -, 'lib/oid.js' -, 'lib/ref.js' -, 'lib/repo.js' -, 'lib/revwalk.js' -, 'lib/sig.js' -, 'lib/tree.js' -, 'lib/tree_entry.js' -, 'lib/util.js' +var files = []; - // Test unit test -, 'test/convenience-repo.js' -, 'test/index.js' -, 'test/raw-blob.js' -, 'test/raw-commit.js' -, 'test/raw-error.js' -, 'test/raw-object.js' -, 'test/raw-oid.js' -, 'test/raw-reference.js' -, 'test/raw-repo.js' -, 'test/raw-revwalk.js' - - // Test examples -, 'example/convenience-repo.js' -, 'example/convenience-tree.js' -, 'example/raw-error.js' -, 'example/raw-oid.js' -, 'example/raw-repo.js' -, 'example/raw-revwalk.js' -]; +['lib', 'test', 'example'].forEach(function(dir) { + console.log(dir); + fs.readdirSync(dir).forEach(function(file) { + if (/\.js$/.test(file)) files.push(path.join(dir, file)); + }); +}); -nodejshint( files, function( failures ) { - console.log( failures, 'failures' ); +nodejshint(files, function(failures) { + console.log(failures, 'failures'); - if( !files.length ) { - process.exit( 0 ); - } - else { - process.exit( 1 ); + if(!files.length) { + process.exit(0); + } else { + process.exit(1); } }); diff --git a/v0.18.0.json b/v0.18.0.json new file mode 100644 index 000000000..8c781448c --- /dev/null +++ b/v0.18.0.json @@ -0,0 +1,17335 @@ +[ + { + "filename": "attr.h", + "ignore": true, + "jsClassName": "Attr", + "cppClassName": "Attr", + "cType": "git_attr", + "functions": [ + { + "cFunctionName": "git_attr_get", + "args": [ + { + "name": "value_out", + "cType": "const char **", + "cppClassName": "String", + "jsClassName": "String", + "comment": "Output of the value of the attribute. Use the GIT_ATTR_... macros to test for TRUE, FALSE, UNSPECIFIED, etc. or just use the string value for attributes set to a value. You should NOT modify or free this value." + }, + { + "name": "repo", + "cType": "git_repository *", + "cppClassName": "GitRepo", + "jsClassName": "Repository", + "comment": "The repository containing the path." + }, + { + "name": "flags", + "cType": "uint32_t", + "cppClassName": "Uint32", + "jsClassName": "Uint32", + "comment": "A combination of GIT_ATTR_CHECK... flags." + }, + { + "name": "path", + "cType": "const char *", + "cppClassName": "String", + "jsClassName": "String", + "comment": "The path to check for attributes. Relative paths are interpreted relative to the repo root. The file does not have to exist, but if it does not, then it will be treated as a plain file (not a directory)." + }, + { + "name": "name", + "cType": "const char *", + "cppClassName": "String", + "jsClassName": "String", + "comment": "The name of the attribute to look up." + } + ], + "isAsync": false, + "isConstructorMethod": false, + "isPrototypeMethod": false, + "jsFunctionName": "get", + "cppFunctionName": "Get", + "return": { + "cType": "int", + "cppClassName": "Int32", + "isErrorCode": true, + "jsClassName": "Number" + }, + "description": "

Look up the value of one git attribute for path.

\n" + }, + { + "cFunctionName": "git_attr_get_many", + "args": [ + { + "name": "values_out", + "cType": "const char **", + "cppClassName": "String", + "jsClassName": "String", + "comment": "An array of num_attr entries that will have string pointers written into it for the values of the attributes. You should not modify or free the values that are written into this array (although of course, you should free the array itself if you allocated it)." + }, + { + "name": "repo", + "cType": "git_repository *", + "cppClassName": "GitRepo", + "jsClassName": "Repository", + "comment": "The repository containing the path." + }, + { + "name": "flags", + "cType": "uint32_t", + "cppClassName": "Uint32", + "jsClassName": "Uint32", + "comment": "A combination of GIT_ATTR_CHECK... flags." + }, + { + "name": "path", + "cType": "const char *", + "cppClassName": "String", + "jsClassName": "String", + "comment": "The path inside the repo to check attributes. This does not have to exist, but if it does not, then it will be treated as a plain file (i.e. not a directory)." + }, + { + "name": "num_attr", + "cType": "size_t", + "cppClassName": "Uint32", + "jsClassName": "Number", + "comment": "The number of attributes being looked up" + }, + { + "name": "names", + "cType": "const char **", + "cppClassName": "String", + "jsClassName": "String", + "comment": "An array of num_attr strings containing attribute names." + } + ], + "isAsync": false, + "isConstructorMethod": false, + "isPrototypeMethod": false, + "jsFunctionName": "getMany", + "cppFunctionName": "GetMany", + "return": { + "cType": "int", + "cppClassName": "Int32", + "isErrorCode": true, + "jsClassName": "Number" + }, + "description": "

Look up a list of git attributes for path.

\n" + }, + { + "cFunctionName": "git_attr_foreach", + "args": [ + { + "name": "repo", + "cType": "git_repository *", + "cppClassName": "GitRepo", + "jsClassName": "Repository", + "comment": "The repository containing the path." + }, + { + "name": "flags", + "cType": "uint32_t", + "cppClassName": "Uint32", + "jsClassName": "Uint32", + "comment": "A combination of GIT_ATTR_CHECK... flags." + }, + { + "name": "path", + "cType": "const char *", + "cppClassName": "String", + "jsClassName": "String", + "comment": "Path inside the repo to check attributes. This does not have to exist, but if it does not, then it will be treated as a plain file (i.e. not a directory)." + }, + { + "name": "callback", + "cType": "git_attr_foreach_cb", + "cppClassName": "AttrForeachCb", + "jsClassName": "AttrForeachCb", + "comment": "Function to invoke on each attribute name and value. The value may be NULL is the attribute is explicitly set to UNSPECIFIED using the '!' sign. Callback will be invoked only once per attribute name, even if there are multiple rules for a given file. The highest priority rule will be used. Return a non-zero value from this to stop looping." + }, + { + "name": "payload", + "cType": "void *", + "cppClassName": "void", + "jsClassName": "void", + "comment": "Passed on as extra parameter to callback function." + } + ], + "ignore": true, + "isAsync": false, + "isConstructorMethod": false, + "isPrototypeMethod": false, + "jsFunctionName": "foreach", + "cppFunctionName": "Foreach", + "return": { + "cType": "int", + "cppClassName": "Int32", + "isErrorCode": true, + "comment": "0 on success, GIT_EUSER on non-zero callback, or error code", + "jsClassName": "Number" + }, + "description": "

Loop over all the git attributes for a path.

\n" + }, + { + "cFunctionName": "git_attr_cache_flush", + "args": [ + { + "name": "repo", + "cType": "git_repository *", + "cppClassName": "GitRepo", + "jsClassName": "Repository" + } + ], + "isAsync": false, + "isConstructorMethod": false, + "isPrototypeMethod": false, + "jsFunctionName": "cacheFlush", + "cppFunctionName": "CacheFlush", + "return": { + "cType": "void", + "cppClassName": "void", + "jsClassName": "void" + }, + "description": "

Flush the gitattributes cache.

\n" + }, + { + "cFunctionName": "git_attr_add_macro", + "args": [ + { + "name": "repo", + "cType": "git_repository *", + "cppClassName": "GitRepo", + "jsClassName": "Repository" + }, + { + "name": "name", + "cType": "const char *", + "cppClassName": "String", + "jsClassName": "String" + }, + { + "name": "values", + "cType": "const char *", + "cppClassName": "String", + "jsClassName": "String" + } + ], + "isAsync": false, + "isConstructorMethod": false, + "isPrototypeMethod": false, + "jsFunctionName": "addMacro", + "cppFunctionName": "AddMacro", + "return": { + "cType": "int", + "cppClassName": "Int32", + "isErrorCode": true, + "jsClassName": "Number" + }, + "description": "

Add a macro definition.

\n" + } + ] + }, + { + "filename": "blob.h", + "dependencies": [ + "../include/repo.h", + "../include/oid.h", + "../include/wrapper.h", + "node_buffer.h" + ], + "jsClassName": "Blob", + "cppClassName": "GitBlob", + "cType": "git_blob", + "freeFunctionName": "git_blob_free", + "functions": [ + { + "cFunctionName": "git_blob_free", + "args": [ + { + "name": "blob", + "cType": "git_blob *", + "cppClassName": "GitBlob", + "jsClassName": "Blob", + "comment": "the blob to close" + } + ], + "ignore": true, + "isAsync": false, + "isConstructorMethod": false, + "isPrototypeMethod": false, + "isFree": true, + "jsFunctionName": "free", + "cppFunctionName": "Free", + "return": { + "cType": "void", + "cppClassName": "void", + "jsClassName": "void" + }, + "description": "

Close an open blob

\n" + }, + { + "cFunctionName": "git_blob_id", + "args": [ + { + "name": "blob", + "cType": "const git_blob *", + "cppClassName": "GitBlob", + "jsClassName": "Blob", + "isSelf": true, + "comment": "a previously loaded blob." + } + ], + "isAsync": false, + "isConstructorMethod": false, + "isPrototypeMethod": true, + "jsFunctionName": "oid", + "cppFunctionName": "Oid", + "return": { + "cType": "const git_oid *", + "cppClassName": "GitOid", + "copy": "git_oid_dup", + "comment": "SHA1 hash for this blob.", + "jsClassName": "Oid" + }, + "description": "

Get the id of a blob.

\n" + }, + { + "cFunctionName": "git_blob_rawcontent", + "args": [ + { + "name": "blob", + "cType": "const git_blob *", + "cppClassName": "GitBlob", + "jsClassName": "Blob", + "isSelf": true, + "comment": "pointer to the blob" + } + ], + "isAsync": false, + "isConstructorMethod": false, + "isPrototypeMethod": true, + "jsFunctionName": "content", + "cppFunctionName": "Content", + "return": { + "cType": "const void *", + "cppClassName": "Wrapper", + "comment": "the pointer; NULL if the blob has no contents" + }, + "description": "

Get a read-only buffer with the raw content of a blob.

\n" + }, + { + "cFunctionName": "git_blob_rawsize", + "args": [ + { + "name": "blob", + "cType": "const git_blob *", + "cppClassName": "GitBlob", + "jsClassName": "Blob", + "isSelf": true, + "comment": "pointer to the blob" + } + ], + "isAsync": false, + "isConstructorMethod": false, + "isPrototypeMethod": true, + "jsFunctionName": "size", + "cppFunctionName": "Size", + "return": { + "cType": "git_off_t", + "cppClassName": "Number", + "comment": "size on bytes", + "jsClassName": "Number" + }, + "description": "

Get the size in bytes of the contents of a blob

\n" + }, + { + "cFunctionName": "git_blob_is_binary", + "args": [ + { + "name": "blob", + "cType": "git_blob *", + "cppClassName": "GitBlob", + "jsClassName": "Blob", + "isSelf": true, + "comment": "The blob which content should be analyzed" + } + ], + "isAsync": false, + "isConstructorMethod": false, + "isPrototypeMethod": true, + "jsFunctionName": "isBinary", + "cppFunctionName": "IsBinary", + "return": { + "cType": "int", + "cppClassName": "Boolean", + "comment": "1 if the content of the blob is detected as binary; 0 otherwise.", + "jsClassName": "Boolean" + }, + "description": "

Determine if the blob content is most certainly binary or not.

\n" + } + ] + }, + { + "filename": "branch.h", + "jsClassName": "Branch", + "cppClassName": "Branch", + "cType": "git_branch", + "freeFunctionName": "git_branch_free", + "functions": [ + { + "cFunctionName": "git_branch_create", + "args": [ + { + "name": "out", + "isReturn": true, + "cType": "git_reference **", + "cppClassName": "GitReference", + "jsClassName": "Reference", + "comment": "Pointer where to store the underlying reference." + }, + { + "name": "repo", + "cType": "git_repository *", + "cppClassName": "GitRepo", + "jsClassName": "Repository" + }, + { + "name": "branch_name", + "cType": "const char *", + "cppClassName": "String", + "jsClassName": "String", + "comment": "Name for the branch; this name is validated for consistency. It should also not conflict with an already existing branch name." + }, + { + "name": "target", + "cType": "const git_commit *", + "cppClassName": "GitCommit", + "jsClassName": "Commit", + "comment": "Commit to which this branch should point. This object must belong to the given `repo`." + }, + { + "name": "force", + "cType": "int", + "cppClassName": "Int32", + "jsClassName": "Number", + "comment": "Overwrite existing branch." + } + ], + "isAsync": false, + "isConstructorMethod": false, + "isPrototypeMethod": false, + "jsFunctionName": "create", + "cppFunctionName": "Create", + "return": { + "cType": "int", + "cppClassName": "Int32", + "isErrorCode": true, + "comment": "0, GIT_EINVALIDSPEC or an error code. A proper reference is written in the refs/heads namespace pointing to the provided target commit.", + "jsClassName": "Number" + }, + "description": "

Create a new branch pointing at a target commit

\n" + }, + { + "cFunctionName": "git_branch_delete", + "args": [ + { + "name": "branch", + "cType": "git_reference *", + "cppClassName": "GitReference", + "jsClassName": "Reference", + "comment": "A valid reference representing a branch" + } + ], + "isAsync": false, + "isConstructorMethod": false, + "isPrototypeMethod": false, + "jsFunctionName": "delete", + "cppFunctionName": "Delete", + "return": { + "cType": "int", + "cppClassName": "Int32", + "isErrorCode": true, + "comment": "0 on success, or an error code.", + "jsClassName": "Number" + }, + "description": "

Delete an existing branch reference.

\n" + }, + { + "cFunctionName": "git_branch_foreach", + "args": [ + { + "name": "repo", + "cType": "git_repository *", + "cppClassName": "GitRepo", + "jsClassName": "Repository", + "comment": "Repository where to find the branches." + }, + { + "name": "list_flags", + "cType": "unsigned int", + "cppClassName": "Uint32", + "jsClassName": "Number", + "comment": "Filtering flags for the branch listing. Valid values are GIT_BRANCH_LOCAL, GIT_BRANCH_REMOTE or a combination of the two." + }, + { + "name": "branch_cb", + "cType": "git_branch_foreach_cb", + "cppClassName": "BranchForeachCb", + "jsClassName": "BranchForeachCb", + "comment": "Callback to invoke per found branch." + }, + { + "name": "payload", + "cType": "void *", + "cppClassName": "void", + "jsClassName": "void", + "comment": "Extra parameter to callback function." + } + ], + "isAsync": false, + "isConstructorMethod": false, + "isPrototypeMethod": false, + "jsFunctionName": "foreach", + "cppFunctionName": "Foreach", + "return": { + "cType": "int", + "cppClassName": "Int32", + "isErrorCode": true, + "comment": "0 on success, GIT_EUSER on non-zero callback, or error code", + "jsClassName": "Number" + }, + "description": "

Loop over all the branches and issue a callback for each one.

\n" + }, + { + "cFunctionName": "git_branch_move", + "args": [ + { + "name": "out", + "isReturn": true, + "cType": "git_reference **", + "cppClassName": "GitReference", + "jsClassName": "Reference" + }, + { + "name": "branch", + "cType": "git_reference *", + "cppClassName": "GitReference", + "jsClassName": "Reference", + "comment": "Current underlying reference of the branch." + }, + { + "name": "new_branch_name", + "cType": "const char *", + "cppClassName": "String", + "jsClassName": "String", + "comment": "Target name of the branch once the move is performed; this name is validated for consistency." + }, + { + "name": "force", + "cType": "int", + "cppClassName": "Int32", + "jsClassName": "Number", + "comment": "Overwrite existing branch." + } + ], + "isAsync": false, + "isConstructorMethod": false, + "isPrototypeMethod": false, + "jsFunctionName": "move", + "cppFunctionName": "Move", + "return": { + "cType": "int", + "cppClassName": "Int32", + "isErrorCode": true, + "comment": "0 on success, GIT_EINVALIDSPEC or an error code.", + "jsClassName": "Number" + }, + "description": "

Move/rename an existing local branch reference.

\n" + }, + { + "cFunctionName": "git_branch_lookup", + "args": [ + { + "name": "out", + "isReturn": true, + "cType": "git_reference **", + "cppClassName": "GitReference", + "jsClassName": "Reference", + "comment": "pointer to the looked-up branch reference" + }, + { + "name": "repo", + "cType": "git_repository *", + "cppClassName": "GitRepo", + "jsClassName": "Repository", + "comment": "the repository to look up the branch" + }, + { + "name": "branch_name", + "cType": "const char *", + "cppClassName": "String", + "jsClassName": "String", + "comment": "Name of the branch to be looked-up; this name is validated for consistency." + }, + { + "name": "branch_type", + "cType": "git_branch_t", + "cppClassName": "BranchT", + "jsClassName": "BranchT", + "comment": "Type of the considered branch. This should be valued with either GIT_BRANCH_LOCAL or GIT_BRANCH_REMOTE." + } + ], + "isAsync": false, + "isConstructorMethod": false, + "isPrototypeMethod": false, + "jsFunctionName": "lookup", + "cppFunctionName": "Lookup", + "return": { + "cType": "int", + "cppClassName": "Int32", + "isErrorCode": true, + "comment": "0 on success; GIT_ENOTFOUND when no matching branch exists, GIT_EINVALIDSPEC, otherwise an error code.", + "jsClassName": "Number" + }, + "description": "

Lookup a branch by its name in a repository.

\n" + }, + { + "cFunctionName": "git_branch_name", + "args": [ + { + "name": "out", + "isReturn": true, + "cType": "const char **", + "cppClassName": "String", + "jsClassName": "String", + "comment": "where the pointer of branch name is stored; this is valid as long as the ref is not freed." + }, + { + "name": "ref", + "cType": "git_reference *", + "cppClassName": "GitReference", + "jsClassName": "Reference", + "comment": "the reference ideally pointing to a branch" + } + ], + "isAsync": false, + "isConstructorMethod": false, + "isPrototypeMethod": false, + "jsFunctionName": "name", + "cppFunctionName": "Name", + "return": { + "cType": "int", + "cppClassName": "Int32", + "isErrorCode": true, + "comment": "0 on success; otherwise an error code (e.g., if the ref is no local or remote branch).", + "jsClassName": "Number" + }, + "description": "

Return the name of the given local or remote branch.

\n" + }, + { + "cFunctionName": "git_branch_upstream", + "args": [ + { + "name": "out", + "isReturn": true, + "cType": "git_reference **", + "cppClassName": "GitReference", + "jsClassName": "Reference", + "comment": "Pointer where to store the retrieved reference." + }, + { + "name": "branch", + "cType": "git_reference *", + "cppClassName": "GitReference", + "jsClassName": "Reference", + "comment": "Current underlying reference of the branch." + } + ], + "isAsync": false, + "isConstructorMethod": false, + "isPrototypeMethod": false, + "jsFunctionName": "upstream", + "cppFunctionName": "Upstream", + "return": { + "cType": "int", + "cppClassName": "Int32", + "isErrorCode": true, + "comment": "0 on success; GIT_ENOTFOUND when no remote tracking reference exists, otherwise an error code.", + "jsClassName": "Number" + }, + "description": "

Return the reference supporting the remote tracking branch,\ngiven a local branch reference.

\n" + }, + { + "cFunctionName": "git_branch_set_upstream", + "args": [ + { + "name": "branch", + "cType": "git_reference *", + "cppClassName": "GitReference", + "jsClassName": "Reference", + "comment": "the branch to configure" + }, + { + "name": "upstream_name", + "cType": "const char *", + "cppClassName": "String", + "jsClassName": "String", + "comment": "remote-tracking or local branch to set as upstream. Pass NULL to unset." + } + ], + "isAsync": false, + "isConstructorMethod": false, + "isPrototypeMethod": false, + "jsFunctionName": "setUpstream", + "cppFunctionName": "SetUpstream", + "return": { + "cType": "int", + "cppClassName": "Int32", + "isErrorCode": true, + "comment": "0 or an error code", + "jsClassName": "Number" + }, + "description": "

Set the upstream configuration for a given local branch

\n" + }, + { + "cFunctionName": "git_branch_upstream_name", + "args": [ + { + "name": "tracking_branch_name_out", + "cType": "char *", + "cppClassName": "String", + "jsClassName": "String", + "comment": "The user-allocated buffer which will be filled with the name of the reference. Pass NULL if you just want to get the needed size of the name of the reference as the output value." + }, + { + "name": "buffer_size", + "cType": "size_t", + "cppClassName": "Uint32", + "jsClassName": "Number", + "comment": "Size of the `out` buffer in bytes." + }, + { + "name": "repo", + "cType": "git_repository *", + "cppClassName": "GitRepo", + "jsClassName": "Repository", + "comment": "the repository where the branches live" + }, + { + "name": "canonical_branch_name", + "cType": "const char *", + "cppClassName": "String", + "jsClassName": "String", + "comment": "name of the local branch." + } + ], + "isAsync": false, + "isConstructorMethod": false, + "isPrototypeMethod": false, + "jsFunctionName": "upstreamName", + "cppFunctionName": "UpstreamName", + "return": { + "cType": "int", + "cppClassName": "Int32", + "isErrorCode": true, + "comment": "number of characters in the reference name including the trailing NUL byte; GIT_ENOTFOUND when no remote tracking reference exists, otherwise an error code.", + "jsClassName": "Number" + }, + "description": "

Return the name of the reference supporting the remote tracking branch,\ngiven the name of a local branch reference.

\n" + }, + { + "cFunctionName": "git_branch_is_head", + "args": [ + { + "name": "branch", + "cType": "git_reference *", + "cppClassName": "GitReference", + "jsClassName": "Reference", + "comment": "Current underlying reference of the branch." + } + ], + "isAsync": false, + "isConstructorMethod": false, + "isPrototypeMethod": false, + "jsFunctionName": "isHead", + "cppFunctionName": "IsHead", + "return": { + "cType": "int", + "cppClassName": "Int32", + "isErrorCode": true, + "comment": "1 if HEAD points at the branch, 0 if it isn't, error code otherwise.", + "jsClassName": "Number" + }, + "description": "

Determine if the current local branch is pointed at by HEAD.

\n" + }, + { + "cFunctionName": "git_branch_remote_name", + "args": [ + { + "name": "remote_name_out", + "cType": "char *", + "cppClassName": "String", + "jsClassName": "String", + "comment": "The user-allocated buffer which will be filled with the name of the remote. Pass NULL if you just want to get the needed size of the name of the remote as the output value." + }, + { + "name": "buffer_size", + "cType": "size_t", + "cppClassName": "Uint32", + "jsClassName": "Number", + "comment": "Size of the `out` buffer in bytes." + }, + { + "name": "repo", + "cType": "git_repository *", + "cppClassName": "GitRepo", + "jsClassName": "Repository", + "comment": "The repository where the branch lives." + }, + { + "name": "canonical_branch_name", + "cType": "const char *", + "cppClassName": "String", + "jsClassName": "String", + "comment": "name of the remote tracking branch." + } + ], + "isAsync": false, + "isConstructorMethod": false, + "isPrototypeMethod": false, + "jsFunctionName": "remoteName", + "cppFunctionName": "RemoteName", + "return": { + "cType": "int", + "cppClassName": "Int32", + "isErrorCode": true, + "comment": "Number of characters in the reference name including the trailing NUL byte; GIT_ENOTFOUND when no remote matching remote was found, GIT_EAMBIGUOUS when the branch maps to several remotes, otherwise an error code.", + "jsClassName": "Number" + }, + "description": "

Return the name of remote that the remote tracking branch belongs to.

\n" + } + ] + }, + { + "filename": "checkout.h", + "ignore": true, + "jsClassName": "Checkout", + "cppClassName": "Checkout", + "cType": "git_checkout", + "freeFunctionName": "git_checkout_free", + "functions": [ + { + "cFunctionName": "git_checkout_head", + "args": [ + { + "name": "repo", + "cType": "git_repository *", + "cppClassName": "GitRepo", + "jsClassName": "Repository", + "comment": "repository to check out (must be non-bare)" + }, + { + "name": "opts", + "cType": "git_checkout_opts *", + "cppClassName": "CheckoutOpts", + "jsClassName": "CheckoutOpts", + "comment": "specifies checkout options (may be NULL)" + } + ], + "isAsync": false, + "isConstructorMethod": false, + "isPrototypeMethod": false, + "jsFunctionName": "head", + "cppFunctionName": "Head", + "return": { + "cType": "int", + "cppClassName": "Int32", + "isErrorCode": true, + "comment": "0 on success, GIT_EORPHANEDHEAD when HEAD points to a non existing branch, GIT_ERROR otherwise (use giterr_last for information about the error)", + "jsClassName": "Number" + }, + "description": "

Updates files in the index and the working tree to match the content of\nthe commit pointed at by HEAD.

\n" + }, + { + "cFunctionName": "git_checkout_index", + "args": [ + { + "name": "repo", + "cType": "git_repository *", + "cppClassName": "GitRepo", + "jsClassName": "Repository", + "comment": "repository into which to check out (must be non-bare)" + }, + { + "name": "index", + "cType": "git_index *", + "cppClassName": "GitIndex", + "jsClassName": "Index", + "comment": "index to be checked out (or NULL to use repository index)" + }, + { + "name": "opts", + "cType": "git_checkout_opts *", + "cppClassName": "CheckoutOpts", + "jsClassName": "CheckoutOpts", + "comment": "specifies checkout options (may be NULL)" + } + ], + "isAsync": false, + "isConstructorMethod": false, + "isPrototypeMethod": false, + "jsFunctionName": "index", + "cppFunctionName": "Index", + "return": { + "cType": "int", + "cppClassName": "Int32", + "isErrorCode": true, + "comment": "0 on success, GIT_ERROR otherwise (use giterr_last for information about the error)", + "jsClassName": "Number" + }, + "description": "

Updates files in the working tree to match the content of the index.

\n" + }, + { + "cFunctionName": "git_checkout_tree", + "args": [ + { + "name": "repo", + "cType": "git_repository *", + "cppClassName": "GitRepo", + "jsClassName": "Repository", + "comment": "repository to check out (must be non-bare)" + }, + { + "name": "treeish", + "cType": "const git_object *", + "cppClassName": "GitObject", + "jsClassName": "Object", + "comment": "a commit, tag or tree which content will be used to update the working directory" + }, + { + "name": "opts", + "cType": "git_checkout_opts *", + "cppClassName": "CheckoutOpts", + "jsClassName": "CheckoutOpts", + "comment": "specifies checkout options (may be NULL)" + } + ], + "isAsync": false, + "isConstructorMethod": false, + "isPrototypeMethod": false, + "jsFunctionName": "tree", + "cppFunctionName": "Tree", + "return": { + "cType": "int", + "cppClassName": "Int32", + "isErrorCode": true, + "comment": "0 on success, GIT_ERROR otherwise (use giterr_last for information about the error)", + "jsClassName": "Number" + }, + "description": "

Updates files in the index and working tree to match the content of the\ntree pointed at by the treeish.

\n" + } + ] + }, + { + "filename": "commit.h", + "dependencies": [ + "../include/oid.h", + "../include/repo.h", + "../include/signature.h", + "../include/tree.h" + ], + "jsClassName": "Commit", + "cppClassName": "GitCommit", + "cType": "git_commit", + "freeFunctionName": "git_commit_free", + "functions": [ + { + "cFunctionName": "git_commit_lookup_prefix", + "args": [ + { + "name": "commit", + "cType": "git_commit **", + "cppClassName": "GitCommit", + "jsClassName": "Commit", + "isReturn": true, + "comment": "pointer to the looked up commit" + }, + { + "name": "repo", + "cType": "git_repository *", + "cppClassName": "GitRepo", + "jsClassName": "Repository", + "comment": "the repo to use when locating the commit." + }, + { + "name": "id", + "cType": "const git_oid *", + "cppClassName": "GitOid", + "jsClassName": "Oid", + "comment": "identity of the commit to locate. If the object is an annotated tag it will be peeled back to the commit." + }, + { + "name": "len", + "cType": "size_t", + "cppClassName": "Uint32", + "jsClassName": "Number", + "comment": "the length of the short identifier" + } + ], + "ignore": true, + "isAsync": true, + "isConstructorMethod": true, + "isPrototypeMethod": false, + "jsFunctionName": "lookupPrefix", + "cppFunctionName": "LookupPrefix", + "return": { + "cType": "int", + "cppClassName": "Int32", + "isErrorCode": true, + "comment": "0 or an error code", + "jsClassName": "Number" + }, + "description": "

Lookup a commit object from a repository,\ngiven a prefix of its identifier (short id).

\n" + }, + { + "cFunctionName": "git_commit_free", + "args": [ + { + "name": "commit", + "cType": "git_commit *", + "cppClassName": "GitCommit", + "jsClassName": "Commit", + "isSelf": true, + "comment": "the commit to close" + } + ], + "ignore": true, + "isAsync": false, + "isConstructorMethod": false, + "isPrototypeMethod": true, + "isFree": true, + "jsFunctionName": "free", + "cppFunctionName": "Free", + "return": { + "cType": "void", + "cppClassName": "void", + "jsClassName": "void" + }, + "description": "

Close an open commit

\n" + }, + { + "cFunctionName": "git_commit_id", + "args": [ + { + "name": "commit", + "cType": "const git_commit *", + "cppClassName": "GitCommit", + "jsClassName": "Commit", + "isSelf": true, + "comment": "a previously loaded commit." + } + ], + "isAsync": false, + "isConstructorMethod": false, + "isPrototypeMethod": true, + "jsFunctionName": "oid", + "cppFunctionName": "Oid", + "return": { + "cType": "const git_oid *", + "cppClassName": "GitOid", + "copy": "git_oid_dup", + "comment": "object identity for the commit.", + "jsClassName": "Oid" + }, + "description": "

Get the id of a commit.

\n" + }, + { + "cFunctionName": "git_commit_message_encoding", + "args": [ + { + "name": "commit", + "cType": "const git_commit *", + "cppClassName": "GitCommit", + "jsClassName": "Commit", + "isSelf": true, + "comment": "a previously loaded commit." + } + ], + "isAsync": false, + "isConstructorMethod": false, + "isPrototypeMethod": true, + "jsFunctionName": "messageEncoding", + "cppFunctionName": "MessageEncoding", + "return": { + "cType": "const char *", + "cppClassName": "String", + "comment": "NULL, or the encoding", + "jsClassName": "String" + }, + "description": "

Get the encoding for the message of a commit,\nas a string representing a standard encoding name.

\n" + }, + { + "cFunctionName": "git_commit_message", + "args": [ + { + "name": "commit", + "cType": "const git_commit *", + "cppClassName": "GitCommit", + "jsClassName": "Commit", + "isSelf": true, + "comment": "a previously loaded commit." + } + ], + "isAsync": false, + "isConstructorMethod": false, + "isPrototypeMethod": true, + "jsFunctionName": "message", + "cppFunctionName": "Message", + "return": { + "cType": "const char *", + "cppClassName": "String", + "comment": "the message of a commit", + "jsClassName": "String" + }, + "description": "

Get the full message of a commit.

\n" + }, + { + "cFunctionName": "git_commit_time", + "args": [ + { + "name": "commit", + "cType": "const git_commit *", + "cppClassName": "GitCommit", + "jsClassName": "Commit", + "isSelf": true, + "comment": "a previously loaded commit." + } + ], + "isAsync": false, + "isConstructorMethod": false, + "isPrototypeMethod": true, + "jsFunctionName": "time", + "cppFunctionName": "Time", + "return": { + "cType": "git_time_t", + "cppClassName": "Number", + "comment": "the time of a commit", + "jsClassName": "Number" + }, + "description": "

Get the commit time (i.e. committer time) of a commit.

\n" + }, + { + "cFunctionName": "git_commit_time_offset", + "args": [ + { + "name": "commit", + "cType": "const git_commit *", + "cppClassName": "GitCommit", + "jsClassName": "Commit", + "isSelf": true, + "comment": "a previously loaded commit." + } + ], + "isAsync": false, + "isConstructorMethod": false, + "isPrototypeMethod": true, + "jsFunctionName": "offset", + "cppFunctionName": "Offset", + "return": { + "cType": "int", + "cppClassName": "Integer", + "comment": "positive or negative timezone offset, in minutes from UTC", + "jsClassName": "Number" + }, + "description": "

Get the commit timezone offset (i.e. committer's preferred timezone) of a commit.

\n" + }, + { + "cFunctionName": "git_commit_committer", + "args": [ + { + "name": "commit", + "cType": "const git_commit *", + "cppClassName": "GitCommit", + "jsClassName": "Commit", + "isSelf": true, + "comment": "a previously loaded commit." + } + ], + "isAsync": false, + "isConstructorMethod": false, + "isPrototypeMethod": true, + "jsFunctionName": "committer", + "cppFunctionName": "Committer", + "return": { + "cType": "const git_signature *", + "cppClassName": "GitSignature", + "copy": "git_signature_dup", + "comment": "the committer of a commit", + "jsClassName": "Signature" + }, + "description": "

Get the committer of a commit.

\n" + }, + { + "cFunctionName": "git_commit_author", + "args": [ + { + "name": "commit", + "cType": "const git_commit *", + "cppClassName": "GitCommit", + "jsClassName": "Commit", + "isSelf": true, + "comment": "a previously loaded commit." + } + ], + "isAsync": false, + "isConstructorMethod": false, + "isPrototypeMethod": true, + "jsFunctionName": "author", + "cppFunctionName": "Author", + "return": { + "cType": "const git_signature *", + "cppClassName": "GitSignature", + "copy": "git_signature_dup", + "comment": "the author of a commit", + "jsClassName": "Signature" + }, + "description": "

Get the author of a commit.

\n" + }, + { + "cFunctionName": "git_commit_tree", + "args": [ + { + "name": "tree_out", + "cType": "git_tree **", + "cppClassName": "GitTree", + "jsClassName": "Tree", + "isReturn": true, + "comment": "pointer where to store the tree object" + }, + { + "name": "commit", + "cType": "const git_commit *", + "cppClassName": "GitCommit", + "jsClassName": "Commit", + "isSelf": true, + "comment": "a previously loaded commit." + } + ], + "ignore": true, + "isAsync": true, + "isConstructorMethod": false, + "isPrototypeMethod": true, + "jsFunctionName": "getTree", + "cppFunctionName": "GetTree", + "return": { + "cType": "int", + "cppClassName": "Int32", + "isErrorCode": true, + "comment": "0 or an error code", + "jsClassName": "Number" + }, + "description": "

Get the tree pointed to by a commit.

\n" + }, + { + "cFunctionName": "git_commit_tree_id", + "args": [ + { + "name": "commit", + "cType": "const git_commit *", + "cppClassName": "GitCommit", + "jsClassName": "Commit", + "isSelf": true, + "comment": "a previously loaded commit." + } + ], + "isAsync": false, + "isConstructorMethod": false, + "isPrototypeMethod": true, + "jsFunctionName": "treeId", + "cppFunctionName": "TreeId", + "return": { + "cType": "const git_oid *", + "cppClassName": "GitOid", + "copy": "git_oid_dup", + "comment": "the id of tree pointed to by commit.", + "jsClassName": "Oid" + }, + "description": "

Get the id of the tree pointed to by a commit. This differs from\ngit_commit_tree in that no attempts are made to fetch an object\nfrom the ODB.

\n" + }, + { + "cFunctionName": "git_commit_parentcount", + "args": [ + { + "name": "commit", + "cType": "const git_commit *", + "cppClassName": "GitCommit", + "jsClassName": "Commit", + "isSelf": true, + "comment": "a previously loaded commit." + } + ], + "isAsync": false, + "isConstructorMethod": false, + "isPrototypeMethod": true, + "jsFunctionName": "parentCount", + "cppFunctionName": "ParentCount", + "return": { + "cType": "unsigned int", + "cppClassName": "Uint32", + "comment": "integer of count of parents", + "jsClassName": "Number" + }, + "description": "

Get the number of parents of this commit

\n" + }, + { + "cFunctionName": "git_commit_parent", + "args": [ + { + "name": "out", + "isReturn": true, + "cType": "git_commit **", + "cppClassName": "GitCommit", + "jsClassName": "Commit", + "comment": "Pointer where to store the parent commit" + }, + { + "name": "commit", + "cType": "git_commit *", + "cppClassName": "GitCommit", + "jsClassName": "Commit", + "isSelf": true, + "comment": "a previously loaded commit." + }, + { + "name": "n", + "cType": "unsigned int", + "cppClassName": "Uint32", + "jsClassName": "Number", + "comment": "the position of the parent (from 0 to `parentcount`)" + } + ], + "ignore": true, + "isAsync": true, + "isConstructorMethod": false, + "isPrototypeMethod": true, + "jsFunctionName": "parent", + "cppFunctionName": "Parent", + "return": { + "cType": "int", + "cppClassName": "Int32", + "isErrorCode": true, + "comment": "0 or an error code", + "jsClassName": "Number" + }, + "description": "

Get the specified parent of the commit.

\n" + }, + { + "cFunctionName": "git_commit_parent_id", + "args": [ + { + "name": "commit", + "cType": "git_commit *", + "cppClassName": "GitCommit", + "jsClassName": "Commit", + "isSelf": true, + "comment": "a previously loaded commit." + }, + { + "name": "n", + "cType": "unsigned int", + "cppClassName": "Uint32", + "jsClassName": "Number", + "comment": "the position of the parent (from 0 to `parentcount`)" + } + ], + "isAsync": false, + "isConstructorMethod": false, + "isPrototypeMethod": true, + "jsFunctionName": "parentId", + "cppFunctionName": "ParentId", + "return": { + "cType": "const git_oid *", + "cppClassName": "GitOid", + "copy": "git_oid_dup", + "comment": "the id of the parent, NULL on error.", + "jsClassName": "Oid" + }, + "description": "

Get the oid of a specified parent for a commit. This is different from\ngit_commit_parent, which will attempt to load the parent commit from\nthe ODB.

\n" + }, + { + "cFunctionName": "git_commit_nth_gen_ancestor", + "args": [ + { + "name": "ancestor", + "cType": "git_commit **", + "cppClassName": "GitCommit", + "jsClassName": "Commit", + "isReturn": true, + "comment": "Pointer where to store the ancestor commit" + }, + { + "name": "commit", + "cType": "const git_commit *", + "cppClassName": "GitCommit", + "jsClassName": "Commit", + "isSelf": true, + "comment": "a previously loaded commit." + }, + { + "name": "n", + "cType": "unsigned int", + "cppClassName": "Uint32", + "jsClassName": "Number", + "comment": "the requested generation" + } + ], + "isAsync": false, + "isConstructorMethod": false, + "isPrototypeMethod": true, + "jsFunctionName": "nthGenAncestor", + "cppFunctionName": "NthGenAncestor", + "return": { + "cType": "int", + "cppClassName": "Int32", + "isErrorCode": true, + "comment": "0 on success; GIT_ENOTFOUND if no matching ancestor exists or an error code", + "jsClassName": "Number" + }, + "description": "

Get the commit object that is the th generation ancestor\nof the named commit object, following only the first parents.\nThe returned commit has to be freed by the caller.

\n" + }, + { + "cFunctionName": "git_commit_create_v", + "args": [ + { + "name": "id", + "cType": "git_oid *", + "cppClassName": "GitOid", + "jsClassName": "Oid", + "shouldAlloc": true, + "isReturn": true + }, + { + "name": "repo", + "cType": "git_repository *", + "cppClassName": "GitRepo", + "jsClassName": "Repository" + }, + { + "name": "update_ref", + "cType": "const char *", + "cppClassName": "String", + "jsClassName": "String" + }, + { + "name": "author", + "cType": "const git_signature *", + "cppClassName": "GitSignature", + "jsClassName": "Signature" + }, + { + "name": "committer", + "cType": "const git_signature *", + "cppClassName": "GitSignature", + "jsClassName": "Signature" + }, + { + "name": "message_encoding", + "cType": "const char *", + "cppClassName": "String", + "jsClassName": "String" + }, + { + "name": "message", + "cType": "const char *", + "cppClassName": "String", + "jsClassName": "String" + }, + { + "name": "tree", + "cType": "const git_tree *", + "cppClassName": "GitTree", + "jsClassName": "Tree" + }, + { + "name": "parent_count", + "cType": "int", + "cppClassName": "Int32", + "jsClassName": "Number" + } + ], + "ignore": true, + "isAsync": false, + "isConstructorMethod": false, + "isPrototypeMethod": false, + "jsFunctionName": "createV", + "cppFunctionName": "CreateV", + "return": { + "cType": "int", + "cppClassName": "Int32", + "isErrorCode": true, + "jsClassName": "Number" + }, + "description": "

Create new commit in the repository using a variable argument list.

\n" + } + ] + }, + { + "filename": "common.h", + "ignore": true, + "jsClassName": "Common", + "cppClassName": "Common", + "cType": "git_common", + "functions": [ + { + "cFunctionName": "git_libgit2_version", + "args": [ + { + "name": "major", + "cType": "int *", + "cppClassName": "Int32", + "jsClassName": "Number", + "comment": "Store the major version number" + }, + { + "name": "minor", + "cType": "int *", + "cppClassName": "Int32", + "jsClassName": "Number", + "comment": "Store the minor version number" + }, + { + "name": "rev", + "cType": "int *", + "cppClassName": "Int32", + "jsClassName": "Number", + "comment": "Store the revision (patch) number" + } + ], + "isAsync": false, + "isConstructorMethod": false, + "isPrototypeMethod": false, + "jsFunctionName": "gitLibgit2Version", + "cppFunctionName": "GitLibgit2Version", + "return": { + "cType": "void", + "cppClassName": "void", + "jsClassName": "void" + }, + "description": "

Return the version of the libgit2 library\nbeing currently used.

\n" + }, + { + "cFunctionName": "git_libgit2_capabilities", + "args": [], + "isAsync": false, + "isConstructorMethod": false, + "isPrototypeMethod": false, + "jsFunctionName": "gitLibgit2Capabilities", + "cppFunctionName": "GitLibgit2Capabilities", + "return": { + "cType": "int", + "cppClassName": "Int32", + "isErrorCode": true, + "comment": "A combination of GIT_CAP_* values. - GIT_CAP_THREADS Libgit2 was compiled with thread support. Note that thread support is still to be seen as a 'work in progress' - basic object lookups are believed to be threadsafe, but other operations may not be. - GIT_CAP_HTTPS Libgit2 supports the https:// protocol. This requires the openssl library to be found when compiling libgit2.", + "jsClassName": "Number" + }, + "description": "

Query compile time options for libgit2.

\n" + }, + { + "cFunctionName": "git_libgit2_opts", + "args": [ + { + "name": "option", + "cType": "int", + "cppClassName": "Int32", + "jsClassName": "Number", + "comment": "Option key" + } + ], + "isAsync": false, + "isConstructorMethod": false, + "isPrototypeMethod": false, + "jsFunctionName": "gitLibgit2Opts", + "cppFunctionName": "GitLibgit2Opts", + "return": { + "cType": "int", + "cppClassName": "Int32", + "isErrorCode": true, + "comment": "0 on success, <0 on failure", + "jsClassName": "Number" + }, + "description": "

Set or query a library global option

\n" + } + ] + }, + { + "filename": "config.h", + "ignore": true, + "jsClassName": "Config", + "cppClassName": "Config", + "cType": "git_config", + "freeFunctionName": "git_config_free", + "functions": [ + { + "cFunctionName": "git_config_find_global", + "args": [ + { + "name": "out", + "isReturn": true, + "cType": "char *", + "cppClassName": "String", + "jsClassName": "String", + "comment": "Buffer to store the path in" + }, + { + "name": "length", + "cType": "size_t", + "cppClassName": "Uint32", + "jsClassName": "Number", + "comment": "size of the buffer in bytes" + } + ], + "isAsync": false, + "isConstructorMethod": false, + "isPrototypeMethod": false, + "jsFunctionName": "findGlobal", + "cppFunctionName": "FindGlobal", + "return": { + "cType": "int", + "cppClassName": "Int32", + "isErrorCode": true, + "comment": "0 if a global configuration file has been found. Its path will be stored in `buffer`.", + "jsClassName": "Number" + }, + "description": "

Locate the path to the global configuration file

\n" + }, + { + "cFunctionName": "git_config_find_xdg", + "args": [ + { + "name": "out", + "isReturn": true, + "cType": "char *", + "cppClassName": "String", + "jsClassName": "String", + "comment": "Buffer to store the path in" + }, + { + "name": "length", + "cType": "size_t", + "cppClassName": "Uint32", + "jsClassName": "Number", + "comment": "size of the buffer in bytes" + } + ], + "isAsync": false, + "isConstructorMethod": false, + "isPrototypeMethod": false, + "jsFunctionName": "findXdg", + "cppFunctionName": "FindXdg", + "return": { + "cType": "int", + "cppClassName": "Int32", + "isErrorCode": true, + "comment": "0 if a xdg compatible configuration file has been found. Its path will be stored in `buffer`.", + "jsClassName": "Number" + }, + "description": "

Locate the path to the global xdg compatible configuration file

\n" + }, + { + "cFunctionName": "git_config_find_system", + "args": [ + { + "name": "out", + "isReturn": true, + "cType": "char *", + "cppClassName": "String", + "jsClassName": "String", + "comment": "Buffer to store the path in" + }, + { + "name": "length", + "cType": "size_t", + "cppClassName": "Uint32", + "jsClassName": "Number", + "comment": "size of the buffer in bytes" + } + ], + "isAsync": false, + "isConstructorMethod": false, + "isPrototypeMethod": false, + "jsFunctionName": "findSystem", + "cppFunctionName": "FindSystem", + "return": { + "cType": "int", + "cppClassName": "Int32", + "isErrorCode": true, + "comment": "0 if a system configuration file has been found. Its path will be stored in `buffer`.", + "jsClassName": "Number" + }, + "description": "

Locate the path to the system configuration file

\n" + }, + { + "cFunctionName": "git_config_open_default", + "args": [ + { + "name": "out", + "isReturn": true, + "cType": "git_config **", + "cppClassName": "Config", + "jsClassName": "Config", + "comment": "Pointer to store the config instance" + } + ], + "isAsync": false, + "isConstructorMethod": true, + "isPrototypeMethod": false, + "jsFunctionName": "openDefault", + "cppFunctionName": "OpenDefault", + "return": { + "cType": "int", + "cppClassName": "Int32", + "isErrorCode": true, + "comment": "0 or an error code", + "jsClassName": "Number" + }, + "description": "

Open the global, XDG and system configuration files

\n" + }, + { + "cFunctionName": "git_config_new", + "args": [ + { + "name": "out", + "isReturn": true, + "cType": "git_config **", + "cppClassName": "Config", + "jsClassName": "Config", + "comment": "pointer to the new configuration" + } + ], + "isAsync": false, + "isConstructorMethod": true, + "isPrototypeMethod": false, + "jsFunctionName": "new", + "cppFunctionName": "New", + "return": { + "cType": "int", + "cppClassName": "Int32", + "isErrorCode": true, + "comment": "0 or an error code", + "jsClassName": "Number" + }, + "description": "

Allocate a new configuration object

\n" + }, + { + "cFunctionName": "git_config_add_backend", + "args": [ + { + "name": "cfg", + "cType": "git_config *", + "cppClassName": "Config", + "jsClassName": "Config", + "isSelf": true, + "comment": "the configuration to add the file to" + }, + { + "name": "file", + "cType": "git_config_backend *", + "cppClassName": "ConfigBackend", + "jsClassName": "ConfigBackend", + "comment": "the configuration file (backend) to add" + }, + { + "name": "level", + "cType": "unsigned int", + "cppClassName": "Uint32", + "jsClassName": "Number", + "comment": "the priority level of the backend" + }, + { + "name": "force", + "cType": "int", + "cppClassName": "Int32", + "jsClassName": "Number", + "comment": "if a config file already exists for the given priority level, replace it" + } + ], + "isAsync": false, + "isConstructorMethod": false, + "isPrototypeMethod": true, + "jsFunctionName": "addBackend", + "cppFunctionName": "AddBackend", + "return": { + "cType": "int", + "cppClassName": "Int32", + "isErrorCode": true, + "comment": "0 on success, GIT_EEXISTS when adding more than one file for a given priority level (and force_replace set to 0), or error code", + "jsClassName": "Number" + }, + "description": "

Add a generic config file instance to an existing config

\n" + }, + { + "cFunctionName": "git_config_add_file_ondisk", + "args": [ + { + "name": "cfg", + "cType": "git_config *", + "cppClassName": "Config", + "jsClassName": "Config", + "isSelf": true, + "comment": "the configuration to add the file to" + }, + { + "name": "path", + "cType": "const char *", + "cppClassName": "String", + "jsClassName": "String", + "comment": "path to the configuration file to add" + }, + { + "name": "level", + "cType": "unsigned int", + "cppClassName": "Uint32", + "jsClassName": "Number", + "comment": "the priority level of the backend" + }, + { + "name": "force", + "cType": "int", + "cppClassName": "Int32", + "jsClassName": "Number", + "comment": "replace config file at the given priority level" + } + ], + "isAsync": false, + "isConstructorMethod": false, + "isPrototypeMethod": true, + "jsFunctionName": "addFileOndisk", + "cppFunctionName": "AddFileOndisk", + "return": { + "cType": "int", + "cppClassName": "Int32", + "isErrorCode": true, + "comment": "0 on success, GIT_EEXISTS when adding more than one file for a given priority level (and force_replace set to 0), GIT_ENOTFOUND when the file doesn't exist or error code", + "jsClassName": "Number" + }, + "description": "

Add an on-disk config file instance to an existing config

\n" + }, + { + "cFunctionName": "git_config_open_ondisk", + "args": [ + { + "name": "out", + "isReturn": true, + "cType": "git_config **", + "cppClassName": "Config", + "jsClassName": "Config", + "comment": "The configuration instance to create" + }, + { + "name": "path", + "cType": "const char *", + "cppClassName": "String", + "jsClassName": "String", + "comment": "Path to the on-disk file to open" + } + ], + "isAsync": false, + "isConstructorMethod": true, + "isPrototypeMethod": false, + "jsFunctionName": "openOndisk", + "cppFunctionName": "OpenOndisk", + "return": { + "cType": "int", + "cppClassName": "Int32", + "isErrorCode": true, + "comment": "0 on success, GIT_ENOTFOUND when the file doesn't exist or an error code", + "jsClassName": "Number" + }, + "description": "

Create a new config instance containing a single on-disk file

\n" + }, + { + "cFunctionName": "git_config_open_level", + "args": [ + { + "name": "out", + "isReturn": true, + "cType": "git_config **", + "cppClassName": "Config", + "jsClassName": "Config", + "comment": "The configuration instance to create" + }, + { + "name": "parent", + "cType": "const git_config *", + "cppClassName": "Config", + "jsClassName": "Config", + "comment": "Multi-level config to search for the given level" + }, + { + "name": "level", + "cType": "unsigned int", + "cppClassName": "Uint32", + "jsClassName": "Number", + "comment": "Configuration level to search for" + } + ], + "isAsync": false, + "isConstructorMethod": true, + "isPrototypeMethod": false, + "jsFunctionName": "openLevel", + "cppFunctionName": "OpenLevel", + "return": { + "cType": "int", + "cppClassName": "Int32", + "isErrorCode": true, + "comment": "0, GIT_ENOTFOUND if the passed level cannot be found in the multi-level parent config, or an error code", + "jsClassName": "Number" + }, + "description": "

Build a single-level focused config object from a multi-level one.

\n" + }, + { + "cFunctionName": "git_config_refresh", + "args": [ + { + "name": "cfg", + "cType": "git_config *", + "cppClassName": "Config", + "jsClassName": "Config", + "isSelf": true, + "comment": "The configuration to refresh" + } + ], + "isAsync": false, + "isConstructorMethod": false, + "isPrototypeMethod": true, + "jsFunctionName": "refresh", + "cppFunctionName": "Refresh", + "return": { + "cType": "int", + "cppClassName": "Int32", + "isErrorCode": true, + "comment": "0 or an error code", + "jsClassName": "Number" + }, + "description": "

Reload changed config files

\n" + }, + { + "cFunctionName": "git_config_free", + "args": [ + { + "name": "cfg", + "cType": "git_config *", + "cppClassName": "Config", + "jsClassName": "Config", + "comment": "the configuration to free" + } + ], + "isAsync": false, + "isConstructorMethod": false, + "isPrototypeMethod": false, + "isFree": true, + "jsFunctionName": "free", + "cppFunctionName": "Free", + "return": { + "cType": "void", + "cppClassName": "void", + "jsClassName": "void" + }, + "description": "

Free the configuration and its associated memory and files

\n" + }, + { + "cFunctionName": "git_config_get_entry", + "args": [ + { + "name": "out", + "isReturn": true, + "cType": "const git_config_entry **", + "cppClassName": "ConfigEntry", + "jsClassName": "ConfigEntry", + "comment": "pointer to the variable git_config_entry" + }, + { + "name": "cfg", + "cType": "const git_config *", + "cppClassName": "Config", + "jsClassName": "Config", + "comment": "where to look for the variable" + }, + { + "name": "name", + "cType": "const char *", + "cppClassName": "String", + "jsClassName": "String", + "comment": "the variable's name" + } + ], + "isAsync": false, + "isConstructorMethod": false, + "isPrototypeMethod": false, + "jsFunctionName": "getEntry", + "cppFunctionName": "GetEntry", + "return": { + "cType": "int", + "cppClassName": "Int32", + "isErrorCode": true, + "comment": "0 or an error code", + "jsClassName": "Number" + }, + "description": "

Get the git_config_entry of a config variable.

\n" + }, + { + "cFunctionName": "git_config_get_int32", + "args": [ + { + "name": "out", + "isReturn": true, + "cType": "int32_t *", + "cppClassName": "int32_t", + "jsClassName": "int32_t", + "comment": "pointer to the variable where the value should be stored" + }, + { + "name": "cfg", + "cType": "const git_config *", + "cppClassName": "Config", + "jsClassName": "Config", + "comment": "where to look for the variable" + }, + { + "name": "name", + "cType": "const char *", + "cppClassName": "String", + "jsClassName": "String", + "comment": "the variable's name" + } + ], + "isAsync": false, + "isConstructorMethod": false, + "isPrototypeMethod": false, + "jsFunctionName": "getInt32", + "cppFunctionName": "GetInt32", + "return": { + "cType": "int", + "cppClassName": "Int32", + "isErrorCode": true, + "comment": "0 or an error code", + "jsClassName": "Number" + }, + "description": "

Get the value of an integer config variable.

\n" + }, + { + "cFunctionName": "git_config_get_int64", + "args": [ + { + "name": "out", + "isReturn": true, + "cType": "int64_t *", + "cppClassName": "int64_t", + "jsClassName": "int64_t", + "comment": "pointer to the variable where the value should be stored" + }, + { + "name": "cfg", + "cType": "const git_config *", + "cppClassName": "Config", + "jsClassName": "Config", + "comment": "where to look for the variable" + }, + { + "name": "name", + "cType": "const char *", + "cppClassName": "String", + "jsClassName": "String", + "comment": "the variable's name" + } + ], + "isAsync": false, + "isConstructorMethod": false, + "isPrototypeMethod": false, + "jsFunctionName": "getInt64", + "cppFunctionName": "GetInt64", + "return": { + "cType": "int", + "cppClassName": "Int32", + "isErrorCode": true, + "comment": "0 or an error code", + "jsClassName": "Number" + }, + "description": "

Get the value of a long integer config variable.

\n" + }, + { + "cFunctionName": "git_config_get_bool", + "args": [ + { + "name": "out", + "isReturn": true, + "cType": "int *", + "cppClassName": "Int32", + "jsClassName": "Number", + "comment": "pointer to the variable where the value should be stored" + }, + { + "name": "cfg", + "cType": "const git_config *", + "cppClassName": "Config", + "jsClassName": "Config", + "comment": "where to look for the variable" + }, + { + "name": "name", + "cType": "const char *", + "cppClassName": "String", + "jsClassName": "String", + "comment": "the variable's name" + } + ], + "isAsync": false, + "isConstructorMethod": false, + "isPrototypeMethod": false, + "jsFunctionName": "getBool", + "cppFunctionName": "GetBool", + "return": { + "cType": "int", + "cppClassName": "Int32", + "isErrorCode": true, + "comment": "0 or an error code", + "jsClassName": "Number" + }, + "description": "

Get the value of a boolean config variable.

\n" + }, + { + "cFunctionName": "git_config_get_string", + "args": [ + { + "name": "out", + "isReturn": true, + "cType": "const char **", + "cppClassName": "String", + "jsClassName": "String", + "comment": "pointer to the variable's value" + }, + { + "name": "cfg", + "cType": "const git_config *", + "cppClassName": "Config", + "jsClassName": "Config", + "comment": "where to look for the variable" + }, + { + "name": "name", + "cType": "const char *", + "cppClassName": "String", + "jsClassName": "String", + "comment": "the variable's name" + } + ], + "isAsync": false, + "isConstructorMethod": false, + "isPrototypeMethod": false, + "jsFunctionName": "getString", + "cppFunctionName": "GetString", + "return": { + "cType": "int", + "cppClassName": "Int32", + "isErrorCode": true, + "comment": "0 or an error code", + "jsClassName": "Number" + }, + "description": "

Get the value of a string config variable.

\n" + }, + { + "cFunctionName": "git_config_get_multivar", + "args": [ + { + "name": "cfg", + "cType": "const git_config *", + "cppClassName": "Config", + "jsClassName": "Config", + "isSelf": true, + "comment": "where to look for the variable" + }, + { + "name": "name", + "cType": "const char *", + "cppClassName": "String", + "jsClassName": "String", + "comment": "the variable's name" + }, + { + "name": "regexp", + "cType": "const char *", + "cppClassName": "String", + "jsClassName": "String", + "comment": "regular expression to filter which variables we're interested in. Use NULL to indicate all" + }, + { + "name": "callback", + "cType": "git_config_foreach_cb", + "cppClassName": "ConfigForeachCb", + "jsClassName": "ConfigForeachCb", + "comment": "the function to be called on each value of the variable" + }, + { + "name": "payload", + "cType": "void *", + "cppClassName": "void", + "jsClassName": "void", + "comment": "opaque pointer to pass to the callback" + } + ], + "isAsync": false, + "isConstructorMethod": false, + "isPrototypeMethod": true, + "jsFunctionName": "getMultivar", + "cppFunctionName": "GetMultivar", + "return": { + "cType": "int", + "cppClassName": "Int32", + "isErrorCode": true, + "jsClassName": "Number" + }, + "description": "

Get each value of a multivar.

\n" + }, + { + "cFunctionName": "git_config_set_int32", + "args": [ + { + "name": "cfg", + "cType": "git_config *", + "cppClassName": "Config", + "jsClassName": "Config", + "isSelf": true, + "comment": "where to look for the variable" + }, + { + "name": "name", + "cType": "const char *", + "cppClassName": "String", + "jsClassName": "String", + "comment": "the variable's name" + }, + { + "name": "value", + "cType": "int32_t", + "cppClassName": "int32_t", + "jsClassName": "int32_t", + "comment": "Integer value for the variable" + } + ], + "isAsync": false, + "isConstructorMethod": false, + "isPrototypeMethod": true, + "jsFunctionName": "setInt32", + "cppFunctionName": "SetInt32", + "return": { + "cType": "int", + "cppClassName": "Int32", + "isErrorCode": true, + "comment": "0 or an error code", + "jsClassName": "Number" + }, + "description": "

Set the value of an integer config variable in the config file\nwith the highest level (usually the local one).

\n" + }, + { + "cFunctionName": "git_config_set_int64", + "args": [ + { + "name": "cfg", + "cType": "git_config *", + "cppClassName": "Config", + "jsClassName": "Config", + "isSelf": true, + "comment": "where to look for the variable" + }, + { + "name": "name", + "cType": "const char *", + "cppClassName": "String", + "jsClassName": "String", + "comment": "the variable's name" + }, + { + "name": "value", + "cType": "int64_t", + "cppClassName": "int64_t", + "jsClassName": "int64_t", + "comment": "Long integer value for the variable" + } + ], + "isAsync": false, + "isConstructorMethod": false, + "isPrototypeMethod": true, + "jsFunctionName": "setInt64", + "cppFunctionName": "SetInt64", + "return": { + "cType": "int", + "cppClassName": "Int32", + "isErrorCode": true, + "comment": "0 or an error code", + "jsClassName": "Number" + }, + "description": "

Set the value of a long integer config variable in the config file\nwith the highest level (usually the local one).

\n" + }, + { + "cFunctionName": "git_config_set_bool", + "args": [ + { + "name": "cfg", + "cType": "git_config *", + "cppClassName": "Config", + "jsClassName": "Config", + "isSelf": true, + "comment": "where to look for the variable" + }, + { + "name": "name", + "cType": "const char *", + "cppClassName": "String", + "jsClassName": "String", + "comment": "the variable's name" + }, + { + "name": "value", + "cType": "int", + "cppClassName": "Int32", + "jsClassName": "Number", + "comment": "the value to store" + } + ], + "isAsync": false, + "isConstructorMethod": false, + "isPrototypeMethod": true, + "jsFunctionName": "setBool", + "cppFunctionName": "SetBool", + "return": { + "cType": "int", + "cppClassName": "Int32", + "isErrorCode": true, + "comment": "0 or an error code", + "jsClassName": "Number" + }, + "description": "

Set the value of a boolean config variable in the config file\nwith the highest level (usually the local one).

\n" + }, + { + "cFunctionName": "git_config_set_string", + "args": [ + { + "name": "cfg", + "cType": "git_config *", + "cppClassName": "Config", + "jsClassName": "Config", + "isSelf": true, + "comment": "where to look for the variable" + }, + { + "name": "name", + "cType": "const char *", + "cppClassName": "String", + "jsClassName": "String", + "comment": "the variable's name" + }, + { + "name": "value", + "cType": "const char *", + "cppClassName": "String", + "jsClassName": "String", + "comment": "the string to store." + } + ], + "isAsync": false, + "isConstructorMethod": false, + "isPrototypeMethod": true, + "jsFunctionName": "setString", + "cppFunctionName": "SetString", + "return": { + "cType": "int", + "cppClassName": "Int32", + "isErrorCode": true, + "comment": "0 or an error code", + "jsClassName": "Number" + }, + "description": "

Set the value of a string config variable in the config file\nwith the highest level (usually the local one).

\n" + }, + { + "cFunctionName": "git_config_set_multivar", + "args": [ + { + "name": "cfg", + "cType": "git_config *", + "cppClassName": "Config", + "jsClassName": "Config", + "isSelf": true, + "comment": "where to look for the variable" + }, + { + "name": "name", + "cType": "const char *", + "cppClassName": "String", + "jsClassName": "String", + "comment": "the variable's name" + }, + { + "name": "regexp", + "cType": "const char *", + "cppClassName": "String", + "jsClassName": "String", + "comment": "a regular expression to indicate which values to replace" + }, + { + "name": "value", + "cType": "const char *", + "cppClassName": "String", + "jsClassName": "String", + "comment": "the new value." + } + ], + "isAsync": false, + "isConstructorMethod": false, + "isPrototypeMethod": true, + "jsFunctionName": "setMultivar", + "cppFunctionName": "SetMultivar", + "return": { + "cType": "int", + "cppClassName": "Int32", + "isErrorCode": true, + "jsClassName": "Number" + }, + "description": "

Set a multivar in the local config file.

\n" + }, + { + "cFunctionName": "git_config_delete_entry", + "args": [ + { + "name": "cfg", + "cType": "git_config *", + "cppClassName": "Config", + "jsClassName": "Config", + "isSelf": true, + "comment": "the configuration" + }, + { + "name": "name", + "cType": "const char *", + "cppClassName": "String", + "jsClassName": "String", + "comment": "the variable to delete" + } + ], + "isAsync": false, + "isConstructorMethod": false, + "isPrototypeMethod": true, + "jsFunctionName": "deleteEntry", + "cppFunctionName": "DeleteEntry", + "return": { + "cType": "int", + "cppClassName": "Int32", + "isErrorCode": true, + "jsClassName": "Number" + }, + "description": "

Delete a config variable from the config file\nwith the highest level (usually the local one).

\n" + }, + { + "cFunctionName": "git_config_foreach", + "args": [ + { + "name": "cfg", + "cType": "const git_config *", + "cppClassName": "Config", + "jsClassName": "Config", + "isSelf": true, + "comment": "where to get the variables from" + }, + { + "name": "callback", + "cType": "git_config_foreach_cb", + "cppClassName": "ConfigForeachCb", + "jsClassName": "ConfigForeachCb", + "comment": "the function to call on each variable" + }, + { + "name": "payload", + "cType": "void *", + "cppClassName": "void", + "jsClassName": "void", + "comment": "the data to pass to the callback" + } + ], + "isAsync": false, + "isConstructorMethod": false, + "isPrototypeMethod": true, + "jsFunctionName": "foreach", + "cppFunctionName": "Foreach", + "return": { + "cType": "int", + "cppClassName": "Int32", + "isErrorCode": true, + "comment": "0 on success, GIT_EUSER on non-zero callback, or error code", + "jsClassName": "Number" + }, + "description": "

Perform an operation on each config variable.

\n" + }, + { + "cFunctionName": "git_config_foreach_match", + "args": [ + { + "name": "cfg", + "cType": "const git_config *", + "cppClassName": "Config", + "jsClassName": "Config", + "isSelf": true, + "comment": "where to get the variables from" + }, + { + "name": "regexp", + "cType": "const char *", + "cppClassName": "String", + "jsClassName": "String", + "comment": "regular expression to match against config names" + }, + { + "name": "callback", + "cType": "git_config_foreach_cb", + "cppClassName": "ConfigForeachCb", + "jsClassName": "ConfigForeachCb", + "comment": "the function to call on each variable" + }, + { + "name": "payload", + "cType": "void *", + "cppClassName": "void", + "jsClassName": "void", + "comment": "the data to pass to the callback" + } + ], + "isAsync": false, + "isConstructorMethod": false, + "isPrototypeMethod": true, + "jsFunctionName": "foreachMatch", + "cppFunctionName": "ForeachMatch", + "return": { + "cType": "int", + "cppClassName": "Int32", + "isErrorCode": true, + "comment": "0 or the return value of the callback which didn't return 0", + "jsClassName": "Number" + }, + "description": "

Perform an operation on each config variable matching a regular expression.

\n" + }, + { + "cFunctionName": "git_config_get_mapped", + "args": [ + { + "name": "out", + "isReturn": true, + "cType": "int *", + "cppClassName": "Int32", + "jsClassName": "Number", + "comment": "place to store the result of the mapping" + }, + { + "name": "cfg", + "cType": "const git_config *", + "cppClassName": "Config", + "jsClassName": "Config", + "comment": "config file to get the variables from" + }, + { + "name": "name", + "cType": "const char *", + "cppClassName": "String", + "jsClassName": "String", + "comment": "name of the config variable to lookup" + }, + { + "name": "maps", + "cType": "const git_cvar_map *", + "cppClassName": "CvarMap", + "jsClassName": "CvarMap", + "comment": "array of `git_cvar_map` objects specifying the possible mappings" + }, + { + "name": "map_n", + "cType": "size_t", + "cppClassName": "Uint32", + "jsClassName": "Number", + "comment": "number of mapping objects in `maps`" + } + ], + "isAsync": false, + "isConstructorMethod": false, + "isPrototypeMethod": false, + "jsFunctionName": "getMapped", + "cppFunctionName": "GetMapped", + "return": { + "cType": "int", + "cppClassName": "Int32", + "isErrorCode": true, + "comment": "0 on success, error code otherwise", + "jsClassName": "Number" + }, + "description": "

Query the value of a config variable and return it mapped to\nan integer constant.

\n" + }, + { + "cFunctionName": "git_config_lookup_map_value", + "args": [ + { + "name": "out", + "isReturn": true, + "cType": "int *", + "cppClassName": "Int32", + "jsClassName": "Number", + "comment": "place to store the result of the parsing" + }, + { + "name": "maps", + "cType": "const git_cvar_map *", + "cppClassName": "CvarMap", + "jsClassName": "CvarMap", + "comment": "array of `git_cvar_map` objects specifying the possible mappings" + }, + { + "name": "map_n", + "cType": "size_t", + "cppClassName": "Uint32", + "jsClassName": "Number", + "comment": "number of mapping objects in `maps`" + }, + { + "name": "value", + "cType": "const char *", + "cppClassName": "String", + "jsClassName": "String", + "comment": "value to parse" + } + ], + "isAsync": false, + "isConstructorMethod": false, + "isPrototypeMethod": false, + "jsFunctionName": "lookupMapValue", + "cppFunctionName": "LookupMapValue", + "return": { + "cType": "int", + "cppClassName": "Int32", + "isErrorCode": true, + "jsClassName": "Number" + }, + "description": "

Maps a string value to an integer constant

\n" + }, + { + "cFunctionName": "git_config_parse_bool", + "args": [ + { + "name": "out", + "isReturn": true, + "cType": "int *", + "cppClassName": "Int32", + "jsClassName": "Number", + "comment": "place to store the result of the parsing" + }, + { + "name": "value", + "cType": "const char *", + "cppClassName": "String", + "jsClassName": "String", + "comment": "value to parse" + } + ], + "isAsync": false, + "isConstructorMethod": false, + "isPrototypeMethod": false, + "jsFunctionName": "parseBool", + "cppFunctionName": "ParseBool", + "return": { + "cType": "int", + "cppClassName": "Int32", + "isErrorCode": true, + "jsClassName": "Number" + }, + "description": "

Parse a string value as a bool.

\n" + }, + { + "cFunctionName": "git_config_parse_int32", + "args": [ + { + "name": "out", + "isReturn": true, + "cType": "int32_t *", + "cppClassName": "int32_t", + "jsClassName": "int32_t", + "comment": "place to store the result of the parsing" + }, + { + "name": "value", + "cType": "const char *", + "cppClassName": "String", + "jsClassName": "String", + "comment": "value to parse" + } + ], + "isAsync": false, + "isConstructorMethod": false, + "isPrototypeMethod": false, + "jsFunctionName": "parseInt32", + "cppFunctionName": "ParseInt32", + "return": { + "cType": "int", + "cppClassName": "Int32", + "isErrorCode": true, + "jsClassName": "Number" + }, + "description": "

Parse a string value as an int32.

\n" + }, + { + "cFunctionName": "git_config_parse_int64", + "args": [ + { + "name": "out", + "isReturn": true, + "cType": "int64_t *", + "cppClassName": "int64_t", + "jsClassName": "int64_t", + "comment": "place to store the result of the parsing" + }, + { + "name": "value", + "cType": "const char *", + "cppClassName": "String", + "jsClassName": "String", + "comment": "value to parse" + } + ], + "isAsync": false, + "isConstructorMethod": false, + "isPrototypeMethod": false, + "jsFunctionName": "parseInt64", + "cppFunctionName": "ParseInt64", + "return": { + "cType": "int", + "cppClassName": "Int32", + "isErrorCode": true, + "jsClassName": "Number" + }, + "description": "

Parse a string value as an int64.

\n" + } + ] + }, + { + "filename": "cred_helpers.h", + "ignore": true, + "jsClassName": "CredHelpers", + "cppClassName": "CredHelpers", + "cType": "git_cred_helpers", + "freeFunctionName": "git_cred_helpers_free", + "functions": [ + { + "cFunctionName": "git_cred_userpass", + "args": [ + { + "name": "cred", + "cType": "git_cred **", + "cppClassName": "Cred", + "jsClassName": "Cred", + "comment": "The newly created credential object." + }, + { + "name": "url", + "cType": "const char *", + "cppClassName": "String", + "jsClassName": "String", + "comment": "The resource for which we are demanding a credential." + }, + { + "name": "user_from_url", + "cType": "const char *", + "cppClassName": "String", + "jsClassName": "String", + "comment": "The username that was embedded in a \"user@host\" remote url, or NULL if not included." + }, + { + "name": "allowed_types", + "cType": "unsigned int", + "cppClassName": "Uint32", + "jsClassName": "Number", + "comment": "A bitmask stating which cred types are OK to return." + }, + { + "name": "payload", + "cType": "void *", + "cppClassName": "void", + "jsClassName": "void", + "comment": "The payload provided when specifying this callback. (This is interpreted as a `git_cred_userpass_payload*`.)" + } + ], + "isAsync": false, + "isConstructorMethod": false, + "isPrototypeMethod": false, + "jsFunctionName": "gitCredUserpass", + "cppFunctionName": "GitCredUserpass", + "return": { + "cType": "int", + "cppClassName": "Int32", + "isErrorCode": true, + "jsClassName": "Number" + }, + "description": "

Stock callback usable as a git_cred_acquire_cb. This calls\ngit_cred_userpass_plaintext_new unless the protocol has not specified\nGIT_CREDTYPE_USERPASS_PLAINTEXT as an allowed type.

\n" + } + ] + }, + { + "filename": "patch.h", + "dependencies": [ + "../include/delta.h", + "../include/diff_range.h" + ], + "jsClassName": "Patch", + "cppClassName": "GitPatch", + "cType": "git_diff_patch", + "freeFunctionName": "git_diff_patch_free", + "functions": [ + { + "cFunctionName": "git_diff_patch_free", + "args": [ + { + "name": "patch", + "cType": "git_diff_patch *", + "cppClassName": "GitPatch", + "jsClassName": "Patch", + "isSelf": true + } + ], + "ignore": true, + "isAsync": false, + "isConstructorMethod": false, + "isPrototypeMethod": true, + "isFree": true, + "jsFunctionName": "patchFree", + "cppFunctionName": "PatchFree", + "return": { + "cType": "void", + "cppClassName": "void", + "jsClassName": "void" + }, + "description": "

Free a git_diff_patch object.

\n" + }, + { + "cFunctionName": "git_diff_patch_delta", + "args": [ + { + "name": "patch", + "cType": "git_diff_patch *", + "cppClassName": "GitPatch", + "jsClassName": "Patch", + "isSelf": true + } + ], + "isAsync": false, + "isConstructorMethod": false, + "isPrototypeMethod": true, + "jsFunctionName": "delta", + "cppFunctionName": "Delta", + "return": { + "cType": "const git_diff_delta *", + "cppClassName": "GitDelta", + "copy": "git_diff_delta_dup", + "jsClassName": "Delta" + }, + "description": "

Get the delta associated with a patch

\n" + }, + { + "cFunctionName": "git_diff_patch_num_hunks", + "args": [ + { + "name": "patch", + "cType": "git_diff_patch *", + "cppClassName": "GitPatch", + "jsClassName": "Patch", + "isSelf": true + } + ], + "isAsync": false, + "isConstructorMethod": false, + "isPrototypeMethod": true, + "jsFunctionName": "size", + "cppFunctionName": "Size", + "return": { + "cType": "size_t", + "cppClassName": "Uint32", + "jsClassName": "Number" + }, + "description": "

Get the number of hunks in a patch

\n" + }, + { + "cFunctionName": "git_diff_patch_line_stats", + "args": [ + { + "name": "total_context", + "cType": "size_t *", + "cppClassName": "Integer", + "jsClassName": "Number", + "isReturn": true, + "comment": "Count of context lines in output, can be NULL." + }, + { + "name": "total_additions", + "cType": "size_t *", + "cppClassName": "Integer", + "jsClassName": "Number", + "isReturn": true, + "comment": "Count of addition lines in output, can be NULL." + }, + { + "name": "total_deletions", + "cType": "size_t *", + "cppClassName": "Integer", + "jsClassName": "Number", + "isReturn": true, + "comment": "Count of deletion lines in output, can be NULL." + }, + { + "name": "patch", + "cType": "const git_diff_patch *", + "cppClassName": "GitPatch", + "jsClassName": "Patch", + "isSelf": true, + "comment": "The git_diff_patch object" + } + ], + "isAsync": false, + "isConstructorMethod": false, + "isPrototypeMethod": true, + "jsFunctionName": "stats", + "cppFunctionName": "Stats", + "return": { + "cType": "int", + "cppClassName": "Int32", + "isErrorCode": true, + "comment": "0 on success, <0 on error", + "jsClassName": "Number" + }, + "description": "

Get line counts of each type in a patch.

\n" + }, + { + "cFunctionName": "git_diff_patch_get_hunk", + "args": [ + { + "name": "range", + "jsName": "range", + "cType": "const git_diff_range **", + "cppClassName": "GitDiffRange", + "jsClassName": "DiffRange", + "isReturn": true, + "copy": "git_diff_range_dup", + "comment": "Output pointer to git_diff_range of hunk" + }, + { + "name": "header", + "jsName": "header", + "cType": "const char **", + "cppClassName": "String", + "jsClassName": "String", + "isReturn": true, + "comment": "Output pointer to header string for hunk. Unlike the content pointer for each line, this will be NUL-terminated" + }, + { + "name": "header_len", + "jsName": "headerLength", + "cType": "size_t *", + "cppClassName": "Uint32", + "jsClassName": "Number", + "isReturn": true, + "comment": "Output value of characters in header string" + }, + { + "name": "lines_in_hunk", + "jsName": "lines", + "cType": "size_t *", + "cppClassName": "Uint32", + "jsClassName": "Number", + "isReturn": true, + "comment": "Output count of total lines in this hunk" + }, + { + "name": "patch", + "cType": "git_diff_patch *", + "cppClassName": "GitPatch", + "jsClassName": "Patch", + "isSelf": true, + "comment": "Input pointer to patch object" + }, + { + "name": "hunk_idx", + "cType": "size_t", + "cppClassName": "Uint32", + "jsClassName": "Number", + "comment": "Input index of hunk to get information about" + } + ], + "isAsync": false, + "isConstructorMethod": false, + "isPrototypeMethod": true, + "jsFunctionName": "hunk", + "cppFunctionName": "Hunk", + "return": { + "cType": "int", + "cppClassName": "Int32", + "isErrorCode": true, + "comment": "0 on success, GIT_ENOTFOUND if hunk_idx out of range, <0 on error", + "jsClassName": "Number" + }, + "description": "

Get the information about a hunk in a patch

\n" + }, + { + "cFunctionName": "git_diff_patch_num_lines_in_hunk", + "args": [ + { + "name": "patch", + "cType": "git_diff_patch *", + "cppClassName": "GitPatch", + "jsClassName": "Patch", + "isSelf": true, + "comment": "The git_diff_patch object" + }, + { + "name": "hunk_idx", + "cType": "size_t", + "cppClassName": "Uint32", + "jsClassName": "Number", + "comment": "Index of the hunk" + } + ], + "isAsync": false, + "isConstructorMethod": false, + "isPrototypeMethod": true, + "jsFunctionName": "lines", + "cppFunctionName": "Lines", + "return": { + "cType": "int", + "cppClassName": "Int32", + "comment": "Number of lines in hunk or -1 if invalid hunk index", + "jsClassName": "Number" + }, + "description": "

Get the number of lines in a hunk.

\n" + }, + { + "cFunctionName": "git_diff_patch_get_line_in_hunk", + "args": [ + { + "name": "line_origin", + "jsName": "lineOrigin", + "cType": "char *", + "cppClassName": "Integer", + "jsClassName": "Number", + "isReturn": true, + "comment": "A GIT_DIFF_LINE constant from above" + }, + { + "name": "content", + "jsName": "content", + "size": "content_len", + "cType": "const char **", + "cppClassName": "String", + "jsClassName": "String", + "isReturn": true, + "comment": "Pointer to content of diff line, not NUL-terminated" + }, + { + "name": "content_len", + "jsName": "length", + "cType": "size_t *", + "cppClassName": "Uint32", + "jsClassName": "Number", + "isReturn": true, + "comment": "Number of characters in content" + }, + { + "name": "old_lineno", + "jsName": "oldLineNumber", + "cType": "int *", + "cppClassName": "Int32", + "jsClassName": "Number", + "isReturn": true, + "comment": "Line number in old file or -1 if line is added" + }, + { + "name": "new_lineno", + "jsName": "newLineNumber", + "cType": "int *", + "cppClassName": "Int32", + "jsClassName": "Number", + "isReturn": true, + "comment": "Line number in new file or -1 if line is deleted" + }, + { + "name": "patch", + "cType": "git_diff_patch *", + "cppClassName": "GitPatch", + "jsClassName": "Patch", + "isSelf": true, + "comment": "The patch to look in" + }, + { + "name": "hunk_idx", + "cType": "size_t", + "cppClassName": "Uint32", + "jsClassName": "Number", + "comment": "The index of the hunk" + }, + { + "name": "line_of_hunk", + "cType": "size_t", + "cppClassName": "Uint32", + "jsClassName": "Number", + "comment": "The index of the line in the hunk" + } + ], + "isAsync": false, + "isConstructorMethod": false, + "isPrototypeMethod": true, + "jsFunctionName": "line", + "cppFunctionName": "Line", + "return": { + "cType": "int", + "cppClassName": "Int32", + "isErrorCode": true, + "comment": "0 on success, <0 on failure", + "jsClassName": "Number" + }, + "description": "

Get data about a line in a hunk of a patch.

\n" + }, + { + "cFunctionName": "git_diff_patch_print", + "args": [ + { + "name": "patch", + "cType": "git_diff_patch *", + "cppClassName": "GitPatch", + "jsClassName": "Patch", + "isSelf": true, + "comment": "A git_diff_patch representing changes to one file" + }, + { + "name": "print_cb", + "cType": "git_diff_data_cb", + "cppClassName": "DiffDataCb", + "jsClassName": "DiffDataCb", + "comment": "Callback function to output lines of the patch. Will be called for file headers, hunk headers, and diff lines." + }, + { + "name": "payload", + "cType": "void *", + "cppClassName": "void", + "jsClassName": "void", + "comment": "Reference pointer that will be passed to your callbacks." + } + ], + "ignore": true, + "isAsync": false, + "isConstructorMethod": false, + "isPrototypeMethod": true, + "jsFunctionName": "patchPrint", + "cppFunctionName": "PatchPrint", + "return": { + "cType": "int", + "cppClassName": "Int32", + "isErrorCode": true, + "comment": "0 on success, GIT_EUSER on non-zero callback, or error code", + "jsClassName": "Number" + }, + "description": "

Serialize the patch to text via callback.

\n" + }, + { + "cFunctionName": "git_diff_patch_to_str", + "args": [ + { + "name": "string", + "cType": "char **", + "cppClassName": "String", + "jsClassName": "String", + "isReturn": true, + "comment": "Allocated string; caller must free.", + "freeFunctionName": "free" + }, + { + "name": "patch", + "cType": "git_diff_patch *", + "cppClassName": "GitPatch", + "jsClassName": "Patch", + "isSelf": true, + "comment": "A git_diff_patch representing changes to one file" + } + ], + "isAsync": false, + "isConstructorMethod": false, + "isPrototypeMethod": false, + "jsFunctionName": "toString", + "cppFunctionName": "ToString", + "return": { + "cType": "int", + "cppClassName": "Int32", + "isErrorCode": true, + "comment": "0 on success, <0 on failure.", + "jsClassName": "Number" + }, + "description": "

Get the content of a patch as a single diff text.

\n" + } + ] + }, + { + "filename": "clone_options.h", + "dependencies": [], + "jsClassName": "CloneOptions", + "cppClassName": "GitCloneOptions", + "cType": "git_clone_options", + "freeFunctionName": "free", + "fields": [] + }, + { + "filename": "diff_options.h", + "dependencies": [], + "jsClassName": "DiffOptions", + "cppClassName": "GitDiffOptions", + "cType": "git_diff_options", + "freeFunctionName": "free", + "fields": [] + }, + { + "filename": "diff_find_options.h", + "dependencies": [], + "jsClassName": "DiffFindOptions", + "cppClassName": "GitDiffFindOptions", + "cType": "git_diff_find_options", + "freeFunctionName": "free", + "fields": [] + }, + { + "filename": "diff_range.h", + "dependencies": [], + "jsClassName": "DiffRange", + "cppClassName": "GitDiffRange", + "cType": "git_diff_range", + "freeFunctionName": "free", + "fields": [ + { + "jsFunctionName": "oldStart", + "cppFunctionName": "OldStart", + "name": "old_start", + "cType": "int", + "cppClassName": "Integer", + "jsClassName": "Number" + }, + { + "jsFunctionName": "oldLines", + "cppFunctionName": "OldLines", + "name": "old_lines", + "cType": "int", + "cppClassName": "Integer", + "jsClassName": "Number" + }, + { + "jsFunctionName": "newStart", + "cppFunctionName": "NewStart", + "name": "new_start", + "cType": "int", + "cppClassName": "Integer", + "jsClassName": "Number" + }, + { + "jsFunctionName": "newLines", + "cppFunctionName": "NewLines", + "name": "new_lines", + "cType": "int", + "cppClassName": "Integer", + "jsClassName": "Number" + } + ] + }, + { + "filename": "diff_file.h", + "dependencies": [ + "../include/oid.h" + ], + "jsClassName": "DiffFile", + "cppClassName": "GitDiffFile", + "cType": "git_diff_file", + "freeFunctionName": "free", + "fields": [ + { + "jsFunctionName": "oid", + "cppFunctionName": "Oid", + "name": "oid", + "cType": "git_oid", + "cppClassName": "GitOid", + "jsClassName": "Oid", + "copy": "git_oid_dup" + }, + { + "jsFunctionName": "path", + "cppFunctionName": "Path", + "name": "path", + "cType": "const char *", + "cppClassName": "String", + "jsClassName": "String" + }, + { + "jsFunctionName": "size", + "cppFunctionName": "Size", + "name": "size", + "cType": "git_off_t", + "cppClassName": "Integer", + "jsClassName": "Number" + }, + { + "jsFunctionName": "flags", + "cppFunctionName": "Flags", + "name": "flags", + "cType": "uint32_t", + "cppClassName": "Integer", + "jsClassName": "Number" + }, + { + "jsFunctionName": "mode", + "cppFunctionName": "Mode", + "name": "mode", + "cType": "uint16_t", + "cppClassName": "Integer", + "jsClassName": "Number" + } + ] + }, + { + "filename": "delta.h", + "dependencies": [ + "../include/diff_file.h" + ], + "jsClassName": "Delta", + "cppClassName": "GitDelta", + "cType": "git_diff_delta", + "freeFunctionName": "free", + "fields": [ + { + "jsFunctionName": "oldFile", + "cppFunctionName": "OldFile", + "name": "old_file", + "cType": "git_diff_file", + "cppClassName": "GitDiffFile", + "jsClassName": "DiffFile", + "copy": "git_diff_file_dup" + }, + { + "jsFunctionName": "newFile", + "cppFunctionName": "NewFile", + "name": "new_file", + "cType": "git_diff_file", + "cppClassName": "GitDiffFile", + "jsClassName": "DiffFile", + "copy": "git_diff_file_dup" + }, + { + "jsFunctionName": "status", + "cppFunctionName": "Status", + "name": "status", + "cType": "git_delta_t", + "cppClassName": "Integer", + "jsClassName": "Number" + }, + { + "jsFunctionName": "similarity", + "cppFunctionName": "Similarity", + "name": "similarity", + "cType": "uint32_t", + "cppClassName": "Integer", + "jsClassName": "Number" + }, + { + "jsFunctionName": "flags", + "cppFunctionName": "Flags", + "name": "flags", + "cType": "uint32_t", + "cppClassName": "Integer", + "jsClassName": "Number" + } + ] + }, + { + "filename": "diff_list.h", + "dependencies": [ + "../include/diff_options.h", + "../include/diff_find_options.h", + "../include/repo.h", + "../include/tree.h", + "../include/index.h", + "../include/patch.h", + "../include/delta.h" + ], + "jsClassName": "DiffList", + "cppClassName": "GitDiffList", + "cType": "git_diff_list", + "freeFunctionName": "git_diff_list_free", + "functions": [ + { + "cFunctionName": "git_diff_list_free", + "args": [ + { + "name": "diff", + "cType": "git_diff_list *", + "cppClassName": "GitDiffList", + "jsClassName": "DiffList", + "comment": "The previously created diff list; cannot be used after free." + } + ], + "ignore": true, + "isAsync": false, + "isConstructorMethod": false, + "isPrototypeMethod": false, + "isFree": true, + "jsFunctionName": "listFree", + "cppFunctionName": "ListFree", + "return": { + "cType": "void", + "cppClassName": "void", + "jsClassName": "void" + }, + "description": "

Deallocate a diff list.

\n" + }, + { + "cFunctionName": "git_diff_merge", + "args": [ + { + "name": "onto", + "cType": "git_diff_list *", + "cppClassName": "GitDiffList", + "jsClassName": "DiffList", + "isSelf": true, + "comment": "Diff to merge into." + }, + { + "name": "from", + "cType": "const git_diff_list *", + "cppClassName": "GitDiffList", + "jsClassName": "DiffList", + "comment": "Diff to merge." + } + ], + "isAsync": false, + "isConstructorMethod": false, + "isPrototypeMethod": true, + "jsFunctionName": "merge", + "cppFunctionName": "Merge", + "return": { + "cType": "int", + "cppClassName": "Int32", + "isErrorCode": true, + "jsClassName": "Number" + }, + "description": "

Merge one diff list into another.

\n" + }, + { + "cFunctionName": "git_diff_find_similar", + "args": [ + { + "name": "diff", + "cType": "git_diff_list *", + "cppClassName": "GitDiffList", + "jsClassName": "DiffList", + "isSelf": true, + "comment": "Diff list to run detection algorithms on" + }, + { + "name": "options", + "cType": "git_diff_find_options *", + "cppClassName": "GitDiffFindOptions", + "jsClassName": "DiffFindOptions", + "comment": "Control how detection should be run, NULL for defaults" + } + ], + "isAsync": false, + "isConstructorMethod": false, + "isPrototypeMethod": true, + "jsFunctionName": "findSimilar", + "cppFunctionName": "FindSimilar", + "return": { + "cType": "int", + "cppClassName": "Int32", + "isErrorCode": true, + "comment": "0 on success, -1 on failure", + "jsClassName": "Number" + }, + "description": "

Transform a diff list marking file renames, copies, etc.

\n" + }, + { + "cFunctionName": "git_diff_foreach", + "args": [ + { + "name": "diff", + "cType": "git_diff_list *", + "cppClassName": "GitDiffList", + "jsClassName": "DiffList", + "comment": "A git_diff_list generated by one of the above functions." + }, + { + "name": "file_cb", + "cType": "git_diff_file_cb", + "cppClassName": "DiffFileCb", + "jsClassName": "DiffFileCb", + "comment": "Callback function to make per file in the diff." + }, + { + "name": "hunk_cb", + "cType": "git_diff_hunk_cb", + "cppClassName": "DiffHunkCb", + "jsClassName": "DiffHunkCb", + "comment": "Optional callback to make per hunk of text diff. This callback is called to describe a range of lines in the diff. It will not be issued for binary files." + }, + { + "name": "line_cb", + "cType": "git_diff_data_cb", + "cppClassName": "DiffDataCb", + "jsClassName": "DiffDataCb", + "comment": "Optional callback to make per line of diff text. This same callback will be made for context lines, added, and removed lines, and even for a deleted trailing newline." + }, + { + "name": "payload", + "cType": "void *", + "cppClassName": "void", + "jsClassName": "void", + "comment": "Reference pointer that will be passed to your callbacks." + } + ], + "ignore": true, + "isAsync": false, + "isConstructorMethod": false, + "isPrototypeMethod": false, + "jsFunctionName": "foreach", + "cppFunctionName": "Foreach", + "return": { + "cType": "int", + "cppClassName": "Int32", + "isErrorCode": true, + "comment": "0 on success, GIT_EUSER on non-zero callback, or error code", + "jsClassName": "Number" + }, + "description": "

Loop over all deltas in a diff list issuing callbacks.

\n" + }, + { + "cFunctionName": "git_diff_print_compact", + "args": [ + { + "name": "diff", + "cType": "git_diff_list *", + "cppClassName": "GitDiffList", + "jsClassName": "DiffList", + "comment": "A git_diff_list generated by one of the above functions." + }, + { + "name": "print_cb", + "cType": "git_diff_data_cb", + "cppClassName": "DiffDataCb", + "jsClassName": "DiffDataCb", + "comment": "Callback to make per line of diff text." + }, + { + "name": "payload", + "cType": "void *", + "cppClassName": "void", + "jsClassName": "void", + "comment": "Reference pointer that will be passed to your callback." + } + ], + "ignore": true, + "isAsync": false, + "isConstructorMethod": false, + "isPrototypeMethod": false, + "jsFunctionName": "printCompact", + "cppFunctionName": "PrintCompact", + "return": { + "cType": "int", + "cppClassName": "Int32", + "isErrorCode": true, + "comment": "0 on success, GIT_EUSER on non-zero callback, or error code", + "jsClassName": "Number" + }, + "description": "

Iterate over a diff generating text output like "git diff --name-status".

\n" + }, + { + "cFunctionName": "git_diff_status_char", + "args": [ + { + "name": "status", + "cType": "git_delta_t", + "cppClassName": "Int32", + "jsClassName": "Number", + "comment": "The git_delta_t value to look up" + } + ], + "ignore": true, + "isAsync": false, + "isConstructorMethod": false, + "isPrototypeMethod": false, + "jsFunctionName": "statusChar", + "cppFunctionName": "StatusChar", + "return": { + "cType": "char", + "cppClassName": "String", + "comment": "The single character label for that code", + "jsClassName": "String" + }, + "description": "

Look up the single character abbreviation for a delta status code.

\n" + }, + { + "cFunctionName": "git_diff_print_patch", + "args": [ + { + "name": "diff", + "cType": "git_diff_list *", + "cppClassName": "GitDiffList", + "jsClassName": "DiffList", + "isSelf": true, + "comment": "A git_diff_list generated by one of the above functions." + }, + { + "name": "print_cb", + "cType": "git_diff_data_cb", + "cppClassName": "DiffDataCb", + "jsClassName": "DiffDataCb", + "comment": "Callback function to output lines of the diff. This same function will be called for file headers, hunk headers, and diff lines. Fortunately, you can probably use various GIT_DIFF_LINE constants to determine what text you are given." + }, + { + "name": "payload", + "cType": "void *", + "cppClassName": "void", + "jsClassName": "void", + "comment": "Reference pointer that will be passed to your callbacks." + } + ], + "ignore": true, + "isAsync": false, + "isConstructorMethod": false, + "isPrototypeMethod": true, + "jsFunctionName": "printPatch", + "cppFunctionName": "PrintPatch", + "return": { + "cType": "int", + "cppClassName": "Int32", + "isErrorCode": true, + "comment": "0 on success, GIT_EUSER on non-zero callback, or error code", + "jsClassName": "Number" + }, + "description": "

Iterate over a diff generating text output like "git diff".

\n" + }, + { + "cFunctionName": "git_diff_num_deltas", + "args": [ + { + "name": "diff", + "cType": "git_diff_list *", + "cppClassName": "GitDiffList", + "jsClassName": "DiffList", + "isSelf": true, + "comment": "A git_diff_list generated by one of the above functions" + } + ], + "isAsync": false, + "isConstructorMethod": false, + "isPrototypeMethod": true, + "jsFunctionName": "size", + "cppFunctionName": "Size", + "return": { + "cType": "size_t", + "cppClassName": "Uint32", + "comment": "Count of number of deltas in the list", + "jsClassName": "Number" + }, + "description": "

Query how many diff records are there in a diff list.

\n" + }, + { + "cFunctionName": "git_diff_num_deltas_of_type", + "args": [ + { + "name": "diff", + "cType": "git_diff_list *", + "cppClassName": "GitDiffList", + "jsClassName": "DiffList", + "comment": "A git_diff_list generated by one of the above functions" + }, + { + "name": "type", + "cType": "git_delta_t", + "cppClassName": "Int32", + "jsClassName": "Number", + "comment": "A git_delta_t value to filter the count" + } + ], + "isAsync": false, + "isConstructorMethod": false, + "isPrototypeMethod": false, + "jsFunctionName": "numDeltasOfType", + "cppFunctionName": "NumDeltasOfType", + "return": { + "cType": "size_t", + "cppClassName": "Uint32", + "comment": "Count of number of deltas matching delta_t type", + "jsClassName": "Number" + }, + "description": "

Query how many diff deltas are there in a diff list filtered by type.

\n" + }, + { + "cFunctionName": "git_diff_get_patch", + "args": [ + { + "name": "patch_out", + "jsName": "patch", + "cType": "git_diff_patch **", + "cppClassName": "GitPatch", + "jsClassName": "Patch", + "isReturn": true, + "comment": "Output parameter for the delta patch object" + }, + { + "name": "delta_out", + "jsName": "delta", + "cType": "const git_diff_delta **", + "cppClassName": "GitDelta", + "jsClassName": "Delta", + "isReturn": true, + "comment": "Output parameter for the delta object" + }, + { + "name": "diff", + "cType": "git_diff_list *", + "cppClassName": "GitDiffList", + "jsClassName": "DiffList", + "isSelf": true, + "comment": "Diff list object" + }, + { + "name": "idx", + "cType": "size_t", + "cppClassName": "Uint32", + "jsClassName": "Number", + "comment": "Index into diff list" + } + ], + "isAsync": false, + "isConstructorMethod": false, + "isPrototypeMethod": true, + "jsFunctionName": "patch", + "cppFunctionName": "Patch", + "return": { + "cType": "int", + "cppClassName": "Int32", + "isErrorCode": true, + "comment": "0 on success, other value < 0 on error", + "jsClassName": "Number" + }, + "description": "

Return the diff delta and patch for an entry in the diff list.

\n" + }, + { + "cFunctionName": "git_diff_blobs", + "args": [ + { + "name": "old_blob", + "cType": "const git_blob *", + "cppClassName": "GitBlob", + "jsClassName": "Blob", + "comment": "Blob for old side of diff, or NULL for empty blob" + }, + { + "name": "new_blob", + "cType": "const git_blob *", + "cppClassName": "GitBlob", + "jsClassName": "Blob" + }, + { + "name": "options", + "cType": "const git_diff_options *", + "cppClassName": "GitDiffOptions", + "jsClassName": "DiffOptions" + }, + { + "name": "file_cb", + "cType": "git_diff_file_cb", + "cppClassName": "DiffFileCb", + "jsClassName": "DiffFileCb" + }, + { + "name": "hunk_cb", + "cType": "git_diff_hunk_cb", + "cppClassName": "DiffHunkCb", + "jsClassName": "DiffHunkCb" + }, + { + "name": "line_cb", + "cType": "git_diff_data_cb", + "cppClassName": "DiffDataCb", + "jsClassName": "DiffDataCb" + }, + { + "name": "payload", + "cType": "void *", + "cppClassName": "void", + "jsClassName": "void" + } + ], + "ignore": true, + "isAsync": false, + "isConstructorMethod": false, + "isPrototypeMethod": false, + "jsFunctionName": "blobs", + "cppFunctionName": "Blobs", + "return": { + "cType": "int", + "cppClassName": "Int32", + "isErrorCode": true, + "comment": "0 on success, GIT_EUSER on non-zero callback return, or error code", + "jsClassName": "Number" + }, + "description": "

Directly run a diff on two blobs.

\n" + }, + { + "cFunctionName": "git_diff_blob_to_buffer", + "args": [ + { + "name": "old_blob", + "cType": "const git_blob *", + "cppClassName": "GitBlob", + "jsClassName": "Blob", + "comment": "Blob for old side of diff, or NULL for empty blob" + }, + { + "name": "buffer", + "cType": "const char *", + "cppClassName": "String", + "jsClassName": "String" + }, + { + "name": "buffer_len", + "cType": "size_t", + "cppClassName": "Uint32", + "jsClassName": "Number" + }, + { + "name": "options", + "cType": "const git_diff_options *", + "cppClassName": "GitDiffOptions", + "jsClassName": "DiffOptions" + }, + { + "name": "file_cb", + "cType": "git_diff_file_cb", + "cppClassName": "DiffFileCb", + "jsClassName": "DiffFileCb" + }, + { + "name": "hunk_cb", + "cType": "git_diff_hunk_cb", + "cppClassName": "DiffHunkCb", + "jsClassName": "DiffHunkCb" + }, + { + "name": "data_cb", + "cType": "git_diff_data_cb", + "cppClassName": "DiffDataCb", + "jsClassName": "DiffDataCb" + }, + { + "name": "payload", + "cType": "void *", + "cppClassName": "void", + "jsClassName": "void" + } + ], + "ignore": true, + "isAsync": false, + "isConstructorMethod": false, + "isPrototypeMethod": false, + "jsFunctionName": "blobToBuffer", + "cppFunctionName": "BlobToBuffer", + "return": { + "cType": "int", + "cppClassName": "Int32", + "isErrorCode": true, + "comment": "0 on success, GIT_EUSER on non-zero callback return, or error code", + "jsClassName": "Number" + }, + "description": "

Directly run a diff between a blob and a buffer.

\n" + } + ] + }, + { + "filename": "error.h", + "ignore": true, + "jsClassName": "Error", + "cppClassName": "GitError", + "cType": "git_error", + "freeFunctionName": "git_errors_free", + "functions": [ + { + "cFunctionName": "giterr_last", + "args": [], + "ignore": true, + "isAsync": false, + "isConstructorMethod": false, + "isPrototypeMethod": true, + "jsFunctionName": "lastError", + "cppFunctionName": "LastError", + "return": { + "cType": "const git_error *", + "cppClassName": "Error", + "copy": "fixme", + "comment": "A git_error object." + }, + "description": "

Return the last git_error object that was generated for the\ncurrent thread or NULL if no error has occurred.

\n" + }, + { + "cFunctionName": "giterr_clear", + "args": [], + "ignore": true, + "isAsync": false, + "isConstructorMethod": false, + "isPrototypeMethod": false, + "jsFunctionName": "clear", + "cppFunctionName": "Clear", + "return": { + "cType": "void", + "cppClassName": "void", + "jsClassName": "void" + }, + "description": "

Clear the last library error that occurred for this thread.

\n" + }, + { + "cFunctionName": "giterr_set_str", + "args": [ + { + "name": "error_class", + "cType": "int", + "cppClassName": "Int32", + "jsClassName": "Number", + "comment": "One of the `git_error_t` enum above describing the general subsystem that is responsible for the error." + }, + { + "name": "string", + "cType": "const char *", + "cppClassName": "String", + "jsClassName": "String", + "comment": "The formatted error message to keep" + } + ], + "ignore": true, + "isAsync": false, + "isConstructorMethod": false, + "isPrototypeMethod": false, + "jsFunctionName": "setString", + "cppFunctionName": "SetString", + "return": { + "cType": "void", + "cppClassName": "void", + "jsClassName": "void" + }, + "description": "

Set the error message string for this thread.

\n" + }, + { + "cFunctionName": "giterr_set_oom", + "args": [], + "ignore": true, + "isAsync": false, + "isConstructorMethod": false, + "isPrototypeMethod": false, + "jsFunctionName": "setOOM", + "cppFunctionName": "SetOOM", + "return": { + "cType": "void", + "cppClassName": "void", + "jsClassName": "void" + }, + "description": "

Set the error message to a special value for memory allocation failure.

\n" + } + ] + }, + { + "filename": "graph.h", + "ignore": true, + "jsClassName": "Graph", + "cppClassName": "Graph", + "cType": "git_graph", + "freeFunctionName": "git_graph_free", + "functions": [ + { + "cFunctionName": "git_graph_ahead_behind", + "args": [ + { + "name": "ahead", + "cType": "size_t *", + "cppClassName": "Uint32", + "jsClassName": "Number", + "comment": "number of unique from commits in `upstream`" + }, + { + "name": "behind", + "cType": "size_t *", + "cppClassName": "Uint32", + "jsClassName": "Number", + "comment": "number of unique from commits in `local`" + }, + { + "name": "repo", + "cType": "git_repository *", + "cppClassName": "GitRepo", + "jsClassName": "Repository", + "comment": "the repository where the commits exist" + }, + { + "name": "local", + "cType": "const git_oid *", + "cppClassName": "GitOid", + "jsClassName": "Oid", + "comment": "the commit for local" + }, + { + "name": "upstream", + "cType": "const git_oid *", + "cppClassName": "GitOid", + "jsClassName": "Oid", + "comment": "the commit for upstream" + } + ], + "isAsync": false, + "isConstructorMethod": false, + "isPrototypeMethod": false, + "jsFunctionName": "aheadBehind", + "cppFunctionName": "AheadBehind", + "return": { + "cType": "int", + "cppClassName": "Int32", + "isErrorCode": true, + "jsClassName": "Number" + }, + "description": "

Count the number of unique commits between two commit objects

\n" + } + ] + }, + { + "filename": "ignore.h", + "ignore": true, + "jsClassName": "Ignore", + "cppClassName": "Ignore", + "cType": "git_ignore", + "freeFunctionName": "git_ignore_free", + "functions": [ + { + "cFunctionName": "git_ignore_add_rule", + "args": [ + { + "name": "repo", + "cType": "git_repository *", + "cppClassName": "GitRepo", + "jsClassName": "Repository", + "comment": "The repository to add ignore rules to." + }, + { + "name": "rules", + "cType": "const char *", + "cppClassName": "String", + "jsClassName": "String", + "comment": "Text of rules, a la the contents of a .gitignore file. It is okay to have multiple rules in the text; if so, each rule should be terminated with a newline." + } + ], + "isAsync": false, + "isConstructorMethod": false, + "isPrototypeMethod": false, + "jsFunctionName": "addRule", + "cppFunctionName": "AddRule", + "return": { + "cType": "int", + "cppClassName": "Int32", + "isErrorCode": true, + "comment": "0 on success", + "jsClassName": "Number" + }, + "description": "

Add ignore rules for a repository.

\n" + }, + { + "cFunctionName": "git_ignore_clear_internal_rules", + "args": [ + { + "name": "repo", + "cType": "git_repository *", + "cppClassName": "GitRepo", + "jsClassName": "Repository", + "comment": "The repository to remove ignore rules from." + } + ], + "isAsync": false, + "isConstructorMethod": false, + "isPrototypeMethod": false, + "jsFunctionName": "clearInternalRules", + "cppFunctionName": "ClearInternalRules", + "return": { + "cType": "int", + "cppClassName": "Int32", + "isErrorCode": true, + "comment": "0 on success", + "jsClassName": "Number" + }, + "description": "

Clear ignore rules that were explicitly added.

\n" + }, + { + "cFunctionName": "git_ignore_path_is_ignored", + "args": [ + { + "name": "ignored", + "cType": "int *", + "cppClassName": "Int32", + "jsClassName": "Number", + "comment": "boolean returning 0 if the file is not ignored, 1 if it is" + }, + { + "name": "repo", + "cType": "git_repository *", + "cppClassName": "GitRepo", + "jsClassName": "Repository", + "comment": "a repository object" + }, + { + "name": "path", + "cType": "const char *", + "cppClassName": "String", + "jsClassName": "String", + "comment": "the file to check ignores for, relative to the repo's workdir." + } + ], + "isAsync": false, + "isConstructorMethod": false, + "isPrototypeMethod": false, + "jsFunctionName": "pathIsIgnored", + "cppFunctionName": "PathIsIgnored", + "return": { + "cType": "int", + "cppClassName": "Int32", + "isErrorCode": true, + "comment": "0 if ignore rules could be processed for the file (regardless of whether it exists or not), or an error < 0 if they could not.", + "jsClassName": "Number" + }, + "description": "

Test if the ignore rules apply to a given path.

\n" + } + ] + }, + { + "filename": "index_time.h", + "jsClassName": "IndexTime", + "cppClassName": "GitIndexTime", + "cType": "git_index_time", + "freeFunctionName": "free", + "fields": [ + { + "jsFunctionName": "seconds", + "cppFunctionName": "Seconds", + "name": "seconds", + "cType": "git_time_t", + "cppClassName": "Uint32", + "jsClassName": "Number" + }, + { + "jsFunctionName": "nanoseconds", + "cppFunctionName": "Nanoseconds", + "name": "nanoseconds", + "cType": "unsigned int", + "cppClassName": "Uint32", + "jsClassName": "Number" + } + ] + }, + { + "filename": "index_entry.h", + "dependencies": [ + "../include/index_time.h" + ], + "jsClassName": "IndexEntry", + "cppClassName": "GitIndexEntry", + "cType": "git_index_entry", + "freeFunctionName": "free", + "fields": [ + { + "jsFunctionName": "ctime", + "cppFunctionName": "Ctime", + "name": "ctime", + "cType": "git_index_time", + "cppClassName": "GitIndexTime", + "jsClassName": "IndexTime", + "copy": "git_index_time_dup" + }, + { + "jsFunctionName": "mtime", + "cppFunctionName": "Mtime", + "name": "mtime", + "cType": "git_index_time", + "cppClassName": "GitIndexTime", + "jsClassName": "IndexTime", + "copy": "git_index_time_dup" + }, + { + "jsFunctionName": "path", + "cppFunctionName": "Path", + "name": "path", + "cType": "char *", + "cppClassName": "String", + "jsClassName": "String" + } + ] + }, + { + "filename": "index.h", + "dependencies": [ + "../include/oid.h", + "../include/repo.h", + "../include/tree.h", + "../include/diff_list.h", + "../include/diff_options.h", + "../include/index_entry.h" + ], + "jsClassName": "Index", + "cppClassName": "GitIndex", + "cType": "git_index", + "freeFunctionName": "git_index_free", + "functions": [ + { + "cFunctionName": "git_index_open", + "args": [ + { + "name": "out", + "isReturn": true, + "cType": "git_index **", + "cppClassName": "GitIndex", + "jsClassName": "Index", + "comment": "the pointer for the new index" + }, + { + "name": "index_path", + "cType": "const char *", + "cppClassName": "String", + "jsClassName": "String", + "comment": "the path to the index file in disk" + } + ], + "isAsync": true, + "isConstructorMethod": true, + "isPrototypeMethod": false, + "jsFunctionName": "open", + "cppFunctionName": "Open", + "return": { + "cType": "int", + "cppClassName": "Int32", + "isErrorCode": true, + "comment": "0 or an error code", + "jsClassName": "Number" + }, + "description": "

Create a new bare Git index object as a memory representation\nof the Git index file in 'index_path', without a repository\nto back it.

\n" + }, + { + "cFunctionName": "git_index_new", + "args": [ + { + "name": "out", + "isReturn": true, + "cType": "git_index **", + "cppClassName": "GitIndex", + "jsClassName": "Index", + "comment": "the pointer for the new index" + } + ], + "ignore": true, + "isAsync": false, + "isConstructorMethod": true, + "isPrototypeMethod": false, + "jsFunctionName": "new", + "cppFunctionName": "New", + "return": { + "cType": "int", + "cppClassName": "Int32", + "isErrorCode": true, + "comment": "0 or an error code", + "jsClassName": "Number" + }, + "description": "

Create an in-memory index object.

\n" + }, + { + "cFunctionName": "git_index_free", + "args": [ + { + "name": "index", + "cType": "git_index *", + "cppClassName": "GitIndex", + "jsClassName": "Index", + "comment": "an existing index object" + } + ], + "ignore": true, + "isAsync": false, + "isConstructorMethod": false, + "isPrototypeMethod": true, + "isFree": true, + "jsFunctionName": "free", + "cppFunctionName": "Free", + "return": { + "cType": "void", + "cppClassName": "void", + "jsClassName": "void" + }, + "description": "

Free an existing index object.

\n" + }, + { + "cFunctionName": "git_index_owner", + "args": [ + { + "name": "index", + "cType": "const git_index *", + "cppClassName": "GitIndex", + "jsClassName": "Index", + "isSelf": true, + "comment": "The index" + } + ], + "ignore": "Never make public for memory allocation reasons", + "isAsync": false, + "isConstructorMethod": false, + "isPrototypeMethod": true, + "jsFunctionName": "owner", + "cppFunctionName": "Owner", + "return": { + "cType": "git_repository *", + "cppClassName": "GitRepo", + "comment": "A pointer to the repository", + "jsClassName": "Repository" + }, + "description": "

Get the repository this index relates to

\n" + }, + { + "cFunctionName": "git_index_caps", + "args": [ + { + "name": "index", + "cType": "const git_index *", + "cppClassName": "GitIndex", + "jsClassName": "Index", + "isSelf": true, + "comment": "An existing index object" + } + ], + "ignore": true, + "isAsync": false, + "isConstructorMethod": false, + "isPrototypeMethod": true, + "jsFunctionName": "caps", + "cppFunctionName": "Caps", + "return": { + "cType": "unsigned int", + "cppClassName": "Uint32", + "comment": "A combination of GIT_INDEXCAP values", + "jsClassName": "Number" + }, + "description": "

Read index capabilities flags.

\n" + }, + { + "cFunctionName": "git_index_set_caps", + "args": [ + { + "name": "index", + "cType": "git_index *", + "cppClassName": "GitIndex", + "jsClassName": "Index", + "isSelf": true, + "comment": "An existing index object" + }, + { + "name": "caps", + "cType": "unsigned int", + "cppClassName": "Uint32", + "jsClassName": "Number", + "comment": "A combination of GIT_INDEXCAP values" + } + ], + "ignore": true, + "isAsync": false, + "isConstructorMethod": false, + "isPrototypeMethod": true, + "jsFunctionName": "setCaps", + "cppFunctionName": "SetCaps", + "return": { + "cType": "int", + "cppClassName": "Int32", + "isErrorCode": true, + "comment": "0 on success, -1 on failure", + "jsClassName": "Number" + }, + "description": "

Set index capabilities flags.

\n" + }, + { + "cFunctionName": "git_index_read", + "args": [ + { + "name": "index", + "cType": "git_index *", + "cppClassName": "GitIndex", + "jsClassName": "Index", + "isSelf": true, + "comment": "an existing index object" + } + ], + "isAsync": true, + "isConstructorMethod": false, + "isPrototypeMethod": true, + "jsFunctionName": "read", + "cppFunctionName": "Read", + "return": { + "cType": "int", + "cppClassName": "Int32", + "isErrorCode": true, + "comment": "0 or an error code", + "jsClassName": "Number" + }, + "description": "

Update the contents of an existing index object in memory\nby reading from the hard disk.

\n" + }, + { + "cFunctionName": "git_index_write", + "args": [ + { + "name": "index", + "cType": "git_index *", + "cppClassName": "GitIndex", + "jsClassName": "Index", + "isSelf": true, + "comment": "an existing index object" + } + ], + "isAsync": true, + "isConstructorMethod": false, + "isPrototypeMethod": true, + "jsFunctionName": "write", + "cppFunctionName": "Write", + "return": { + "cType": "int", + "cppClassName": "Int32", + "isErrorCode": true, + "comment": "0 or an error code", + "jsClassName": "Number" + }, + "description": "

Write an existing index object from memory back to disk\nusing an atomic file lock.

\n" + }, + { + "cFunctionName": "git_index_read_tree", + "args": [ + { + "name": "index", + "cType": "git_index *", + "cppClassName": "GitIndex", + "jsClassName": "Index", + "isSelf": true, + "comment": "an existing index object" + }, + { + "name": "tree", + "cType": "const git_tree *", + "cppClassName": "GitTree", + "jsClassName": "Tree", + "comment": "tree to read" + } + ], + "isAsync": true, + "isConstructorMethod": false, + "isPrototypeMethod": true, + "jsFunctionName": "readTree", + "cppFunctionName": "ReadTree", + "return": { + "cType": "int", + "cppClassName": "Int32", + "isErrorCode": true, + "comment": "0 or an error code", + "jsClassName": "Number" + }, + "description": "

Read a tree into the index file with stats

\n" + }, + { + "cFunctionName": "git_index_write_tree", + "args": [ + { + "name": "out", + "isReturn": true, + "cType": "git_oid *", + "cppClassName": "GitOid", + "jsClassName": "Oid", + "shouldAlloc": true, + "comment": "Pointer where to store the OID of the written tree" + }, + { + "name": "index", + "cType": "git_index *", + "cppClassName": "GitIndex", + "jsClassName": "Index", + "isSelf": true, + "comment": "Index to write" + } + ], + "isAsync": true, + "isConstructorMethod": false, + "isPrototypeMethod": true, + "jsFunctionName": "writeTree", + "cppFunctionName": "WriteTree", + "return": { + "cType": "int", + "cppClassName": "Int32", + "isErrorCode": true, + "comment": "0 on success, GIT_EUNMERGED when the index is not clean or an error code", + "jsClassName": "Number" + }, + "description": "

Write the index as a tree

\n" + }, + { + "cFunctionName": "git_index_write_tree_to", + "args": [ + { + "name": "out", + "isReturn": true, + "cType": "git_oid *", + "cppClassName": "GitOid", + "jsClassName": "Oid", + "shouldAlloc": true, + "comment": "Pointer where to store OID of the the written tree" + }, + { + "name": "index", + "cType": "git_index *", + "cppClassName": "GitIndex", + "jsClassName": "Index", + "comment": "Index to write" + }, + { + "name": "repo", + "cType": "git_repository *", + "cppClassName": "GitRepo", + "jsClassName": "Repository", + "comment": "Repository where to write the tree" + } + ], + "ignore": true, + "isAsync": false, + "isConstructorMethod": false, + "isPrototypeMethod": false, + "jsFunctionName": "writeTreeTo", + "cppFunctionName": "WriteTreeTo", + "return": { + "cType": "int", + "cppClassName": "Int32", + "isErrorCode": true, + "comment": "0 on success, GIT_EUNMERGED when the index is not clean or an error code", + "jsClassName": "Number" + }, + "description": "

Write the index as a tree to the given repository

\n" + }, + { + "cFunctionName": "git_index_entrycount", + "args": [ + { + "name": "index", + "cType": "const git_index *", + "cppClassName": "GitIndex", + "jsClassName": "Index", + "isSelf": true, + "comment": "an existing index object" + } + ], + "isAsync": false, + "isConstructorMethod": false, + "isPrototypeMethod": true, + "jsFunctionName": "size", + "cppFunctionName": "Size", + "return": { + "cType": "size_t", + "cppClassName": "Uint32", + "comment": "integer of count of current entries", + "jsClassName": "Number" + }, + "description": "

Get the count of entries currently in the index

\n" + }, + { + "cFunctionName": "git_index_clear", + "args": [ + { + "name": "index", + "cType": "git_index *", + "cppClassName": "GitIndex", + "jsClassName": "Index", + "isSelf": true, + "comment": "an existing index object" + } + ], + "isAsync": false, + "isConstructorMethod": false, + "isPrototypeMethod": true, + "jsFunctionName": "clear", + "cppFunctionName": "Clear", + "return": { + "cType": "void", + "cppClassName": "void", + "jsClassName": "void" + }, + "description": "

Clear the contents (all the entries) of an index object.\nThis clears the index object in memory; changes must be manually\nwritten to disk for them to take effect.

\n" + }, + { + "cFunctionName": "git_index_get_byindex", + "args": [ + { + "name": "index", + "cType": "git_index *", + "cppClassName": "GitIndex", + "jsClassName": "Index", + "isSelf": true, + "comment": "an existing index object" + }, + { + "name": "n", + "cType": "size_t", + "cppClassName": "Uint32", + "jsClassName": "Number", + "comment": "the position of the entry" + } + ], + "isAsync": false, + "isConstructorMethod": false, + "isPrototypeMethod": true, + "jsFunctionName": "entry", + "cppFunctionName": "Entry", + "return": { + "cType": "const git_index_entry *", + "cppClassName": "GitIndexEntry", + "copy": "git_index_entry_dup", + "comment": "a pointer to the entry; NULL if out of bounds", + "jsClassName": "IndexEntry" + }, + "description": "

Get a pointer to one of the entries in the index

\n" + }, + { + "cFunctionName": "git_index_get_bypath", + "args": [ + { + "name": "index", + "cType": "git_index *", + "cppClassName": "GitIndex", + "jsClassName": "Index", + "isSelf": true, + "comment": "an existing index object" + }, + { + "name": "path", + "cType": "const char *", + "cppClassName": "String", + "jsClassName": "String", + "comment": "path to search" + }, + { + "name": "stage", + "cType": "int", + "cppClassName": "Int32", + "jsClassName": "Number", + "comment": "stage to search" + } + ], + "ignore": true, + "isAsync": false, + "isConstructorMethod": false, + "isPrototypeMethod": true, + "jsFunctionName": "getEntry", + "cppFunctionName": "GetEntry", + "return": { + "cType": "const git_index_entry *", + "cppClassName": "GitIndexEntry", + "copy": "git_index_entry_dup", + "comment": "a pointer to the entry; NULL if it was not found", + "jsClassName": "IndexEntry" + }, + "description": "

Get a pointer to one of the entries in the index

\n" + }, + { + "cFunctionName": "git_index_remove", + "args": [ + { + "name": "index", + "cType": "git_index *", + "cppClassName": "GitIndex", + "jsClassName": "Index", + "isSelf": true, + "comment": "an existing index object" + }, + { + "name": "path", + "cType": "const char *", + "cppClassName": "String", + "jsClassName": "String", + "comment": "path to search" + }, + { + "name": "stage", + "cType": "int", + "cppClassName": "Int32", + "jsClassName": "Number", + "comment": "stage to search" + } + ], + "isAsync": false, + "isConstructorMethod": false, + "isPrototypeMethod": true, + "jsFunctionName": "remove", + "cppFunctionName": "Remove", + "return": { + "cType": "int", + "cppClassName": "Int32", + "isErrorCode": true, + "comment": "0 or an error code", + "jsClassName": "Number" + }, + "description": "

Remove an entry from the index

\n" + }, + { + "cFunctionName": "git_index_remove_directory", + "args": [ + { + "name": "index", + "cType": "git_index *", + "cppClassName": "GitIndex", + "jsClassName": "Index", + "isSelf": true, + "comment": "an existing index object" + }, + { + "name": "dir", + "cType": "const char *", + "cppClassName": "String", + "jsClassName": "String", + "comment": "container directory path" + }, + { + "name": "stage", + "cType": "int", + "cppClassName": "Int32", + "jsClassName": "Number", + "comment": "stage to search" + } + ], + "isAsync": false, + "isConstructorMethod": false, + "isPrototypeMethod": true, + "jsFunctionName": "removeDirectory", + "cppFunctionName": "RemoveDirectory", + "return": { + "cType": "int", + "cppClassName": "Int32", + "isErrorCode": true, + "comment": "0 or an error code", + "jsClassName": "Number" + }, + "description": "

Remove all entries from the index under a given directory

\n" + }, + { + "cFunctionName": "git_index_add", + "args": [ + { + "name": "index", + "cType": "git_index *", + "cppClassName": "GitIndex", + "jsClassName": "Index", + "isSelf": true, + "comment": "an existing index object" + }, + { + "name": "source_entry", + "cType": "const git_index_entry *", + "cppClassName": "GitIndexEntry", + "jsClassName": "IndexEntry", + "comment": "new entry object" + } + ], + "ignore": true, + "isAsync": false, + "isConstructorMethod": false, + "isPrototypeMethod": true, + "jsFunctionName": "add", + "cppFunctionName": "Add", + "return": { + "cType": "int", + "cppClassName": "Int32", + "isErrorCode": true, + "comment": "0 or an error code", + "jsClassName": "Number" + }, + "description": "

Add or update an index entry from an in-memory struct

\n" + }, + { + "cFunctionName": "git_index_entry_stage", + "args": [ + { + "name": "entry", + "cType": "const git_index_entry *", + "cppClassName": "GitIndexEntry", + "jsClassName": "IndexEntry", + "comment": "The entry" + } + ], + "ignore": true, + "isAsync": false, + "isConstructorMethod": false, + "isPrototypeMethod": false, + "jsFunctionName": "entryStage", + "cppFunctionName": "EntryStage", + "return": { + "cType": "int", + "cppClassName": "Int32", + "isErrorCode": true, + "jsClassName": "Number" + }, + "description": "

Return the stage number from a git index entry

\n" + }, + { + "cFunctionName": "git_index_add_bypath", + "args": [ + { + "name": "index", + "cType": "git_index *", + "cppClassName": "GitIndex", + "jsClassName": "Index", + "isSelf": true, + "comment": "an existing index object" + }, + { + "name": "path", + "cType": "const char *", + "cppClassName": "String", + "jsClassName": "String", + "comment": "filename to add" + } + ], + "isAsync": true, + "isConstructorMethod": false, + "isPrototypeMethod": true, + "jsFunctionName": "addByPath", + "cppFunctionName": "AddBypath", + "return": { + "cType": "int", + "cppClassName": "Int32", + "isErrorCode": true, + "comment": "0 or an error code", + "jsClassName": "Number" + }, + "description": "

Add or update an index entry from a file on disk

\n" + }, + { + "cFunctionName": "git_index_remove_bypath", + "args": [ + { + "name": "index", + "cType": "git_index *", + "cppClassName": "GitIndex", + "jsClassName": "Index", + "isSelf": true, + "comment": "an existing index object" + }, + { + "name": "path", + "cType": "const char *", + "cppClassName": "String", + "jsClassName": "String", + "comment": "filename to remove" + } + ], + "isAsync": false, + "isConstructorMethod": false, + "isPrototypeMethod": true, + "jsFunctionName": "removeByPath", + "cppFunctionName": "RemoveBypath", + "return": { + "cType": "int", + "cppClassName": "Int32", + "isErrorCode": true, + "comment": "0 or an error code", + "jsClassName": "Number" + }, + "description": "

Remove an index entry corresponding to a file on disk

\n" + }, + { + "cFunctionName": "git_index_find", + "args": [ + { + "name": "at_pos", + "cType": "size_t *", + "cppClassName": "Uint32", + "jsClassName": "Number", + "comment": "the address to which the position of the index entry is written (optional)" + }, + { + "name": "index", + "cType": "git_index *", + "cppClassName": "GitIndex", + "jsClassName": "Index", + "isSelf": true, + "comment": "an existing index object" + }, + { + "name": "path", + "cType": "const char *", + "cppClassName": "String", + "jsClassName": "String", + "comment": "path to search" + } + ], + "isAsync": false, + "isConstructorMethod": false, + "isPrototypeMethod": true, + "jsFunctionName": "find", + "cppFunctionName": "Find", + "return": { + "cType": "int", + "cppClassName": "Int32", + "comment": "a zero-based position in the index if found; GIT_ENOTFOUND otherwise", + "jsClassName": "Number" + }, + "description": "

Find the first position of any entries which point to given\npath in the Git index.

\n" + }, + { + "cFunctionName": "git_index_conflict_add", + "args": [ + { + "name": "index", + "cType": "git_index *", + "cppClassName": "GitIndex", + "jsClassName": "Index", + "isSelf": true, + "comment": "an existing index object" + }, + { + "name": "ancestor_entry", + "cType": "const git_index_entry *", + "cppClassName": "GitIndexEntry", + "jsClassName": "IndexEntry", + "comment": "the entry data for the ancestor of the conflict" + }, + { + "name": "our_entry", + "cType": "const git_index_entry *", + "cppClassName": "GitIndexEntry", + "jsClassName": "IndexEntry", + "comment": "the entry data for our side of the merge conflict" + }, + { + "name": "their_entry", + "cType": "const git_index_entry *", + "cppClassName": "GitIndexEntry", + "jsClassName": "IndexEntry", + "comment": "the entry data for their side of the merge conflict" + } + ], + "ignore": true, + "isAsync": false, + "isConstructorMethod": false, + "isPrototypeMethod": true, + "jsFunctionName": "conflictAdd", + "cppFunctionName": "ConflictAdd", + "return": { + "cType": "int", + "cppClassName": "Int32", + "isErrorCode": true, + "comment": "0 or an error code", + "jsClassName": "Number" + }, + "description": "

Add or update index entries to represent a conflict

\n" + }, + { + "cFunctionName": "git_index_conflict_get", + "args": [ + { + "name": "ancestor_out", + "cType": "git_index_entry **", + "cppClassName": "GitIndexEntry", + "jsClassName": "IndexEntry", + "comment": "Pointer to store the ancestor entry" + }, + { + "name": "our_out", + "cType": "git_index_entry **", + "cppClassName": "GitIndexEntry", + "jsClassName": "IndexEntry", + "comment": "Pointer to store the our entry" + }, + { + "name": "their_out", + "cType": "git_index_entry **", + "cppClassName": "GitIndexEntry", + "jsClassName": "IndexEntry", + "comment": "Pointer to store the their entry" + }, + { + "name": "index", + "cType": "git_index *", + "cppClassName": "GitIndex", + "jsClassName": "Index", + "comment": "an existing index object" + }, + { + "name": "path", + "cType": "const char *", + "cppClassName": "String", + "jsClassName": "String", + "comment": "path to search" + } + ], + "ignore": true, + "isAsync": false, + "isConstructorMethod": false, + "isPrototypeMethod": false, + "jsFunctionName": "conflictGet", + "cppFunctionName": "ConflictGet", + "return": { + "cType": "int", + "cppClassName": "Int32", + "isErrorCode": true, + "jsClassName": "Number" + }, + "description": "

Get the index entries that represent a conflict of a single file.

\n" + }, + { + "cFunctionName": "git_index_conflict_remove", + "args": [ + { + "name": "index", + "cType": "git_index *", + "cppClassName": "GitIndex", + "jsClassName": "Index", + "isSelf": true, + "comment": "an existing index object" + }, + { + "name": "path", + "cType": "const char *", + "cppClassName": "String", + "jsClassName": "String", + "comment": "to search" + } + ], + "isAsync": false, + "isConstructorMethod": false, + "isPrototypeMethod": true, + "jsFunctionName": "conflictRemove", + "cppFunctionName": "ConflictRemove", + "return": { + "cType": "int", + "cppClassName": "Int32", + "isErrorCode": true, + "jsClassName": "Number" + }, + "description": "

Removes the index entries that represent a conflict of a single file.

\n" + }, + { + "cFunctionName": "git_index_conflict_cleanup", + "args": [ + { + "name": "index", + "cType": "git_index *", + "cppClassName": "GitIndex", + "jsClassName": "Index", + "isSelf": true, + "comment": "an existing index object" + } + ], + "isAsync": false, + "isConstructorMethod": false, + "isPrototypeMethod": true, + "jsFunctionName": "conflictCleanup", + "cppFunctionName": "ConflictCleanup", + "return": { + "cType": "void", + "cppClassName": "void", + "jsClassName": "void" + }, + "description": "

Remove all conflicts in the index (entries with a stage greater than 0.)

\n" + }, + { + "cFunctionName": "git_index_has_conflicts", + "args": [ + { + "name": "index", + "cType": "const git_index *", + "cppClassName": "GitIndex", + "jsClassName": "Index", + "isSelf": true + } + ], + "isAsync": false, + "isConstructorMethod": false, + "isPrototypeMethod": true, + "jsFunctionName": "hasConflicts", + "cppFunctionName": "HasConflicts", + "return": { + "cType": "int", + "cppClassName": "Int32", + "comment": "1 if at least one conflict is found, 0 otherwise.", + "jsClassName": "Number" + }, + "description": "

Determine if the index contains entries representing file conflicts.

\n" + }, + { + "cFunctionName": "git_index_reuc_entrycount", + "args": [ + { + "name": "index", + "cType": "git_index *", + "cppClassName": "GitIndex", + "jsClassName": "Index", + "isSelf": true, + "comment": "an existing index object" + } + ], + "ignore": true, + "isAsync": false, + "isConstructorMethod": false, + "isPrototypeMethod": true, + "jsFunctionName": "reucEntrycount", + "cppFunctionName": "ReucEntrycount", + "return": { + "cType": "unsigned int", + "cppClassName": "Uint32", + "comment": "integer of count of current resolve undo entries", + "jsClassName": "Number" + }, + "description": "

Get the count of resolve undo entries currently in the index.

\n" + }, + { + "cFunctionName": "git_index_reuc_find", + "args": [ + { + "name": "at_pos", + "cType": "size_t *", + "cppClassName": "Uint32", + "jsClassName": "Number", + "comment": "the address to which the position of the reuc entry is written (optional)" + }, + { + "name": "index", + "cType": "git_index *", + "cppClassName": "GitIndex", + "jsClassName": "Index", + "comment": "an existing index object" + }, + { + "name": "path", + "cType": "const char *", + "cppClassName": "String", + "jsClassName": "String", + "comment": "path to search" + } + ], + "ignore": true, + "isAsync": false, + "isConstructorMethod": false, + "isPrototypeMethod": false, + "jsFunctionName": "reucFind", + "cppFunctionName": "ReucFind", + "return": { + "cType": "int", + "cppClassName": "Int32", + "isErrorCode": true, + "comment": "0 if found, < 0 otherwise (GIT_ENOTFOUND)", + "jsClassName": "Number" + }, + "description": "

Finds the resolve undo entry that points to the given path in the Git\nindex.

\n" + }, + { + "cFunctionName": "git_index_reuc_get_bypath", + "args": [ + { + "name": "index", + "cType": "git_index *", + "cppClassName": "GitIndex", + "jsClassName": "Index", + "isSelf": true, + "comment": "an existing index object" + }, + { + "name": "path", + "cType": "const char *", + "cppClassName": "String", + "jsClassName": "String", + "comment": "path to search" + } + ], + "ignore": true, + "isAsync": false, + "isConstructorMethod": false, + "isPrototypeMethod": true, + "jsFunctionName": "reucGetBypath", + "cppFunctionName": "ReucGetBypath", + "return": { + "cType": "const git_index_reuc_entry *", + "cppClassName": "IndexReucEntry", + "copy": "fixme", + "comment": "the resolve undo entry; NULL if not found" + }, + "description": "

Get a resolve undo entry from the index.

\n" + }, + { + "cFunctionName": "git_index_reuc_get_byindex", + "args": [ + { + "name": "index", + "cType": "git_index *", + "cppClassName": "GitIndex", + "jsClassName": "Index", + "isSelf": true, + "comment": "an existing index object" + }, + { + "name": "n", + "cType": "size_t", + "cppClassName": "Uint32", + "jsClassName": "Number", + "comment": "the position of the entry" + } + ], + "ignore": true, + "isAsync": false, + "isConstructorMethod": false, + "isPrototypeMethod": true, + "jsFunctionName": "reucGetByindex", + "cppFunctionName": "ReucGetByindex", + "return": { + "cType": "const git_index_reuc_entry *", + "cppClassName": "IndexReucEntry", + "copy": "fixme", + "comment": "a pointer to the resolve undo entry; NULL if out of bounds" + }, + "description": "

Get a resolve undo entry from the index.

\n" + }, + { + "cFunctionName": "git_index_reuc_add", + "args": [ + { + "name": "index", + "cType": "git_index *", + "cppClassName": "GitIndex", + "jsClassName": "Index", + "isSelf": true, + "comment": "an existing index object" + }, + { + "name": "path", + "cType": "const char *", + "cppClassName": "String", + "jsClassName": "String", + "comment": "filename to add" + }, + { + "name": "ancestor_mode", + "cType": "int", + "cppClassName": "Int32", + "jsClassName": "Number", + "comment": "mode of the ancestor file" + }, + { + "name": "ancestor_id", + "cType": "git_oid *", + "cppClassName": "GitOid", + "jsClassName": "Oid", + "comment": "oid of the ancestor file" + }, + { + "name": "our_mode", + "cType": "int", + "cppClassName": "Int32", + "jsClassName": "Number", + "comment": "mode of our file" + }, + { + "name": "our_id", + "cType": "git_oid *", + "cppClassName": "GitOid", + "jsClassName": "Oid", + "comment": "oid of our file" + }, + { + "name": "their_mode", + "cType": "int", + "cppClassName": "Int32", + "jsClassName": "Number", + "comment": "mode of their file" + }, + { + "name": "their_id", + "cType": "git_oid *", + "cppClassName": "GitOid", + "jsClassName": "Oid", + "comment": "oid of their file" + } + ], + "ignore": true, + "isAsync": false, + "isConstructorMethod": false, + "isPrototypeMethod": true, + "jsFunctionName": "reucAdd", + "cppFunctionName": "ReucAdd", + "return": { + "cType": "int", + "cppClassName": "Int32", + "isErrorCode": true, + "comment": "0 or an error code", + "jsClassName": "Number" + }, + "description": "

Adds a resolve undo entry for a file based on the given parameters.

\n" + }, + { + "cFunctionName": "git_index_reuc_remove", + "args": [ + { + "name": "index", + "cType": "git_index *", + "cppClassName": "GitIndex", + "jsClassName": "Index", + "isSelf": true, + "comment": "an existing index object" + }, + { + "name": "n", + "cType": "size_t", + "cppClassName": "Uint32", + "jsClassName": "Number", + "comment": "position of the resolve undo entry to remove" + } + ], + "ignore": true, + "isAsync": false, + "isConstructorMethod": false, + "isPrototypeMethod": true, + "jsFunctionName": "reucRemove", + "cppFunctionName": "ReucRemove", + "return": { + "cType": "int", + "cppClassName": "Int32", + "isErrorCode": true, + "comment": "0 or an error code", + "jsClassName": "Number" + }, + "description": "

Remove an resolve undo entry from the index

\n" + }, + { + "cFunctionName": "git_index_reuc_clear", + "args": [ + { + "name": "index", + "cType": "git_index *", + "cppClassName": "GitIndex", + "jsClassName": "Index", + "isSelf": true, + "comment": "an existing index object" + } + ], + "ignore": true, + "isAsync": false, + "isConstructorMethod": false, + "isPrototypeMethod": true, + "jsFunctionName": "reucClear", + "cppFunctionName": "ReucClear", + "return": { + "cType": "void", + "cppClassName": "void", + "comment": "0 or an error code", + "jsClassName": "void" + }, + "description": "

Remove all resolve undo entries from the index

\n" + }, + { + "cFunctionName": "git_diff_index_to_workdir", + "args": [ + { + "name": "diff", + "cType": "git_diff_list **", + "cppClassName": "GitDiffList", + "jsClassName": "DiffList", + "isReturn": true, + "comment": "Output pointer to a git_diff_list pointer to be allocated." + }, + { + "name": "repo", + "cType": "git_repository *", + "cppClassName": "GitRepo", + "jsClassName": "Repository", + "comment": "The repository." + }, + { + "name": "index", + "cType": "git_index *", + "cppClassName": "GitIndex", + "jsClassName": "Index", + "comment": "The index to diff from; repo index used if NULL." + }, + { + "name": "opts", + "cType": "const git_diff_options *", + "cppClassName": "GitDiffOptions", + "jsClassName": "DiffOptions", + "comment": "Structure with options to influence diff or NULL for defaults." + } + ], + "isAsync": true, + "isConstructorMethod": true, + "isPrototypeMethod": false, + "jsFunctionName": "indexToWorkdir", + "cppFunctionName": "IndexToWorkdir", + "return": { + "cType": "int", + "cppClassName": "Int32", + "isErrorCode": true, + "jsClassName": "Number" + }, + "description": "

Create a diff list between the repository index and the workdir directory.

\n" + } + ] + }, + { + "filename": "indexer.h", + "ignore": true, + "jsClassName": "Indexer", + "cppClassName": "Indexer", + "cType": "git_indexer", + "freeFunctionName": "git_indexer_free", + "functions": [ + { + "cFunctionName": "git_indexer_stream_new", + "args": [ + { + "name": "out", + "isReturn": true, + "cType": "git_indexer_stream **", + "cppClassName": "IndexerStream", + "jsClassName": "IndexerStream", + "comment": "where to store the indexer instance" + }, + { + "name": "path", + "cType": "const char *", + "cppClassName": "String", + "jsClassName": "String", + "comment": "to the directory where the packfile should be stored" + }, + { + "name": "progress_cb", + "cType": "git_transfer_progress_callback", + "cppClassName": "TransferProgressCallback", + "jsClassName": "TransferProgressCallback", + "comment": "function to call with progress information" + }, + { + "name": "progress_cb_payload", + "cType": "void *", + "cppClassName": "void", + "jsClassName": "void", + "comment": "payload for the progress callback" + } + ], + "isAsync": false, + "isConstructorMethod": false, + "isPrototypeMethod": false, + "jsFunctionName": "streamNew", + "cppFunctionName": "StreamNew", + "return": { + "cType": "int", + "cppClassName": "Int32", + "isErrorCode": true, + "jsClassName": "Number" + }, + "description": "

Create a new streaming indexer instance

\n" + }, + { + "cFunctionName": "git_indexer_stream_add", + "args": [ + { + "name": "idx", + "cType": "git_indexer_stream *", + "cppClassName": "IndexerStream", + "jsClassName": "IndexerStream", + "comment": "the indexer" + }, + { + "name": "data", + "cType": "const void *", + "cppClassName": "void", + "jsClassName": "void", + "comment": "the data to add" + }, + { + "name": "size", + "cType": "size_t", + "cppClassName": "Uint32", + "jsClassName": "Number", + "comment": "the size of the data in bytes" + }, + { + "name": "stats", + "cType": "git_transfer_progress *", + "cppClassName": "TransferProgress", + "jsClassName": "TransferProgress", + "comment": "stat storage" + } + ], + "isAsync": false, + "isConstructorMethod": false, + "isPrototypeMethod": false, + "jsFunctionName": "streamAdd", + "cppFunctionName": "StreamAdd", + "return": { + "cType": "int", + "cppClassName": "Int32", + "isErrorCode": true, + "jsClassName": "Number" + }, + "description": "

Add data to the indexer

\n" + }, + { + "cFunctionName": "git_indexer_stream_finalize", + "args": [ + { + "name": "idx", + "cType": "git_indexer_stream *", + "cppClassName": "IndexerStream", + "jsClassName": "IndexerStream", + "comment": "the indexer" + }, + { + "name": "stats", + "cType": "git_transfer_progress *", + "cppClassName": "TransferProgress", + "jsClassName": "TransferProgress" + } + ], + "isAsync": false, + "isConstructorMethod": false, + "isPrototypeMethod": false, + "jsFunctionName": "streamFinalize", + "cppFunctionName": "StreamFinalize", + "return": { + "cType": "int", + "cppClassName": "Int32", + "isErrorCode": true, + "jsClassName": "Number" + }, + "description": "

Finalize the pack and index

\n" + }, + { + "cFunctionName": "git_indexer_stream_hash", + "args": [ + { + "name": "idx", + "cType": "const git_indexer_stream *", + "cppClassName": "IndexerStream", + "jsClassName": "IndexerStream", + "comment": "the indexer instance" + } + ], + "isAsync": false, + "isConstructorMethod": false, + "isPrototypeMethod": false, + "jsFunctionName": "streamHash", + "cppFunctionName": "StreamHash", + "return": { + "cType": "const git_oid *", + "cppClassName": "GitOid", + "copy": "git_oid_dup", + "jsClassName": "Oid" + }, + "description": "

Get the packfile's hash

\n" + }, + { + "cFunctionName": "git_indexer_stream_free", + "args": [ + { + "name": "idx", + "cType": "git_indexer_stream *", + "cppClassName": "IndexerStream", + "jsClassName": "IndexerStream", + "comment": "the indexer to free" + } + ], + "isAsync": false, + "isConstructorMethod": false, + "isPrototypeMethod": false, + "isFree": true, + "jsFunctionName": "streamFree", + "cppFunctionName": "StreamFree", + "return": { + "cType": "void", + "cppClassName": "void", + "jsClassName": "void" + }, + "description": "

Free the indexer and its resources

\n" + } + ] + }, + { + "filename": "inttypes.h", + "ignore": true, + "jsClassName": "Inttypes", + "cppClassName": "Inttypes", + "cType": "git_inttypes", + "freeFunctionName": "git_inttypes_free", + "functions": [] + }, + { + "filename": "merge.h", + "ignore": true, + "jsClassName": "Merge", + "cppClassName": "Merge", + "cType": "git_merge", + "freeFunctionName": "git_merge_free", + "functions": [ + { + "cFunctionName": "git_merge_base", + "args": [ + { + "name": "out", + "isReturn": true, + "cType": "git_oid *", + "cppClassName": "GitOid", + "jsClassName": "Oid", + "shouldAlloc": true, + "comment": "the OID of a merge base between 'one' and 'two'" + }, + { + "name": "repo", + "cType": "git_repository *", + "cppClassName": "GitRepo", + "jsClassName": "Repository", + "comment": "the repository where the commits exist" + }, + { + "name": "one", + "cType": "const git_oid *", + "cppClassName": "GitOid", + "jsClassName": "Oid", + "comment": "one of the commits" + }, + { + "name": "two", + "cType": "const git_oid *", + "cppClassName": "GitOid", + "jsClassName": "Oid", + "comment": "the other commit" + } + ], + "isAsync": false, + "isConstructorMethod": false, + "isPrototypeMethod": false, + "jsFunctionName": "base", + "cppFunctionName": "Base", + "return": { + "cType": "int", + "cppClassName": "Int32", + "isErrorCode": true, + "comment": "Zero on success; GIT_ENOTFOUND or -1 on failure.", + "jsClassName": "Number" + }, + "description": "

Find a merge base between two commits

\n" + }, + { + "cFunctionName": "git_merge_base_many", + "args": [ + { + "name": "out", + "isReturn": true, + "cType": "git_oid *", + "cppClassName": "GitOid", + "jsClassName": "Oid", + "shouldAlloc": true, + "comment": "the OID of a merge base considering all the commits" + }, + { + "name": "repo", + "cType": "git_repository *", + "cppClassName": "GitRepo", + "jsClassName": "Repository", + "comment": "the repository where the commits exist" + }, + { + "name": "length", + "cType": "size_t", + "cppClassName": "Uint32", + "jsClassName": "Number", + "comment": "The number of commits in the provided `input_array`" + } + ], + "isAsync": false, + "isConstructorMethod": false, + "isPrototypeMethod": false, + "jsFunctionName": "baseMany", + "cppFunctionName": "BaseMany", + "return": { + "cType": "int", + "cppClassName": "Int32", + "isErrorCode": true, + "comment": "Zero on success; GIT_ENOTFOUND or -1 on failure.", + "jsClassName": "Number" + }, + "description": "

Find a merge base given a list of commits

\n" + } + ] + }, + { + "filename": "message.h", + "ignore": true, + "jsClassName": "Message", + "cppClassName": "Message", + "cType": "git_message", + "freeFunctionName": "git_message_free", + "functions": [ + { + "cFunctionName": "git_message_prettify", + "args": [ + { + "name": "out", + "isReturn": true, + "cType": "char *", + "cppClassName": "String", + "jsClassName": "String", + "comment": "The user-allocated buffer which will be filled with the cleaned up message. Pass NULL if you just want to get the needed size of the prettified message as the output value." + }, + { + "name": "out_size", + "cType": "size_t", + "cppClassName": "Uint32", + "jsClassName": "Number", + "comment": "Size of the `out` buffer in bytes." + }, + { + "name": "message", + "cType": "const char *", + "cppClassName": "String", + "jsClassName": "String", + "comment": "The message to be prettified." + }, + { + "name": "strip_comments", + "cType": "int", + "cppClassName": "Int32", + "jsClassName": "Number", + "comment": "Non-zero to remove lines starting with \"#\", 0 to leave them in." + } + ], + "isAsync": false, + "isConstructorMethod": false, + "isPrototypeMethod": false, + "jsFunctionName": "prettify", + "cppFunctionName": "Prettify", + "return": { + "cType": "int", + "cppClassName": "Int32", + "isErrorCode": true, + "comment": "-1 on error, else number of characters in prettified message including the trailing NUL byte", + "jsClassName": "Number" + }, + "description": "

Clean up message from excess whitespace and make sure that the last line\nends with a '\\n'.

\n" + } + ] + }, + { + "filename": "net.h", + "ignore": true, + "jsClassName": "Net", + "cppClassName": "Net", + "cType": "git_net", + "freeFunctionName": "git_net_free", + "functions": [] + }, + { + "filename": "notes.h", + "ignore": true, + "jsClassName": "Notes", + "cppClassName": "Notes", + "cType": "git_notes", + "freeFunctionName": "git_notes_free", + "functions": [ + { + "cFunctionName": "git_note_iterator_new", + "args": [ + { + "name": "out", + "isReturn": true, + "cType": "git_note_iterator **", + "cppClassName": "NoteIterator", + "jsClassName": "NoteIterator", + "comment": "pointer to the iterator" + }, + { + "name": "repo", + "cType": "git_repository *", + "cppClassName": "GitRepo", + "jsClassName": "Repository", + "comment": "repository where to look up the note" + }, + { + "name": "notes_ref", + "cType": "const char *", + "cppClassName": "String", + "jsClassName": "String", + "comment": "canonical name of the reference to use (optional); defaults to \"refs/notes/commits\"" + } + ], + "isAsync": false, + "isConstructorMethod": false, + "isPrototypeMethod": false, + "jsFunctionName": "gitNoteIteratorNew", + "cppFunctionName": "GitNoteIteratorNew", + "return": { + "cType": "int", + "cppClassName": "Int32", + "isErrorCode": true, + "comment": "0 or an error code", + "jsClassName": "Number" + }, + "description": "

Creates a new iterator for notes

\n" + }, + { + "cFunctionName": "git_note_iterator_free", + "args": [ + { + "name": "it", + "cType": "git_note_iterator *", + "cppClassName": "NoteIterator", + "jsClassName": "NoteIterator", + "comment": "pointer to the iterator" + } + ], + "isAsync": false, + "isConstructorMethod": false, + "isPrototypeMethod": false, + "isFree": true, + "jsFunctionName": "gitNoteIteratorFree", + "cppFunctionName": "GitNoteIteratorFree", + "return": { + "cType": "void", + "cppClassName": "void", + "jsClassName": "void" + }, + "description": "

Frees an git_note_iterator

\n" + }, + { + "cFunctionName": "git_note_next", + "args": [ + { + "name": "note_id", + "cType": "git_oid*", + "cppClassName": "Oid*", + "jsClassName": "Oid*", + "comment": "id of blob containing the message" + }, + { + "name": "annotated_id", + "cType": "git_oid*", + "cppClassName": "Oid*", + "jsClassName": "Oid*", + "comment": "id of the git object being annotated" + }, + { + "name": "it", + "cType": "git_note_iterator *", + "cppClassName": "NoteIterator", + "jsClassName": "NoteIterator", + "comment": "pointer to the iterator" + } + ], + "isAsync": false, + "isConstructorMethod": false, + "isPrototypeMethod": false, + "jsFunctionName": "gitNoteNext", + "cppFunctionName": "GitNoteNext", + "return": { + "cType": "int", + "cppClassName": "Int32", + "isErrorCode": true, + "comment": "0 (no error), GIT_ITEROVER (iteration is done) or an error code (negative value)", + "jsClassName": "Number" + }, + "description": "

Returns the current item (note_id and annotated_id) and advance the iterator\ninternally to the next value

\n" + }, + { + "cFunctionName": "git_note_read", + "args": [ + { + "name": "out", + "isReturn": true, + "cType": "git_note **", + "cppClassName": "Note", + "jsClassName": "Note", + "comment": "pointer to the read note; NULL in case of error" + }, + { + "name": "repo", + "cType": "git_repository *", + "cppClassName": "GitRepo", + "jsClassName": "Repository", + "comment": "repository where to look up the note" + }, + { + "name": "notes_ref", + "cType": "const char *", + "cppClassName": "String", + "jsClassName": "String", + "comment": "canonical name of the reference to use (optional); defaults to \"refs/notes/commits\"" + }, + { + "name": "oid", + "cType": "const git_oid *", + "cppClassName": "GitOid", + "jsClassName": "Oid", + "comment": "OID of the git object to read the note from" + } + ], + "isAsync": false, + "isConstructorMethod": false, + "isPrototypeMethod": false, + "jsFunctionName": "gitNoteRead", + "cppFunctionName": "GitNoteRead", + "return": { + "cType": "int", + "cppClassName": "Int32", + "isErrorCode": true, + "comment": "0 or an error code", + "jsClassName": "Number" + }, + "description": "

Read the note for an object

\n" + }, + { + "cFunctionName": "git_note_message", + "args": [ + { + "name": "note", + "cType": "const git_note *", + "cppClassName": "Note", + "jsClassName": "Note", + "comment": "" + } + ], + "isAsync": false, + "isConstructorMethod": false, + "isPrototypeMethod": false, + "jsFunctionName": "gitNoteMessage", + "cppFunctionName": "GitNoteMessage", + "return": { + "cType": "const char *", + "cppClassName": "String", + "comment": "the note message", + "jsClassName": "String" + }, + "description": "

Get the note message

\n" + }, + { + "cFunctionName": "git_note_oid", + "args": [ + { + "name": "note", + "cType": "const git_note *", + "cppClassName": "Note", + "jsClassName": "Note", + "comment": "" + } + ], + "isAsync": false, + "isConstructorMethod": false, + "isPrototypeMethod": false, + "jsFunctionName": "gitNoteOid", + "cppFunctionName": "GitNoteOid", + "return": { + "cType": "const git_oid *", + "cppClassName": "GitOid", + "copy": "git_oid_dup", + "comment": "the note object OID", + "jsClassName": "Oid" + }, + "description": "

Get the note object OID

\n" + }, + { + "cFunctionName": "git_note_create", + "args": [ + { + "name": "out", + "isReturn": true, + "cType": "git_oid *", + "cppClassName": "GitOid", + "jsClassName": "Oid", + "shouldAlloc": true, + "comment": "pointer to store the OID (optional); NULL in case of error" + }, + { + "name": "repo", + "cType": "git_repository *", + "cppClassName": "GitRepo", + "jsClassName": "Repository", + "comment": "repository where to store the note" + }, + { + "name": "author", + "cType": "const git_signature *", + "cppClassName": "GitSignature", + "jsClassName": "Signature", + "comment": "signature of the notes commit author" + }, + { + "name": "committer", + "cType": "const git_signature *", + "cppClassName": "GitSignature", + "jsClassName": "Signature", + "comment": "signature of the notes commit committer" + }, + { + "name": "notes_ref", + "cType": "const char *", + "cppClassName": "String", + "jsClassName": "String", + "comment": "canonical name of the reference to use (optional); defaults to \"refs/notes/commits\"" + }, + { + "name": "oid", + "cType": "const git_oid *", + "cppClassName": "GitOid", + "jsClassName": "Oid", + "comment": "OID of the git object to decorate" + }, + { + "name": "note", + "cType": "const char *", + "cppClassName": "String", + "jsClassName": "String", + "comment": "s_ref canonical name of the reference to use (optional); defaults to \"refs/notes/commits\"" + }, + { + "name": "force", + "cType": "int", + "cppClassName": "Int32", + "jsClassName": "Number", + "comment": "Overwrite existing note" + } + ], + "isAsync": false, + "isConstructorMethod": false, + "isPrototypeMethod": false, + "jsFunctionName": "gitNoteCreate", + "cppFunctionName": "GitNoteCreate", + "return": { + "cType": "int", + "cppClassName": "Int32", + "isErrorCode": true, + "comment": "0 or an error code", + "jsClassName": "Number" + }, + "description": "

Add a note for an object

\n" + }, + { + "cFunctionName": "git_note_remove", + "args": [ + { + "name": "repo", + "cType": "git_repository *", + "cppClassName": "GitRepo", + "jsClassName": "Repository", + "comment": "repository where the note lives" + }, + { + "name": "notes_ref", + "cType": "const char *", + "cppClassName": "String", + "jsClassName": "String", + "comment": "canonical name of the reference to use (optional); defaults to \"refs/notes/commits\"" + }, + { + "name": "author", + "cType": "const git_signature *", + "cppClassName": "GitSignature", + "jsClassName": "Signature", + "comment": "signature of the notes commit author" + }, + { + "name": "committer", + "cType": "const git_signature *", + "cppClassName": "GitSignature", + "jsClassName": "Signature", + "comment": "signature of the notes commit committer" + }, + { + "name": "oid", + "cType": "const git_oid *", + "cppClassName": "GitOid", + "jsClassName": "Oid", + "comment": "OID of the git object to remove the note from" + } + ], + "isAsync": false, + "isConstructorMethod": false, + "isPrototypeMethod": false, + "jsFunctionName": "gitNoteRemove", + "cppFunctionName": "GitNoteRemove", + "return": { + "cType": "int", + "cppClassName": "Int32", + "isErrorCode": true, + "comment": "0 or an error code", + "jsClassName": "Number" + }, + "description": "

Remove the note for an object

\n" + }, + { + "cFunctionName": "git_note_free", + "args": [ + { + "name": "note", + "cType": "git_note *", + "cppClassName": "Note", + "jsClassName": "Note", + "comment": "git_note object" + } + ], + "isAsync": false, + "isConstructorMethod": false, + "isPrototypeMethod": false, + "isFree": true, + "jsFunctionName": "gitNoteFree", + "cppFunctionName": "GitNoteFree", + "return": { + "cType": "void", + "cppClassName": "void", + "jsClassName": "void" + }, + "description": "

Free a git_note object

\n" + }, + { + "cFunctionName": "git_note_default_ref", + "args": [ + { + "name": "out", + "isReturn": true, + "cType": "const char **", + "cppClassName": "String", + "jsClassName": "String", + "comment": "Pointer to the default notes reference" + }, + { + "name": "repo", + "cType": "git_repository *", + "cppClassName": "GitRepo", + "jsClassName": "Repository", + "comment": "The Git repository" + } + ], + "isAsync": false, + "isConstructorMethod": false, + "isPrototypeMethod": false, + "jsFunctionName": "gitNoteDefaultRef", + "cppFunctionName": "GitNoteDefaultRef", + "return": { + "cType": "int", + "cppClassName": "Int32", + "isErrorCode": true, + "comment": "0 or an error code", + "jsClassName": "Number" + }, + "description": "

Get the default notes reference for a repository

\n" + }, + { + "cFunctionName": "git_note_foreach", + "args": [ + { + "name": "repo", + "cType": "git_repository *", + "cppClassName": "GitRepo", + "jsClassName": "Repository", + "comment": "Repository where to find the notes." + }, + { + "name": "notes_ref", + "cType": "const char *", + "cppClassName": "String", + "jsClassName": "String", + "comment": "Reference to read from (optional); defaults to \"refs/notes/commits\"." + }, + { + "name": "note_cb", + "cType": "git_note_foreach_cb", + "cppClassName": "NoteForeachCb", + "jsClassName": "NoteForeachCb", + "comment": "Callback to invoke per found annotation. Return non-zero to stop looping." + }, + { + "name": "payload", + "cType": "void *", + "cppClassName": "void", + "jsClassName": "void", + "comment": "Extra parameter to callback function." + } + ], + "isAsync": false, + "isConstructorMethod": false, + "isPrototypeMethod": false, + "jsFunctionName": "gitNoteForeach", + "cppFunctionName": "GitNoteForeach", + "return": { + "cType": "int", + "cppClassName": "Int32", + "isErrorCode": true, + "comment": "0 on success, GIT_EUSER on non-zero callback, or error code", + "jsClassName": "Number" + }, + "description": "

Loop over all the notes within a specified namespace\nand issue a callback for each one.

\n" + } + ] + }, + { + "filename": "object.h", + "dependencies": [ + "../include/oid.h", + "../include/repo.h" + ], + "jsClassName": "Object", + "cppClassName": "GitObject", + "cType": "git_object", + "freeFunctionName": "git_object_free", + "functions": [ + { + "cFunctionName": "git_object_id", + "args": [ + { + "name": "obj", + "cType": "const git_object *", + "cppClassName": "GitObject", + "jsClassName": "Object", + "isSelf": true, + "comment": "the repository object" + } + ], + "isAsync": false, + "isConstructorMethod": false, + "isPrototypeMethod": true, + "jsFunctionName": "oid", + "cppFunctionName": "Oid", + "return": { + "cType": "const git_oid *", + "cppClassName": "GitOid", + "copy": "git_oid_dup", + "comment": "the SHA1 id", + "jsClassName": "Oid" + }, + "description": "

Get the id (SHA1) of a repository object

\n" + }, + { + "cFunctionName": "git_object_type", + "args": [ + { + "name": "obj", + "cType": "const git_object *", + "cppClassName": "GitObject", + "jsClassName": "Object", + "isSelf": true, + "comment": "the repository object" + } + ], + "isAsync": false, + "isConstructorMethod": false, + "isPrototypeMethod": true, + "jsFunctionName": "type", + "cppFunctionName": "Type", + "return": { + "cType": "git_otype", + "cppClassName": "Number", + "comment": "the object's type", + "jsClassName": "Number" + }, + "description": "

Get the object type of an object

\n" + }, + { + "cFunctionName": "git_object_owner", + "args": [ + { + "name": "obj", + "cType": "const git_object *", + "cppClassName": "GitObject", + "jsClassName": "Object", + "isSelf": true, + "comment": "the object" + } + ], + "ignore": "Never make public for memory allocation reasons", + "isAsync": false, + "isConstructorMethod": false, + "isPrototypeMethod": true, + "jsFunctionName": "owner", + "cppFunctionName": "Owner", + "return": { + "cType": "git_repository *", + "cppClassName": "GitRepo", + "comment": "the repository who owns this object", + "jsClassName": "Repository" + }, + "description": "

Get the repository that owns this object

\n" + }, + { + "cFunctionName": "git_object_free", + "args": [ + { + "name": "object", + "cType": "git_object *", + "cppClassName": "GitObject", + "jsClassName": "Object", + "comment": "the object to close" + } + ], + "ignore": true, + "isAsync": false, + "isConstructorMethod": false, + "isPrototypeMethod": false, + "isFree": true, + "jsFunctionName": "free", + "cppFunctionName": "Free", + "return": { + "cType": "void", + "cppClassName": "void", + "jsClassName": "void" + }, + "description": "

Close an open object

\n" + }, + { + "cFunctionName": "git_object_type2string", + "args": [ + { + "name": "type", + "cType": "git_otype", + "cppClassName": "Number", + "jsClassName": "Number", + "comment": "object type to convert." + } + ], + "ignore": true, + "isAsync": false, + "isConstructorMethod": false, + "isPrototypeMethod": false, + "jsFunctionName": "type2string", + "cppFunctionName": "Type2string", + "return": { + "cType": "const char *", + "cppClassName": "String", + "comment": "the corresponding string representation.", + "jsClassName": "String" + }, + "description": "

Convert an object type to it's string representation.

\n" + }, + { + "cFunctionName": "git_object_string2type", + "args": [ + { + "name": "str", + "cType": "const char *", + "cppClassName": "String", + "jsClassName": "String", + "comment": "the string to convert." + } + ], + "ignore": true, + "isAsync": false, + "isConstructorMethod": false, + "isPrototypeMethod": false, + "jsFunctionName": "string2type", + "cppFunctionName": "String2type", + "return": { + "cType": "git_otype", + "cppClassName": "Number", + "comment": "the corresponding git_otype.", + "jsClassName": "Number" + }, + "description": "

Convert a string object type representation to it's git_otype.

\n" + }, + { + "cFunctionName": "git_object_typeisloose", + "args": [ + { + "name": "type", + "cType": "git_otype", + "cppClassName": "Number", + "jsClassName": "Number", + "comment": "object type to test." + } + ], + "ignore": true, + "isAsync": false, + "isConstructorMethod": false, + "isPrototypeMethod": false, + "jsFunctionName": "typeisloose", + "cppFunctionName": "Typeisloose", + "return": { + "cType": "int", + "cppClassName": "Int32", + "isErrorCode": true, + "comment": "true if the type represents a valid loose object type, false otherwise.", + "jsClassName": "Number" + }, + "description": "

Determine if the given git_otype is a valid loose object type.

\n" + }, + { + "cFunctionName": "git_object__size", + "args": [ + { + "name": "type", + "cType": "git_otype", + "cppClassName": "Int32", + "jsClassName": "Number", + "comment": "object type to get its size" + } + ], + "ignore": true, + "isAsync": false, + "isConstructorMethod": false, + "isPrototypeMethod": false, + "jsFunctionName": "Size", + "cppFunctionName": "Size", + "return": { + "cType": "size_t", + "cppClassName": "Uint32", + "comment": "size in bytes of the object", + "jsClassName": "Number" + }, + "description": "

Get the size in bytes for the structure which\nacts as an in-memory representation of any given\nobject type.

\n" + }, + { + "cFunctionName": "git_object_peel", + "args": [ + { + "name": "peeled", + "cType": "git_object **", + "cppClassName": "GitObject", + "jsClassName": "Object", + "isReturn": true, + "comment": "Pointer to the peeled git_object" + }, + { + "name": "object", + "cType": "const git_object *", + "cppClassName": "GitObject", + "jsClassName": "Object", + "isSelf": true, + "comment": "The object to be processed" + }, + { + "name": "target_type", + "cType": "git_otype", + "cppClassName": "Int32", + "jsClassName": "Number", + "comment": "The type of the requested object (GIT_OBJ_COMMIT, GIT_OBJ_TAG, GIT_OBJ_TREE, GIT_OBJ_BLOB or GIT_OBJ_ANY)." + } + ], + "isAsync": true, + "isConstructorMethod": false, + "isPrototypeMethod": true, + "jsFunctionName": "peel", + "cppFunctionName": "Peel", + "return": { + "cType": "int", + "cppClassName": "Int32", + "isErrorCode": true, + "comment": "0 on success, GIT_EAMBIGUOUS, GIT_ENOTFOUND or an error code", + "jsClassName": "Number" + }, + "description": "

Recursively peel an object until an object of the specified type is met.

\n" + }, + { + "cFunctionName": "git_object_dup", + "args": [ + { + "name": "dest", + "cType": "git_object **", + "cppClassName": "GitObject", + "jsClassName": "Object", + "isReturn": true, + "comment": "Pointer to store the copy of the object" + }, + { + "name": "source", + "cType": "git_object *", + "cppClassName": "GitObject", + "jsClassName": "Object", + "ignore": true, + "isSelf": true, + "comment": "Original object to copy" + } + ], + "ignore": true, + "isAsync": false, + "isConstructorMethod": false, + "isPrototypeMethod": true, + "jsFunctionName": "dup", + "cppFunctionName": "Dup", + "return": { + "cType": "int", + "cppClassName": "Int32", + "isErrorCode": true, + "jsClassName": "Number" + }, + "description": "

Create an in-memory copy of a Git object. The copy must be\nexplicitly free'd or it will leak.

\n" + } + ] + }, + { + "filename": "odb.h", + "dependencies": [ + "../include/oid.h", + "../include/odb_object.h", + "node_buffer.h" + ], + "jsClassName": "Odb", + "cppClassName": "GitOdb", + "cType": "git_odb", + "freeFunctionName": "git_odb_free", + "functions": [ + { + "cFunctionName": "git_odb_new", + "args": [ + { + "name": "out", + "isReturn": true, + "cType": "git_odb **", + "cppClassName": "GitOdb", + "jsClassName": "Odb", + "comment": "location to store the database pointer, if opened. Set to NULL if the open failed." + } + ], + "isAsync": false, + "isConstructorMethod": true, + "isPrototypeMethod": false, + "jsFunctionName": "create()", + "cppFunctionName": "Create", + "return": { + "cType": "int", + "cppClassName": "Int32", + "isErrorCode": true, + "comment": "0 or an error code", + "jsClassName": "Number" + }, + "description": "

Create a new object database with no backends.

\n" + }, + { + "cFunctionName": "git_odb_open", + "args": [ + { + "name": "out", + "isReturn": true, + "cType": "git_odb **", + "cppClassName": "GitOdb", + "jsClassName": "Odb", + "comment": "location to store the database pointer, if opened. Set to NULL if the open failed." + }, + { + "name": "objects_dir", + "cType": "const char *", + "cppClassName": "String", + "jsClassName": "String", + "comment": "path of the backends' \"objects\" directory." + } + ], + "isAsync": false, + "isConstructorMethod": true, + "isPrototypeMethod": false, + "jsFunctionName": "open", + "cppFunctionName": "Open", + "return": { + "cType": "int", + "cppClassName": "Int32", + "isErrorCode": true, + "comment": "0 or an error code", + "jsClassName": "Number" + }, + "description": "

Create a new object database and automatically add\nthe two default backends:

\n" + }, + { + "cFunctionName": "git_odb_add_backend", + "args": [ + { + "name": "odb", + "cType": "git_odb *", + "cppClassName": "GitOdb", + "jsClassName": "Odb", + "isSelf": true, + "comment": "database to add the backend to" + }, + { + "name": "backend", + "cType": "git_odb_backend *", + "cppClassName": "OdbBackend", + "jsClassName": "OdbBackend", + "comment": "pointer to a git_odb_backend instance" + }, + { + "name": "priority", + "cType": "int", + "cppClassName": "Int32", + "jsClassName": "Number", + "comment": "Value for ordering the backends queue" + } + ], + "ignore": true, + "isAsync": false, + "isConstructorMethod": false, + "isPrototypeMethod": true, + "jsFunctionName": "addBackend", + "cppFunctionName": "AddBackend", + "return": { + "cType": "int", + "cppClassName": "Int32", + "isErrorCode": true, + "comment": "0 on success; error code otherwise", + "jsClassName": "Number" + }, + "description": "

Add a custom backend to an existing Object DB

\n" + }, + { + "cFunctionName": "git_odb_add_alternate", + "args": [ + { + "name": "odb", + "cType": "git_odb *", + "cppClassName": "GitOdb", + "jsClassName": "Odb", + "isSelf": true, + "comment": "database to add the backend to" + }, + { + "name": "backend", + "cType": "git_odb_backend *", + "cppClassName": "OdbBackend", + "jsClassName": "OdbBackend", + "comment": "pointer to a git_odb_backend instance" + }, + { + "name": "priority", + "cType": "int", + "cppClassName": "Int32", + "jsClassName": "Number", + "comment": "Value for ordering the backends queue" + } + ], + "ignore": true, + "isAsync": false, + "isConstructorMethod": false, + "isPrototypeMethod": true, + "jsFunctionName": "addAlternate", + "cppFunctionName": "AddAlternate", + "return": { + "cType": "int", + "cppClassName": "Int32", + "isErrorCode": true, + "comment": "0 on success; error code otherwise", + "jsClassName": "Number" + }, + "description": "

Add a custom backend to an existing Object DB; this\nbackend will work as an alternate.

\n" + }, + { + "cFunctionName": "git_odb_add_disk_alternate", + "args": [ + { + "name": "odb", + "cType": "git_odb *", + "cppClassName": "GitOdb", + "jsClassName": "Odb", + "isSelf": true, + "comment": "database to add the backend to" + }, + { + "name": "path", + "cType": "const char *", + "cppClassName": "String", + "jsClassName": "String", + "comment": "path to the objects folder for the alternate" + } + ], + "isAsync": false, + "isConstructorMethod": false, + "isPrototypeMethod": true, + "jsFunctionName": "addDiskAlternate", + "cppFunctionName": "AddDiskAlternate", + "return": { + "cType": "int", + "cppClassName": "Int32", + "isErrorCode": true, + "comment": "0 on success; error code otherwise", + "jsClassName": "Number" + }, + "description": "

Add an on-disk alternate to an existing Object DB.

\n" + }, + { + "cFunctionName": "git_odb_free", + "args": [ + { + "name": "db", + "cType": "git_odb *", + "cppClassName": "GitOdb", + "jsClassName": "Odb", + "comment": "database pointer to close. If NULL no action is taken." + } + ], + "ignore": true, + "isAsync": false, + "isConstructorMethod": false, + "isPrototypeMethod": false, + "isFree": true, + "jsFunctionName": "free", + "cppFunctionName": "Free", + "return": { + "cType": "void", + "cppClassName": "void", + "jsClassName": "void" + }, + "description": "

Close an open object database.

\n" + }, + { + "cFunctionName": "git_odb_read", + "args": [ + { + "name": "out", + "isReturn": true, + "cType": "git_odb_object **", + "cppClassName": "GitOdbObject", + "jsClassName": "OdbObject", + "comment": "pointer where to store the read object" + }, + { + "name": "db", + "cType": "git_odb *", + "cppClassName": "GitOdb", + "jsClassName": "Odb", + "isSelf": true, + "comment": "database to search for the object in." + }, + { + "name": "id", + "cType": "const git_oid *", + "cppClassName": "GitOid", + "jsClassName": "Oid", + "comment": "identity of the object to read." + } + ], + "isAsync": true, + "isConstructorMethod": false, + "isPrototypeMethod": true, + "jsFunctionName": "read", + "cppFunctionName": "Read", + "return": { + "cType": "int", + "cppClassName": "Int32", + "isErrorCode": true, + "comment": "- 0 if the object was read; - GIT_ENOTFOUND if the object is not in the database.", + "jsClassName": "Number" + }, + "description": "

Read an object from the database.

\n" + }, + { + "cFunctionName": "git_odb_read_prefix", + "args": [ + { + "name": "out", + "isReturn": true, + "cType": "git_odb_object **", + "cppClassName": "GitOdbObject", + "jsClassName": "OdbObject", + "comment": "pointer where to store the read object" + }, + { + "name": "db", + "cType": "git_odb *", + "cppClassName": "GitOdb", + "jsClassName": "Odb", + "comment": "database to search for the object in." + }, + { + "name": "short_id", + "cType": "const git_oid *", + "cppClassName": "GitOid", + "jsClassName": "Oid", + "comment": "a prefix of the id of the object to read." + }, + { + "name": "len", + "cType": "size_t", + "cppClassName": "Uint32", + "jsClassName": "Number", + "comment": "the length of the prefix" + } + ], + "isAsync": false, + "isConstructorMethod": false, + "isPrototypeMethod": false, + "jsFunctionName": "readPrefix", + "cppFunctionName": "ReadPrefix", + "return": { + "cType": "int", + "cppClassName": "Int32", + "isErrorCode": true, + "comment": "- 0 if the object was read; - GIT_ENOTFOUND if the object is not in the database. - GIT_EAMBIGUOUS if the prefix is ambiguous (several objects match the prefix)", + "jsClassName": "Number" + }, + "description": "

Read an object from the database, given a prefix\nof its identifier.

\n" + }, + { + "cFunctionName": "git_odb_read_header", + "args": [ + { + "name": "len_out", + "cType": "size_t *", + "cppClassName": "Uint32", + "jsClassName": "Number", + "comment": "pointer where to store the length" + }, + { + "name": "type_out", + "cType": "git_otype *", + "cppClassName": "Int32", + "jsClassName": "Number", + "comment": "pointer where to store the type" + }, + { + "name": "db", + "cType": "git_odb *", + "cppClassName": "GitOdb", + "jsClassName": "Odb", + "comment": "database to search for the object in." + }, + { + "name": "id", + "cType": "const git_oid *", + "cppClassName": "GitOid", + "jsClassName": "Oid", + "comment": "identity of the object to read." + } + ], + "isAsync": false, + "isConstructorMethod": false, + "isPrototypeMethod": false, + "jsFunctionName": "readHeader", + "cppFunctionName": "ReadHeader", + "return": { + "cType": "int", + "cppClassName": "Int32", + "isErrorCode": true, + "comment": "- 0 if the object was read; - GIT_ENOTFOUND if the object is not in the database.", + "jsClassName": "Number" + }, + "description": "

Read the header of an object from the database, without\nreading its full contents.

\n" + }, + { + "cFunctionName": "git_odb_exists", + "args": [ + { + "name": "db", + "cType": "git_odb *", + "cppClassName": "GitOdb", + "jsClassName": "Odb", + "isSelf": true, + "comment": "database to be searched for the given object." + }, + { + "name": "id", + "cType": "const git_oid *", + "cppClassName": "GitOid", + "jsClassName": "Oid", + "comment": "the object to search for." + } + ], + "isAsync": false, + "isConstructorMethod": false, + "isPrototypeMethod": true, + "jsFunctionName": "exists", + "cppFunctionName": "Exists", + "return": { + "cType": "int", + "cppClassName": "Int32", + "isErrorCode": true, + "comment": "- 1, if the object was found - 0, otherwise", + "jsClassName": "Number" + }, + "description": "

Determine if the given object can be found in the object database.

\n" + }, + { + "cFunctionName": "git_odb_refresh", + "args": [ + { + "name": "db", + "cType": "struct git_odb *", + "cppClassName": "GitOdb", + "jsClassName": "Odb", + "isSelf": true, + "comment": "database to refresh" + } + ], + "isAsync": false, + "isConstructorMethod": false, + "isPrototypeMethod": true, + "jsFunctionName": "refresh", + "cppFunctionName": "Refresh", + "return": { + "cType": "int", + "cppClassName": "Int32", + "isErrorCode": true, + "comment": "0 on success, error code otherwise", + "jsClassName": "Number" + }, + "description": "

Refresh the object database to load newly added files.

\n" + }, + { + "cFunctionName": "git_odb_foreach", + "args": [ + { + "name": "db", + "cType": "git_odb *", + "cppClassName": "GitOdb", + "jsClassName": "Odb", + "isSelf": true, + "comment": "database to use" + }, + { + "name": "cb", + "cType": "git_odb_foreach_cb", + "cppClassName": "OdbForeachCb", + "jsClassName": "OdbForeachCb", + "comment": "the callback to call for each object" + }, + { + "name": "payload", + "cType": "void *", + "cppClassName": "void", + "jsClassName": "void", + "comment": "data to pass to the callback" + } + ], + "ignore": true, + "isAsync": false, + "isConstructorMethod": false, + "isPrototypeMethod": true, + "jsFunctionName": "foreach", + "cppFunctionName": "Foreach", + "return": { + "cType": "int", + "cppClassName": "Int32", + "isErrorCode": true, + "comment": "0 on success, GIT_EUSER on non-zero callback, or error code", + "jsClassName": "Number" + }, + "description": "

List all objects available in the database

\n" + }, + { + "cFunctionName": "git_odb_write", + "args": [ + { + "name": "out", + "isReturn": true, + "shouldAlloc": true, + "cType": "git_oid *", + "cppClassName": "GitOid", + "jsClassName": "Oid", + "comment": "pointer to store the OID result of the write" + }, + { + "name": "odb", + "cType": "git_odb *", + "cppClassName": "GitOdb", + "jsClassName": "Odb", + "isSelf": true, + "comment": "object database where to store the object" + }, + { + "name": "data", + "cType": "const void *", + "cppClassName": "String", + "jsClassName": "String", + "comment": "buffer with the data to store" + }, + { + "name": "len", + "cType": "size_t", + "cppClassName": "Uint32", + "jsClassName": "Number", + "comment": "size of the buffer" + }, + { + "name": "type", + "cType": "git_otype", + "cppClassName": "Int32", + "jsClassName": "Number", + "comment": "type of the data to store" + } + ], + "isAsync": true, + "isConstructorMethod": false, + "isPrototypeMethod": true, + "jsFunctionName": "write", + "cppFunctionName": "Write", + "return": { + "cType": "int", + "cppClassName": "Int32", + "isErrorCode": true, + "comment": "0 or an error code", + "jsClassName": "Number" + }, + "description": "

Write an object directly into the ODB

\n" + }, + { + "cFunctionName": "git_odb_open_wstream", + "args": [ + { + "name": "out", + "isReturn": true, + "cType": "git_odb_stream **", + "cppClassName": "GitOdbStream", + "jsClassName": "OdbStream", + "comment": "pointer where to store the stream" + }, + { + "name": "db", + "cType": "git_odb *", + "cppClassName": "GitOdb", + "jsClassName": "Odb", + "comment": "object database where the stream will write" + }, + { + "name": "size", + "cType": "size_t", + "cppClassName": "Uint32", + "jsClassName": "Number", + "comment": "final size of the object that will be written" + }, + { + "name": "type", + "cType": "git_otype", + "cppClassName": "Int32", + "jsClassName": "Number", + "comment": "type of the object that will be written" + } + ], + "ignore": true, + "isAsync": false, + "isConstructorMethod": false, + "isPrototypeMethod": false, + "jsFunctionName": "openWstream", + "cppFunctionName": "OpenWstream", + "return": { + "cType": "int", + "cppClassName": "Int32", + "isErrorCode": true, + "comment": "0 if the stream was created; error code otherwise", + "jsClassName": "Number" + }, + "description": "

Open a stream to write an object into the ODB

\n" + }, + { + "cFunctionName": "git_odb_open_rstream", + "args": [ + { + "name": "out", + "isReturn": true, + "cType": "git_odb_stream **", + "cppClassName": "GitOdbStream", + "jsClassName": "OdbStream", + "comment": "pointer where to store the stream" + }, + { + "name": "db", + "cType": "git_odb *", + "cppClassName": "GitOdb", + "jsClassName": "Odb", + "comment": "object database where the stream will read from" + }, + { + "name": "oid", + "cType": "const git_oid *", + "cppClassName": "GitOid", + "jsClassName": "Oid", + "comment": "oid of the object the stream will read from" + } + ], + "ignore": true, + "isAsync": false, + "isConstructorMethod": false, + "isPrototypeMethod": false, + "jsFunctionName": "openRstream", + "cppFunctionName": "OpenRstream", + "return": { + "cType": "int", + "cppClassName": "Int32", + "isErrorCode": true, + "comment": "0 if the stream was created; error code otherwise", + "jsClassName": "Number" + }, + "description": "

Open a stream to read an object from the ODB

\n" + }, + { + "cFunctionName": "git_odb_write_pack", + "args": [ + { + "name": "out", + "isReturn": true, + "cType": "git_odb_writepack **", + "cppClassName": "OdbWritepack", + "jsClassName": "OdbWritepack", + "comment": "pointer to the writepack functions" + }, + { + "name": "db", + "cType": "git_odb *", + "cppClassName": "GitOdb", + "jsClassName": "Odb", + "comment": "object database where the stream will read from" + }, + { + "name": "progress_cb", + "cType": "git_transfer_progress_callback", + "cppClassName": "TransferProgressCallback", + "jsClassName": "TransferProgressCallback", + "comment": "function to call with progress information. Be aware that this is called inline with network and indexing operations, so performance may be affected." + }, + { + "name": "progress_payload", + "cType": "void *", + "cppClassName": "void", + "jsClassName": "void", + "comment": "payload for the progress callback" + } + ], + "ignore": true, + "isAsync": false, + "isConstructorMethod": false, + "isPrototypeMethod": false, + "jsFunctionName": "writePack", + "cppFunctionName": "WritePack", + "return": { + "cType": "int", + "cppClassName": "Int32", + "isErrorCode": true, + "jsClassName": "Number" + }, + "description": "

Open a stream for writing a pack file to the ODB.

\n" + }, + { + "cFunctionName": "git_odb_hash", + "args": [ + { + "name": "out", + "isReturn": true, + "shouldAlloc": true, + "cType": "git_oid *", + "cppClassName": "GitOid", + "jsClassName": "Oid", + "comment": "the resulting object-ID." + }, + { + "name": "data", + "cType": "const void *", + "cppClassName": "Buffer", + "jsClassName": "Buffer", + "comment": "data to hash" + }, + { + "name": "len", + "cType": "size_t", + "cppClassName": "Uint32", + "jsClassName": "Number", + "comment": "size of the data" + }, + { + "name": "type", + "cType": "git_otype", + "cppClassName": "Int32", + "jsClassName": "Number", + "comment": "of the data to hash" + } + ], + "isAsync": false, + "isConstructorMethod": false, + "isPrototypeMethod": false, + "jsFunctionName": "hash", + "cppFunctionName": "Hash", + "return": { + "cType": "int", + "cppClassName": "Int32", + "isErrorCode": true, + "comment": "0 or an error code", + "jsClassName": "Number" + }, + "description": "

Determine the object-ID (sha1 hash) of a data buffer

\n" + }, + { + "cFunctionName": "git_odb_hashfile", + "args": [ + { + "name": "out", + "isReturn": true, + "shouldAlloc": true, + "cType": "git_oid *", + "cppClassName": "GitOid", + "jsClassName": "Oid", + "comment": "oid structure the result is written into." + }, + { + "name": "path", + "cType": "const char *", + "cppClassName": "String", + "jsClassName": "String", + "comment": "file to read and determine object id for" + }, + { + "name": "type", + "cType": "git_otype", + "cppClassName": "Int32", + "jsClassName": "Number", + "comment": "the type of the object that will be hashed" + } + ], + "isAsync": false, + "isConstructorMethod": false, + "isPrototypeMethod": false, + "jsFunctionName": "hashfile", + "cppFunctionName": "Hashfile", + "return": { + "cType": "int", + "cppClassName": "Int32", + "isErrorCode": true, + "comment": "0 or an error code", + "jsClassName": "Number" + }, + "description": "

Read a file from disk and fill a git_oid with the object id\nthat the file would have if it were written to the Object\nDatabase as an object of the given type (w/o applying filters).\nSimilar functionality to git.git's git hash-object without\nthe -w flag, however, with the --no-filters flag.\nIf you need filters, see git_repository_hashfile.

\n" + } + ] + }, + { + "filename": "odb_object.h", + "dependencies": [ + "../include/wrapper.h", + "../include/oid.h" + ], + "jsClassName": "OdbObject", + "cppClassName": "GitOdbObject", + "cType": "git_odb_object", + "freeFunctionName": "git_odb_object_free", + "functions": [ + { + "cFunctionName": "git_odb_object_data", + "args": [ + { + "name": "object", + "cType": "git_odb_object *", + "cppClassName": "GitOdbObject", + "jsClassName": "OdbObject", + "isSelf": true, + "comment": "the object" + } + ], + "isAsync": false, + "isConstructorMethod": false, + "isPrototypeMethod": true, + "jsFunctionName": "data", + "cppFunctionName": "Data", + "return": { + "cType": "const void *", + "cppClassName": "Wrapper", + "comment": "a pointer to the data" + }, + "description": "

Return the data of an ODB object

\n" + }, + { + "cFunctionName": "git_odb_object_size", + "args": [ + { + "name": "object", + "cType": "git_odb_object *", + "cppClassName": "GitOdbObject", + "jsClassName": "OdbObject", + "isSelf": true, + "comment": "the object" + } + ], + "isAsync": false, + "isConstructorMethod": false, + "isPrototypeMethod": true, + "jsFunctionName": "size", + "cppFunctionName": "Size", + "return": { + "cType": "size_t", + "cppClassName": "Uint32", + "comment": "the size", + "jsClassName": "Number" + }, + "description": "

Return the size of an ODB object

\n" + }, + { + "cFunctionName": "git_odb_object_type", + "args": [ + { + "name": "object", + "cType": "git_odb_object *", + "cppClassName": "GitOdbObject", + "jsClassName": "OdbObject", + "isSelf": true, + "comment": "the object" + } + ], + "isAsync": false, + "isConstructorMethod": false, + "isPrototypeMethod": true, + "jsFunctionName": "type", + "cppFunctionName": "Type", + "return": { + "cType": "git_otype", + "cppClassName": "Int32", + "comment": "the type", + "jsClassName": "Number" + }, + "description": "

Return the type of an ODB object

\n" + }, + { + "cFunctionName": "git_odb_object_free", + "args": [ + { + "name": "object", + "cType": "git_odb_object *", + "cppClassName": "GitOdbObject", + "jsClassName": "OdbObject", + "isSelf": true, + "comment": "object to close" + } + ], + "ignore": true, + "isAsync": false, + "isConstructorMethod": false, + "isPrototypeMethod": true, + "isFree": true, + "jsFunctionName": "free", + "cppFunctionName": "Free", + "return": { + "cType": "void", + "cppClassName": "void", + "jsClassName": "void" + }, + "description": "

Close an ODB object

\n" + }, + { + "cFunctionName": "git_odb_object_id", + "args": [ + { + "name": "object", + "cType": "git_odb_object *", + "cppClassName": "GitOdbObject", + "jsClassName": "OdbObject", + "isSelf": true, + "comment": "the object" + } + ], + "isAsync": false, + "isConstructorMethod": false, + "isPrototypeMethod": true, + "jsFunctionName": "oid", + "cppFunctionName": "Oid", + "return": { + "cType": "const git_oid *", + "cppClassName": "GitOid", + "copy": "git_oid_dup", + "comment": "a pointer to the OID", + "jsClassName": "Oid" + }, + "description": "

Return the OID of an ODB object

\n" + } + ] + }, + { + "filename": "odb_backend.h", + "ignore": true, + "jsClassName": "OdbBackend", + "cppClassName": "OdbBackend", + "cType": "git_odb_backend", + "freeFunctionName": "git_odb_backend_free", + "functions": [ + { + "cFunctionName": "git_odb_backend_pack", + "args": [ + { + "name": "out", + "isReturn": true, + "cType": "git_odb_backend **", + "cppClassName": "OdbBackend", + "jsClassName": "OdbBackend", + "comment": "location to store the odb backend pointer" + }, + { + "name": "objects_dir", + "cType": "const char *", + "cppClassName": "String", + "jsClassName": "String", + "comment": "the Git repository's objects directory" + } + ], + "isAsync": false, + "isConstructorMethod": true, + "isPrototypeMethod": false, + "jsFunctionName": "pack", + "cppFunctionName": "Pack", + "return": { + "cType": "int", + "cppClassName": "Int32", + "isErrorCode": true, + "comment": "0 or an error code", + "jsClassName": "Number" + }, + "description": "

Create a backend for the packfiles.

\n" + } + ] + }, + { + "filename": "oid.h", + "dependencies": [], + "jsClassName": "Oid", + "cppClassName": "GitOid", + "cType": "git_oid", + "freeFunctionName": "free", + "functions": [ + { + "cFunctionName": "git_oid_fromstr", + "args": [ + { + "name": "out", + "isReturn": true, + "shouldAlloc": true, + "cType": "git_oid *", + "cppClassName": "GitOid", + "jsClassName": "Oid", + "comment": "oid structure the result is written into." + }, + { + "name": "str", + "cType": "const char *", + "cppClassName": "String", + "jsClassName": "String", + "comment": "input hex string; must be pointing at the start of the hex sequence and have at least the number of bytes needed for an oid encoded in hex (40 bytes)." + } + ], + "isAsync": false, + "isConstructorMethod": true, + "isPrototypeMethod": false, + "jsFunctionName": "fromString", + "cppFunctionName": "FromString", + "return": { + "cType": "int", + "cppClassName": "Int32", + "isErrorCode": true, + "comment": "0 or an error code", + "jsClassName": "Number" + }, + "description": "

Parse a hex formatted object id into a git_oid.

\n" + }, + { + "cFunctionName": "git_oid_fromstrp", + "args": [ + { + "name": "out", + "isReturn": true, + "cType": "git_oid *", + "cppClassName": "GitOid", + "jsClassName": "Oid", + "shouldAlloc": true, + "comment": "oid structure the result is written into." + }, + { + "name": "str", + "cType": "const char *", + "cppClassName": "String", + "jsClassName": "String", + "comment": "input hex string; must be at least 4 characters long and null-terminated." + } + ], + "ignore": true, + "isAsync": false, + "isConstructorMethod": true, + "isPrototypeMethod": false, + "jsFunctionName": "fromstrp", + "cppFunctionName": "Fromstrp", + "return": { + "cType": "int", + "cppClassName": "Int32", + "isErrorCode": true, + "comment": "0 or an error code", + "jsClassName": "Number" + }, + "description": "

Parse a hex formatted null-terminated string into a git_oid.

\n" + }, + { + "cFunctionName": "git_oid_fromstrn", + "args": [ + { + "name": "out", + "isReturn": true, + "cType": "git_oid *", + "cppClassName": "GitOid", + "jsClassName": "Oid", + "shouldAlloc": true, + "comment": "oid structure the result is written into." + }, + { + "name": "str", + "cType": "const char *", + "cppClassName": "String", + "jsClassName": "String", + "comment": "input hex string of at least size `length`" + }, + { + "name": "length", + "cType": "size_t", + "cppClassName": "Uint32", + "jsClassName": "Number", + "comment": "length of the input string" + } + ], + "ignore": true, + "isAsync": false, + "isConstructorMethod": true, + "isPrototypeMethod": false, + "jsFunctionName": "fromstrn", + "cppFunctionName": "Fromstrn", + "return": { + "cType": "int", + "cppClassName": "Int32", + "isErrorCode": true, + "comment": "0 or an error code", + "jsClassName": "Number" + }, + "description": "

Parse N characters of a hex formatted object id into a git_oid

\n" + }, + { + "cFunctionName": "git_oid_fromraw", + "args": [ + { + "name": "out", + "isReturn": true, + "cType": "git_oid *", + "cppClassName": "GitOid", + "jsClassName": "Oid", + "shouldAlloc": true, + "comment": "oid structure the result is written into." + }, + { + "name": "raw", + "cType": "const unsigned char *", + "cppClassName": "String", + "jsClassName": "String", + "comment": "the raw input bytes to be copied." + } + ], + "ignore": true, + "isAsync": false, + "isConstructorMethod": true, + "isPrototypeMethod": false, + "jsFunctionName": "fromraw", + "cppFunctionName": "Fromraw", + "return": { + "cType": "void", + "cppClassName": "void", + "jsClassName": "void" + }, + "description": "

Copy an already raw oid into a git_oid structure.

\n" + }, + { + "cFunctionName": "git_oid_fmt", + "args": [ + { + "name": "out", + "isReturn": true, + "cType": "char *", + "cppClassName": "String", + "jsClassName": "String", + "comment": "output hex string; must be pointing at the start of the hex sequence and have at least the number of bytes needed for an oid encoded in hex (40 bytes). Only the oid digits are written; a '\\\\0' terminator must be added by the caller if it is required." + }, + { + "name": "id", + "cType": "const git_oid *", + "cppClassName": "GitOid", + "jsClassName": "Oid", + "isSelf": true, + "comment": "oid structure to format." + } + ], + "ignore": true, + "isAsync": false, + "isConstructorMethod": false, + "isPrototypeMethod": true, + "jsFunctionName": "fmt", + "cppFunctionName": "Fmt", + "return": { + "cType": "void", + "cppClassName": "void", + "jsClassName": "void" + }, + "description": "

Format a git_oid into a hex string.

\n" + }, + { + "cFunctionName": "git_oid_pathfmt", + "args": [ + { + "name": "out", + "isReturn": true, + "cType": "char *", + "cppClassName": "String", + "jsClassName": "String", + "comment": "output hex string; must be pointing at the start of the hex sequence and have at least the number of bytes needed for an oid encoded in hex (41 bytes). Only the oid digits are written; a '\\\\0' terminator must be added by the caller if it is required." + }, + { + "name": "id", + "cType": "const git_oid *", + "cppClassName": "GitOid", + "jsClassName": "Oid", + "comment": "oid structure to format." + } + ], + "ignore": true, + "isAsync": false, + "isConstructorMethod": false, + "isPrototypeMethod": false, + "jsFunctionName": "pathfmt", + "cppFunctionName": "Pathfmt", + "return": { + "cType": "void", + "cppClassName": "void", + "jsClassName": "void" + }, + "description": "

Format a git_oid into a loose-object path string.

\n" + }, + { + "cFunctionName": "git_oid_allocfmt", + "args": [ + { + "name": "id", + "cType": "const git_oid *", + "cppClassName": "GitOid", + "jsClassName": "Oid", + "isSelf": true, + "comment": "the oid structure to format" + } + ], + "isAsync": false, + "isConstructorMethod": false, + "isPrototypeMethod": true, + "jsFunctionName": "sha", + "cppFunctionName": "Sha", + "return": { + "cType": "char *", + "cppClassName": "String", + "comment": "the c-string; NULL if memory is exhausted. Caller must deallocate the string with git__free().", + "jsClassName": "String", + "freeFunctionName": "free" + }, + "description": "

Format a git_oid into a newly allocated c-string.

\n" + }, + { + "cFunctionName": "git_oid_tostr", + "args": [ + { + "name": "out", + "isReturn": true, + "cType": "char *", + "cppClassName": "String", + "jsClassName": "String", + "comment": "the buffer into which the oid string is output." + }, + { + "name": "n", + "cType": "size_t", + "cppClassName": "Uint32", + "jsClassName": "Number", + "comment": "the size of the out buffer." + }, + { + "name": "id", + "cType": "const git_oid *", + "cppClassName": "GitOid", + "jsClassName": "Oid", + "comment": "the oid structure to format." + } + ], + "ignore": true, + "isAsync": false, + "isConstructorMethod": false, + "isPrototypeMethod": false, + "jsFunctionName": "sha", + "cppFunctionName": "Sha", + "return": { + "cType": "char *", + "cppClassName": "String", + "comment": "the out buffer pointer, assuming no input parameter errors, otherwise a pointer to an empty string.", + "jsClassName": "String" + }, + "description": "

Format a git_oid into a buffer as a hex format c-string.

\n" + }, + { + "cFunctionName": "git_oid_cpy", + "args": [ + { + "name": "out", + "isReturn": true, + "cType": "git_oid *", + "cppClassName": "GitOid", + "jsClassName": "Oid", + "shouldAlloc": true, + "comment": "oid structure the result is written into." + }, + { + "name": "src", + "cType": "const git_oid *", + "cppClassName": "GitOid", + "jsClassName": "Oid", + "isSelf": true, + "comment": "oid structure to copy from." + } + ], + "ignore": true, + "isAsync": false, + "isConstructorMethod": false, + "isPrototypeMethod": true, + "jsFunctionName": "cpy", + "cppFunctionName": "Cpy", + "return": { + "cType": "void", + "cppClassName": "void", + "jsClassName": "void" + }, + "description": "

Copy an oid from one structure to another.

\n" + }, + { + "cFunctionName": "git_oid_cmp", + "args": [ + { + "name": "a", + "cType": "const git_oid *", + "cppClassName": "GitOid", + "jsClassName": "Oid", + "isSelf": true, + "comment": "first oid structure." + }, + { + "name": "b", + "cType": "const git_oid *", + "cppClassName": "GitOid", + "jsClassName": "Oid", + "comment": "second oid structure." + } + ], + "ignore": true, + "isAsync": false, + "isConstructorMethod": false, + "isPrototypeMethod": true, + "jsFunctionName": "cmp", + "cppFunctionName": "Cmp", + "return": { + "cType": "int", + "cppClassName": "Int32", + "isErrorCode": true, + "comment": "<0, 0, >0 if a < b, a == b, a > b.", + "jsClassName": "Number" + }, + "description": "

Compare two oid structures.

\n" + }, + { + "cFunctionName": "git_oid_equal", + "args": [ + { + "name": "a", + "cType": "const git_oid *", + "cppClassName": "GitOid", + "jsClassName": "Oid", + "isSelf": true, + "comment": "first oid structure." + }, + { + "name": "b", + "cType": "const git_oid *", + "cppClassName": "GitOid", + "jsClassName": "Oid", + "comment": "second oid structure." + } + ], + "ignore": true, + "isAsync": false, + "isConstructorMethod": false, + "isPrototypeMethod": true, + "jsFunctionName": "equal", + "cppFunctionName": "Equal", + "return": { + "cType": "int", + "cppClassName": "Int32", + "isErrorCode": true, + "comment": "true if equal, false otherwise", + "jsClassName": "Number" + }, + "description": "

Compare two oid structures for equality

\n" + }, + { + "cFunctionName": "git_oid_ncmp", + "args": [ + { + "name": "a", + "cType": "const git_oid *", + "cppClassName": "GitOid", + "jsClassName": "Oid", + "isSelf": true, + "comment": "first oid structure." + }, + { + "name": "b", + "cType": "const git_oid *", + "cppClassName": "GitOid", + "jsClassName": "Oid", + "comment": "second oid structure." + }, + { + "name": "len", + "cType": "size_t", + "cppClassName": "Uint32", + "jsClassName": "Number", + "comment": "the number of hex chars to compare" + } + ], + "ignore": true, + "isAsync": false, + "isConstructorMethod": false, + "isPrototypeMethod": true, + "jsFunctionName": "ncmp", + "cppFunctionName": "Ncmp", + "return": { + "cType": "int", + "cppClassName": "Int32", + "isErrorCode": true, + "comment": "0 in case of a match", + "jsClassName": "Number" + }, + "description": "

Compare the first 'len' hexadecimal characters (packets of 4 bits)\nof two oid structures.

\n" + }, + { + "cFunctionName": "git_oid_streq", + "args": [ + { + "name": "id", + "cType": "const git_oid *", + "cppClassName": "GitOid", + "jsClassName": "Oid", + "isSelf": true, + "comment": "oid structure." + }, + { + "name": "str", + "cType": "const char *", + "cppClassName": "String", + "jsClassName": "String", + "comment": "input hex string of an object id." + } + ], + "ignore": true, + "isAsync": false, + "isConstructorMethod": false, + "isPrototypeMethod": true, + "jsFunctionName": "streq", + "cppFunctionName": "Streq", + "return": { + "cType": "int", + "cppClassName": "Int32", + "isErrorCode": true, + "comment": "GIT_ENOTOID if str is not a valid hex string, 0 in case of a match, GIT_ERROR otherwise.", + "jsClassName": "Number" + }, + "description": "

Check if an oid equals an hex formatted object id.

\n" + }, + { + "cFunctionName": "git_oid_iszero", + "args": [ + { + "name": "id", + "cType": "const git_oid *", + "cppClassName": "GitOid", + "jsClassName": "Oid", + "isSelf": true + } + ], + "ignore": true, + "isAsync": false, + "isConstructorMethod": false, + "isPrototypeMethod": true, + "jsFunctionName": "iszero", + "cppFunctionName": "Iszero", + "return": { + "cType": "int", + "cppClassName": "Int32", + "isErrorCode": true, + "comment": "1 if all zeros, 0 otherwise.", + "jsClassName": "Number" + }, + "description": "

Check is an oid is all zeros.

\n" + }, + { + "cFunctionName": "git_oid_shorten_new", + "args": [ + { + "name": "min_length", + "cType": "size_t", + "cppClassName": "Uint32", + "jsClassName": "Number", + "comment": "The minimal length for all identifiers, which will be used even if shorter OIDs would still be unique." + } + ], + "ignore": true, + "isAsync": false, + "isConstructorMethod": false, + "isPrototypeMethod": false, + "jsFunctionName": "shortenNew", + "cppFunctionName": "ShortenNew", + "return": { + "cType": "git_oid_shorten *", + "cppClassName": "OidShorten", + "copy": "fixme", + "comment": "a `git_oid_shorten` instance, NULL if OOM", + "jsClassName": "OidShorten" + }, + "description": "

Create a new OID shortener.

\n" + }, + { + "cFunctionName": "git_oid_shorten_add", + "args": [ + { + "name": "os", + "cType": "git_oid_shorten *", + "cppClassName": "OidShorten", + "jsClassName": "OidShorten", + "comment": "a `git_oid_shorten` instance" + }, + { + "name": "text_id", + "cType": "const char *", + "cppClassName": "String", + "jsClassName": "String", + "comment": "an OID in text form" + } + ], + "ignore": true, + "isAsync": false, + "isConstructorMethod": false, + "isPrototypeMethod": false, + "jsFunctionName": "shortenAdd", + "cppFunctionName": "ShortenAdd", + "return": { + "cType": "int", + "cppClassName": "Int32", + "isErrorCode": true, + "comment": "the minimal length to uniquely identify all OIDs added so far to the set; or an error code (<0) if an error occurs.", + "jsClassName": "Number" + }, + "description": "

Add a new OID to set of shortened OIDs and calculate\nthe minimal length to uniquely identify all the OIDs in\nthe set.

\n" + }, + { + "cFunctionName": "git_oid_shorten_free", + "args": [ + { + "name": "os", + "cType": "git_oid_shorten *", + "cppClassName": "OidShorten", + "jsClassName": "OidShorten", + "comment": "a `git_oid_shorten` instance" + } + ], + "ignore": true, + "isAsync": false, + "isConstructorMethod": false, + "isPrototypeMethod": false, + "isFree": true, + "jsFunctionName": "shortenFree", + "cppFunctionName": "ShortenFree", + "return": { + "cType": "void", + "cppClassName": "void", + "jsClassName": "void" + }, + "description": "

Free an OID shortener instance

\n" + } + ] + }, + { + "filename": "pack.h", + "ignore": true, + "jsClassName": "Pack", + "cppClassName": "Pack", + "cType": "git_pack", + "freeFunctionName": "git_pack_free", + "functions": [ + { + "cFunctionName": "git_packbuilder_new", + "args": [ + { + "name": "out", + "isReturn": true, + "cType": "git_packbuilder **", + "cppClassName": "Packbuilder", + "jsClassName": "Packbuilder", + "comment": "The new packbuilder object" + }, + { + "name": "repo", + "cType": "git_repository *", + "cppClassName": "GitRepo", + "jsClassName": "Repository", + "comment": "The repository" + } + ], + "isAsync": false, + "isConstructorMethod": false, + "isPrototypeMethod": false, + "jsFunctionName": "gitPackbuilderNew", + "cppFunctionName": "GitPackbuilderNew", + "return": { + "cType": "int", + "cppClassName": "Int32", + "isErrorCode": true, + "comment": "0 or an error code", + "jsClassName": "Number" + }, + "description": "

Initialize a new packbuilder

\n" + }, + { + "cFunctionName": "git_packbuilder_set_threads", + "args": [ + { + "name": "pb", + "cType": "git_packbuilder *", + "cppClassName": "Packbuilder", + "jsClassName": "Packbuilder", + "comment": "The packbuilder" + }, + { + "name": "n", + "cType": "unsigned int", + "cppClassName": "Uint32", + "jsClassName": "Number", + "comment": "Number of threads to spawn" + } + ], + "isAsync": false, + "isConstructorMethod": false, + "isPrototypeMethod": false, + "jsFunctionName": "gitPackbuilderSetThreads", + "cppFunctionName": "GitPackbuilderSetThreads", + "return": { + "cType": "unsigned int", + "cppClassName": "Uint32", + "comment": "number of actual threads to be used", + "jsClassName": "Number" + }, + "description": "

Set number of threads to spawn

\n" + }, + { + "cFunctionName": "git_packbuilder_insert", + "args": [ + { + "name": "pb", + "cType": "git_packbuilder *", + "cppClassName": "Packbuilder", + "jsClassName": "Packbuilder", + "comment": "The packbuilder" + }, + { + "name": "id", + "cType": "const git_oid *", + "cppClassName": "GitOid", + "jsClassName": "Oid", + "comment": "The oid of the commit" + }, + { + "name": "name", + "cType": "const char *", + "cppClassName": "String", + "jsClassName": "String", + "comment": "The name; might be NULL" + } + ], + "isAsync": false, + "isConstructorMethod": false, + "isPrototypeMethod": false, + "jsFunctionName": "gitPackbuilderInsert", + "cppFunctionName": "GitPackbuilderInsert", + "return": { + "cType": "int", + "cppClassName": "Int32", + "isErrorCode": true, + "comment": "0 or an error code", + "jsClassName": "Number" + }, + "description": "

Insert a single object

\n" + }, + { + "cFunctionName": "git_packbuilder_insert_tree", + "args": [ + { + "name": "pb", + "cType": "git_packbuilder *", + "cppClassName": "Packbuilder", + "jsClassName": "Packbuilder", + "comment": "The packbuilder" + }, + { + "name": "id", + "cType": "const git_oid *", + "cppClassName": "GitOid", + "jsClassName": "Oid", + "comment": "The oid of the root tree" + } + ], + "isAsync": false, + "isConstructorMethod": false, + "isPrototypeMethod": false, + "jsFunctionName": "gitPackbuilderInsertTree", + "cppFunctionName": "GitPackbuilderInsertTree", + "return": { + "cType": "int", + "cppClassName": "Int32", + "isErrorCode": true, + "comment": "0 or an error code", + "jsClassName": "Number" + }, + "description": "

Insert a root tree object

\n" + }, + { + "cFunctionName": "git_packbuilder_write", + "args": [ + { + "name": "pb", + "cType": "git_packbuilder *", + "cppClassName": "Packbuilder", + "jsClassName": "Packbuilder", + "comment": "The packbuilder" + }, + { + "name": "file", + "cType": "const char *", + "cppClassName": "String", + "jsClassName": "String" + } + ], + "isAsync": false, + "isConstructorMethod": false, + "isPrototypeMethod": false, + "jsFunctionName": "gitPackbuilderWrite", + "cppFunctionName": "GitPackbuilderWrite", + "return": { + "cType": "int", + "cppClassName": "Int32", + "isErrorCode": true, + "comment": "0 or an error code", + "jsClassName": "Number" + }, + "description": "

Write the new pack and corresponding index file to path.

\n" + }, + { + "cFunctionName": "git_packbuilder_foreach", + "args": [ + { + "name": "pb", + "cType": "git_packbuilder *", + "cppClassName": "Packbuilder", + "jsClassName": "Packbuilder", + "comment": "the packbuilder" + }, + { + "name": "cb", + "cType": "git_packbuilder_foreach_cb", + "cppClassName": "PackbuilderForeachCb", + "jsClassName": "PackbuilderForeachCb", + "comment": "the callback to call with each packed object's buffer" + }, + { + "name": "payload", + "cType": "void *", + "cppClassName": "void", + "jsClassName": "void", + "comment": "the callback's data" + } + ], + "isAsync": false, + "isConstructorMethod": false, + "isPrototypeMethod": false, + "jsFunctionName": "gitPackbuilderForeach", + "cppFunctionName": "GitPackbuilderForeach", + "return": { + "cType": "int", + "cppClassName": "Int32", + "isErrorCode": true, + "comment": "0 or an error code", + "jsClassName": "Number" + }, + "description": "

Create the new pack and pass each object to the callback

\n" + }, + { + "cFunctionName": "git_packbuilder_object_count", + "args": [ + { + "name": "pb", + "cType": "git_packbuilder *", + "cppClassName": "Packbuilder", + "jsClassName": "Packbuilder", + "comment": "the packbuilder" + } + ], + "isAsync": false, + "isConstructorMethod": false, + "isPrototypeMethod": false, + "jsFunctionName": "gitPackbuilderObjectCount", + "cppFunctionName": "GitPackbuilderObjectCount", + "return": { + "cType": "uint32_t", + "cppClassName": "Uint32", + "jsClassName": "Number" + }, + "description": "

Get the total number of objects the packbuilder will write out

\n" + }, + { + "cFunctionName": "git_packbuilder_written", + "args": [ + { + "name": "pb", + "cType": "git_packbuilder *", + "cppClassName": "Packbuilder", + "jsClassName": "Packbuilder", + "comment": "the packbuilder" + } + ], + "isAsync": false, + "isConstructorMethod": false, + "isPrototypeMethod": false, + "jsFunctionName": "gitPackbuilderWritten", + "cppFunctionName": "GitPackbuilderWritten", + "return": { + "cType": "uint32_t", + "cppClassName": "Uint32", + "jsClassName": "Number" + }, + "description": "

Get the number of objects the packbuilder has already written out

\n" + }, + { + "cFunctionName": "git_packbuilder_free", + "args": [ + { + "name": "pb", + "cType": "git_packbuilder *", + "cppClassName": "Packbuilder", + "jsClassName": "Packbuilder", + "comment": "The packbuilder" + } + ], + "isAsync": false, + "isConstructorMethod": false, + "isPrototypeMethod": false, + "isFree": true, + "jsFunctionName": "gitPackbuilderFree", + "cppFunctionName": "GitPackbuilderFree", + "return": { + "cType": "void", + "cppClassName": "void", + "jsClassName": "void" + }, + "description": "

Free the packbuilder and all associated data

\n" + } + ] + }, + { + "filename": "push.h", + "ignore": true, + "jsClassName": "Push", + "cppClassName": "Push", + "cType": "git_push", + "freeFunctionName": "git_push_free", + "functions": [ + { + "cFunctionName": "git_push_new", + "args": [ + { + "name": "out", + "isReturn": true, + "cType": "git_push **", + "cppClassName": "Push", + "jsClassName": "Push", + "comment": "New push object" + }, + { + "name": "remote", + "cType": "git_remote *", + "cppClassName": "GitRemote", + "jsClassName": "Remote", + "comment": "Remote instance" + } + ], + "isAsync": false, + "isConstructorMethod": true, + "isPrototypeMethod": false, + "jsFunctionName": "new", + "cppFunctionName": "New", + "return": { + "cType": "int", + "cppClassName": "Int32", + "isErrorCode": true, + "comment": "0 or an error code", + "jsClassName": "Number" + }, + "description": "

Create a new push object

\n" + }, + { + "cFunctionName": "git_push_set_options", + "args": [ + { + "name": "push", + "cType": "git_push *", + "cppClassName": "Push", + "jsClassName": "Push", + "isSelf": true, + "comment": "The push object" + }, + { + "name": "opts", + "cType": "const git_push_options *", + "cppClassName": "PushOptions", + "jsClassName": "PushOptions", + "comment": "The options to set on the push object" + } + ], + "isAsync": false, + "isConstructorMethod": false, + "isPrototypeMethod": true, + "jsFunctionName": "setOptions", + "cppFunctionName": "SetOptions", + "return": { + "cType": "int", + "cppClassName": "Int32", + "isErrorCode": true, + "comment": "0 or an error code", + "jsClassName": "Number" + }, + "description": "

Set options on a push object

\n" + }, + { + "cFunctionName": "git_push_add_refspec", + "args": [ + { + "name": "push", + "cType": "git_push *", + "cppClassName": "Push", + "jsClassName": "Push", + "isSelf": true, + "comment": "The push object" + }, + { + "name": "refspec", + "cType": "const char *", + "cppClassName": "String", + "jsClassName": "String", + "comment": "Refspec string" + } + ], + "isAsync": false, + "isConstructorMethod": false, + "isPrototypeMethod": true, + "jsFunctionName": "addRefspec", + "cppFunctionName": "AddRefspec", + "return": { + "cType": "int", + "cppClassName": "Int32", + "isErrorCode": true, + "comment": "0 or an error code", + "jsClassName": "Number" + }, + "description": "

Add a refspec to be pushed

\n" + }, + { + "cFunctionName": "git_push_update_tips", + "args": [ + { + "name": "push", + "cType": "git_push *", + "cppClassName": "Push", + "jsClassName": "Push", + "isSelf": true, + "comment": "The push object" + } + ], + "isAsync": false, + "isConstructorMethod": false, + "isPrototypeMethod": true, + "jsFunctionName": "updateTips", + "cppFunctionName": "UpdateTips", + "return": { + "cType": "int", + "cppClassName": "Int32", + "isErrorCode": true, + "comment": "0 or an error code", + "jsClassName": "Number" + }, + "description": "

Update remote tips after a push

\n" + }, + { + "cFunctionName": "git_push_finish", + "args": [ + { + "name": "push", + "cType": "git_push *", + "cppClassName": "Push", + "jsClassName": "Push", + "isSelf": true, + "comment": "The push object" + } + ], + "isAsync": false, + "isConstructorMethod": false, + "isPrototypeMethod": true, + "jsFunctionName": "finish", + "cppFunctionName": "Finish", + "return": { + "cType": "int", + "cppClassName": "Int32", + "isErrorCode": true, + "comment": "0 or an error code", + "jsClassName": "Number" + }, + "description": "

Actually push all given refspecs

\n" + }, + { + "cFunctionName": "git_push_unpack_ok", + "args": [ + { + "name": "push", + "cType": "git_push *", + "cppClassName": "Push", + "jsClassName": "Push", + "isSelf": true, + "comment": "The push object" + } + ], + "isAsync": false, + "isConstructorMethod": false, + "isPrototypeMethod": true, + "jsFunctionName": "unpackOk", + "cppFunctionName": "UnpackOk", + "return": { + "cType": "int", + "cppClassName": "Int32", + "isErrorCode": true, + "comment": "true if equal, false otherwise", + "jsClassName": "Number" + }, + "description": "

Check if remote side successfully unpacked

\n" + }, + { + "cFunctionName": "git_push_status_foreach", + "args": [ + { + "name": "push", + "cType": "git_push *", + "cppClassName": "Push", + "jsClassName": "Push", + "isSelf": true, + "comment": "The push object" + }, + { + "name": "cb", + "cType": "int (*)(const char *ref, const char *msg, void *data)", + "cppClassName": "Int32", + "jsClassName": "Number", + "comment": "The callback to call on each object" + }, + { + "name": "data", + "cType": "void *", + "cppClassName": "void", + "jsClassName": "void" + } + ], + "isAsync": false, + "isConstructorMethod": false, + "isPrototypeMethod": true, + "jsFunctionName": "statusForeach", + "cppFunctionName": "StatusForeach", + "return": { + "cType": "int", + "cppClassName": "Int32", + "isErrorCode": true, + "comment": "0 on success, GIT_EUSER on non-zero callback, or error code", + "jsClassName": "Number" + }, + "description": "

Call callback `cb' on each status

\n" + }, + { + "cFunctionName": "git_push_free", + "args": [ + { + "name": "push", + "cType": "git_push *", + "cppClassName": "Push", + "jsClassName": "Push", + "comment": "The push object" + } + ], + "isAsync": false, + "isConstructorMethod": false, + "isPrototypeMethod": false, + "isFree": true, + "jsFunctionName": "free", + "cppFunctionName": "Free", + "return": { + "cType": "void", + "cppClassName": "void", + "jsClassName": "void" + }, + "description": "

Free the given push object

\n" + } + ] + }, + { + "filename": "refdb.h", + "jsClassName": "RefDb", + "cppClassName": "GitRefDb", + "cType": "git_refdb", + "note": "this should be git_refdb_free, but it's not available", + "freeFunctionName": "free", + "functions": [ + { + "cFunctionName": "git_reference__alloc", + "args": [ + { + "name": "refdb", + "cType": "git_refdb *", + "cppClassName": "GitRefDb", + "jsClassName": "RefDb", + "isSelf": true + }, + { + "name": "name", + "cType": "const char *", + "cppClassName": "String", + "jsClassName": "String" + }, + { + "name": "oid", + "cType": "const git_oid *", + "cppClassName": "GitOid", + "jsClassName": "Oid" + }, + { + "name": "symbolic", + "cType": "const char *", + "cppClassName": "String", + "jsClassName": "String" + } + ], + "ignore": true, + "isAsync": false, + "isConstructorMethod": false, + "isPrototypeMethod": true, + "jsFunctionName": "gitReference_Alloc", + "cppFunctionName": "GitReference_Alloc", + "return": { + "cType": "git_reference *", + "cppClassName": "GitReference", + "copy": "fixme", + "comment": "the created git_reference or NULL on error", + "jsClassName": "Reference" + }, + "description": "

Create a new direct reference from an OID.

\n" + }, + { + "cFunctionName": "git_refdb_compress", + "args": [ + { + "name": "refdb", + "cType": "git_refdb *", + "cppClassName": "GitRefDb", + "jsClassName": "RefDb", + "isSelf": true + } + ], + "ignore": true, + "isAsync": true, + "isConstructorMethod": false, + "isPrototypeMethod": true, + "jsFunctionName": "compress", + "cppFunctionName": "Compress", + "return": { + "cType": "int", + "cppClassName": "Int32", + "isErrorCode": true, + "jsClassName": "Number" + }, + "description": "

Suggests that the given refdb compress or optimize its references.\nThis mechanism is implementation specific. For on-disk reference\ndatabases, for example, this may pack all loose references.

\n" + }, + { + "cFunctionName": "git_refdb_free", + "args": [ + { + "name": "refdb", + "cType": "git_refdb *", + "cppClassName": "GitRefDb", + "jsClassName": "RefDb", + "comment": "reference database pointer or NULL" + } + ], + "ignore": true, + "isAsync": false, + "isConstructorMethod": false, + "isPrototypeMethod": false, + "isFree": true, + "jsFunctionName": "free", + "cppFunctionName": "Free", + "return": { + "cType": "void", + "cppClassName": "void", + "jsClassName": "void" + }, + "description": "

Close an open reference database.

\n" + }, + { + "cFunctionName": "git_refdb_set_backend", + "args": [ + { + "name": "refdb", + "cType": "git_refdb *", + "cppClassName": "GitRefDb", + "jsClassName": "RefDb", + "isSelf": true, + "comment": "database to add the backend to" + }, + { + "name": "backend", + "cType": "git_refdb_backend *", + "cppClassName": "RefdbBackend", + "jsClassName": "RefdbBackend", + "comment": "pointer to a git_refdb_backend instance" + } + ], + "ignore": true, + "isAsync": false, + "isConstructorMethod": false, + "isPrototypeMethod": true, + "jsFunctionName": "setBackend", + "cppFunctionName": "SetBackend", + "return": { + "cType": "int", + "cppClassName": "Int32", + "isErrorCode": true, + "comment": "0 on success; error code otherwise", + "jsClassName": "Number" + }, + "description": "

Sets the custom backend to an existing reference DB

\n" + } + ] + }, + { + "filename": "refdb_backend.h", + "ignore": true, + "jsClassName": "RefdbBackend", + "cppClassName": "RefdbBackend", + "cType": "git_refdb_backend", + "freeFunctionName": "git_refdb_backend_free", + "functions": [] + }, + { + "filename": "reflog.h", + "ignore": true, + "jsClassName": "Reflog", + "cppClassName": "Reflog", + "cType": "git_reflog", + "freeFunctionName": "git_reflog_free", + "functions": [ + { + "cFunctionName": "git_reflog_read", + "args": [ + { + "name": "out", + "isReturn": true, + "cType": "git_reflog **", + "cppClassName": "Reflog", + "jsClassName": "Reflog", + "comment": "pointer to reflog" + }, + { + "name": "ref", + "cType": "const git_reference *", + "cppClassName": "GitReference", + "jsClassName": "Reference", + "comment": "reference to read the reflog for" + } + ], + "isAsync": false, + "isConstructorMethod": true, + "isPrototypeMethod": false, + "jsFunctionName": "read", + "cppFunctionName": "Read", + "return": { + "cType": "int", + "cppClassName": "Int32", + "isErrorCode": true, + "comment": "0 or an error code", + "jsClassName": "Number" + }, + "description": "

Read the reflog for the given reference

\n" + }, + { + "cFunctionName": "git_reflog_write", + "args": [ + { + "name": "reflog", + "cType": "git_reflog *", + "cppClassName": "Reflog", + "jsClassName": "Reflog", + "isSelf": true, + "comment": "an existing reflog object" + } + ], + "isAsync": false, + "isConstructorMethod": false, + "isPrototypeMethod": true, + "jsFunctionName": "write", + "cppFunctionName": "Write", + "return": { + "cType": "int", + "cppClassName": "Int32", + "isErrorCode": true, + "comment": "0 or an error code", + "jsClassName": "Number" + }, + "description": "

Write an existing in-memory reflog object back to disk\nusing an atomic file lock.

\n" + }, + { + "cFunctionName": "git_reflog_append", + "args": [ + { + "name": "reflog", + "cType": "git_reflog *", + "cppClassName": "Reflog", + "jsClassName": "Reflog", + "isSelf": true, + "comment": "an existing reflog object" + }, + { + "name": "id", + "cType": "const git_oid *", + "cppClassName": "GitOid", + "jsClassName": "Oid", + "comment": "the OID the reference is now pointing to" + }, + { + "name": "committer", + "cType": "const git_signature *", + "cppClassName": "GitSignature", + "jsClassName": "Signature", + "comment": "the signature of the committer" + }, + { + "name": "msg", + "cType": "const char *", + "cppClassName": "String", + "jsClassName": "String", + "comment": "the reflog message" + } + ], + "isAsync": false, + "isConstructorMethod": false, + "isPrototypeMethod": true, + "jsFunctionName": "append", + "cppFunctionName": "Append", + "return": { + "cType": "int", + "cppClassName": "Int32", + "isErrorCode": true, + "comment": "0 or an error code", + "jsClassName": "Number" + }, + "description": "

Add a new entry to the reflog.

\n" + }, + { + "cFunctionName": "git_reflog_rename", + "args": [ + { + "name": "ref", + "cType": "git_reference *", + "cppClassName": "GitReference", + "jsClassName": "Reference", + "comment": "the reference" + }, + { + "name": "name", + "cType": "const char *", + "cppClassName": "String", + "jsClassName": "String", + "comment": "the new name of the reference" + } + ], + "isAsync": false, + "isConstructorMethod": false, + "isPrototypeMethod": false, + "jsFunctionName": "rename", + "cppFunctionName": "Rename", + "return": { + "cType": "int", + "cppClassName": "Int32", + "isErrorCode": true, + "comment": "0 on success, GIT_EINVALIDSPEC or an error code", + "jsClassName": "Number" + }, + "description": "

Rename the reflog for the given reference

\n" + }, + { + "cFunctionName": "git_reflog_delete", + "args": [ + { + "name": "ref", + "cType": "git_reference *", + "cppClassName": "GitReference", + "jsClassName": "Reference", + "comment": "the reference" + } + ], + "isAsync": false, + "isConstructorMethod": false, + "isPrototypeMethod": false, + "jsFunctionName": "delete", + "cppFunctionName": "Delete", + "return": { + "cType": "int", + "cppClassName": "Int32", + "isErrorCode": true, + "comment": "0 or an error code", + "jsClassName": "Number" + }, + "description": "

Delete the reflog for the given reference

\n" + }, + { + "cFunctionName": "git_reflog_entrycount", + "args": [ + { + "name": "reflog", + "cType": "git_reflog *", + "cppClassName": "Reflog", + "jsClassName": "Reflog", + "isSelf": true, + "comment": "the previously loaded reflog" + } + ], + "isAsync": false, + "isConstructorMethod": false, + "isPrototypeMethod": true, + "jsFunctionName": "entrycount", + "cppFunctionName": "Entrycount", + "return": { + "cType": "size_t", + "cppClassName": "Uint32", + "comment": "the number of log entries", + "jsClassName": "Number" + }, + "description": "

Get the number of log entries in a reflog

\n" + }, + { + "cFunctionName": "git_reflog_entry_byindex", + "args": [ + { + "name": "reflog", + "cType": "git_reflog *", + "cppClassName": "Reflog", + "jsClassName": "Reflog", + "isSelf": true, + "comment": "a previously loaded reflog" + }, + { + "name": "idx", + "cType": "size_t", + "cppClassName": "Uint32", + "jsClassName": "Number", + "comment": "the position of the entry to lookup. Should be greater than or equal to 0 (zero) and less than `git_reflog_entrycount()`." + } + ], + "ignore": true, + "isAsync": false, + "isConstructorMethod": false, + "isPrototypeMethod": true, + "jsFunctionName": "entryByindex", + "cppFunctionName": "EntryByindex", + "return": { + "cType": "const git_reflog_entry *", + "cppClassName": "ReflogEntry", + "copy": "fixme", + "comment": "the entry; NULL if not found", + "jsClassName": "ReflogEntry" + }, + "description": "

Lookup an entry by its index

\n" + }, + { + "cFunctionName": "git_reflog_drop", + "args": [ + { + "name": "reflog", + "cType": "git_reflog *", + "cppClassName": "Reflog", + "jsClassName": "Reflog", + "isSelf": true, + "comment": "a previously loaded reflog." + }, + { + "name": "idx", + "cType": "size_t", + "cppClassName": "Uint32", + "jsClassName": "Number", + "comment": "the position of the entry to remove. Should be greater than or equal to 0 (zero) and less than `git_reflog_entrycount()`." + }, + { + "name": "rewrite_previous_entry", + "cType": "int", + "cppClassName": "Int32", + "jsClassName": "Number", + "comment": "1 to rewrite the history; 0 otherwise." + } + ], + "isAsync": false, + "isConstructorMethod": false, + "isPrototypeMethod": true, + "jsFunctionName": "drop", + "cppFunctionName": "Drop", + "return": { + "cType": "int", + "cppClassName": "Int32", + "isErrorCode": true, + "comment": "0 on success, GIT_ENOTFOUND if the entry doesn't exist or an error code.", + "jsClassName": "Number" + }, + "description": "

Remove an entry from the reflog by its index

\n" + }, + { + "cFunctionName": "git_reflog_entry_id_old", + "args": [ + { + "name": "entry", + "cType": "const git_reflog_entry *", + "cppClassName": "ReflogEntry", + "jsClassName": "ReflogEntry", + "comment": "a reflog entry" + } + ], + "isAsync": false, + "isConstructorMethod": false, + "isPrototypeMethod": false, + "jsFunctionName": "entryIdOld", + "cppFunctionName": "EntryIdOld", + "return": { + "cType": "const git_oid *", + "cppClassName": "GitOid", + "copy": "git_oid_dup", + "comment": "the old oid", + "jsClassName": "Oid" + }, + "description": "

Get the old oid

\n" + }, + { + "cFunctionName": "git_reflog_entry_id_new", + "args": [ + { + "name": "entry", + "cType": "const git_reflog_entry *", + "cppClassName": "ReflogEntry", + "jsClassName": "ReflogEntry", + "comment": "a reflog entry" + } + ], + "isAsync": false, + "isConstructorMethod": false, + "isPrototypeMethod": false, + "jsFunctionName": "entryIdNew", + "cppFunctionName": "EntryIdNew", + "return": { + "cType": "const git_oid *", + "cppClassName": "GitOid", + "copy": "git_oid_dup", + "comment": "the new oid at this time", + "jsClassName": "Oid" + }, + "description": "

Get the new oid

\n" + }, + { + "cFunctionName": "git_reflog_entry_committer", + "args": [ + { + "name": "entry", + "cType": "const git_reflog_entry *", + "cppClassName": "ReflogEntry", + "jsClassName": "ReflogEntry", + "comment": "a reflog entry" + } + ], + "isAsync": false, + "isConstructorMethod": false, + "isPrototypeMethod": false, + "jsFunctionName": "entryCommitter", + "cppFunctionName": "EntryCommitter", + "return": { + "cType": "const git_signature *", + "cppClassName": "GitSignature", + "copy": "git_signature_dup", + "comment": "the committer", + "jsClassName": "Signature" + }, + "description": "

Get the committer of this entry

\n" + }, + { + "cFunctionName": "git_reflog_entry_message", + "args": [ + { + "name": "entry", + "cType": "const git_reflog_entry *", + "cppClassName": "ReflogEntry", + "jsClassName": "ReflogEntry", + "comment": "a reflog entry" + } + ], + "isAsync": false, + "isConstructorMethod": false, + "isPrototypeMethod": false, + "jsFunctionName": "entryMessage", + "cppFunctionName": "EntryMessage", + "return": { + "cType": "const char *", + "cppClassName": "String", + "comment": "the log msg", + "jsClassName": "String" + }, + "description": "

Get the log message

\n" + }, + { + "cFunctionName": "git_reflog_free", + "args": [ + { + "name": "reflog", + "cType": "git_reflog *", + "cppClassName": "Reflog", + "jsClassName": "Reflog", + "comment": "reflog to free" + } + ], + "isAsync": false, + "isConstructorMethod": false, + "isPrototypeMethod": false, + "isFree": true, + "jsFunctionName": "free", + "cppFunctionName": "Free", + "return": { + "cType": "void", + "cppClassName": "void", + "jsClassName": "void" + }, + "description": "

Free the reflog

\n" + } + ] + }, + { + "filename": "reference.h", + "dependencies": [ + "../include/repo.h", + "../include/oid.h", + "../include/object.h" + ], + "jsClassName": "Reference", + "cppClassName": "GitReference", + "cType": "git_reference", + "freeFunctionName": "git_reference_free", + "functions": [ + { + "cFunctionName": "git_reference_name_to_id", + "args": [ + { + "name": "out", + "isReturn": true, + "cType": "git_oid *", + "cppClassName": "GitOid", + "jsClassName": "Oid", + "shouldAlloc": true, + "comment": "Pointer to oid to be filled in" + }, + { + "name": "repo", + "cType": "git_repository *", + "cppClassName": "GitRepo", + "jsClassName": "Repository", + "comment": "The repository in which to look up the reference" + }, + { + "name": "name", + "cType": "const char *", + "cppClassName": "String", + "jsClassName": "String", + "comment": "The long name for the reference (e.g. HEAD, refs/heads/master, refs/tags/v0.1.0, ...)" + } + ], + "isAsync": true, + "isConstructorMethod": false, + "isPrototypeMethod": false, + "jsFunctionName": "oidForName", + "cppFunctionName": "OidForName", + "return": { + "cType": "int", + "cppClassName": "Int32", + "isErrorCode": true, + "comment": "0 on success, ENOTFOUND, EINVALIDSPEC or an error code.", + "jsClassName": "Number" + }, + "description": "

Lookup a reference by name and resolve immediately to OID.

\n" + }, + { + "cFunctionName": "git_reference_target", + "args": [ + { + "name": "ref", + "cType": "const git_reference *", + "cppClassName": "GitReference", + "jsClassName": "Reference", + "isSelf": true, + "comment": "The reference" + } + ], + "isAsync": false, + "isConstructorMethod": false, + "isPrototypeMethod": true, + "jsFunctionName": "target", + "cppFunctionName": "Target", + "return": { + "cType": "const git_oid *", + "cppClassName": "GitOid", + "copy": "git_oid_dup", + "comment": "a pointer to the oid if available, NULL otherwise", + "jsClassName": "Oid" + }, + "description": "

Get the OID pointed to by a direct reference.

\n" + }, + { + "cFunctionName": "git_reference_symbolic_target", + "args": [ + { + "name": "ref", + "cType": "const git_reference *", + "cppClassName": "GitReference", + "jsClassName": "Reference", + "isSelf": true, + "comment": "The reference" + } + ], + "isAsync": false, + "isConstructorMethod": false, + "isPrototypeMethod": true, + "jsFunctionName": "symbolicTarget", + "cppFunctionName": "SymbolicTarget", + "return": { + "cType": "const char *", + "cppClassName": "String", + "comment": "a pointer to the name if available, NULL otherwise", + "jsClassName": "String" + }, + "description": "

Get full name to the reference pointed to by a symbolic reference.

\n" + }, + { + "cFunctionName": "git_reference_type", + "args": [ + { + "name": "ref", + "cType": "const git_reference *", + "cppClassName": "GitReference", + "jsClassName": "Reference", + "isSelf": true, + "comment": "The reference" + } + ], + "isAsync": false, + "isConstructorMethod": false, + "isPrototypeMethod": true, + "jsFunctionName": "type", + "cppFunctionName": "Type", + "return": { + "cType": "git_ref_t", + "cppClassName": "Number", + "comment": "the type", + "jsClassName": "Number" + }, + "description": "

Get the type of a reference.

\n" + }, + { + "cFunctionName": "git_reference_name", + "args": [ + { + "name": "ref", + "cType": "const git_reference *", + "cppClassName": "GitReference", + "jsClassName": "Reference", + "isSelf": true, + "comment": "The reference" + } + ], + "isAsync": false, + "isConstructorMethod": false, + "isPrototypeMethod": true, + "jsFunctionName": "name", + "cppFunctionName": "Name", + "return": { + "cType": "const char *", + "cppClassName": "String", + "comment": "the full name for the ref", + "jsClassName": "String" + }, + "description": "

Get the full name of a reference.

\n" + }, + { + "cFunctionName": "git_reference_resolve", + "args": [ + { + "name": "out", + "isReturn": true, + "cType": "git_reference **", + "cppClassName": "GitReference", + "jsClassName": "Reference", + "comment": "Pointer to the peeled reference" + }, + { + "name": "ref", + "cType": "const git_reference *", + "cppClassName": "GitReference", + "jsClassName": "Reference", + "isSelf": true, + "comment": "The reference" + } + ], + "isAsync": true, + "isConstructorMethod": false, + "isPrototypeMethod": true, + "jsFunctionName": "resolve", + "cppFunctionName": "Resolve", + "return": { + "cType": "int", + "cppClassName": "Int32", + "isErrorCode": true, + "comment": "0 or an error code", + "jsClassName": "Number" + }, + "description": "

Resolve a symbolic reference to a direct reference.

\n" + }, + { + "cFunctionName": "git_reference_owner", + "args": [ + { + "name": "ref", + "cType": "const git_reference *", + "cppClassName": "GitReference", + "jsClassName": "Reference", + "isSelf": true, + "comment": "The reference" + } + ], + "ignore": "Never make public for memory allocation reasons", + "isAsync": false, + "isConstructorMethod": false, + "isPrototypeMethod": true, + "jsFunctionName": "owner", + "cppFunctionName": "owner", + "return": { + "cType": "git_repository *", + "cppClassName": "GitRepo", + "comment": "a pointer to the repo", + "jsClassName": "Repository" + }, + "description": "

Get the repository where a reference resides.

\n" + }, + { + "cFunctionName": "git_reference_symbolic_set_target", + "args": [ + { + "name": "out", + "isReturn": true, + "cType": "git_reference **", + "cppClassName": "GitReference", + "jsClassName": "Reference", + "comment": "Pointer to the newly created reference" + }, + { + "name": "ref", + "cType": "git_reference *", + "cppClassName": "GitReference", + "jsClassName": "Reference", + "isSelf": true, + "comment": "The reference" + }, + { + "name": "target", + "cType": "const char *", + "cppClassName": "String", + "jsClassName": "String", + "comment": "The new target for the reference" + } + ], + "isAsync": false, + "isConstructorMethod": false, + "isPrototypeMethod": true, + "jsFunctionName": "setSymbolicTarget", + "cppFunctionName": "SetSymbolicTarget", + "return": { + "cType": "int", + "cppClassName": "Int32", + "isErrorCode": true, + "comment": "0 on success, EINVALIDSPEC or an error code", + "jsClassName": "Number" + }, + "description": "

Create a new reference with the same name as the given reference but a\ndifferent symbolic target. The reference must be a symbolic reference,\notherwise this will fail.

\n" + }, + { + "cFunctionName": "git_reference_set_target", + "args": [ + { + "name": "out", + "isReturn": true, + "cType": "git_reference **", + "cppClassName": "GitReference", + "jsClassName": "Reference", + "comment": "Pointer to the newly created reference" + }, + { + "name": "ref", + "cType": "git_reference *", + "cppClassName": "GitReference", + "jsClassName": "Reference", + "isSelf": true, + "comment": "The reference" + }, + { + "name": "id", + "cType": "const git_oid *", + "cppClassName": "GitOid", + "jsClassName": "Oid", + "comment": "The new target OID for the reference" + } + ], + "isAsync": false, + "isConstructorMethod": false, + "isPrototypeMethod": true, + "jsFunctionName": "setTarget", + "cppFunctionName": "setTarget", + "return": { + "cType": "int", + "cppClassName": "Int32", + "isErrorCode": true, + "comment": "0 or an error code", + "jsClassName": "Number" + }, + "description": "

Create a new reference with the same name as the given reference but a\ndifferent OID target. The reference must be a direct reference, otherwise\nthis will fail.

\n" + }, + { + "cFunctionName": "git_reference_rename", + "args": [ + { + "name": "out", + "isReturn": true, + "cType": "git_reference **", + "cppClassName": "GitReference", + "jsClassName": "Reference" + }, + { + "name": "ref", + "cType": "git_reference *", + "cppClassName": "GitReference", + "jsClassName": "Reference", + "isSelf": true, + "comment": "The reference to rename" + }, + { + "name": "new_name", + "cType": "const char *", + "cppClassName": "String", + "jsClassName": "String", + "comment": "The new name for the reference" + }, + { + "name": "force", + "cType": "int", + "cppClassName": "Int32", + "jsClassName": "Number", + "comment": "Overwrite an existing reference" + } + ], + "isAsync": true, + "isConstructorMethod": false, + "isPrototypeMethod": true, + "jsFunctionName": "rename", + "cppFunctionName": "Rename", + "return": { + "cType": "int", + "cppClassName": "Int32", + "isErrorCode": true, + "comment": "0 on success, EINVALIDSPEC, EEXISTS or an error code", + "jsClassName": "Number" + }, + "description": "

Rename an existing reference.

\n" + }, + { + "cFunctionName": "git_reference_delete", + "args": [ + { + "name": "ref", + "cType": "git_reference *", + "cppClassName": "GitReference", + "jsClassName": "Reference", + "isSelf": true, + "comment": "The reference to remove" + } + ], + "isAsync": true, + "isConstructorMethod": false, + "isPrototypeMethod": true, + "jsFunctionName": "delete", + "cppFunctionName": "Delete", + "return": { + "cType": "int", + "cppClassName": "Int32", + "isErrorCode": true, + "comment": "0 or an error code", + "jsClassName": "Number" + }, + "description": "

Delete an existing reference.

\n" + }, + { + "cFunctionName": "git_reference_foreach", + "args": [ + { + "name": "repo", + "cType": "git_repository *", + "cppClassName": "GitRepo", + "jsClassName": "Repository", + "comment": "Repository where to find the refs" + }, + { + "name": "list_flags", + "cType": "unsigned int", + "cppClassName": "Uint32", + "jsClassName": "Number" + }, + { + "name": "callback", + "cType": "git_reference_foreach_cb", + "cppClassName": "ReferenceForeachCb", + "jsClassName": "ReferenceForeachCb" + }, + { + "name": "payload", + "cType": "void *", + "cppClassName": "void", + "jsClassName": "void" + } + ], + "ignore": true, + "isAsync": false, + "isConstructorMethod": false, + "isPrototypeMethod": false, + "jsFunctionName": "foreach", + "cppFunctionName": "Foreach", + "return": { + "cType": "int", + "cppClassName": "Int32", + "isErrorCode": true, + "comment": "0 on success, GIT_EUSER on non-zero callback, or error code", + "jsClassName": "Number" + }, + "description": "

Perform a callback on each reference in the repository.

\n" + }, + { + "cFunctionName": "git_reference_free", + "args": [ + { + "name": "ref", + "cType": "git_reference *", + "cppClassName": "GitReference", + "jsClassName": "Reference", + "comment": "git_reference" + } + ], + "ignore": true, + "isAsync": false, + "isConstructorMethod": false, + "isPrototypeMethod": false, + "isFree": true, + "jsFunctionName": "gitReferenceFree", + "cppFunctionName": "GitReferenceFree", + "return": { + "cType": "void", + "cppClassName": "void", + "jsClassName": "void" + }, + "description": "

Free the given reference.

\n" + }, + { + "cFunctionName": "git_reference_cmp", + "args": [ + { + "name": "ref1", + "cType": "git_reference *", + "cppClassName": "GitReference", + "jsClassName": "Reference", + "isSelf": true, + "comment": "The first git_reference" + }, + { + "name": "ref2", + "cType": "git_reference *", + "cppClassName": "GitReference", + "jsClassName": "Reference", + "comment": "The second git_reference" + } + ], + "ignore": true, + "isAsync": false, + "isConstructorMethod": false, + "isPrototypeMethod": true, + "jsFunctionName": "compare", + "cppFunctionName": "Compare", + "return": { + "cType": "int", + "cppClassName": "Int32", + "isErrorCode": true, + "comment": "0 if the same, else a stable but meaningless ordering.", + "jsClassName": "Number" + }, + "description": "

Compare two references.

\n" + }, + { + "cFunctionName": "git_reference_foreach_glob", + "args": [ + { + "name": "repo", + "cType": "git_repository *", + "cppClassName": "GitRepo", + "jsClassName": "Repository", + "comment": "Repository where to find the refs" + }, + { + "name": "glob", + "cType": "const char *", + "cppClassName": "String", + "jsClassName": "String", + "comment": "Pattern to match (fnmatch-style) against reference name." + }, + { + "name": "list_flags", + "cType": "unsigned int", + "cppClassName": "Uint32", + "jsClassName": "Number" + }, + { + "name": "callback", + "cType": "git_reference_foreach_cb", + "cppClassName": "ReferenceForeachCb", + "jsClassName": "ReferenceForeachCb" + }, + { + "name": "payload", + "cType": "void *", + "cppClassName": "void", + "jsClassName": "void" + } + ], + "ignore": true, + "isAsync": true, + "isConstructorMethod": false, + "isPrototypeMethod": false, + "jsFunctionName": "foreachGlob", + "cppFunctionName": "ForeachGlob", + "return": { + "cType": "int", + "cppClassName": "Int32", + "isErrorCode": true, + "comment": "0 on success, GIT_EUSER on non-zero callback, or error code", + "jsClassName": "Number" + }, + "description": "

Perform a callback on each reference in the repository whose name\nmatches the given pattern.

\n" + }, + { + "cFunctionName": "git_reference_has_log", + "args": [ + { + "name": "ref", + "cType": "git_reference *", + "cppClassName": "GitReference", + "jsClassName": "Reference", + "isSelf": true, + "comment": "A git reference" + } + ], + "ignore": true, + "isAsync": false, + "isConstructorMethod": false, + "isPrototypeMethod": true, + "jsFunctionName": "hasLog", + "cppFunctionName": "HasLog", + "return": { + "cType": "int", + "cppClassName": "Int32", + "isErrorCode": true, + "comment": "0 when no reflog can be found, 1 when it exists; otherwise an error code.", + "jsClassName": "Number" + }, + "description": "

Check if a reflog exists for the specified reference.

\n" + }, + { + "cFunctionName": "git_reference_is_branch", + "args": [ + { + "name": "ref", + "cType": "git_reference *", + "cppClassName": "GitReference", + "jsClassName": "Reference", + "isSelf": true, + "comment": "A git reference" + } + ], + "isAsync": false, + "isConstructorMethod": false, + "isPrototypeMethod": true, + "jsFunctionName": "isBranch", + "cppFunctionName": "IsBranch", + "return": { + "cType": "int", + "cppClassName": "Int32", + "isErrorCode": true, + "comment": "1 when the reference lives in the refs/heads namespace; 0 otherwise.", + "jsClassName": "Number" + }, + "description": "

Check if a reference is a local branch.

\n" + }, + { + "cFunctionName": "git_reference_is_remote", + "args": [ + { + "name": "ref", + "cType": "git_reference *", + "cppClassName": "GitReference", + "jsClassName": "Reference", + "isSelf": true, + "comment": "A git reference" + } + ], + "isAsync": false, + "isConstructorMethod": false, + "isPrototypeMethod": true, + "jsFunctionName": "isRemote", + "cppFunctionName": "IsRemote", + "return": { + "cType": "int", + "cppClassName": "Int32", + "isErrorCode": true, + "comment": "1 when the reference lives in the refs/remotes namespace; 0 otherwise.", + "jsClassName": "Number" + }, + "description": "

Check if a reference is a remote tracking branch

\n" + }, + { + "cFunctionName": "git_reference_normalize_name", + "args": [ + { + "name": "buffer_out", + "cType": "char *", + "cppClassName": "String", + "jsClassName": "String", + "isSelf": true, + "comment": "User allocated buffer to store normalized name" + }, + { + "name": "buffer_size", + "cType": "size_t", + "cppClassName": "Integer", + "jsClassName": "Number", + "comment": "Size of buffer_out" + }, + { + "name": "name", + "cType": "const char *", + "cppClassName": "String", + "jsClassName": "String", + "comment": "Reference name to be checked." + }, + { + "name": "flags", + "cType": "unsigned int", + "cppClassName": "Uint32", + "jsClassName": "Number", + "comment": "Flags to constrain name validation rules - see the GIT_REF_FORMAT constants above." + } + ], + "ignore": true, + "isAsync": false, + "isConstructorMethod": false, + "isPrototypeMethod": true, + "jsFunctionName": "normalizeName", + "cppFunctionName": "NormalizeName", + "return": { + "cType": "int", + "cppClassName": "Int32", + "isErrorCode": true, + "comment": "0 on success, GIT_EBUFS if buffer is too small, EINVALIDSPEC or an error code.", + "jsClassName": "Number" + }, + "description": "

Normalize reference name and check validity.

\n" + }, + { + "cFunctionName": "git_reference_peel", + "args": [ + { + "name": "out", + "isReturn": true, + "cType": "git_object **", + "cppClassName": "GitObject", + "jsClassName": "Object", + "comment": "Pointer to the peeled git_object" + }, + { + "name": "ref", + "cType": "git_reference *", + "cppClassName": "GitReference", + "jsClassName": "Reference", + "isSelf": true, + "comment": "The reference to be processed" + }, + { + "name": "type", + "cType": "git_otype", + "cppClassName": "Int32", + "jsClassName": "Number", + "comment": "The type of the requested object (GIT_OBJ_COMMIT, GIT_OBJ_TAG, GIT_OBJ_TREE, GIT_OBJ_BLOB or GIT_OBJ_ANY)." + } + ], + "isAsync": false, + "isConstructorMethod": false, + "isPrototypeMethod": true, + "jsFunctionName": "peel", + "cppFunctionName": "Peel", + "return": { + "cType": "int", + "cppClassName": "Int32", + "isErrorCode": true, + "comment": "0 on success, GIT_EAMBIGUOUS, GIT_ENOTFOUND or an error code", + "jsClassName": "Number" + }, + "description": "

Recursively peel reference until object of the specified type is found.

\n" + }, + { + "cFunctionName": "git_reference_is_valid_name", + "args": [ + { + "name": "refname", + "cType": "const char *", + "cppClassName": "String", + "jsClassName": "String", + "comment": "name to be checked." + } + ], + "isAsync": false, + "isConstructorMethod": false, + "isPrototypeMethod": false, + "jsFunctionName": "isValidName", + "cppFunctionName": "IsValidName", + "return": { + "cType": "int", + "cppClassName": "Int32", + "isErrorCode": true, + "comment": "1 if the reference name is acceptable; 0 if it isn't", + "jsClassName": "Number" + }, + "description": "

Ensure the reference name is well-formed.

\n" + } + ] + }, + { + "filename": "refspec.h", + "ignore": true, + "jsClassName": "Refspec", + "cppClassName": "Refspec", + "cType": "git_refspec", + "freeFunctionName": "git_refspec_free", + "functions": [ + { + "cFunctionName": "git_refspec_src", + "args": [ + { + "name": "refspec", + "cType": "const git_refspec *", + "cppClassName": "Refspec", + "jsClassName": "Refspec", + "isSelf": true, + "comment": "the refspec" + } + ], + "isAsync": false, + "isConstructorMethod": false, + "isPrototypeMethod": true, + "jsFunctionName": "src", + "cppFunctionName": "Src", + "return": { + "cType": "const char *", + "cppClassName": "String", + "comment": "the refspec's source specifier", + "jsClassName": "String" + }, + "description": "

Get the source specifier

\n" + }, + { + "cFunctionName": "git_refspec_dst", + "args": [ + { + "name": "refspec", + "cType": "const git_refspec *", + "cppClassName": "Refspec", + "jsClassName": "Refspec", + "isSelf": true, + "comment": "the refspec" + } + ], + "isAsync": false, + "isConstructorMethod": false, + "isPrototypeMethod": true, + "jsFunctionName": "dst", + "cppFunctionName": "Dst", + "return": { + "cType": "const char *", + "cppClassName": "String", + "comment": "the refspec's destination specifier", + "jsClassName": "String" + }, + "description": "

Get the destination specifier

\n" + }, + { + "cFunctionName": "git_refspec_force", + "args": [ + { + "name": "refspec", + "cType": "const git_refspec *", + "cppClassName": "Refspec", + "jsClassName": "Refspec", + "isSelf": true, + "comment": "the refspec" + } + ], + "isAsync": false, + "isConstructorMethod": false, + "isPrototypeMethod": true, + "jsFunctionName": "force", + "cppFunctionName": "Force", + "return": { + "cType": "int", + "cppClassName": "Int32", + "isErrorCode": true, + "comment": "1 if force update has been set, 0 otherwise", + "jsClassName": "Number" + }, + "description": "

Get the force update setting

\n" + }, + { + "cFunctionName": "git_refspec_src_matches", + "args": [ + { + "name": "refspec", + "cType": "const git_refspec *", + "cppClassName": "Refspec", + "jsClassName": "Refspec", + "isSelf": true, + "comment": "the refspec" + }, + { + "name": "refname", + "cType": "const char *", + "cppClassName": "String", + "jsClassName": "String", + "comment": "the name of the reference to check" + } + ], + "isAsync": false, + "isConstructorMethod": false, + "isPrototypeMethod": true, + "jsFunctionName": "srcMatches", + "cppFunctionName": "SrcMatches", + "return": { + "cType": "int", + "cppClassName": "Int32", + "isErrorCode": true, + "comment": "1 if the refspec matches, 0 otherwise", + "jsClassName": "Number" + }, + "description": "

Check if a refspec's source descriptor matches a reference

\n" + }, + { + "cFunctionName": "git_refspec_dst_matches", + "args": [ + { + "name": "refspec", + "cType": "const git_refspec *", + "cppClassName": "Refspec", + "jsClassName": "Refspec", + "isSelf": true, + "comment": "the refspec" + }, + { + "name": "refname", + "cType": "const char *", + "cppClassName": "String", + "jsClassName": "String", + "comment": "the name of the reference to check" + } + ], + "isAsync": false, + "isConstructorMethod": false, + "isPrototypeMethod": true, + "jsFunctionName": "dstMatches", + "cppFunctionName": "DstMatches", + "return": { + "cType": "int", + "cppClassName": "Int32", + "isErrorCode": true, + "comment": "1 if the refspec matches, 0 otherwise", + "jsClassName": "Number" + }, + "description": "

Check if a refspec's destination descriptor matches a reference

\n" + }, + { + "cFunctionName": "git_refspec_transform", + "args": [ + { + "name": "out", + "isReturn": true, + "cType": "char *", + "cppClassName": "String", + "jsClassName": "String", + "comment": "where to store the target name" + }, + { + "name": "outlen", + "cType": "size_t", + "cppClassName": "Uint32", + "jsClassName": "Number", + "comment": "the size of the `out` buffer" + }, + { + "name": "spec", + "cType": "const git_refspec *", + "cppClassName": "Refspec", + "jsClassName": "Refspec", + "comment": "the refspec" + }, + { + "name": "name", + "cType": "const char *", + "cppClassName": "String", + "jsClassName": "String", + "comment": "the name of the reference to transform" + } + ], + "isAsync": false, + "isConstructorMethod": false, + "isPrototypeMethod": false, + "jsFunctionName": "transform", + "cppFunctionName": "Transform", + "return": { + "cType": "int", + "cppClassName": "Int32", + "isErrorCode": true, + "comment": "0, GIT_EBUFS or another error", + "jsClassName": "Number" + }, + "description": "

Transform a reference to its target following the refspec's rules

\n" + }, + { + "cFunctionName": "git_refspec_rtransform", + "args": [ + { + "name": "out", + "isReturn": true, + "cType": "char *", + "cppClassName": "String", + "jsClassName": "String", + "comment": "where to store the source reference name" + }, + { + "name": "outlen", + "cType": "size_t", + "cppClassName": "Uint32", + "jsClassName": "Number", + "comment": "the size of the `out` buffer" + }, + { + "name": "spec", + "cType": "const git_refspec *", + "cppClassName": "Refspec", + "jsClassName": "Refspec", + "comment": "the refspec" + }, + { + "name": "name", + "cType": "const char *", + "cppClassName": "String", + "jsClassName": "String", + "comment": "the name of the reference to transform" + } + ], + "isAsync": false, + "isConstructorMethod": false, + "isPrototypeMethod": false, + "jsFunctionName": "rtransform", + "cppFunctionName": "Rtransform", + "return": { + "cType": "int", + "cppClassName": "Int32", + "isErrorCode": true, + "comment": "0, GIT_EBUFS or another error", + "jsClassName": "Number" + }, + "description": "

Transform a target reference to its source reference following the refspec's rules

\n" + } + ] + }, + { + "filename": "remote.h", + "dependencies": [ + "git2/net.h" + ], + "jsClassName": "Remote", + "cppClassName": "GitRemote", + "cType": "git_remote", + "freeFunctionName": "git_remote_free", + "functions": [ + { + "cFunctionName": "git_remote_save", + "args": [ + { + "name": "remote", + "cType": "const git_remote *", + "cppClassName": "GitRemote", + "jsClassName": "Remote", + "isSelf": true, + "comment": "the remote to save to config" + } + ], + "ignore": "called automatically by git_remote_create", + "isAsync": false, + "isConstructorMethod": false, + "isPrototypeMethod": true, + "jsFunctionName": "save", + "cppFunctionName": "Save", + "return": { + "cType": "int", + "cppClassName": "Int32", + "isErrorCode": true, + "comment": "0, GIT_EINVALIDSPEC or an error code", + "jsClassName": "Number" + }, + "description": "

Save a remote to its repository's configuration

\n" + }, + { + "cFunctionName": "git_remote_name", + "args": [ + { + "name": "remote", + "cType": "const git_remote *", + "cppClassName": "GitRemote", + "jsClassName": "Remote", + "isSelf": true, + "comment": "the remote" + } + ], + "isAsync": false, + "isConstructorMethod": false, + "isPrototypeMethod": true, + "jsFunctionName": "name", + "cppFunctionName": "Name", + "return": { + "cType": "const char *", + "cppClassName": "String", + "comment": "a pointer to the name or NULL for in-memory remotes", + "jsClassName": "String" + }, + "description": "

Get the remote's name

\n" + }, + { + "cFunctionName": "git_remote_url", + "args": [ + { + "name": "remote", + "cType": "const git_remote *", + "cppClassName": "GitRemote", + "jsClassName": "Remote", + "isSelf": true, + "comment": "the remote" + } + ], + "isAsync": false, + "isConstructorMethod": false, + "isPrototypeMethod": true, + "jsFunctionName": "url", + "cppFunctionName": "Url", + "return": { + "cType": "const char *", + "cppClassName": "String", + "comment": "a pointer to the url", + "jsClassName": "String" + }, + "description": "

Get the remote's url

\n" + }, + { + "cFunctionName": "git_remote_pushurl", + "args": [ + { + "name": "remote", + "cType": "const git_remote *", + "cppClassName": "GitRemote", + "jsClassName": "Remote", + "isSelf": true, + "comment": "the remote" + } + ], + "isAsync": false, + "isConstructorMethod": false, + "isPrototypeMethod": true, + "jsFunctionName": "pushUrl", + "cppFunctionName": "PushUrl", + "return": { + "cType": "const char *", + "cppClassName": "String", + "comment": "a pointer to the url or NULL if no special url for pushing is set", + "jsClassName": "String" + }, + "description": "

Get the remote's url for pushing

\n" + }, + { + "cFunctionName": "git_remote_set_url", + "args": [ + { + "name": "remote", + "cType": "git_remote *", + "cppClassName": "GitRemote", + "jsClassName": "Remote", + "isSelf": true, + "comment": "the remote" + }, + { + "name": "url", + "cType": "const char*", + "cppClassName": "String", + "jsClassName": "String", + "comment": "the url to set" + } + ], + "isAsync": false, + "isConstructorMethod": false, + "isPrototypeMethod": true, + "jsFunctionName": "setUrl", + "cppFunctionName": "SetUrl", + "return": { + "cType": "int", + "cppClassName": "Int32", + "isErrorCode": true, + "comment": "0 or an error value", + "jsClassName": "Number" + }, + "description": "

Set the remote's url

\n" + }, + { + "cFunctionName": "git_remote_set_pushurl", + "args": [ + { + "name": "remote", + "cType": "git_remote *", + "cppClassName": "GitRemote", + "jsClassName": "Remote", + "isSelf": true, + "comment": "the remote" + }, + { + "name": "url", + "cType": "const char*", + "cppClassName": "String", + "jsClassName": "String", + "comment": "the url to set or NULL to clear the pushurl" + } + ], + "isAsync": false, + "isConstructorMethod": false, + "isPrototypeMethod": true, + "jsFunctionName": "setPushUrl", + "cppFunctionName": "SetPushUrl", + "return": { + "cType": "int", + "cppClassName": "Int32", + "isErrorCode": true, + "comment": "0 or an error value", + "jsClassName": "Number" + }, + "description": "

Set the remote's url for pushing

\n" + }, + { + "cFunctionName": "git_remote_set_fetchspec", + "args": [ + { + "name": "remote", + "cType": "git_remote *", + "cppClassName": "GitRemote", + "jsClassName": "Remote", + "isSelf": true + }, + { + "name": "spec", + "cType": "const char *", + "cppClassName": "String", + "jsClassName": "String" + } + ], + "ignore": true, + "isAsync": false, + "isConstructorMethod": false, + "isPrototypeMethod": true, + "jsFunctionName": "setFetchspec", + "cppFunctionName": "SetFetchspec", + "return": { + "cType": "int", + "cppClassName": "Int32", + "isErrorCode": true, + "jsClassName": "Number" + } + }, + { + "cFunctionName": "git_remote_fetchspec", + "args": [ + { + "name": "remote", + "cType": "const git_remote *", + "cppClassName": "GitRemote", + "jsClassName": "Remote", + "isSelf": true + } + ], + "ignore": true, + "isAsync": false, + "isConstructorMethod": false, + "isPrototypeMethod": true, + "jsFunctionName": "fetchspec", + "cppFunctionName": "Fetchspec", + "return": { + "cType": "const git_refspec *", + "cppClassName": "Refspec", + "copy": "fixme", + "jsClassName": "Refspec" + } + }, + { + "cFunctionName": "git_remote_set_pushspec", + "args": [ + { + "name": "remote", + "cType": "git_remote *", + "cppClassName": "GitRemote", + "jsClassName": "Remote", + "isSelf": true + }, + { + "name": "spec", + "cType": "const char *", + "cppClassName": "String", + "jsClassName": "String" + } + ], + "ignore": true, + "isAsync": false, + "isConstructorMethod": false, + "isPrototypeMethod": true, + "jsFunctionName": "setPushspec", + "cppFunctionName": "SetPushspec", + "return": { + "cType": "int", + "cppClassName": "Int32", + "isErrorCode": true, + "jsClassName": "Number" + } + }, + { + "cFunctionName": "git_remote_pushspec", + "args": [ + { + "name": "remote", + "cType": "const git_remote *", + "cppClassName": "GitRemote", + "jsClassName": "Remote", + "isSelf": true + } + ], + "ignore": true, + "isAsync": false, + "isConstructorMethod": false, + "isPrototypeMethod": true, + "jsFunctionName": "pushspec", + "cppFunctionName": "Pushspec", + "return": { + "cType": "const git_refspec *", + "cppClassName": "Refspec", + "copy": "fixme", + "jsClassName": "Refspec" + } + }, + { + "cFunctionName": "git_remote_connect", + "args": [ + { + "name": "remote", + "cType": "git_remote *", + "cppClassName": "GitRemote", + "jsClassName": "Remote", + "isSelf": true, + "comment": "the remote to connect to" + }, + { + "name": "direction", + "cType": "git_direction", + "cppClassName": "Number", + "jsClassName": "Number", + "comment": "GIT_DIRECTION_FETCH if you want to fetch or GIT_DIRECTION_PUSH if you want to push" + } + ], + "isAsync": true, + "isConstructorMethod": false, + "isPrototypeMethod": true, + "jsFunctionName": "connect", + "cppFunctionName": "Connect", + "return": { + "cType": "int", + "cppClassName": "Int32", + "isErrorCode": true, + "jsClassName": "Number" + }, + "description": "

Open a connection to a remote

\n" + }, + { + "cFunctionName": "git_remote_ls", + "args": [ + { + "name": "remote", + "cType": "git_remote *", + "cppClassName": "GitRemote", + "jsClassName": "Remote", + "isSelf": true, + "comment": "the remote" + }, + { + "name": "list_cb", + "cType": "git_headlist_cb", + "cppClassName": "HeadlistCb", + "jsClassName": "HeadlistCb", + "comment": "function to call with each ref discovered at the remote" + }, + { + "name": "payload", + "cType": "void *", + "cppClassName": "void", + "jsClassName": "void", + "comment": "additional data to pass to the callback" + } + ], + "ignore": true, + "isAsync": false, + "isConstructorMethod": false, + "isPrototypeMethod": true, + "jsFunctionName": "ls", + "cppFunctionName": "Ls", + "return": { + "cType": "int", + "cppClassName": "Int32", + "isErrorCode": true, + "jsClassName": "Number" + }, + "description": "

Get a list of refs at the remote

\n" + }, + { + "cFunctionName": "git_remote_download", + "args": [ + { + "name": "remote", + "cType": "git_remote *", + "cppClassName": "GitRemote", + "jsClassName": "Remote", + "isSelf": true, + "comment": "the remote to download from" + }, + { + "name": "progress_cb", + "cType": "git_transfer_progress_callback", + "cppClassName": "Function", + "jsClassName": "Function", + "isOptional": true, + "comment": "function to call with progress information. Be aware that this is called inline with network and indexing operations, so performance may be affected." + }, + { + "name": "payload", + "cType": "void *", + "cppClassName": "void", + "jsClassName": "void", + "isPayload": true, + "comment": "payload for the progress callback" + } + ], + "isAsync": true, + "isConstructorMethod": false, + "isPrototypeMethod": true, + "jsFunctionName": "download", + "cppFunctionName": "Download", + "return": { + "cType": "int", + "cppClassName": "Int32", + "isErrorCode": true, + "jsClassName": "Number" + }, + "description": "

Download the packfile

\n" + }, + { + "cFunctionName": "git_remote_connected", + "args": [ + { + "name": "remote", + "cType": "git_remote *", + "cppClassName": "GitRemote", + "jsClassName": "Remote", + "isSelf": true, + "comment": "the remote" + } + ], + "isAsync": false, + "isConstructorMethod": false, + "isPrototypeMethod": true, + "jsFunctionName": "connected", + "cppFunctionName": "Connected", + "return": { + "cType": "int", + "cppClassName": "Int32", + "isErrorCode": true, + "jsClassName": "Number" + }, + "description": "

Check whether the remote is connected

\n" + }, + { + "cFunctionName": "git_remote_stop", + "args": [ + { + "name": "remote", + "cType": "git_remote *", + "cppClassName": "GitRemote", + "jsClassName": "Remote", + "isSelf": true, + "comment": "the remote" + } + ], + "isAsync": false, + "isConstructorMethod": false, + "isPrototypeMethod": true, + "jsFunctionName": "stop", + "cppFunctionName": "Stop", + "return": { + "cType": "void", + "cppClassName": "void", + "jsClassName": "void" + }, + "description": "

Cancel the operation

\n" + }, + { + "cFunctionName": "git_remote_disconnect", + "args": [ + { + "name": "remote", + "cType": "git_remote *", + "cppClassName": "GitRemote", + "jsClassName": "Remote", + "isSelf": true, + "comment": "the remote to disconnect from" + } + ], + "isAsync": true, + "isConstructorMethod": false, + "isPrototypeMethod": true, + "jsFunctionName": "disconnect", + "cppFunctionName": "Disconnect", + "return": { + "cType": "void", + "cppClassName": "void", + "jsClassName": "void" + }, + "description": "

Disconnect from the remote

\n" + }, + { + "cFunctionName": "git_remote_free", + "args": [ + { + "name": "remote", + "cType": "git_remote *", + "cppClassName": "GitRemote", + "jsClassName": "Remote", + "comment": "the remote to free" + } + ], + "ignore": true, + "isAsync": false, + "isConstructorMethod": false, + "isPrototypeMethod": false, + "isFree": true, + "jsFunctionName": "free", + "cppFunctionName": "Free", + "return": { + "cType": "void", + "cppClassName": "void", + "jsClassName": "void" + }, + "description": "

Free the memory associated with a remote

\n" + }, + { + "cFunctionName": "git_remote_update_tips", + "args": [ + { + "name": "remote", + "cType": "git_remote *", + "cppClassName": "GitRemote", + "jsClassName": "Remote", + "isSelf": true, + "comment": "the remote to update" + } + ], + "isAsync": false, + "isConstructorMethod": false, + "isPrototypeMethod": true, + "jsFunctionName": "updateTips", + "cppFunctionName": "UpdateTips", + "return": { + "cType": "int", + "cppClassName": "Int32", + "isErrorCode": true, + "jsClassName": "Number" + }, + "description": "

Update the tips to the new state

\n" + }, + { + "cFunctionName": "git_remote_valid_url", + "args": [ + { + "name": "url", + "cType": "const char *", + "cppClassName": "String", + "jsClassName": "String", + "comment": "the url to check" + } + ], + "isAsync": false, + "isConstructorMethod": false, + "isPrototypeMethod": false, + "jsFunctionName": "validUrl", + "cppFunctionName": "ValidUrl", + "return": { + "cType": "int", + "cppClassName": "Int32", + "isErrorCode": true, + "jsClassName": "Number" + }, + "description": "

Return whether a string is a valid remote URL

\n" + }, + { + "cFunctionName": "git_remote_supported_url", + "args": [ + { + "name": "url", + "cType": "const char*", + "cppClassName": "String", + "jsClassName": "String", + "comment": "the url to check" + } + ], + "isAsync": false, + "isConstructorMethod": false, + "isPrototypeMethod": false, + "jsFunctionName": "supportedUrl", + "cppFunctionName": "SupportedUrl", + "return": { + "cType": "int", + "cppClassName": "Int32", + "isErrorCode": true, + "jsClassName": "Number" + }, + "description": "

Return whether the passed URL is supported by this version of the library.

\n" + }, + { + "cFunctionName": "git_remote_check_cert", + "args": [ + { + "name": "remote", + "cType": "git_remote *", + "cppClassName": "GitRemote", + "jsClassName": "Remote", + "isSelf": true, + "comment": "the remote to configure" + }, + { + "name": "check", + "cType": "int", + "cppClassName": "Int32", + "jsClassName": "Number", + "comment": "whether to check the server's certificate (defaults to yes)" + } + ], + "isAsync": false, + "isConstructorMethod": false, + "isPrototypeMethod": true, + "jsFunctionName": "checkCert", + "cppFunctionName": "CheckCert", + "return": { + "cType": "void", + "cppClassName": "void", + "jsClassName": "void" + }, + "description": "

Choose whether to check the server's certificate (applies to HTTPS only)

\n" + }, + { + "cFunctionName": "git_remote_set_cred_acquire_cb", + "args": [ + { + "name": "remote", + "cType": "git_remote *", + "cppClassName": "GitRemote", + "jsClassName": "Remote", + "isSelf": true, + "comment": "the remote to configure" + }, + { + "name": "cred_acquire_cb", + "cType": "git_cred_acquire_cb", + "cppClassName": "CredAcquireCb", + "jsClassName": "CredAcquireCb", + "comment": "The credentials acquisition callback to use (defaults to NULL)" + }, + { + "name": "payload", + "cType": "void *", + "cppClassName": "void", + "jsClassName": "void" + } + ], + "ignore": true, + "isAsync": false, + "isConstructorMethod": false, + "isPrototypeMethod": true, + "jsFunctionName": "setCredAcquireCb", + "cppFunctionName": "SetCredAcquireCb", + "return": { + "cType": "void", + "cppClassName": "void", + "jsClassName": "void" + }, + "description": "

Set a credentials acquisition callback for this remote. If the remote is\nnot available for anonymous access, then you must set this callback in order\nto provide credentials to the transport at the time of authentication\nfailure so that retry can be performed.

\n" + }, + { + "cFunctionName": "git_remote_set_transport", + "args": [ + { + "name": "remote", + "cType": "git_remote *", + "cppClassName": "GitRemote", + "jsClassName": "Remote", + "isSelf": true, + "comment": "the remote to configure" + }, + { + "name": "transport", + "cType": "git_transport *", + "cppClassName": "Transport", + "jsClassName": "Transport", + "comment": "the transport object for the remote to use" + } + ], + "ignore": true, + "isAsync": false, + "isConstructorMethod": false, + "isPrototypeMethod": true, + "jsFunctionName": "setTransport", + "cppFunctionName": "SetTransport", + "return": { + "cType": "int", + "cppClassName": "Int32", + "isErrorCode": true, + "jsClassName": "Number" + }, + "description": "

Sets a custom transport for the remote. The caller can use this function\nto bypass the automatic discovery of a transport by URL scheme (i.e.\nhttp://, https://, git://) and supply their own transport to be used\ninstead. After providing the transport to a remote using this function,\nthe transport object belongs exclusively to that remote, and the remote will\nfree it when it is freed with git_remote_free.

\n" + }, + { + "cFunctionName": "git_remote_set_callbacks", + "args": [ + { + "name": "remote", + "cType": "git_remote *", + "cppClassName": "GitRemote", + "jsClassName": "Remote", + "isSelf": true, + "comment": "the remote to configure" + }, + { + "name": "callbacks", + "cType": "git_remote_callbacks *", + "cppClassName": "RemoteCallbacks", + "jsClassName": "RemoteCallbacks", + "comment": "a pointer to the user's callback settings" + } + ], + "ignore": true, + "isAsync": false, + "isConstructorMethod": false, + "isPrototypeMethod": true, + "jsFunctionName": "setCallbacks", + "cppFunctionName": "SetCallbacks", + "return": { + "cType": "int", + "cppClassName": "Int32", + "isErrorCode": true, + "jsClassName": "Number" + }, + "description": "

Set the callbacks for a remote

\n" + }, + { + "cFunctionName": "git_remote_stats", + "args": [ + { + "name": "remote", + "cType": "git_remote *", + "cppClassName": "GitRemote", + "jsClassName": "Remote", + "isSelf": true + } + ], + "ignore": true, + "isAsync": false, + "isConstructorMethod": false, + "isPrototypeMethod": true, + "jsFunctionName": "stats", + "cppFunctionName": "Stats", + "return": { + "cType": "const git_transfer_progress *", + "cppClassName": "TransferProgress", + "jsClassName": "TransferProgress" + }, + "description": "

Get the statistics structure that is filled in by the fetch operation.

\n" + }, + { + "cFunctionName": "git_remote_autotag", + "args": [], + "ignore": true, + "isAsync": false, + "isConstructorMethod": false, + "isPrototypeMethod": false, + "jsFunctionName": "autotag", + "cppFunctionName": "Autotag", + "return": { + "cType": "GIT_EXTERN(", + "cppClassName": "GIT_EXTERN(" + }, + "description": "

Retrieve the tag auto-follow setting

\n" + }, + { + "cFunctionName": "git_remote_set_autotag", + "args": [ + { + "name": "remote", + "cType": "git_remote *", + "cppClassName": "GitRemote", + "jsClassName": "Remote", + "isSelf": true, + "comment": "the remote to configure" + }, + { + "name": "value", + "cType": "git_remote_autotag_option_t", + "cppClassName": "RemoteAutotagOptionT", + "jsClassName": "RemoteAutotagOptionT", + "comment": "a GIT_REMOTE_DOWNLOAD_TAGS value" + } + ], + "ignore": true, + "isAsync": false, + "isConstructorMethod": false, + "isPrototypeMethod": true, + "jsFunctionName": "setAutotag", + "cppFunctionName": "SetAutotag", + "return": { + "cType": "void", + "cppClassName": "void", + "jsClassName": "void" + }, + "description": "

Set the tag auto-follow setting

\n" + }, + { + "cFunctionName": "git_remote_rename", + "args": [ + { + "name": "remote", + "cType": "git_remote *", + "cppClassName": "GitRemote", + "jsClassName": "Remote", + "isSelf": true, + "comment": "the remote to rename" + }, + { + "name": "new_name", + "cType": "const char *", + "cppClassName": "String", + "jsClassName": "String", + "comment": "the new name the remote should bear" + }, + { + "name": "callback", + "cType": "git_remote_rename_problem_cb", + "cppClassName": "RemoteRenameProblemCb", + "jsClassName": "RemoteRenameProblemCb", + "comment": "Optional callback to notify the consumer of fetch refspecs that haven't been automatically updated and need potential manual tweaking." + }, + { + "name": "payload", + "cType": "void *", + "cppClassName": "void", + "jsClassName": "void", + "comment": "Additional data to pass to the callback" + } + ], + "ignore": true, + "isAsync": false, + "isConstructorMethod": false, + "isPrototypeMethod": true, + "jsFunctionName": "rename", + "cppFunctionName": "Rename", + "return": { + "cType": "int", + "cppClassName": "Int32", + "isErrorCode": true, + "jsClassName": "Number" + }, + "description": "

Give the remote a new name

\n" + }, + { + "cFunctionName": "git_remote_update_fetchhead", + "args": [ + { + "name": "remote", + "cType": "git_remote *", + "cppClassName": "GitRemote", + "jsClassName": "Remote", + "isSelf": true, + "comment": "the remote to query" + } + ], + "isAsync": false, + "isConstructorMethod": false, + "isPrototypeMethod": true, + "jsFunctionName": "updateFetchhead", + "cppFunctionName": "UpdateFetchhead", + "return": { + "cType": "int", + "cppClassName": "Int32", + "isErrorCode": true, + "jsClassName": "Number" + }, + "description": "

Retrieve the update FETCH_HEAD setting.

\n" + }, + { + "cFunctionName": "git_remote_set_update_fetchhead", + "args": [ + { + "name": "remote", + "cType": "git_remote *", + "cppClassName": "GitRemote", + "jsClassName": "Remote", + "isSelf": true, + "comment": "the remote to configure" + }, + { + "name": "value", + "cType": "int", + "cppClassName": "Int32", + "jsClassName": "Number", + "comment": "0 to disable updating FETCH_HEAD" + } + ], + "isAsync": false, + "isConstructorMethod": false, + "isPrototypeMethod": true, + "jsFunctionName": "setUpdateFetchhead", + "cppFunctionName": "SetUpdateFetchhead", + "return": { + "cType": "void", + "cppClassName": "void", + "jsClassName": "void" + }, + "description": "

Sets the update FETCH_HEAD setting. By default, FETCH_HEAD will be\nupdated on every fetch. Set to 0 to disable.

\n" + }, + { + "cFunctionName": "git_remote_is_valid_name", + "args": [ + { + "name": "remote_name", + "cType": "const char *", + "cppClassName": "String", + "jsClassName": "String", + "comment": "name to be checked." + } + ], + "isAsync": false, + "isConstructorMethod": false, + "isPrototypeMethod": false, + "jsFunctionName": "isValidName", + "cppFunctionName": "IsValidName", + "return": { + "cType": "int", + "cppClassName": "Int32", + "isErrorCode": true, + "jsClassName": "Number" + }, + "description": "

Ensure the remote name is well-formed.

\n" + } + ] + }, + { + "filename": "repo.h", + "dependencies": [ + "../include/oid.h", + "../include/commit.h", + "../include/blob.h", + "../include/object.h", + "../include/reference.h", + "../include/submodule.h", + "../include/refdb.h", + "../include/revwalk.h", + "../include/tag.h", + "../include/signature.h", + "../include/tree.h", + "../include/odb.h", + "../include/index.h", + "../include/remote.h", + "../include/clone_options.h", + "node_buffer.h" + ], + "jsClassName": "Repo", + "cppClassName": "GitRepo", + "cType": "git_repository", + "freeFunctionName": "git_repository_free", + "functions": [ + { + "cFunctionName": "git_repository_open", + "args": [ + { + "name": "out", + "isReturn": true, + "cType": "git_repository **", + "cppClassName": "GitRepo", + "jsClassName": "Repository", + "comment": "pointer to the repo which will be opened" + }, + { + "name": "path", + "cType": "const char *", + "cppClassName": "String", + "jsClassName": "String", + "comment": "the path to the repository" + } + ], + "isAsync": true, + "isConstructorMethod": true, + "isPrototypeMethod": false, + "jsFunctionName": "open", + "cppFunctionName": "Open", + "return": { + "cType": "int", + "cppClassName": "Int32", + "isErrorCode": true, + "comment": "0 or an error code", + "jsClassName": "Number" + }, + "description": "

Open a git repository.

\n" + }, + { + "cFunctionName": "git_repository_wrap_odb", + "args": [ + { + "name": "out", + "isReturn": true, + "cType": "git_repository **", + "cppClassName": "GitRepo", + "jsClassName": "Repository", + "comment": "pointer to the repo" + }, + { + "name": "odb", + "cType": "git_odb *", + "cppClassName": "GitOdb", + "jsClassName": "Odb", + "comment": "the object database to wrap" + } + ], + "ignore": true, + "isAsync": false, + "isConstructorMethod": true, + "isPrototypeMethod": false, + "jsFunctionName": "wrapOdb", + "cppFunctionName": "WrapOdb", + "return": { + "cType": "int", + "cppClassName": "Int32", + "isErrorCode": true, + "comment": "0 or an error code", + "jsClassName": "Number" + }, + "description": "

Create a "fake" repository to wrap an object database

\n" + }, + { + "cFunctionName": "git_repository_discover", + "args": [ + { + "name": "path_out", + "cType": "char *", + "cppClassName": "String", + "jsClassName": "String", + "comment": "The user allocated buffer which will contain the found path." + }, + { + "name": "path_size", + "cType": "size_t", + "cppClassName": "Uint32", + "jsClassName": "Number", + "comment": "repository_path size" + }, + { + "name": "start_path", + "cType": "const char *", + "cppClassName": "String", + "jsClassName": "String", + "comment": "The base path where the lookup starts." + }, + { + "name": "across_fs", + "cType": "int", + "cppClassName": "Int32", + "jsClassName": "Number", + "comment": "If true, then the lookup will not stop when a filesystem device change is detected while exploring parent directories." + }, + { + "name": "ceiling_dirs", + "cType": "const char *", + "cppClassName": "String", + "jsClassName": "String", + "comment": "A GIT_PATH_LIST_SEPARATOR separated list of absolute symbolic link free paths. The lookup will stop when any of this paths is reached. Note that the lookup always performs on start_path no matter start_path appears in ceiling_dirs ceiling_dirs might be NULL (which is equivalent to an empty string)" + } + ], + "ignore": true, + "isAsync": false, + "isConstructorMethod": false, + "isPrototypeMethod": false, + "jsFunctionName": "discover", + "cppFunctionName": "Discover", + "return": { + "cType": "int", + "cppClassName": "Int32", + "isErrorCode": true, + "comment": "0 or an error code", + "jsClassName": "Number" + }, + "description": "

Look for a git repository and copy its path in the given buffer.\nThe lookup start from base_path and walk across parent directories\nif nothing has been found. The lookup ends when the first repository\nis found, or when reaching a directory referenced in ceiling_dirs\nor when the filesystem changes (in case across_fs is true).

\n" + }, + { + "cFunctionName": "git_repository_open_ext", + "args": [ + { + "name": "out", + "isReturn": true, + "cType": "git_repository **", + "cppClassName": "GitRepo", + "jsClassName": "Repository", + "comment": "Pointer to the repo which will be opened. This can actually be NULL if you only want to use the error code to see if a repo at this path could be opened." + }, + { + "name": "path", + "cType": "const char *", + "cppClassName": "String", + "jsClassName": "String", + "comment": "Path to open as git repository. If the flags permit \"searching\", then this can be a path to a subdirectory inside the working directory of the repository." + }, + { + "name": "flags", + "cType": "unsigned int", + "cppClassName": "Uint32", + "jsClassName": "Number", + "comment": "A combination of the GIT_REPOSITORY_OPEN flags above." + }, + { + "name": "ceiling_dirs", + "cType": "const char *", + "cppClassName": "String", + "jsClassName": "String", + "comment": "A GIT_PATH_LIST_SEPARATOR delimited list of path prefixes at which the search for a containing repository should terminate." + } + ], + "ignore": true, + "isAsync": false, + "isConstructorMethod": true, + "isPrototypeMethod": false, + "jsFunctionName": "openExt", + "cppFunctionName": "OpenExt", + "return": { + "cType": "int", + "cppClassName": "Int32", + "isErrorCode": true, + "comment": "0 on success, GIT_ENOTFOUND if no repository could be found, or -1 if there was a repository but open failed for some reason (such as repo corruption or system errors).", + "jsClassName": "Number" + }, + "description": "

Find and open a repository with extended controls.

\n" + }, + { + "cFunctionName": "git_repository_free", + "args": [ + { + "name": "repo", + "cType": "git_repository *", + "cppClassName": "GitRepo", + "jsClassName": "Repository", + "comment": "repository handle to close. If NULL nothing occurs." + } + ], + "ignore": true, + "isAsync": false, + "isConstructorMethod": false, + "isPrototypeMethod": false, + "isFree": true, + "jsFunctionName": "free", + "cppFunctionName": "Free", + "return": { + "cType": "void", + "cppClassName": "void", + "jsClassName": "void" + }, + "description": "

Free a previously allocated repository

\n" + }, + { + "cFunctionName": "git_repository_init", + "args": [ + { + "name": "out", + "isReturn": true, + "cType": "git_repository **", + "cppClassName": "GitRepo", + "jsClassName": "Repository", + "comment": "pointer to the repo which will be created or reinitialized" + }, + { + "name": "path", + "cType": "const char *", + "cppClassName": "String", + "jsClassName": "String", + "comment": "the path to the repository" + }, + { + "name": "is_bare", + "cType": "unsigned", + "cppClassName": "Boolean", + "jsClassName": "Boolean", + "comment": "if true, a Git repository without a working directory is created at the pointed path. If false, provided path will be considered as the working directory into which the .git directory will be created." + } + ], + "isAsync": true, + "isConstructorMethod": true, + "isPrototypeMethod": false, + "jsFunctionName": "init", + "cppFunctionName": "Init", + "return": { + "cType": "int", + "cppClassName": "Int32", + "isErrorCode": true, + "comment": "0 or an error code", + "jsClassName": "Number" + }, + "description": "

Creates a new Git repository in the given folder.

\n" + }, + { + "cFunctionName": "git_repository_init_ext", + "args": [ + { + "name": "out", + "isReturn": true, + "cType": "git_repository **", + "cppClassName": "GitRepo", + "jsClassName": "Repository", + "comment": "Pointer to the repo which will be created or reinitialized." + }, + { + "name": "repo_path", + "cType": "const char *", + "cppClassName": "String", + "jsClassName": "String", + "comment": "The path to the repository." + }, + { + "name": "opts", + "cType": "git_repository_init_options *", + "cppClassName": "RepositoryInitOptions", + "jsClassName": "RepositoryInitOptions", + "comment": "Pointer to git_repository_init_options struct." + } + ], + "ignore": true, + "isAsync": false, + "isConstructorMethod": true, + "isPrototypeMethod": false, + "jsFunctionName": "initExt", + "cppFunctionName": "InitExt", + "return": { + "cType": "int", + "cppClassName": "Int32", + "isErrorCode": true, + "comment": "0 or an error code on failure.", + "jsClassName": "Number" + }, + "description": "

Create a new Git repository in the given folder with extended controls.

\n" + }, + { + "cFunctionName": "git_repository_head", + "args": [ + { + "name": "out", + "isReturn": true, + "cType": "git_reference **", + "cppClassName": "GitReference", + "jsClassName": "Reference", + "comment": "pointer to the reference which will be retrieved" + }, + { + "name": "repo", + "cType": "git_repository *", + "cppClassName": "GitRepo", + "jsClassName": "Repository", + "comment": "a repository object" + } + ], + "ignore": true, + "isAsync": false, + "isConstructorMethod": false, + "isPrototypeMethod": false, + "jsFunctionName": "head", + "cppFunctionName": "Head", + "return": { + "cType": "int", + "cppClassName": "Int32", + "isErrorCode": true, + "comment": "0 on success, GIT_EORPHANEDHEAD when HEAD points to a non existing branch, GIT_ENOTFOUND when HEAD is missing; an error code otherwise", + "jsClassName": "Number" + }, + "description": "

Retrieve and resolve the reference pointed at by HEAD.

\n" + }, + { + "cFunctionName": "git_repository_head_detached", + "args": [ + { + "name": "repo", + "cType": "git_repository *", + "cppClassName": "GitRepo", + "jsClassName": "Repository", + "isSelf": true, + "comment": "Repo to test" + } + ], + "ignore": true, + "isAsync": false, + "isConstructorMethod": false, + "isPrototypeMethod": true, + "jsFunctionName": "headDetached", + "cppFunctionName": "HeadDetached", + "return": { + "cType": "int", + "cppClassName": "Int32", + "isErrorCode": true, + "comment": "1 if HEAD is detached, 0 if it's not; error code if there was an error.", + "jsClassName": "Number" + }, + "description": "

Check if a repository's HEAD is detached

\n" + }, + { + "cFunctionName": "git_repository_head_orphan", + "args": [ + { + "name": "repo", + "cType": "git_repository *", + "cppClassName": "GitRepo", + "jsClassName": "Repository", + "isSelf": true, + "comment": "Repo to test" + } + ], + "ignore": true, + "isAsync": false, + "isConstructorMethod": false, + "isPrototypeMethod": true, + "jsFunctionName": "headOrphan", + "cppFunctionName": "HeadOrphan", + "return": { + "cType": "int", + "cppClassName": "Int32", + "isErrorCode": true, + "comment": "1 if the current branch is an orphan, 0 if it's not; error code if there was an error", + "jsClassName": "Number" + }, + "description": "

Check if the current branch is an orphan

\n" + }, + { + "cFunctionName": "git_repository_is_empty", + "args": [ + { + "name": "repo", + "cType": "git_repository *", + "cppClassName": "GitRepo", + "jsClassName": "Repository", + "isSelf": true, + "comment": "Repo to test" + } + ], + "ignore": true, + "isAsync": false, + "isConstructorMethod": false, + "isPrototypeMethod": true, + "jsFunctionName": "isEmpty", + "cppFunctionName": "IsEmpty", + "return": { + "cType": "int", + "cppClassName": "Int32", + "isErrorCode": true, + "comment": "1 if the repository is empty, 0 if it isn't, error code if the repository is corrupted", + "jsClassName": "Number" + }, + "description": "

Check if a repository is empty

\n" + }, + { + "cFunctionName": "git_repository_path", + "args": [ + { + "name": "repo", + "cType": "git_repository *", + "cppClassName": "GitRepo", + "jsClassName": "Repository", + "isSelf": true, + "comment": "A repository object" + } + ], + "isAsync": false, + "isConstructorMethod": false, + "isPrototypeMethod": true, + "jsFunctionName": "path", + "cppFunctionName": "Path", + "return": { + "cType": "const char *", + "cppClassName": "String", + "comment": "the path to the repository", + "jsClassName": "String" + }, + "description": "

Get the path of this repository

\n" + }, + { + "cFunctionName": "git_repository_workdir", + "args": [ + { + "name": "repo", + "cType": "git_repository *", + "cppClassName": "GitRepo", + "jsClassName": "Repository", + "isSelf": true, + "comment": "A repository object" + } + ], + "isAsync": false, + "isConstructorMethod": false, + "isPrototypeMethod": true, + "jsFunctionName": "workdir", + "cppFunctionName": "Workdir", + "return": { + "cType": "const char *", + "cppClassName": "String", + "comment": "the path to the working dir, if it exists", + "jsClassName": "String" + }, + "description": "

Get the path of the working directory for this repository

\n" + }, + { + "cFunctionName": "git_repository_set_workdir", + "args": [ + { + "name": "repo", + "cType": "git_repository *", + "cppClassName": "GitRepo", + "jsClassName": "Repository", + "isSelf": true, + "comment": "A repository object" + }, + { + "name": "workdir", + "cType": "const char *", + "cppClassName": "String", + "jsClassName": "String", + "comment": "The path to a working directory" + }, + { + "name": "update_gitlink", + "cType": "int", + "cppClassName": "Int32", + "jsClassName": "Number", + "comment": "Create/update gitlink in workdir and set config \"core.worktree\" (if workdir is not the parent of the .git directory)" + } + ], + "ignore": true, + "isAsync": false, + "isConstructorMethod": false, + "isPrototypeMethod": true, + "jsFunctionName": "setWorkdir", + "cppFunctionName": "SetWorkdir", + "return": { + "cType": "int", + "cppClassName": "Int32", + "isErrorCode": true, + "comment": "0, or an error code", + "jsClassName": "Number" + }, + "description": "

Set the path to the working directory for this repository

\n" + }, + { + "cFunctionName": "git_repository_is_bare", + "args": [ + { + "name": "repo", + "cType": "git_repository *", + "cppClassName": "GitRepo", + "jsClassName": "Repository", + "isSelf": true, + "comment": "Repo to test" + } + ], + "ignore": true, + "isAsync": false, + "isConstructorMethod": false, + "isPrototypeMethod": true, + "jsFunctionName": "isBare", + "cppFunctionName": "IsBare", + "return": { + "cType": "int", + "cppClassName": "Int32", + "isErrorCode": true, + "comment": "1 if the repository is bare, 0 otherwise.", + "jsClassName": "Number" + }, + "description": "

Check if a repository is bare

\n" + }, + { + "cFunctionName": "git_repository_config", + "args": [ + { + "name": "out", + "isReturn": true, + "cType": "git_config **", + "cppClassName": "Config", + "jsClassName": "Config", + "comment": "Pointer to store the loaded config file" + }, + { + "name": "repo", + "cType": "git_repository *", + "cppClassName": "GitRepo", + "jsClassName": "Repository", + "comment": "A repository object" + } + ], + "ignore": true, + "isAsync": false, + "isConstructorMethod": false, + "isPrototypeMethod": false, + "jsFunctionName": "config", + "cppFunctionName": "Config", + "return": { + "cType": "int", + "cppClassName": "Int32", + "isErrorCode": true, + "comment": "0, or an error code", + "jsClassName": "Number" + }, + "description": "

Get the configuration file for this repository.

\n" + }, + { + "cFunctionName": "git_repository_set_config", + "args": [ + { + "name": "repo", + "cType": "git_repository *", + "cppClassName": "GitRepo", + "jsClassName": "Repository", + "isSelf": true, + "comment": "A repository object" + }, + { + "name": "config", + "cType": "git_config *", + "cppClassName": "Config", + "jsClassName": "Config", + "comment": "A Config object" + } + ], + "ignore": true, + "isAsync": false, + "isConstructorMethod": false, + "isPrototypeMethod": true, + "jsFunctionName": "setConfig", + "cppFunctionName": "SetConfig", + "return": { + "cType": "void", + "cppClassName": "void", + "jsClassName": "void" + }, + "description": "

Set the configuration file for this repository

\n" + }, + { + "cFunctionName": "git_repository_odb", + "args": [ + { + "name": "out", + "isReturn": true, + "cType": "git_odb **", + "cppClassName": "GitOdb", + "jsClassName": "Odb", + "comment": "Pointer to store the loaded ODB" + }, + { + "name": "repo", + "cType": "git_repository *", + "cppClassName": "GitRepo", + "jsClassName": "Repository", + "isSelf": true, + "comment": "A repository object" + } + ], + "isAsync": false, + "isConstructorMethod": false, + "isPrototypeMethod": true, + "jsFunctionName": "odb", + "cppFunctionName": "Odb", + "return": { + "cType": "int", + "cppClassName": "Int32", + "isErrorCode": true, + "comment": "0, or an error code", + "jsClassName": "Number" + }, + "description": "

Get the Object Database for this repository.

\n" + }, + { + "cFunctionName": "git_repository_set_odb", + "args": [ + { + "name": "repo", + "cType": "git_repository *", + "cppClassName": "GitRepo", + "jsClassName": "Repository", + "isSelf": true, + "comment": "A repository object" + }, + { + "name": "odb", + "cType": "git_odb *", + "cppClassName": "GitOdb", + "jsClassName": "Odb", + "comment": "An ODB object" + } + ], + "ignore": true, + "isAsync": false, + "isConstructorMethod": false, + "isPrototypeMethod": true, + "jsFunctionName": "setOdb", + "cppFunctionName": "SetOdb", + "return": { + "cType": "void", + "cppClassName": "void", + "jsClassName": "void" + }, + "description": "

Set the Object Database for this repository

\n" + }, + { + "cFunctionName": "git_repository_refdb", + "args": [ + { + "name": "out", + "isReturn": true, + "cType": "git_refdb **", + "cppClassName": "GitRefDb", + "jsClassName": "RefDb", + "comment": "Pointer to store the loaded refdb" + }, + { + "name": "repo", + "cType": "git_repository *", + "cppClassName": "GitRepo", + "jsClassName": "Repository", + "comment": "A repository object" + } + ], + "ignore": true, + "isAsync": false, + "isConstructorMethod": false, + "isPrototypeMethod": false, + "jsFunctionName": "refdb", + "cppFunctionName": "Refdb", + "return": { + "cType": "int", + "cppClassName": "Int32", + "isErrorCode": true, + "comment": "0, or an error code", + "jsClassName": "Number" + }, + "description": "

Get the Reference Database Backend for this repository.

\n" + }, + { + "cFunctionName": "git_repository_set_refdb", + "args": [ + { + "name": "repo", + "cType": "git_repository *", + "cppClassName": "GitRepo", + "jsClassName": "Repository", + "isSelf": true, + "comment": "A repository object" + }, + { + "name": "refdb", + "cType": "git_refdb *", + "cppClassName": "GitRefDb", + "jsClassName": "RefDb", + "comment": "An refdb object" + } + ], + "ignore": true, + "isAsync": false, + "isConstructorMethod": false, + "isPrototypeMethod": true, + "jsFunctionName": "setRefdb", + "cppFunctionName": "SetRefdb", + "return": { + "cType": "void", + "cppClassName": "void", + "jsClassName": "void" + }, + "description": "

Set the Reference Database Backend for this repository

\n" + }, + { + "cFunctionName": "git_repository_index", + "args": [ + { + "name": "out", + "isReturn": true, + "cType": "git_index **", + "cppClassName": "GitIndex", + "jsClassName": "Index", + "comment": "Pointer to store the loaded index" + }, + { + "name": "repo", + "cType": "git_repository *", + "cppClassName": "GitRepo", + "jsClassName": "Repository", + "isSelf": true, + "comment": "A repository object" + } + ], + "isAsync": true, + "isConstructorMethod": false, + "isPrototypeMethod": true, + "jsFunctionName": "openIndex", + "cppFunctionName": "openIndex", + "return": { + "cType": "int", + "cppClassName": "Int32", + "isErrorCode": true, + "comment": "0, or an error code", + "jsClassName": "Number" + }, + "description": "

Get the Index file for this repository.

\n" + }, + { + "cFunctionName": "git_repository_set_index", + "args": [ + { + "name": "repo", + "cType": "git_repository *", + "cppClassName": "GitRepo", + "jsClassName": "Repository", + "isSelf": true, + "comment": "A repository object" + }, + { + "name": "index", + "cType": "git_index *", + "cppClassName": "GitIndex", + "jsClassName": "Index", + "comment": "An index object" + } + ], + "ignore": true, + "isAsync": false, + "isConstructorMethod": false, + "isPrototypeMethod": true, + "jsFunctionName": "setIndex", + "cppFunctionName": "SetIndex", + "return": { + "cType": "void", + "cppClassName": "void", + "jsClassName": "void" + }, + "description": "

Set the index file for this repository

\n" + }, + { + "cFunctionName": "git_repository_message", + "args": [ + { + "name": "out", + "isReturn": true, + "cType": "char *", + "cppClassName": "String", + "jsClassName": "String", + "comment": "Buffer to write data into or NULL to just read required size" + }, + { + "name": "len", + "cType": "size_t", + "cppClassName": "Uint32", + "jsClassName": "Number", + "comment": "Length of `out` buffer in bytes" + }, + { + "name": "repo", + "cType": "git_repository *", + "cppClassName": "GitRepo", + "jsClassName": "Repository", + "comment": "Repository to read prepared message from" + } + ], + "ignore": true, + "isAsync": false, + "isConstructorMethod": false, + "isPrototypeMethod": false, + "jsFunctionName": "message", + "cppFunctionName": "Message", + "return": { + "cType": "int", + "cppClassName": "Int32", + "isErrorCode": true, + "comment": "GIT_ENOUTFOUND if no message exists, other value < 0 for other errors, or total bytes in message (may be > `len`) on success", + "jsClassName": "Number" + }, + "description": "

Retrieve git's prepared message

\n" + }, + { + "cFunctionName": "git_repository_message_remove", + "args": [ + { + "name": "repo", + "cType": "git_repository *", + "cppClassName": "GitRepo", + "jsClassName": "Repository", + "isSelf": true + } + ], + "ignore": true, + "isAsync": false, + "isConstructorMethod": false, + "isPrototypeMethod": true, + "jsFunctionName": "messageRemove", + "cppFunctionName": "MessageRemove", + "return": { + "cType": "int", + "cppClassName": "Int32", + "isErrorCode": true, + "jsClassName": "Number" + }, + "description": "

Remove git's prepared message.

\n" + }, + { + "cFunctionName": "git_repository_merge_cleanup", + "args": [ + { + "name": "repo", + "cType": "git_repository *", + "cppClassName": "GitRepo", + "jsClassName": "Repository", + "isSelf": true, + "comment": "A repository object" + } + ], + "ignore": true, + "isAsync": false, + "isConstructorMethod": false, + "isPrototypeMethod": true, + "jsFunctionName": "mergeCleanup", + "cppFunctionName": "MergeCleanup", + "return": { + "cType": "int", + "cppClassName": "Int32", + "isErrorCode": true, + "comment": "0 on success, or error", + "jsClassName": "Number" + }, + "description": "

Remove all the metadata associated with an ongoing git merge, including\nMERGE_HEAD, MERGE_MSG, etc.

\n" + }, + { + "cFunctionName": "git_repository_fetchhead_foreach", + "args": [ + { + "name": "repo", + "cType": "git_repository *", + "cppClassName": "GitRepo", + "jsClassName": "Repository", + "isSelf": true, + "comment": "A repository object" + }, + { + "name": "callback", + "cType": "git_repository_fetchhead_foreach_cb", + "cppClassName": "RepositoryFetchheadForeachCb", + "jsClassName": "RepositoryFetchheadForeachCb", + "comment": "Callback function" + }, + { + "name": "payload", + "cType": "void *", + "cppClassName": "void", + "jsClassName": "void", + "comment": "Pointer to callback data (optional)" + } + ], + "ignore": true, + "isAsync": false, + "isConstructorMethod": false, + "isPrototypeMethod": true, + "jsFunctionName": "fetchheadForeach", + "cppFunctionName": "FetchheadForeach", + "return": { + "cType": "int", + "cppClassName": "Int32", + "isErrorCode": true, + "comment": "0 on success, GIT_ENOTFOUND, GIT_EUSER or error", + "jsClassName": "Number" + }, + "description": "

Call callback 'callback' for each entry in the given FETCH_HEAD file.

\n" + }, + { + "cFunctionName": "git_repository_mergehead_foreach", + "args": [ + { + "name": "repo", + "cType": "git_repository *", + "cppClassName": "GitRepo", + "jsClassName": "Repository", + "isSelf": true, + "comment": "A repository object" + }, + { + "name": "callback", + "cType": "git_repository_mergehead_foreach_cb", + "cppClassName": "RepositoryMergeheadForeachCb", + "jsClassName": "RepositoryMergeheadForeachCb", + "comment": "Callback function" + }, + { + "name": "payload", + "cType": "void *", + "cppClassName": "void", + "jsClassName": "void", + "comment": "Pointer to callback data (optional)" + } + ], + "ignore": true, + "isAsync": false, + "isConstructorMethod": false, + "isPrototypeMethod": true, + "jsFunctionName": "mergeheadForeach", + "cppFunctionName": "MergeheadForeach", + "return": { + "cType": "int", + "cppClassName": "Int32", + "isErrorCode": true, + "comment": "0 on success, GIT_ENOTFOUND, GIT_EUSER or error", + "jsClassName": "Number" + }, + "description": "

If a merge is in progress, call callback 'cb' for each commit ID in the\nMERGE_HEAD file.

\n" + }, + { + "cFunctionName": "git_repository_hashfile", + "args": [ + { + "name": "out", + "isReturn": true, + "cType": "git_oid *", + "cppClassName": "GitOid", + "jsClassName": "Oid", + "shouldAlloc": true, + "comment": "Output value of calculated SHA" + }, + { + "name": "repo", + "cType": "git_repository *", + "cppClassName": "GitRepo", + "jsClassName": "Repository", + "comment": "Repository pointer" + }, + { + "name": "path", + "cType": "const char *", + "cppClassName": "String", + "jsClassName": "String", + "comment": "Path to file on disk whose contents should be hashed. If the repository is not NULL, this can be a relative path." + }, + { + "name": "type", + "cType": "git_otype", + "cppClassName": "Int32", + "jsClassName": "Otype", + "comment": "The object type to hash as (e.g. GIT_OBJ_BLOB)" + }, + { + "name": "as_path", + "cType": "const char *", + "cppClassName": "String", + "jsClassName": "String", + "comment": "The path to use to look up filtering rules. If this is NULL, then the `path` parameter will be used instead. If this is passed as the empty string, then no filters will be applied when calculating the hash." + } + ], + "ignore": true, + "isAsync": false, + "isConstructorMethod": false, + "isPrototypeMethod": false, + "jsFunctionName": "hashfile", + "cppFunctionName": "Hashfile", + "return": { + "cType": "int", + "cppClassName": "Int32", + "isErrorCode": true, + "jsClassName": "Number" + }, + "description": "

Calculate hash of file using repository filtering rules.

\n" + }, + { + "cFunctionName": "git_repository_set_head", + "args": [ + { + "name": "repo", + "cType": "git_repository*", + "cppClassName": "Repository*", + "jsClassName": "Repository*", + "comment": "Repository pointer" + }, + { + "name": "refname", + "cType": "const char*", + "cppClassName": "String", + "jsClassName": "String", + "comment": "Canonical name of the reference the HEAD should point at" + } + ], + "ignore": true, + "isAsync": false, + "isConstructorMethod": false, + "isPrototypeMethod": false, + "jsFunctionName": "setHead", + "cppFunctionName": "SetHead", + "return": { + "cType": "int", + "cppClassName": "Int32", + "isErrorCode": true, + "comment": "0 on success, or an error code", + "jsClassName": "Number" + }, + "description": "

Make the repository HEAD point to the specified reference.

\n" + }, + { + "cFunctionName": "git_repository_set_head_detached", + "args": [ + { + "name": "repo", + "cType": "git_repository*", + "cppClassName": "Repository*", + "jsClassName": "Repository*", + "comment": "Repository pointer" + }, + { + "name": "commitish", + "cType": "const git_oid*", + "cppClassName": "String", + "jsClassName": "String", + "comment": "Object id of the Commit the HEAD should point to" + } + ], + "ignore": true, + "isAsync": false, + "isConstructorMethod": false, + "isPrototypeMethod": false, + "jsFunctionName": "setHeadDetached", + "cppFunctionName": "SetHeadDetached", + "return": { + "cType": "int", + "cppClassName": "Int32", + "isErrorCode": true, + "comment": "0 on success, or an error code", + "jsClassName": "Number" + }, + "description": "

Make the repository HEAD directly point to the Commit.

\n" + }, + { + "cFunctionName": "git_repository_detach_head", + "args": [ + { + "name": "repo", + "cType": "git_repository*", + "cppClassName": "Repository*", + "jsClassName": "Repository*", + "comment": "Repository pointer" + } + ], + "ignore": true, + "isAsync": false, + "isConstructorMethod": false, + "isPrototypeMethod": false, + "jsFunctionName": "detachHead", + "cppFunctionName": "DetachHead", + "return": { + "cType": "int", + "cppClassName": "Int32", + "isErrorCode": true, + "comment": "0 on success, GIT_EORPHANEDHEAD when HEAD points to a non existing branch or an error code", + "jsClassName": "Number" + }, + "description": "

Detach the HEAD.

\n" + }, + { + "cFunctionName": "git_repository_state", + "args": [ + { + "name": "repo", + "cType": "git_repository *", + "cppClassName": "GitRepo", + "jsClassName": "Repository", + "isSelf": true, + "comment": "Repository pointer" + } + ], + "ignore": true, + "isAsync": false, + "isConstructorMethod": false, + "isPrototypeMethod": true, + "jsFunctionName": "state", + "cppFunctionName": "State", + "return": { + "cType": "int", + "cppClassName": "Int32", + "isErrorCode": true, + "comment": "The state of the repository", + "jsClassName": "Number" + }, + "description": "

Determines the status of a git repository - ie, whether an operation\n(merge, cherry-pick, etc) is in progress.

\n" + }, + { + "cFunctionName": "git_blob_lookup", + "args": [ + { + "name": "blob", + "cType": "git_blob **", + "cppClassName": "GitBlob", + "jsClassName": "Blob", + "isReturn": true, + "comment": "pointer to the looked up blob" + }, + { + "name": "repo", + "cType": "git_repository *", + "cppClassName": "GitRepo", + "jsClassName": "Repository", + "isSelf": true, + "comment": "the repo to use when locating the blob." + }, + { + "name": "id", + "cType": "const git_oid *", + "cppClassName": "GitOid", + "jsClassName": "Oid", + "comment": "identity of the blob to locate." + } + ], + "isAsync": true, + "isConstructorMethod": false, + "isPrototypeMethod": true, + "jsFunctionName": "getBlob", + "cppFunctionName": "GetBlob", + "return": { + "cType": "int", + "cppClassName": "Int32", + "isErrorCode": true, + "comment": "0 or an error code", + "jsClassName": "Number" + }, + "description": "

Lookup a blob object from a repository.

\n" + }, + { + "cFunctionName": "git_blob_lookup_prefix", + "args": [ + { + "name": "blob", + "cType": "git_blob **", + "cppClassName": "GitBlob", + "jsClassName": "Blob", + "isReturn": true, + "comment": "pointer to the looked up blob" + }, + { + "name": "repo", + "cType": "git_repository *", + "cppClassName": "GitRepo", + "jsClassName": "Repository", + "isSelf": true, + "comment": "the repo to use when locating the blob." + }, + { + "name": "id", + "cType": "const git_oid *", + "cppClassName": "GitOid", + "jsClassName": "Oid", + "comment": "identity of the blob to locate." + }, + { + "name": "len", + "cType": "size_t", + "cppClassName": "Uint32", + "jsClassName": "Number", + "comment": "the length of the short identifier" + } + ], + "ignore": true, + "isAsync": false, + "isConstructorMethod": false, + "isPrototypeMethod": true, + "jsFunctionName": "getBlobByPrefix", + "cppFunctionName": "GetBlobByPrefix", + "return": { + "cType": "int", + "cppClassName": "Int32", + "isErrorCode": true, + "comment": "0 or an error code", + "jsClassName": "Number" + }, + "description": "

Lookup a blob object from a repository,\ngiven a prefix of its identifier (short id).

\n" + }, + { + "cFunctionName": "git_commit_lookup", + "args": [ + { + "name": "commit", + "cType": "git_commit **", + "cppClassName": "GitCommit", + "jsClassName": "Commit", + "isReturn": true, + "comment": "pointer to the looked up commit" + }, + { + "name": "repo", + "cType": "git_repository *", + "cppClassName": "GitRepo", + "jsClassName": "Repository", + "isSelf": true, + "comment": "the repo to use when locating the commit." + }, + { + "name": "id", + "cType": "const git_oid *", + "cppClassName": "GitOid", + "jsClassName": "Oid", + "comment": "identity of the commit to locate. If the object is an annotated tag it will be peeled back to the commit." + } + ], + "isAsync": true, + "isConstructorMethod": false, + "isPrototypeMethod": true, + "jsFunctionName": "getCommit", + "cppFunctionName": "GetCommit", + "return": { + "cType": "int", + "cppClassName": "Int32", + "isErrorCode": true, + "comment": "0 or an error code", + "jsClassName": "Number" + }, + "description": "

Lookup a commit object from a repository.

\n" + }, + { + "cFunctionName": "git_commit_create", + "args": [ + { + "name": "id", + "cType": "git_oid *", + "cppClassName": "GitOid", + "jsClassName": "Oid", + "isReturn": true, + "shouldAlloc": true, + "comment": "Pointer in which to store the OID of the newly created commit" + }, + { + "name": "repo", + "cType": "git_repository *", + "cppClassName": "GitRepo", + "jsClassName": "Repository", + "isSelf": true, + "comment": "Repository where to store the commit" + }, + { + "name": "update_ref", + "cType": "const char *", + "cppClassName": "String", + "jsClassName": "String", + "isOptional": true, + "comment": "If not NULL, name of the reference that will be updated to point to this commit. If the reference is not direct, it will be resolved to a direct reference. Use \"HEAD\" to update the HEAD of the current branch and make it point to this commit. If the reference doesn't exist yet, it will be created." + }, + { + "name": "author", + "cType": "const git_signature *", + "cppClassName": "GitSignature", + "jsClassName": "Signature", + "comment": "Signature with author and author time of commit" + }, + { + "name": "committer", + "cType": "const git_signature *", + "cppClassName": "GitSignature", + "jsClassName": "Signature", + "comment": "Signature with committer and * commit time of commit" + }, + { + "name": "message_encoding", + "cType": "const char *", + "cppClassName": "String", + "jsClassName": "String", + "isOptional": true, + "comment": "The encoding for the message in the commit, represented with a standard encoding name. E.g. \"UTF-8\". If NULL, no encoding header is written and UTF-8 is assumed." + }, + { + "name": "message", + "cType": "const char *", + "cppClassName": "String", + "jsClassName": "String", + "comment": "_encoding The encoding for the message in the commit, represented with a standard encoding name. E.g. \"UTF-8\". If NULL, no encoding header is written and UTF-8 is assumed." + }, + { + "name": "tree", + "cType": "const git_tree *", + "cppClassName": "GitTree", + "jsClassName": "Tree", + "comment": "An instance of a `git_tree` object that will be used as the tree for the commit. This tree object must also be owned by the given `repo`." + }, + { + "name": "parent_count", + "cType": "int", + "cppClassName": "Int32", + "jsClassName": "Number", + "comment": "Number of parents for this commit" + }, + { + "name": "parents", + "cType": "const git_commit **", + "cppClassName": "Array", + "arrayElementCppClassName": "GitCommit", + "jsClassName": "Array" + } + ], + "isAsync": true, + "isConstructorMethod": false, + "isPrototypeMethod": true, + "jsFunctionName": "createCommit", + "cppFunctionName": "CreateCommit", + "return": { + "cType": "int", + "cppClassName": "Int32", + "isErrorCode": true, + "comment": "0 or an error code The created commit will be written to the Object Database and the given reference will be updated to point to it", + "jsClassName": "Number" + }, + "description": "

Create new commit in the repository from a list of git_object pointers

\n" + }, + { + "cFunctionName": "git_object_lookup", + "args": [ + { + "name": "object", + "cType": "git_object **", + "cppClassName": "GitObject", + "jsClassName": "Object", + "isReturn": true, + "comment": "pointer to the looked-up object" + }, + { + "name": "repo", + "cType": "git_repository *", + "cppClassName": "GitRepo", + "jsClassName": "Repository", + "isSelf": true, + "comment": "the repository to look up the object" + }, + { + "name": "id", + "cType": "const git_oid *", + "cppClassName": "GitOid", + "jsClassName": "Oid", + "comment": "the unique identifier for the object" + }, + { + "name": "type", + "cType": "git_otype", + "cppClassName": "Int32", + "jsClassName": "Number", + "comment": "the type of the object" + } + ], + "isAsync": true, + "isConstructorMethod": false, + "isPrototypeMethod": true, + "jsFunctionName": "getObject", + "cppFunctionName": "GetObject", + "return": { + "cType": "int", + "cppClassName": "Int32", + "isErrorCode": true, + "comment": "a reference to the object", + "jsClassName": "Number" + }, + "description": "

Lookup a reference to one of the objects in a repository.

\n" + }, + { + "cFunctionName": "git_object_lookup_prefix", + "args": [ + { + "name": "object_out", + "cType": "git_object **", + "cppClassName": "GitObject", + "jsClassName": "Object", + "isReturn": true, + "comment": "pointer where to store the looked-up object" + }, + { + "name": "repo", + "cType": "git_repository *", + "cppClassName": "GitRepo", + "jsClassName": "Repository", + "isSelf": true, + "comment": "the repository to look up the object" + }, + { + "name": "id", + "cType": "const git_oid *", + "cppClassName": "GitOid", + "jsClassName": "Oid", + "comment": "a short identifier for the object" + }, + { + "name": "len", + "cType": "size_t", + "cppClassName": "Uint32", + "jsClassName": "Number", + "comment": "the length of the short identifier" + }, + { + "name": "type", + "cType": "git_otype", + "cppClassName": "Number", + "jsClassName": "Number", + "comment": "the type of the object" + } + ], + "ignore": true, + "isAsync": true, + "isConstructorMethod": false, + "isPrototypeMethod": true, + "jsFunctionName": "getObjectByPrefix", + "cppFunctionName": "GetObjectByPrefix", + "return": { + "cType": "int", + "cppClassName": "Int32", + "isErrorCode": true, + "comment": "0 or an error code", + "jsClassName": "Number" + }, + "description": "

Lookup a reference to one of the objects in a repository,\ngiven a prefix of its identifier (short id).

\n" + }, + { + "cFunctionName": "git_refdb_new", + "args": [ + { + "name": "out", + "isReturn": true, + "cType": "git_refdb **", + "cppClassName": "GitRefDb", + "jsClassName": "RefDb", + "comment": "location to store the database pointer, if opened. Set to NULL if the open failed." + }, + { + "name": "repo", + "cType": "git_repository *", + "cppClassName": "GitRepo", + "jsClassName": "Repository", + "isSelf": true, + "comment": "the repository" + } + ], + "ignore": true, + "isAsync": false, + "isConstructorMethod": false, + "isPrototypeMethod": true, + "jsFunctionName": "newRefDbWithoutBackends", + "cppFunctionName": "NewRefDbWithoutBackends", + "return": { + "cType": "int", + "cppClassName": "Int32", + "isErrorCode": true, + "comment": "0 or an error code", + "jsClassName": "Number" + }, + "description": "

Create a new reference database with no backends.

\n" + }, + { + "cFunctionName": "git_refdb_open", + "args": [ + { + "name": "out", + "isReturn": true, + "cType": "git_refdb **", + "cppClassName": "GitRefDb", + "jsClassName": "RefDb", + "comment": "location to store the database pointer, if opened. Set to NULL if the open failed." + }, + { + "name": "repo", + "cType": "git_repository *", + "cppClassName": "GitRepo", + "jsClassName": "Repository", + "isSelf": true, + "comment": "the repository" + } + ], + "ignore": true, + "isAsync": false, + "isConstructorMethod": false, + "isPrototypeMethod": true, + "jsFunctionName": "openRefDb", + "cppFunctionName": "OpenRefDb", + "return": { + "cType": "int", + "cppClassName": "Int32", + "isErrorCode": true, + "comment": "0 or an error code", + "jsClassName": "Number" + }, + "description": "

Create a new reference database and automatically add\nthe default backends:

\n" + }, + { + "cFunctionName": "git_refdb_backend_fs", + "args": [ + { + "name": "backend_out", + "cType": "struct git_refdb_backend **", + "cppClassName": "RefdbBackend", + "jsClassName": "RefdbBackend", + "isReturn": true, + "comment": "Output pointer to the git_refdb_backend object" + }, + { + "name": "repo", + "cType": "git_repository *", + "cppClassName": "GitRepo", + "jsClassName": "Repository", + "isSelf": true, + "comment": "Git repository to access" + }, + { + "name": "refdb", + "cType": "git_refdb *", + "cppClassName": "GitRefDb", + "jsClassName": "RefDb" + } + ], + "ignore": true, + "isAsync": false, + "isConstructorMethod": false, + "isPrototypeMethod": true, + "jsFunctionName": "openRefDbBackend", + "cppFunctionName": "OpenRefDbBackend", + "return": { + "cType": "int", + "cppClassName": "Int32", + "isErrorCode": true, + "comment": "0 on success, <0 error code on failure", + "jsClassName": "Number" + }, + "description": "

Constructors for default filesystem-based refdb backend

\n" + }, + { + "cFunctionName": "git_reference_lookup", + "args": [ + { + "name": "out", + "isReturn": true, + "cType": "git_reference **", + "cppClassName": "GitReference", + "jsClassName": "Reference", + "comment": "pointer to the looked-up reference" + }, + { + "name": "repo", + "cType": "git_repository *", + "cppClassName": "GitRepo", + "jsClassName": "Repository", + "isSelf": true, + "comment": "the repository to look up the reference" + }, + { + "name": "name", + "cType": "const char *", + "cppClassName": "String", + "jsClassName": "String", + "comment": "the long name for the reference (e.g. HEAD, refs/heads/master, refs/tags/v0.1.0, ...)" + } + ], + "isAsync": true, + "isConstructorMethod": false, + "isPrototypeMethod": true, + "jsFunctionName": "getReference", + "cppFunctionName": "GetReference", + "return": { + "cType": "int", + "cppClassName": "Int32", + "isErrorCode": true, + "comment": "0 on success, ENOTFOUND, EINVALIDSPEC or an error code.", + "jsClassName": "Number" + }, + "description": "

Lookup a reference by name in a repository.

\n" + }, + { + "cFunctionName": "git_reference_symbolic_create", + "args": [ + { + "name": "out", + "isReturn": true, + "cType": "git_reference **", + "cppClassName": "GitReference", + "jsClassName": "Reference", + "comment": "Pointer to the newly created reference" + }, + { + "name": "repo", + "cType": "git_repository *", + "cppClassName": "GitRepo", + "jsClassName": "Repository", + "isSelf": true, + "comment": "Repository where that reference will live" + }, + { + "name": "name", + "cType": "const char *", + "cppClassName": "String", + "jsClassName": "String", + "comment": "The name of the reference" + }, + { + "name": "target", + "cType": "const char *", + "cppClassName": "String", + "jsClassName": "String", + "comment": "The target of the reference" + }, + { + "name": "force", + "cType": "int", + "cppClassName": "Int32", + "jsClassName": "Number", + "comment": "Overwrite existing references" + } + ], + "isAsync": false, + "isConstructorMethod": false, + "isPrototypeMethod": true, + "jsFunctionName": "createSymbolicReference", + "cppFunctionName": "CreateSymbolicReference", + "return": { + "cType": "int", + "cppClassName": "Int32", + "isErrorCode": true, + "comment": "0 on success, EEXISTS, EINVALIDSPEC or an error code", + "jsClassName": "Number" + }, + "description": "

Create a new symbolic reference.

\n" + }, + { + "cFunctionName": "git_reference_create", + "args": [ + { + "name": "out", + "isReturn": true, + "cType": "git_reference **", + "cppClassName": "GitReference", + "jsClassName": "Reference", + "comment": "Pointer to the newly created reference" + }, + { + "name": "repo", + "cType": "git_repository *", + "cppClassName": "GitRepo", + "jsClassName": "Repository", + "isSelf": true, + "comment": "Repository where that reference will live" + }, + { + "name": "name", + "cType": "const char *", + "cppClassName": "String", + "jsClassName": "String", + "comment": "The name of the reference" + }, + { + "name": "id", + "cType": "const git_oid *", + "cppClassName": "GitOid", + "jsClassName": "Oid", + "comment": "The object id pointed to by the reference." + }, + { + "name": "force", + "cType": "int", + "cppClassName": "Int32", + "jsClassName": "Number", + "comment": "Overwrite existing references" + } + ], + "isAsync": false, + "isConstructorMethod": false, + "isPrototypeMethod": true, + "jsFunctionName": "createReference", + "cppFunctionName": "CreateReference", + "return": { + "cType": "int", + "cppClassName": "Int32", + "isErrorCode": true, + "comment": "0 on success, EEXISTS, EINVALIDSPEC or an error code", + "jsClassName": "Number" + }, + "description": "

Create a new direct reference.

\n" + }, + { + "cFunctionName": "git_remote_create", + "args": [ + { + "name": "out", + "isReturn": true, + "cType": "git_remote **", + "cppClassName": "GitRemote", + "jsClassName": "Remote", + "comment": "the resulting remote" + }, + { + "name": "repo", + "cType": "git_repository *", + "cppClassName": "GitRepo", + "jsClassName": "Repository", + "isSelf": true, + "comment": "the repository in which to create the remote" + }, + { + "name": "name", + "cType": "const char *", + "cppClassName": "String", + "jsClassName": "String", + "comment": "the remote's name" + }, + { + "name": "url", + "cType": "const char *", + "cppClassName": "String", + "jsClassName": "String", + "comment": "the remote's url" + } + ], + "isAsync": true, + "isConstructorMethod": false, + "isPrototypeMethod": true, + "jsFunctionName": "addRemote", + "cppFunctionName": "AddRemote", + "return": { + "cType": "int", + "cppClassName": "Int32", + "isErrorCode": true, + "comment": "0, GIT_EINVALIDSPEC, GIT_EEXISTS or an error code", + "jsClassName": "Number" + }, + "description": "

Add a remote with the default fetch refspec to the repository's configuration. This\ncalls git_remote_save before returning.

\n" + }, + { + "cFunctionName": "git_remote_create_inmemory", + "args": [ + { + "name": "out", + "isReturn": true, + "cType": "git_remote **", + "cppClassName": "GitRemote", + "jsClassName": "Remote", + "comment": "pointer to the new remote object" + }, + { + "name": "repo", + "cType": "git_repository *", + "cppClassName": "GitRepo", + "jsClassName": "Repository", + "isSelf": true, + "comment": "the associated repository" + }, + { + "name": "fetch", + "cType": "const char *", + "cppClassName": "String", + "jsClassName": "String", + "comment": "the fetch refspec to use for this remote. May be NULL for defaults." + }, + { + "name": "url", + "cType": "const char *", + "cppClassName": "String", + "jsClassName": "String", + "comment": "the remote repository's URL" + } + ], + "ignore": true, + "isAsync": false, + "isConstructorMethod": false, + "isPrototypeMethod": true, + "jsFunctionName": "addRemoteInMemory", + "cppFunctionName": "AddRemoteInMemory", + "return": { + "cType": "int", + "cppClassName": "Int32", + "isErrorCode": true, + "comment": "0 or an error code", + "jsClassName": "Number" + }, + "description": "

Create a remote in memory

\n" + }, + { + "cFunctionName": "git_revwalk_new", + "args": [ + { + "name": "out", + "isReturn": true, + "cType": "git_revwalk **", + "cppClassName": "GitRevWalk", + "jsClassName": "RevWalk", + "comment": "pointer to the new revision walker" + }, + { + "name": "repo", + "cType": "git_repository *", + "cppClassName": "GitRepo", + "jsClassName": "Repository", + "isSelf": true, + "comment": "the repo to walk through" + } + ], + "isAsync": false, + "isConstructorMethod": false, + "isPrototypeMethod": true, + "jsFunctionName": "createRevWalk", + "cppFunctionName": "CreateRevWalk", + "return": { + "cType": "int", + "cppClassName": "Int32", + "isErrorCode": true, + "comment": "0 or an error code", + "jsClassName": "Number" + }, + "description": "

Allocate a new revision walker to iterate through a repo.

\n" + }, + { + "cFunctionName": "git_submodule_lookup", + "args": [ + { + "name": "submodule", + "cType": "git_submodule **", + "cppClassName": "GitSubmodule", + "jsClassName": "Submodule", + "isReturn": true, + "comment": "Pointer to submodule description object pointer.." + }, + { + "name": "repo", + "cType": "git_repository *", + "cppClassName": "GitRepo", + "jsClassName": "Repository", + "isSelf": true, + "comment": "The repository." + }, + { + "name": "name", + "cType": "const char *", + "cppClassName": "String", + "jsClassName": "String", + "comment": "The name of the submodule. Trailing slashes will be ignored." + } + ], + "isAsync": false, + "isConstructorMethod": false, + "isPrototypeMethod": true, + "jsFunctionName": "getSubmodule", + "cppFunctionName": "GetSubmodule", + "return": { + "cType": "int", + "cppClassName": "Int32", + "isErrorCode": true, + "comment": "0 on success, GIT_ENOTFOUND if submodule does not exist, GIT_EEXISTS if submodule exists in working directory only, -1 on other errors.", + "jsClassName": "Number" + }, + "description": "

Lookup submodule information by name or path.

\n" + }, + { + "cFunctionName": "git_submodule_add_setup", + "args": [ + { + "name": "submodule", + "cType": "git_submodule **", + "cppClassName": "GitSubmodule", + "jsClassName": "Submodule", + "isReturn": true, + "comment": "The newly created submodule ready to open for clone" + }, + { + "name": "repo", + "cType": "git_repository *", + "cppClassName": "GitRepo", + "jsClassName": "Repository", + "isSelf": true, + "comment": "Superproject repository to contain the new submodule" + }, + { + "name": "url", + "cType": "const char *", + "cppClassName": "String", + "jsClassName": "String", + "comment": "URL for the submodules remote" + }, + { + "name": "path", + "cType": "const char *", + "cppClassName": "String", + "jsClassName": "String", + "comment": "Path at which the submodule should be created" + }, + { + "name": "use_gitlink", + "cType": "int", + "cppClassName": "Int32", + "jsClassName": "Number", + "comment": "Should workdir contain a gitlink to the repo in .git/modules vs. repo directly in workdir." + } + ], + "isAsync": false, + "isConstructorMethod": false, + "isPrototypeMethod": true, + "jsFunctionName": "addSubmodule", + "cppFunctionName": "AddSubmodule", + "return": { + "cType": "int", + "cppClassName": "Int32", + "isErrorCode": true, + "comment": "0 on success, GIT_EEXISTS if submodule already exists, -1 on other errors.", + "jsClassName": "Number" + }, + "description": "

Set up a new git submodule for checkout.

\n" + }, + { + "cFunctionName": "git_tag_lookup", + "args": [ + { + "name": "out", + "isReturn": true, + "cType": "git_tag **", + "cppClassName": "GitTag", + "jsClassName": "Tag", + "comment": "pointer to the looked up tag" + }, + { + "name": "repo", + "cType": "git_repository *", + "cppClassName": "GitRepo", + "jsClassName": "Repository", + "isSelf": true, + "comment": "the repo to use when locating the tag." + }, + { + "name": "id", + "cType": "const git_oid *", + "cppClassName": "GitOid", + "jsClassName": "Oid", + "comment": "identity of the tag to locate." + } + ], + "isAsync": true, + "isConstructorMethod": false, + "isPrototypeMethod": true, + "jsFunctionName": "getTag", + "cppFunctionName": "GetTag", + "return": { + "cType": "int", + "cppClassName": "Int32", + "isErrorCode": true, + "comment": "0 or an error code", + "jsClassName": "Number" + }, + "description": "

Lookup a tag object from the repository.

\n" + }, + { + "cFunctionName": "git_tag_lookup_prefix", + "args": [ + { + "name": "out", + "isReturn": true, + "cType": "git_tag **", + "cppClassName": "GitTag", + "jsClassName": "Tag", + "comment": "pointer to the looked up tag" + }, + { + "name": "repo", + "cType": "git_repository *", + "cppClassName": "GitRepo", + "jsClassName": "Repository", + "isSelf": true, + "comment": "the repo to use when locating the tag." + }, + { + "name": "id", + "cType": "const git_oid *", + "cppClassName": "GitOid", + "jsClassName": "Oid", + "comment": "identity of the tag to locate." + }, + { + "name": "len", + "cType": "size_t", + "cppClassName": "Uint32", + "jsClassName": "Number", + "comment": "the length of the short identifier" + } + ], + "ignore": true, + "isAsync": false, + "isConstructorMethod": false, + "isPrototypeMethod": true, + "jsFunctionName": "getTagByPrefix", + "cppFunctionName": "GetTagByPrefix", + "return": { + "cType": "int", + "cppClassName": "Int32", + "isErrorCode": true, + "comment": "0 or an error code", + "jsClassName": "Number" + }, + "description": "

Lookup a tag object from the repository,\ngiven a prefix of its identifier (short id).

\n" + }, + { + "cFunctionName": "git_tag_create", + "args": [ + { + "name": "oid", + "cType": "git_oid *", + "cppClassName": "GitOid", + "jsClassName": "Oid", + "isReturn": true, + "shouldAlloc": true, + "comment": "Pointer where to store the OID of the newly created tag. If the tag already exists, this parameter will be the oid of the existing tag, and the function will return a GIT_EEXISTS error code." + }, + { + "name": "repo", + "cType": "git_repository *", + "cppClassName": "GitRepo", + "jsClassName": "Repository", + "isSelf": true, + "comment": "Repository where to store the tag" + }, + { + "name": "tag_name", + "cType": "const char *", + "cppClassName": "String", + "jsClassName": "String", + "comment": "Name for the tag; this name is validated for consistency. It should also not conflict with an already existing tag name" + }, + { + "name": "target", + "cType": "const git_object *", + "cppClassName": "GitObject", + "jsClassName": "Object", + "comment": "Object to which this tag points. This object must belong to the given `repo`." + }, + { + "name": "tagger", + "cType": "const git_signature *", + "cppClassName": "GitSignature", + "jsClassName": "Signature", + "comment": "Signature of the tagger for this tag, and of the tagging time" + }, + { + "name": "message", + "cType": "const char *", + "cppClassName": "String", + "jsClassName": "String", + "comment": "Full message for this tag" + }, + { + "name": "force", + "cType": "int", + "cppClassName": "Int32", + "jsClassName": "Number", + "comment": "Overwrite existing references" + } + ], + "isAsync": true, + "isConstructorMethod": false, + "isPrototypeMethod": true, + "jsFunctionName": "createTag", + "cppFunctionName": "CreateTag", + "return": { + "cType": "int", + "cppClassName": "Int32", + "isErrorCode": true, + "comment": "0 on success, GIT_EINVALIDSPEC or an error code A tag object is written to the ODB, and a proper reference is written in the /refs/tags folder, pointing to it", + "jsClassName": "Number" + }, + "description": "

Create a new tag in the repository from an object

\n" + }, + { + "cFunctionName": "git_tag_create_lightweight", + "args": [ + { + "name": "oid", + "cType": "git_oid *", + "cppClassName": "GitOid", + "jsClassName": "Oid", + "isReturn": true, + "shouldAlloc": true, + "comment": "Pointer where to store the OID of the provided target object. If the tag already exists, this parameter will be filled with the oid of the existing pointed object and the function will return a GIT_EEXISTS error code." + }, + { + "name": "repo", + "cType": "git_repository *", + "cppClassName": "GitRepo", + "jsClassName": "Repository", + "isSelf": true, + "comment": "Repository where to store the lightweight tag" + }, + { + "name": "tag_name", + "cType": "const char *", + "cppClassName": "String", + "jsClassName": "String", + "comment": "Name for the tag; this name is validated for consistency. It should also not conflict with an already existing tag name" + }, + { + "name": "target", + "cType": "const git_object *", + "cppClassName": "GitObject", + "jsClassName": "Object", + "comment": "Object to which this tag points. This object must belong to the given `repo`." + }, + { + "name": "force", + "cType": "int", + "cppClassName": "Int32", + "jsClassName": "Number", + "comment": "Overwrite existing references" + } + ], + "isAsync": true, + "isConstructorMethod": true, + "isPrototypeMethod": false, + "jsFunctionName": "createLightweightTag", + "cppFunctionName": "CreateLightweightTag", + "return": { + "cType": "int", + "cppClassName": "Int32", + "isErrorCode": true, + "comment": "0 on success, GIT_EINVALIDSPEC or an error code A proper reference is written in the /refs/tags folder, pointing to the provided target object", + "jsClassName": "Number" + }, + "description": "

Create a new lightweight tag pointing at a target object

\n" + }, + { + "cFunctionName": "git_tree_lookup", + "args": [ + { + "name": "out", + "isReturn": true, + "cType": "git_tree **", + "cppClassName": "GitTree", + "jsClassName": "Tree", + "comment": "Pointer to the looked up tree" + }, + { + "name": "repo", + "cType": "git_repository *", + "cppClassName": "GitRepo", + "jsClassName": "Repository", + "isSelf": true, + "comment": "The repo to use when locating the tree." + }, + { + "name": "id", + "cType": "const git_oid *", + "cppClassName": "GitOid", + "jsClassName": "Oid", + "comment": "Identity of the tree to locate." + } + ], + "isAsync": true, + "isConstructorMethod": false, + "isPrototypeMethod": true, + "jsFunctionName": "getTree", + "cppFunctionName": "GetTree", + "return": { + "cType": "int", + "cppClassName": "Int32", + "isErrorCode": true, + "comment": "0 or an error code", + "jsClassName": "Number" + }, + "description": "

Lookup a tree object from the repository.

\n" + }, + { + "cFunctionName": "git_tree_lookup_prefix", + "args": [ + { + "name": "out", + "isReturn": true, + "cType": "git_tree **", + "cppClassName": "GitTree", + "jsClassName": "Tree", + "comment": "pointer to the looked up tree" + }, + { + "name": "repo", + "cType": "git_repository *", + "cppClassName": "GitRepo", + "jsClassName": "Repository", + "isSelf": true, + "comment": "the repo to use when locating the tree." + }, + { + "name": "id", + "cType": "const git_oid *", + "cppClassName": "GitOid", + "jsClassName": "Oid", + "comment": "identity of the tree to locate." + }, + { + "name": "len", + "cType": "size_t", + "cppClassName": "Uint32", + "jsClassName": "Number", + "comment": "the length of the short identifier" + } + ], + "ignore": true, + "isAsync": true, + "isConstructorMethod": false, + "isPrototypeMethod": true, + "jsFunctionName": "getTreeByPrefix", + "cppFunctionName": "GetTreeByPrefix", + "return": { + "cType": "int", + "cppClassName": "Int32", + "isErrorCode": true, + "comment": "0 or an error code", + "jsClassName": "Number" + }, + "description": "

Lookup a tree object from the repository,\ngiven a prefix of its identifier (short id).

\n" + }, + { + "cFunctionName": "git_submodule_reload_all", + "args": [ + { + "name": "repo", + "cType": "git_repository *", + "cppClassName": "GitRepo", + "jsClassName": "Repository", + "isSelf": true + } + ], + "isAsync": true, + "isConstructorMethod": false, + "isPrototypeMethod": false, + "jsFunctionName": "reloadSubmodules", + "cppFunctionName": "ReloadSubmodules", + "return": { + "cType": "int", + "cppClassName": "Int32", + "isErrorCode": true, + "jsClassName": "Number" + }, + "description": "

Reread all submodule info.

\n" + }, + { + "cFunctionName": "git_tag_delete", + "args": [ + { + "name": "repo", + "cType": "git_repository *", + "cppClassName": "GitRepo", + "jsClassName": "Repository", + "isSelf": true, + "comment": "Repository where lives the tag" + }, + { + "name": "tag_name", + "cType": "const char *", + "cppClassName": "String", + "jsClassName": "String", + "comment": "Name of the tag to be deleted; this name is validated for consistency." + } + ], + "isAsync": true, + "isConstructorMethod": false, + "isPrototypeMethod": true, + "jsFunctionName": "delete", + "cppFunctionName": "Delete", + "return": { + "cType": "int", + "cppClassName": "Int32", + "isErrorCode": true, + "comment": "0 on success, GIT_EINVALIDSPEC or an error code", + "jsClassName": "Number" + }, + "description": "

Delete an existing tag reference.

\n" + }, + { + "cFunctionName": "git_tag_list", + "args": [ + { + "name": "tag_names", + "cType": "git_strarray *", + "cppClassName": "Array", + "jsClassName": "Array", + "isReturn": true, + "comment": "Pointer to a git_strarray structure where the tag names will be stored" + }, + { + "name": "repo", + "cType": "git_repository *", + "cppClassName": "GitRepo", + "jsClassName": "Repository", + "isSelf": true, + "comment": "Repository where to find the tags" + } + ], + "ignore": true, + "isAsync": true, + "isConstructorMethod": false, + "isPrototypeMethod": true, + "jsFunctionName": "listTags", + "cppFunctionName": "ListTags", + "return": { + "cType": "int", + "cppClassName": "Int32", + "isErrorCode": true, + "comment": "0 or an error code", + "jsClassName": "Number" + }, + "description": "

Fill a list with all the tags in the Repository

\n" + }, + { + "cFunctionName": "git_tag_list_match", + "args": [ + { + "name": "tag_names", + "cType": "git_strarray *", + "cppClassName": "Strarray", + "jsClassName": "Strarray", + "isReturn": true, + "comment": "Pointer to a git_strarray structure where the tag names will be stored" + }, + { + "name": "pattern", + "cType": "const char *", + "cppClassName": "String", + "jsClassName": "String", + "comment": "Standard fnmatch pattern" + }, + { + "name": "repo", + "cType": "git_repository *", + "cppClassName": "GitRepo", + "jsClassName": "Repository", + "isSelf": true, + "comment": "Repository where to find the tags" + } + ], + "ignore": true, + "isAsync": true, + "isConstructorMethod": false, + "isPrototypeMethod": true, + "jsFunctionName": "listMatch", + "cppFunctionName": "ListMatch", + "return": { + "cType": "int", + "cppClassName": "Int32", + "isErrorCode": true, + "comment": "0 or an error code", + "jsClassName": "Number" + }, + "description": "

Fill a list with all the tags in the Repository\nwhich name match a defined pattern

\n" + }, + { + "cFunctionName": "git_tag_foreach", + "args": [ + { + "name": "repo", + "cType": "git_repository *", + "cppClassName": "GitRepo", + "jsClassName": "Repository", + "comment": "Repository" + }, + { + "name": "callback", + "cType": "git_tag_foreach_cb", + "cppClassName": "TagForeachCb", + "jsClassName": "TagForeachCb", + "comment": "Callback function" + }, + { + "name": "payload", + "cType": "void *", + "cppClassName": "void", + "jsClassName": "void", + "comment": "Pointer to callback data (optional)" + } + ], + "ignore": true, + "isAsync": false, + "isConstructorMethod": false, + "isPrototypeMethod": false, + "jsFunctionName": "foreach", + "cppFunctionName": "Foreach", + "return": { + "cType": "int", + "cppClassName": "Int32", + "isErrorCode": true, + "jsClassName": "Number" + }, + "description": "

Call callback `cb' for each tag in the repository

\n" + }, + { + "cFunctionName": "git_reference_list", + "args": [ + { + "name": "array", + "cType": "git_strarray *", + "cppClassName": "Array", + "jsClassName": "Array", + "freeFunctionName": "git_strarray_free", + "size": "count", + "key": "strings", + "shouldAlloc": true, + "isReturn": true, + "comment": "Pointer to a git_strarray structure where the reference names will be stored" + }, + { + "name": "repo", + "cType": "git_repository *", + "cppClassName": "GitRepo", + "jsClassName": "Repository", + "isSelf": true, + "comment": "Repository where to find the refs" + }, + { + "name": "list_flags", + "cType": "unsigned int", + "cppClassName": "Uint32", + "jsClassName": "Number", + "isOptional": true + } + ], + "isAsync": true, + "isConstructorMethod": false, + "isPrototypeMethod": true, + "jsFunctionName": "getReferences", + "cppFunctionName": "GetReferences", + "return": { + "cType": "int", + "cppClassName": "Int32", + "isErrorCode": true, + "comment": "0 or an error code", + "jsClassName": "Number" + }, + "description": "

Fill a list with all the references that can be found in a repository.

\n" + }, + { + "cFunctionName": "git_blob_create_frombuffer", + "args": [ + { + "name": "oid", + "cType": "git_oid *", + "cppClassName": "GitOid", + "jsClassName": "Oid", + "shouldAlloc": true, + "isReturn": true, + "comment": "return the oid of the written blob" + }, + { + "name": "repo", + "cType": "git_repository *", + "cppClassName": "GitRepo", + "jsClassName": "Repository", + "isSelf": true, + "comment": "repository where to blob will be written" + }, + { + "name": "buffer", + "cType": "const void *", + "cppClassName": "Buffer", + "jsClassName": "Buffer", + "comment": "data to be written into the blob" + }, + { + "name": "len", + "cType": "size_t", + "cppClassName": "Number", + "jsClassName": "Number", + "comment": "length of the data" + } + ], + "isAsync": true, + "isConstructorMethod": false, + "isPrototypeMethod": true, + "jsFunctionName": "createBlobFromBuffer", + "cppFunctionName": "CreateBlobFromBuffer", + "return": { + "cType": "int", + "cppClassName": "Int32", + "isErrorCode": true, + "comment": "0 or an error code", + "jsClassName": "Number" + }, + "description": "

Write an in-memory buffer to the ODB as a blob

\n" + }, + { + "cFunctionName": "git_blob_create_fromworkdir", + "args": [ + { + "name": "id", + "cType": "git_oid *", + "cppClassName": "GitOid", + "jsClassName": "Oid", + "shouldAlloc": true, + "isReturn": true, + "comment": "return the id of the written blob" + }, + { + "name": "repo", + "cType": "git_repository *", + "cppClassName": "GitRepo", + "jsClassName": "Repository", + "isSelf": true, + "comment": "repository where the blob will be written. this repository cannot be bare" + }, + { + "name": "relative_path", + "cType": "const char *", + "cppClassName": "String", + "jsClassName": "String", + "comment": "file from which the blob will be created, relative to the repository's working dir" + } + ], + "ignore": true, + "isAsync": false, + "isConstructorMethod": false, + "isPrototypeMethod": true, + "jsFunctionName": "createBlobFromWorkdir", + "cppFunctionName": "CreateBlobFromWorkdir", + "return": { + "cType": "int", + "cppClassName": "Int32", + "isErrorCode": true, + "comment": "0 or an error code", + "jsClassName": "Number" + }, + "description": "

Read a file from the working folder of a repository\nand write it to the Object Database as a loose blob

\n" + }, + { + "cFunctionName": "git_blob_create_fromdisk", + "args": [ + { + "name": "id", + "cType": "git_oid *", + "cppClassName": "GitOid", + "jsClassName": "Oid", + "shouldAlloc": true, + "isReturn": true, + "comment": "return the id of the written blob" + }, + { + "name": "repo", + "cType": "git_repository *", + "cppClassName": "GitRepo", + "jsClassName": "Repository", + "isSelf": true, + "comment": "repository where the blob will be written. this repository can be bare or not" + }, + { + "name": "path", + "cType": "const char *", + "cppClassName": "String", + "jsClassName": "String", + "comment": "file from which the blob will be created" + } + ], + "isAsync": true, + "isConstructorMethod": false, + "isPrototypeMethod": true, + "jsFunctionName": "createBlobFromFile", + "cppFunctionName": "CreateBlobFromFile", + "return": { + "cType": "int", + "cppClassName": "Int32", + "isErrorCode": true, + "comment": "0 or an error code", + "jsClassName": "Number" + }, + "description": "

Read a file from the filesystem and write its content\nto the Object Database as a loose blob

\n" + }, + { + "cFunctionName": "git_blob_create_fromchunks", + "args": [ + { + "name": "id", + "cType": "git_oid *", + "cppClassName": "GitOid", + "jsClassName": "Oid", + "shouldAlloc": true, + "isReturn": true, + "comment": "Return the id of the written blob" + }, + { + "name": "repo", + "cType": "git_repository *", + "cppClassName": "GitRepo", + "jsClassName": "Repository", + "isSelf": true, + "comment": "repository where the blob will be written. This repository can be bare or not." + }, + { + "name": "hintpath", + "cType": "const char *", + "cppClassName": "String", + "jsClassName": "String", + "comment": "if not NULL, will help selecting the filters to apply onto the content of the blob to be created." + }, + { + "name": "callback", + "cType": "git_blob_chunk_cb", + "cppClassName": "BlobChunkCb", + "jsClassName": "BlobChunkCb" + }, + { + "name": "payload", + "cType": "void *", + "cppClassName": "void", + "jsClassName": "void" + } + ], + "ignore": true, + "isAsync": false, + "isConstructorMethod": false, + "isPrototypeMethod": true, + "jsFunctionName": "createBlobFromChunks", + "cppFunctionName": "CreateBlobFromChunks", + "return": { + "cType": "int", + "cppClassName": "Int32", + "isErrorCode": true, + "comment": "0 or an error code", + "jsClassName": "Number" + }, + "description": "

Write a loose blob to the Object Database from a\nprovider of chunks of data.

\n" + }, + { + "cFunctionName": "git_remote_list", + "args": [ + { + "name": "out", + "cType": "git_strarray *", + "cppClassName": "Array", + "jsClassName": "Array", + "freeFunctionName": "git_strarray_free", + "size": "count", + "key": "strings", + "shouldAlloc": true, + "isReturn": true, + "comment": "a string array which receives the names of the remotes" + }, + { + "name": "repo", + "cType": "git_repository *", + "cppClassName": "GitRepo", + "jsClassName": "Repository", + "isSelf": true, + "comment": "the repository to query" + } + ], + "isAsync": true, + "isConstructorMethod": false, + "isPrototypeMethod": true, + "jsFunctionName": "getRemotes", + "cppFunctionName": "GetRemotes", + "return": { + "cType": "int", + "cppClassName": "Int32", + "isErrorCode": true, + "comment": "0 or an error code", + "jsClassName": "Number" + }, + "description": "

Get a list of the configured remotes for a repo

\n" + }, + { + "cFunctionName": "git_clone", + "args": [ + { + "name": "out", + "isReturn": true, + "cType": "git_repository **", + "cppClassName": "GitRepo", + "jsClassName": "Repository", + "comment": "pointer that will receive the resulting repository object" + }, + { + "name": "url", + "cType": "const char *", + "cppClassName": "String", + "jsClassName": "String", + "comment": "the remote repository to clone" + }, + { + "name": "local_path", + "cType": "const char *", + "cppClassName": "String", + "jsClassName": "String", + "comment": "local directory to clone to" + }, + { + "name": "options", + "cType": "const git_clone_options *", + "cppClassName": "GitCloneOptions", + "jsClassName": "CloneOptions", + "isOptional": true, + "comment": "configuration options for the clone. If NULL, the function works as though GIT_OPTIONS_INIT were passed." + } + ], + "isAsync": true, + "isConstructorMethod": true, + "isPrototypeMethod": false, + "jsFunctionName": "clone", + "cppFunctionName": "Clone", + "return": { + "cType": "int", + "cppClassName": "Int32", + "isErrorCode": true, + "comment": "0 on success, GIT_ERROR otherwise (use giterr_last for information about the error)", + "jsClassName": "Number" + }, + "description": "

Clone a remote repository, and checkout the branch pointed to by the remote\nHEAD.

\n" + }, + { + "cFunctionName": "git_remote_load", + "args": [ + { + "name": "out", + "isReturn": true, + "cType": "git_remote **", + "cppClassName": "GitRemote", + "jsClassName": "Remote", + "comment": "pointer to the new remote object" + }, + { + "name": "repo", + "cType": "git_repository *", + "cppClassName": "GitRepo", + "jsClassName": "Repository", + "isSelf": true, + "comment": "the associated repository" + }, + { + "name": "name", + "cType": "const char *", + "cppClassName": "String", + "jsClassName": "String", + "comment": "the remote's name" + } + ], + "isAsync": false, + "isConstructorMethod": false, + "isPrototypeMethod": true, + "jsFunctionName": "getRemote", + "cppFunctionName": "GetRemote", + "return": { + "cType": "int", + "cppClassName": "Int32", + "isErrorCode": true, + "comment": "0, GIT_ENOTFOUND, GIT_EINVALIDSPEC or an error code", + "jsClassName": "Number" + }, + "description": "

Get the information for a particular remote

\n" + } + ] + }, + { + "filename": "reset.h", + "ignore": true, + "jsClassName": "Reset", + "cppClassName": "Reset", + "cType": "git_reset", + "freeFunctionName": "git_reset_free", + "functions": [ + { + "cFunctionName": "git_reset", + "args": [ + { + "name": "repo", + "cType": "git_repository *", + "cppClassName": "GitRepo", + "jsClassName": "Repository", + "comment": "Repository where to perform the reset operation." + }, + { + "name": "target", + "cType": "git_object *", + "cppClassName": "GitObject", + "jsClassName": "Object", + "comment": "Committish to which the Head should be moved to. This object must belong to the given `repo` and can either be a git_commit or a git_tag. When a git_tag is being passed, it should be dereferencable to a git_commit which oid will be used as the target of the branch." + }, + { + "name": "reset_type", + "cType": "git_reset_t", + "cppClassName": "ResetT", + "jsClassName": "ResetT", + "comment": "Kind of reset operation to perform." + } + ], + "isAsync": false, + "isConstructorMethod": false, + "isPrototypeMethod": false, + "jsFunctionName": "gitReset", + "cppFunctionName": "GitReset", + "return": { + "cType": "int", + "cppClassName": "Int32", + "isErrorCode": true, + "comment": "0 on success or an error code", + "jsClassName": "Number" + }, + "description": "

Sets the current head to the specified commit oid and optionally\nresets the index and working tree to match.

\n" + }, + { + "cFunctionName": "git_reset_default", + "args": [ + { + "name": "repo", + "cType": "git_repository *", + "cppClassName": "GitRepo", + "jsClassName": "Repository", + "comment": "Repository where to perform the reset operation." + }, + { + "name": "target", + "cType": "git_object *", + "cppClassName": "GitObject", + "jsClassName": "Object", + "comment": "The committish which content will be used to reset the content of the index." + }, + { + "name": "pathspecs", + "cType": "git_strarray*", + "cppClassName": "Strarray*", + "jsClassName": "Strarray*", + "comment": "List of pathspecs to operate on." + } + ], + "isAsync": false, + "isConstructorMethod": false, + "isPrototypeMethod": false, + "jsFunctionName": "default", + "cppFunctionName": "Default", + "return": { + "cType": "int", + "cppClassName": "Int32", + "isErrorCode": true, + "comment": "0 on success or an error code < 0", + "jsClassName": "Number" + }, + "description": "

Updates some entries in the index from the target commit tree.

\n" + } + ] + }, + { + "filename": "revparse.h", + "ignore": true, + "jsClassName": "Revparse", + "cppClassName": "Revparse", + "cType": "git_revparse", + "freeFunctionName": "git_revparse_free", + "functions": [ + { + "cFunctionName": "git_revparse_single", + "args": [ + { + "name": "out", + "isReturn": true, + "cType": "git_object **", + "cppClassName": "GitObject", + "jsClassName": "Object", + "comment": "pointer to output object" + }, + { + "name": "repo", + "cType": "git_repository *", + "cppClassName": "GitRepo", + "jsClassName": "Repository", + "comment": "the repository to search in" + }, + { + "name": "spec", + "cType": "const char *", + "cppClassName": "String", + "jsClassName": "String", + "comment": "the textual specification for an object" + } + ], + "isAsync": false, + "isConstructorMethod": false, + "isPrototypeMethod": false, + "jsFunctionName": "single", + "cppFunctionName": "Single", + "return": { + "cType": "int", + "cppClassName": "Int32", + "isErrorCode": true, + "comment": "0 on success, GIT_ENOTFOUND, GIT_EAMBIGUOUS, GIT_EINVALIDSPEC or an error code", + "jsClassName": "Number" + }, + "description": "

Find a single object, as specified by a revision string. See man gitrevisions,\nor http://git-scm.com/docs/git-rev-parse.html#_specifying_revisions for\ninformation on the syntax accepted.

\n" + }, + { + "cFunctionName": "git_revparse", + "args": [ + { + "name": "revspec", + "cType": "git_revspec *", + "cppClassName": "Revspec", + "jsClassName": "Revspec", + "comment": "Pointer to an user-allocated git_revspec struct where the result of the rev-parse will be stored" + }, + { + "name": "repo", + "cType": "git_repository *", + "cppClassName": "GitRepo", + "jsClassName": "Repository", + "comment": "the repository to search in" + }, + { + "name": "spec", + "cType": "const char *", + "cppClassName": "String", + "jsClassName": "String", + "comment": "the rev-parse spec to parse" + } + ], + "isAsync": false, + "isConstructorMethod": false, + "isPrototypeMethod": false, + "jsFunctionName": "gitRevparse", + "cppFunctionName": "GitRevparse", + "return": { + "cType": "int", + "cppClassName": "Int32", + "isErrorCode": true, + "comment": "0 on success, GIT_INVALIDSPEC, GIT_ENOTFOUND, GIT_EAMBIGUOUS or an error code", + "jsClassName": "Number" + }, + "description": "

Parse a revision string for from, to, and intent. See man gitrevisions or\nhttp://git-scm.com/docs/git-rev-parse.html#_specifying_revisions for information\non the syntax accepted.

\n" + } + ] + }, + { + "filename": "revwalk.h", + "dependencies": [ + "../include/oid.h", + "../include/repo.h" + ], + "jsClassName": "RevWalk", + "cppClassName": "GitRevWalk", + "cType": "git_revwalk", + "freeFunctionName": "git_revwalk_free", + "functions": [ + { + "cFunctionName": "git_revwalk_reset", + "args": [ + { + "name": "walker", + "cType": "git_revwalk *", + "cppClassName": "GitRevWalk", + "jsClassName": "RevWalk", + "isSelf": true, + "comment": "handle to reset." + } + ], + "isAsync": false, + "isConstructorMethod": false, + "isPrototypeMethod": true, + "jsFunctionName": "reset", + "cppFunctionName": "Reset", + "return": { + "cType": "void", + "cppClassName": "void", + "jsClassName": "void" + }, + "description": "

Reset the revision walker for reuse.

\n" + }, + { + "cFunctionName": "git_revwalk_push", + "args": [ + { + "name": "walk", + "cType": "git_revwalk *", + "cppClassName": "GitRevWalk", + "jsClassName": "RevWalk", + "isSelf": true, + "comment": "the walker being used for the traversal." + }, + { + "name": "id", + "cType": "const git_oid *", + "cppClassName": "GitOid", + "jsClassName": "Oid", + "comment": "the oid of the commit to start from." + } + ], + "isAsync": true, + "isConstructorMethod": false, + "isPrototypeMethod": true, + "jsFunctionName": "push", + "cppFunctionName": "Push", + "return": { + "cType": "int", + "cppClassName": "Int32", + "isErrorCode": true, + "comment": "0 or an error code", + "jsClassName": "Number" + }, + "description": "

Mark a commit to start traversal from.

\n" + }, + { + "cFunctionName": "git_revwalk_push_glob", + "args": [ + { + "name": "walk", + "cType": "git_revwalk *", + "cppClassName": "GitRevWalk", + "jsClassName": "RevWalk", + "isSelf": true, + "comment": "the walker being used for the traversal" + }, + { + "name": "glob", + "cType": "const char *", + "cppClassName": "String", + "jsClassName": "String", + "comment": "the glob pattern references should match" + } + ], + "isAsync": true, + "isConstructorMethod": false, + "isPrototypeMethod": true, + "jsFunctionName": "pushGlob", + "cppFunctionName": "PushGlob", + "return": { + "cType": "int", + "cppClassName": "Int32", + "isErrorCode": true, + "comment": "0 or an error code", + "jsClassName": "Number" + }, + "description": "

Push matching references

\n" + }, + { + "cFunctionName": "git_revwalk_push_head", + "args": [ + { + "name": "walk", + "cType": "git_revwalk *", + "cppClassName": "GitRevWalk", + "jsClassName": "RevWalk", + "isSelf": true, + "comment": "the walker being used for the traversal" + } + ], + "isAsync": true, + "isConstructorMethod": false, + "isPrototypeMethod": true, + "jsFunctionName": "pushHead", + "cppFunctionName": "PushHead", + "return": { + "cType": "int", + "cppClassName": "Int32", + "isErrorCode": true, + "comment": "0 or an error code", + "jsClassName": "Number" + }, + "description": "

Push the repository's HEAD

\n" + }, + { + "cFunctionName": "git_revwalk_hide", + "args": [ + { + "name": "walk", + "cType": "git_revwalk *", + "cppClassName": "GitRevWalk", + "jsClassName": "RevWalk", + "isSelf": true, + "comment": "the walker being used for the traversal." + }, + { + "name": "commit_id", + "cType": "const git_oid *", + "cppClassName": "GitOid", + "jsClassName": "Oid", + "comment": "the oid of commit that will be ignored during the traversal" + } + ], + "isAsync": true, + "isConstructorMethod": false, + "isPrototypeMethod": true, + "jsFunctionName": "hide", + "cppFunctionName": "Hide", + "return": { + "cType": "int", + "cppClassName": "Int32", + "isErrorCode": true, + "comment": "0 or an error code", + "jsClassName": "Number" + }, + "description": "

Mark a commit (and its ancestors) uninteresting for the output.

\n" + }, + { + "cFunctionName": "git_revwalk_hide_glob", + "args": [ + { + "name": "walk", + "cType": "git_revwalk *", + "cppClassName": "GitRevWalk", + "jsClassName": "RevWalk", + "isSelf": true, + "comment": "the walker being used for the traversal" + }, + { + "name": "glob", + "cType": "const char *", + "cppClassName": "String", + "jsClassName": "String", + "comment": "the glob pattern references should match" + } + ], + "isAsync": true, + "isConstructorMethod": false, + "isPrototypeMethod": true, + "jsFunctionName": "hideGlob", + "cppFunctionName": "HideGlob", + "return": { + "cType": "int", + "cppClassName": "Int32", + "isErrorCode": true, + "comment": "0 or an error code", + "jsClassName": "Number" + }, + "description": "

Hide matching references.

\n" + }, + { + "cFunctionName": "git_revwalk_hide_head", + "args": [ + { + "name": "walk", + "cType": "git_revwalk *", + "cppClassName": "GitRevWalk", + "jsClassName": "RevWalk", + "isSelf": true, + "comment": "the walker being used for the traversal" + } + ], + "isAsync": true, + "isConstructorMethod": false, + "isPrototypeMethod": true, + "jsFunctionName": "hideHead", + "cppFunctionName": "HideHead", + "return": { + "cType": "int", + "cppClassName": "Int32", + "isErrorCode": true, + "comment": "0 or an error code", + "jsClassName": "Number" + }, + "description": "

Hide the repository's HEAD

\n" + }, + { + "cFunctionName": "git_revwalk_push_ref", + "args": [ + { + "name": "walk", + "cType": "git_revwalk *", + "cppClassName": "GitRevWalk", + "jsClassName": "RevWalk", + "isSelf": true, + "comment": "the walker being used for the traversal" + }, + { + "name": "refname", + "cType": "const char *", + "cppClassName": "String", + "jsClassName": "String", + "comment": "the reference to push" + } + ], + "isAsync": true, + "isConstructorMethod": false, + "isPrototypeMethod": true, + "jsFunctionName": "pushRef", + "cppFunctionName": "PushRef", + "return": { + "cType": "int", + "cppClassName": "Int32", + "isErrorCode": true, + "comment": "0 or an error code", + "jsClassName": "Number" + }, + "description": "

Push the OID pointed to by a reference

\n" + }, + { + "cFunctionName": "git_revwalk_hide_ref", + "args": [ + { + "name": "walk", + "cType": "git_revwalk *", + "cppClassName": "GitRevWalk", + "jsClassName": "RevWalk", + "isSelf": true, + "comment": "the walker being used for the traversal" + }, + { + "name": "refname", + "cType": "const char *", + "cppClassName": "String", + "jsClassName": "String", + "comment": "the reference to hide" + } + ], + "isAsync": true, + "isConstructorMethod": false, + "isPrototypeMethod": true, + "jsFunctionName": "hideRef", + "cppFunctionName": "HideRef", + "return": { + "cType": "int", + "cppClassName": "Int32", + "isErrorCode": true, + "comment": "0 or an error code", + "jsClassName": "Number" + }, + "description": "

Hide the OID pointed to by a reference

\n" + }, + { + "cFunctionName": "git_revwalk_next", + "args": [ + { + "name": "out", + "isReturn": true, + "cType": "git_oid *", + "shouldAlloc": true, + "cppClassName": "GitOid", + "jsClassName": "Oid", + "comment": "Pointer where to store the oid of the next commit" + }, + { + "name": "walk", + "cType": "git_revwalk *", + "cppClassName": "GitRevWalk", + "jsClassName": "RevWalk", + "isSelf": true, + "comment": "the walker to pop the commit from." + } + ], + "isAsync": true, + "isConstructorMethod": false, + "isPrototypeMethod": true, + "jsFunctionName": "next", + "cppFunctionName": "Next", + "return": { + "cType": "int", + "cppClassName": "Int32", + "isErrorCode": true, + "comment": "0 if the next commit was found; GIT_ITEROVER if there are no commits left to iterate", + "jsClassName": "Number" + }, + "description": "

Get the next commit from the revision walk.

\n" + }, + { + "cFunctionName": "git_revwalk_sorting", + "args": [ + { + "name": "walk", + "cType": "git_revwalk *", + "cppClassName": "GitRevWalk", + "jsClassName": "RevWalk", + "isSelf": true, + "comment": "the walker being used for the traversal." + }, + { + "name": "sort_mode", + "cType": "unsigned int", + "cppClassName": "Uint32", + "jsClassName": "Number", + "comment": "combination of GIT_SORT_XXX flags" + } + ], + "isAsync": false, + "isConstructorMethod": false, + "isPrototypeMethod": true, + "jsFunctionName": "sorting", + "cppFunctionName": "Sorting", + "return": { + "cType": "void", + "cppClassName": "void", + "jsClassName": "void" + }, + "description": "

Change the sorting mode when iterating through the\nrepository's contents.

\n" + }, + { + "cFunctionName": "git_revwalk_push_range", + "args": [ + { + "name": "walk", + "cType": "git_revwalk *", + "cppClassName": "GitRevWalk", + "jsClassName": "RevWalk", + "isSelf": true, + "comment": "the walker being used for the traversal" + }, + { + "name": "range", + "cType": "const char *", + "cppClassName": "String", + "jsClassName": "String", + "comment": "the range" + } + ], + "ignore": "This is in the documentation, but doesn't seem to exist!", + "isAsync": true, + "isConstructorMethod": false, + "isPrototypeMethod": true, + "jsFunctionName": "pushRange", + "cppFunctionName": "PushRange", + "return": { + "cType": "int", + "cppClassName": "Int32", + "isErrorCode": true, + "comment": "0 or an error code", + "jsClassName": "Number" + }, + "description": "

Push and hide the respective endpoints of the given range.

\n" + }, + { + "cFunctionName": "git_revwalk_free", + "args": [ + { + "name": "walk", + "cType": "git_revwalk *", + "cppClassName": "GitRevWalk", + "jsClassName": "RevWalk", + "comment": "traversal handle to close. If NULL nothing occurs." + } + ], + "ignore": true, + "isAsync": false, + "isConstructorMethod": false, + "isPrototypeMethod": false, + "isFree": true, + "jsFunctionName": "free", + "cppFunctionName": "Free", + "return": { + "cType": "void", + "cppClassName": "void", + "jsClassName": "void" + }, + "description": "

Free a revision walker previously allocated.

\n" + }, + { + "cFunctionName": "git_revwalk_repository", + "args": [ + { + "name": "walk", + "cType": "git_revwalk *", + "cppClassName": "GitRevWalk", + "jsClassName": "RevWalk", + "isSelf": true, + "comment": "the revision walker" + } + ], + "ignore": "Never make public for memory allocation reasons", + "isAsync": false, + "isConstructorMethod": false, + "isPrototypeMethod": true, + "jsFunctionName": "repository", + "cppFunctionName": "Repository", + "return": { + "cType": "git_repository *", + "cppClassName": "GitRepo", + "comment": "the repository being walked", + "jsClassName": "Repository" + }, + "description": "

Return the repository on which this walker\nis operating.

\n" + } + ] + }, + { + "filename": "time.h", + "dependencies": [], + "jsClassName": "Time", + "cppClassName": "GitTime", + "cType": "git_time", + "freeFunctionName": "free", + "fields": [ + { + "jsFunctionName": "time", + "cppFunctionName": "Time", + "name": "time", + "cType": "git_time_t", + "cppClassName": "Integer", + "jsClassName": "Number" + }, + { + "jsFunctionName": "offset", + "cppFunctionName": "Offset", + "name": "offset", + "cType": "int", + "cppClassName": "Int32", + "jsClassName": "Number" + } + ] + }, + { + "filename": "signature.h", + "dependencies": [ + "../include/time.h" + ], + "jsClassName": "Signature", + "cppClassName": "GitSignature", + "cType": "git_signature", + "freeFunctionName": "git_signature_free", + "fields": [ + { + "jsFunctionName": "name", + "cppFunctionName": "Name", + "name": "name", + "cType": "const char *", + "cppClassName": "String", + "jsClassName": "String" + }, + { + "jsFunctionName": "email", + "cppFunctionName": "Email", + "name": "email", + "cType": "const char *", + "cppClassName": "String", + "jsClassName": "String" + }, + { + "jsFunctionName": "time", + "cppFunctionName": "Time", + "name": "when", + "cType": "git_time", + "cppClassName": "GitTime", + "jsClassName": "Time", + "copy": "git_time_dup" + } + ], + "functions": [ + { + "cFunctionName": "git_signature_new", + "args": [ + { + "name": "out", + "isReturn": true, + "cType": "git_signature **", + "cppClassName": "GitSignature", + "jsClassName": "Signature", + "comment": "new signature, in case of error NULL" + }, + { + "name": "name", + "cType": "const char *", + "cppClassName": "String", + "jsClassName": "String", + "comment": "name of the person" + }, + { + "name": "email", + "cType": "const char *", + "cppClassName": "String", + "jsClassName": "String", + "comment": "email of the person" + }, + { + "name": "time", + "cType": "git_time_t", + "cppClassName": "Int32", + "jsClassName": "Number", + "comment": "time when the action happened" + }, + { + "name": "offset", + "cType": "int", + "cppClassName": "Int32", + "jsClassName": "Number", + "comment": "timezone offset in minutes for the time" + } + ], + "isAsync": false, + "isConstructorMethod": true, + "isPrototypeMethod": false, + "jsFunctionName": "create", + "cppFunctionName": "Create", + "return": { + "cType": "int", + "cppClassName": "Int32", + "isErrorCode": true, + "comment": "0 or an error code", + "jsClassName": "Number" + }, + "description": "

Create a new action signature.

\n" + }, + { + "cFunctionName": "git_signature_now", + "args": [ + { + "name": "out", + "isReturn": true, + "cType": "git_signature **", + "cppClassName": "GitSignature", + "jsClassName": "Signature", + "comment": "new signature, in case of error NULL" + }, + { + "name": "name", + "cType": "const char *", + "cppClassName": "String", + "jsClassName": "String", + "comment": "name of the person" + }, + { + "name": "email", + "cType": "const char *", + "cppClassName": "String", + "jsClassName": "String", + "comment": "email of the person" + } + ], + "isAsync": false, + "isConstructorMethod": true, + "isPrototypeMethod": false, + "jsFunctionName": "now", + "cppFunctionName": "Now", + "return": { + "cType": "int", + "cppClassName": "Int32", + "isErrorCode": true, + "comment": "0 or an error code", + "jsClassName": "Number" + }, + "description": "

Create a new action signature with a timestamp of 'now'.

\n" + }, + { + "cFunctionName": "git_signature_dup", + "args": [ + { + "name": "sig", + "cType": "const git_signature *", + "cppClassName": "GitSignature", + "jsClassName": "Signature", + "isSelf": true, + "comment": "signature to duplicated" + } + ], + "ignore": true, + "isAsync": false, + "isConstructorMethod": false, + "isPrototypeMethod": true, + "jsFunctionName": "dup", + "cppFunctionName": "Dup", + "return": { + "cType": "git_signature *", + "cppClassName": "GitSignature", + "comment": "a copy of sig, NULL on out of memory", + "jsClassName": "Signature" + }, + "description": "

Create a copy of an existing signature. All internal strings are also\nduplicated.

\n" + }, + { + "cFunctionName": "git_signature_free", + "args": [ + { + "name": "sig", + "cType": "git_signature *", + "cppClassName": "GitSignature", + "jsClassName": "Signature", + "comment": "signature to free" + } + ], + "ignore": true, + "isAsync": false, + "isConstructorMethod": false, + "isPrototypeMethod": false, + "isFree": true, + "jsFunctionName": "free", + "cppFunctionName": "Free", + "return": { + "cType": "void", + "cppClassName": "void", + "jsClassName": "void" + }, + "description": "

Free an existing signature.

\n" + } + ] + }, + { + "filename": "stash.h", + "ignore": true, + "jsClassName": "Stash", + "cppClassName": "Stash", + "cType": "git_stash", + "freeFunctionName": "git_stash_free", + "functions": [ + { + "cFunctionName": "git_stash_save", + "args": [ + { + "name": "out", + "isReturn": true, + "cType": "git_oid *", + "cppClassName": "GitOid", + "jsClassName": "Oid", + "shouldAlloc": true, + "comment": "Object id of the commit containing the stashed state. This commit is also the target of the direct reference refs/stash." + }, + { + "name": "repo", + "cType": "git_repository *", + "cppClassName": "GitRepo", + "jsClassName": "Repository", + "comment": "The owning repository." + }, + { + "name": "stasher", + "cType": "git_signature *", + "cppClassName": "GitSignature", + "jsClassName": "Signature", + "comment": "The identity of the person performing the stashing." + }, + { + "name": "message", + "cType": "const char *", + "cppClassName": "String", + "jsClassName": "String", + "comment": "Optional description along with the stashed state." + }, + { + "name": "flags", + "cType": "unsigned int", + "cppClassName": "Uint32", + "jsClassName": "Number", + "comment": "Flags to control the stashing process. (see GIT_STASH_* above)" + } + ], + "isAsync": false, + "isConstructorMethod": false, + "isPrototypeMethod": false, + "jsFunctionName": "save", + "cppFunctionName": "Save", + "return": { + "cType": "int", + "cppClassName": "Int32", + "isErrorCode": true, + "comment": "0 on success, GIT_ENOTFOUND where there's nothing to stash, or error code.", + "jsClassName": "Number" + }, + "description": "

Save the local modifications to a new stash.

\n" + }, + { + "cFunctionName": "git_stash_foreach", + "args": [ + { + "name": "repo", + "cType": "git_repository *", + "cppClassName": "GitRepo", + "jsClassName": "Repository", + "comment": "Repository where to find the stash." + }, + { + "name": "callback", + "cType": "git_stash_cb", + "cppClassName": "StashCb", + "jsClassName": "StashCb", + "comment": "Callback to invoke per found stashed state. The most recent stash state will be enumerated first." + }, + { + "name": "payload", + "cType": "void *", + "cppClassName": "void", + "jsClassName": "void", + "comment": "Extra parameter to callback function." + } + ], + "isAsync": false, + "isConstructorMethod": false, + "isPrototypeMethod": false, + "jsFunctionName": "foreach", + "cppFunctionName": "Foreach", + "return": { + "cType": "int", + "cppClassName": "Int32", + "isErrorCode": true, + "comment": "0 on success, GIT_EUSER on non-zero callback, or error code", + "jsClassName": "Number" + }, + "description": "

Loop over all the stashed states and issue a callback for each one.

\n" + }, + { + "cFunctionName": "git_stash_drop", + "args": [ + { + "name": "repo", + "cType": "git_repository *", + "cppClassName": "GitRepo", + "jsClassName": "Repository", + "comment": "The owning repository." + }, + { + "name": "index", + "cType": "size_t", + "cppClassName": "Uint32", + "jsClassName": "Number", + "comment": "The position within the stash list. 0 points to the most recent stashed state." + } + ], + "isAsync": false, + "isConstructorMethod": false, + "isPrototypeMethod": false, + "jsFunctionName": "drop", + "cppFunctionName": "Drop", + "return": { + "cType": "int", + "cppClassName": "Int32", + "isErrorCode": true, + "comment": "0 on success, or error code", + "jsClassName": "Number" + }, + "description": "

Remove a single stashed state from the stash list.

\n" + } + ] + }, + { + "filename": "status.h", + "ignore": true, + "jsClassName": "Status", + "cppClassName": "Status", + "cType": "git_status", + "freeFunctionName": "git_status_free", + "functions": [ + { + "cFunctionName": "git_status_foreach", + "args": [ + { + "name": "repo", + "cType": "git_repository *", + "cppClassName": "GitRepo", + "jsClassName": "Repository", + "comment": "A repository object" + }, + { + "name": "callback", + "cType": "git_status_cb", + "cppClassName": "StatusCb", + "jsClassName": "StatusCb", + "comment": "The function to call on each file" + }, + { + "name": "payload", + "cType": "void *", + "cppClassName": "void", + "jsClassName": "void", + "comment": "Pointer to pass through to callback function" + } + ], + "isAsync": false, + "isConstructorMethod": false, + "isPrototypeMethod": false, + "jsFunctionName": "foreach", + "cppFunctionName": "Foreach", + "return": { + "cType": "int", + "cppClassName": "Int32", + "isErrorCode": true, + "comment": "0 on success, GIT_EUSER on non-zero callback, or error code", + "jsClassName": "Number" + }, + "description": "

Gather file statuses and run a callback for each one.

\n" + }, + { + "cFunctionName": "git_status_foreach_ext", + "args": [ + { + "name": "repo", + "cType": "git_repository *", + "cppClassName": "GitRepo", + "jsClassName": "Repository", + "comment": "Repository object" + }, + { + "name": "opts", + "cType": "const git_status_options *", + "cppClassName": "StatusOptions", + "jsClassName": "StatusOptions", + "comment": "Status options structure" + }, + { + "name": "callback", + "cType": "git_status_cb", + "cppClassName": "StatusCb", + "jsClassName": "StatusCb", + "comment": "The function to call on each file" + }, + { + "name": "payload", + "cType": "void *", + "cppClassName": "void", + "jsClassName": "void", + "comment": "Pointer to pass through to callback function" + } + ], + "isAsync": false, + "isConstructorMethod": false, + "isPrototypeMethod": false, + "jsFunctionName": "foreachExt", + "cppFunctionName": "ForeachExt", + "return": { + "cType": "int", + "cppClassName": "Int32", + "isErrorCode": true, + "comment": "0 on success, GIT_EUSER on non-zero callback, or error code", + "jsClassName": "Number" + }, + "description": "

Gather file status information and run callbacks as requested.

\n" + }, + { + "cFunctionName": "git_status_file", + "args": [ + { + "name": "status_flags", + "cType": "unsigned int *", + "cppClassName": "Int32", + "jsClassName": "Number", + "comment": "The status value for the file" + }, + { + "name": "repo", + "cType": "git_repository *", + "cppClassName": "GitRepo", + "jsClassName": "Repository", + "comment": "A repository object" + }, + { + "name": "path", + "cType": "const char *", + "cppClassName": "String", + "jsClassName": "String", + "comment": "The file to retrieve status for, rooted at the repo's workdir" + } + ], + "isAsync": false, + "isConstructorMethod": false, + "isPrototypeMethod": false, + "jsFunctionName": "file", + "cppFunctionName": "File", + "return": { + "cType": "int", + "cppClassName": "Int32", + "isErrorCode": true, + "comment": "0 on success, GIT_ENOTFOUND if the file is not found in the HEAD, index, and work tree, GIT_EINVALIDPATH if `path` points at a folder, GIT_EAMBIGUOUS if \"path\" matches multiple files, -1 on other error.", + "jsClassName": "Number" + }, + "description": "

Get file status for a single file.

\n" + }, + { + "cFunctionName": "git_status_should_ignore", + "args": [ + { + "name": "ignored", + "cType": "int *", + "cppClassName": "Int32", + "jsClassName": "Number", + "comment": "Boolean returning 0 if the file is not ignored, 1 if it is" + }, + { + "name": "repo", + "cType": "git_repository *", + "cppClassName": "GitRepo", + "jsClassName": "Repository", + "comment": "A repository object" + }, + { + "name": "path", + "cType": "const char *", + "cppClassName": "String", + "jsClassName": "String", + "comment": "The file to check ignores for, rooted at the repo's workdir." + } + ], + "isAsync": false, + "isConstructorMethod": false, + "isPrototypeMethod": false, + "jsFunctionName": "shouldIgnore", + "cppFunctionName": "ShouldIgnore", + "return": { + "cType": "int", + "cppClassName": "Int32", + "isErrorCode": true, + "comment": "0 if ignore rules could be processed for the file (regardless of whether it exists or not), or an error < 0 if they could not.", + "jsClassName": "Number" + }, + "description": "

Test if the ignore rules apply to a given file.

\n" + } + ] + }, + { + "filename": "stdint.h", + "ignore": true, + "jsClassName": "Stdint", + "cppClassName": "Stdint", + "cType": "git_stdint", + "freeFunctionName": "git_stdint_free", + "functions": [] + }, + { + "filename": "strarray.h", + "ignore": true, + "jsClassName": "Strarray", + "cppClassName": "Strarray", + "cType": "git_strarray", + "freeFunctionName": "git_strarray_free", + "functions": [ + { + "cFunctionName": "git_strarray_free", + "args": [ + { + "name": "array", + "cType": "git_strarray *", + "cppClassName": "Strarray", + "jsClassName": "Strarray", + "comment": "git_strarray from which to free string data" + } + ], + "isAsync": false, + "isConstructorMethod": false, + "isPrototypeMethod": false, + "isFree": true, + "jsFunctionName": "free", + "cppFunctionName": "Free", + "return": { + "cType": "void", + "cppClassName": "void", + "jsClassName": "void" + }, + "description": "

Close a string array object

\n" + }, + { + "cFunctionName": "git_strarray_copy", + "args": [ + { + "name": "tgt", + "cType": "git_strarray *", + "cppClassName": "Strarray", + "jsClassName": "Strarray", + "isSelf": true, + "comment": "target" + }, + { + "name": "src", + "cType": "const git_strarray *", + "cppClassName": "Strarray", + "jsClassName": "Strarray", + "comment": "source" + } + ], + "isAsync": false, + "isConstructorMethod": false, + "isPrototypeMethod": true, + "jsFunctionName": "copy", + "cppFunctionName": "Copy", + "return": { + "cType": "int", + "cppClassName": "Int32", + "isErrorCode": true, + "comment": "0 on success, < 0 on allocation failure", + "jsClassName": "Number" + }, + "description": "

Copy a string array object from source to target.

\n" + } + ] + }, + { + "filename": "submodule.h", + "dependencies": [ + "../include/oid.h", + "../include/repo.h" + ], + "jsClassName": "Submodule", + "cppClassName": "GitSubmodule", + "cType": "git_submodule", + "freeFunctionName": "free", + "functions": [ + { + "cFunctionName": "git_submodule_foreach", + "args": [ + { + "name": "repo", + "cType": "git_repository *", + "cppClassName": "GitRepo", + "jsClassName": "Repository", + "comment": "The repository" + }, + { + "name": "callback", + "cType": "int (*)(git_submodule *sm, const char *name, void *payload)", + "cppClassName": "Int32", + "jsClassName": "Number", + "comment": "Function to be called with the name of each submodule. Return a non-zero value to terminate the iteration." + }, + { + "name": "payload", + "cType": "void *", + "cppClassName": "void", + "jsClassName": "void", + "comment": "Extra data to pass to callback" + } + ], + "ignore": true, + "isAsync": false, + "isConstructorMethod": false, + "isPrototypeMethod": false, + "jsFunctionName": "foreach", + "cppFunctionName": "Foreach", + "return": { + "cType": "int", + "cppClassName": "Int32", + "isErrorCode": true, + "comment": "0 on success, -1 on error, or non-zero return value of callback", + "jsClassName": "Number" + }, + "description": "

Iterate over all tracked submodules of a repository.

\n" + }, + { + "cFunctionName": "git_submodule_add_finalize", + "args": [ + { + "name": "submodule", + "cType": "git_submodule *", + "cppClassName": "GitSubmodule", + "jsClassName": "Submodule", + "isSelf": true, + "comment": "The submodule to finish adding." + } + ], + "isAsync": true, + "isConstructorMethod": false, + "isPrototypeMethod": true, + "jsFunctionName": "addFinalize", + "cppFunctionName": "AddFinalize", + "return": { + "cType": "int", + "cppClassName": "Int32", + "isErrorCode": true, + "jsClassName": "Number" + }, + "description": "

Resolve the setup of a new git submodule.

\n" + }, + { + "cFunctionName": "git_submodule_add_to_index", + "args": [ + { + "name": "submodule", + "cType": "git_submodule *", + "cppClassName": "GitSubmodule", + "jsClassName": "Submodule", + "isSelf": true, + "comment": "The submodule to add to the index" + }, + { + "name": "write_index", + "cType": "int", + "cppClassName": "Int32", + "jsClassName": "Number", + "comment": "Boolean if this should immediately write the index file. If you pass this as false, you will have to get the git_index and explicitly call `git_index_write()` on it to save the change." + } + ], + "isAsync": true, + "isConstructorMethod": false, + "isPrototypeMethod": true, + "jsFunctionName": "addToIndex", + "cppFunctionName": "AddToIndex", + "return": { + "cType": "int", + "cppClassName": "Int32", + "isErrorCode": true, + "comment": "0 on success, <0 on failure", + "jsClassName": "Number" + }, + "description": "

Add current submodule HEAD commit to index of superproject.

\n" + }, + { + "cFunctionName": "git_submodule_save", + "args": [ + { + "name": "submodule", + "cType": "git_submodule *", + "cppClassName": "GitSubmodule", + "jsClassName": "Submodule", + "isSelf": true, + "comment": "The submodule to write." + } + ], + "isAsync": true, + "isConstructorMethod": false, + "isPrototypeMethod": true, + "jsFunctionName": "save", + "cppFunctionName": "Save", + "return": { + "cType": "int", + "cppClassName": "Int32", + "isErrorCode": true, + "comment": "0 on success, <0 on failure.", + "jsClassName": "Number" + }, + "description": "

Write submodule settings to .gitmodules file.

\n" + }, + { + "cFunctionName": "git_submodule_owner", + "args": [ + { + "name": "submodule", + "cType": "git_submodule *", + "cppClassName": "GitSubmodule", + "jsClassName": "Submodule", + "isSelf": true, + "comment": "Pointer to submodule object" + } + ], + "ignore": "Never make public for memory allocation reasons", + "isAsync": false, + "isConstructorMethod": false, + "isPrototypeMethod": true, + "jsFunctionName": "owner", + "cppFunctionName": "Owner", + "return": { + "cType": "git_repository *", + "cppClassName": "GitRepo", + "comment": "Pointer to `git_repository`", + "jsClassName": "Repository" + }, + "description": "

Get the containing repository for a submodule.

\n" + }, + { + "cFunctionName": "git_submodule_name", + "args": [ + { + "name": "submodule", + "cType": "git_submodule *", + "cppClassName": "GitSubmodule", + "jsClassName": "Submodule", + "isSelf": true, + "comment": "Pointer to submodule object" + } + ], + "isAsync": false, + "isConstructorMethod": false, + "isPrototypeMethod": true, + "jsFunctionName": "name", + "cppFunctionName": "Name", + "return": { + "cType": "const char *", + "cppClassName": "String", + "comment": "Pointer to the submodule name", + "jsClassName": "String" + }, + "description": "

Get the name of submodule.

\n" + }, + { + "cFunctionName": "git_submodule_path", + "args": [ + { + "name": "submodule", + "cType": "git_submodule *", + "cppClassName": "GitSubmodule", + "jsClassName": "Submodule", + "isSelf": true, + "comment": "Pointer to submodule object" + } + ], + "isAsync": false, + "isConstructorMethod": false, + "isPrototypeMethod": true, + "jsFunctionName": "path", + "cppFunctionName": "Path", + "return": { + "cType": "const char *", + "cppClassName": "String", + "comment": "Pointer to the submodule path", + "jsClassName": "String" + }, + "description": "

Get the path to the submodule.

\n" + }, + { + "cFunctionName": "git_submodule_url", + "args": [ + { + "name": "submodule", + "cType": "git_submodule *", + "cppClassName": "GitSubmodule", + "jsClassName": "Submodule", + "isSelf": true, + "comment": "Pointer to submodule object" + } + ], + "isAsync": false, + "isConstructorMethod": false, + "isPrototypeMethod": true, + "jsFunctionName": "url", + "cppFunctionName": "Url", + "return": { + "cType": "const char *", + "cppClassName": "String", + "comment": "Pointer to the submodule url", + "jsClassName": "String" + }, + "description": "

Get the URL for the submodule.

\n" + }, + { + "cFunctionName": "git_submodule_set_url", + "args": [ + { + "name": "submodule", + "cType": "git_submodule *", + "cppClassName": "GitSubmodule", + "jsClassName": "Submodule", + "isSelf": true, + "comment": "Pointer to the submodule object" + }, + { + "name": "url", + "cType": "const char *", + "cppClassName": "String", + "jsClassName": "String", + "comment": "URL that should be used for the submodule" + } + ], + "isAsync": false, + "isConstructorMethod": false, + "isPrototypeMethod": true, + "jsFunctionName": "setUrl", + "cppFunctionName": "SetUrl", + "return": { + "cType": "int", + "cppClassName": "Int32", + "isErrorCode": true, + "comment": "0 on success, <0 on failure", + "jsClassName": "Number" + }, + "description": "

Set the URL for the submodule.

\n" + }, + { + "cFunctionName": "git_submodule_index_id", + "args": [ + { + "name": "submodule", + "cType": "git_submodule *", + "cppClassName": "GitSubmodule", + "jsClassName": "Submodule", + "isSelf": true, + "comment": "Pointer to submodule object" + } + ], + "isAsync": false, + "isConstructorMethod": false, + "isPrototypeMethod": true, + "jsFunctionName": "indexId", + "cppFunctionName": "IndexId", + "return": { + "cType": "const git_oid *", + "cppClassName": "GitOid", + "copy": "git_oid_dup", + "comment": "Pointer to git_oid or NULL if submodule is not in index.", + "jsClassName": "Oid" + }, + "description": "

Get the OID for the submodule in the index.

\n" + }, + { + "cFunctionName": "git_submodule_head_id", + "args": [ + { + "name": "submodule", + "cType": "git_submodule *", + "cppClassName": "GitSubmodule", + "jsClassName": "Submodule", + "isSelf": true, + "comment": "Pointer to submodule object" + } + ], + "isAsync": false, + "isConstructorMethod": false, + "isPrototypeMethod": true, + "jsFunctionName": "headId", + "cppFunctionName": "HeadId", + "return": { + "cType": "const git_oid *", + "cppClassName": "GitOid", + "copy": "git_oid_dup", + "comment": "Pointer to git_oid or NULL if submodule is not in the HEAD.", + "jsClassName": "Oid" + }, + "description": "

Get the OID for the submodule in the current HEAD tree.

\n" + }, + { + "cFunctionName": "git_submodule_wd_id", + "args": [ + { + "name": "submodule", + "cType": "git_submodule *", + "cppClassName": "GitSubmodule", + "jsClassName": "Submodule", + "isSelf": true, + "comment": "Pointer to submodule object" + } + ], + "ignore": true, + "isAsync": false, + "isConstructorMethod": false, + "isPrototypeMethod": true, + "jsFunctionName": "wdId", + "cppFunctionName": "WdId", + "return": { + "cType": "const git_oid *", + "cppClassName": "GitOid", + "copy": "git_oid_dup", + "comment": "Pointer to git_oid or NULL if submodule is not checked out.", + "jsClassName": "Oid" + }, + "description": "

Get the OID for the submodule in the current working directory.

\n" + }, + { + "cFunctionName": "git_submodule_ignore", + "args": [], + "ignore": true, + "isAsync": true, + "isConstructorMethod": false, + "isPrototypeMethod": false, + "jsFunctionName": "ignore", + "cppFunctionName": "Ignore", + "return": { + "cType": "GIT_EXTERN(", + "cppClassName": "GIT_EXTERN(" + }, + "description": "

Get the ignore rule for the submodule.

\n" + }, + { + "cFunctionName": "git_submodule_set_ignore", + "args": [ + { + "name": "submodule", + "cType": "git_submodule *", + "cppClassName": "GitSubmodule", + "jsClassName": "Submodule", + "isSelf": true + }, + { + "name": "ignore", + "cType": "git_submodule_ignore_t", + "cppClassName": "Uint32", + "jsClassName": "Uint32" + } + ], + "ignore": true, + "isAsync": false, + "isConstructorMethod": false, + "isPrototypeMethod": true, + "jsFunctionName": "setIgnore", + "cppFunctionName": "SetIgnore", + "return": { + "cType": "git_submodule_ignore_t", + "cppClassName": "Uint32", + "comment": "old value for ignore", + "jsClassName": "Number" + }, + "description": "

Set the ignore rule for the submodule.

\n" + }, + { + "cFunctionName": "git_submodule_update", + "ignore": true, + "args": [], + "isAsync": false, + "isConstructorMethod": false, + "isPrototypeMethod": false, + "jsFunctionName": "update", + "cppFunctionName": "Update", + "return": { + "cType": "GIT_EXTERN(", + "cppClassName": "GIT_EXTERN(" + }, + "description": "

Get the update rule for the submodule.

\n" + }, + { + "cFunctionName": "git_submodule_set_update", + "args": [ + { + "name": "submodule", + "cType": "git_submodule *", + "cppClassName": "GitSubmodule", + "jsClassName": "Submodule", + "isSelf": true + }, + { + "name": "update", + "cType": "git_submodule_update_t", + "cppClassName": "Uint32", + "jsClassName": "Uint32" + } + ], + "ignore": true, + "isAsync": false, + "isConstructorMethod": false, + "isPrototypeMethod": true, + "jsFunctionName": "setUpdate", + "cppFunctionName": "SetUpdate", + "return": { + "cType": "git_submodule_update_t", + "cppClassName": "SubmoduleUpdateT", + "comment": "old value for update" + }, + "description": "

Set the update rule for the submodule.

\n" + }, + { + "cFunctionName": "git_submodule_fetch_recurse_submodules", + "args": [ + { + "name": "submodule", + "cType": "git_submodule *", + "cppClassName": "GitSubmodule", + "jsClassName": "Submodule", + "isSelf": true + } + ], + "ignore": true, + "isAsync": false, + "isConstructorMethod": false, + "isPrototypeMethod": true, + "jsFunctionName": "fetchRecurseSubmodules", + "cppFunctionName": "FetchRecurseSubmodules", + "return": { + "cType": "int", + "cppClassName": "Int32", + "isErrorCode": true, + "comment": "0 if fetchRecurseSubmodules is false, 1 if true", + "jsClassName": "Number" + }, + "description": "

Read the fetchRecurseSubmodules rule for a submodule.

\n" + }, + { + "cFunctionName": "git_submodule_set_fetch_recurse_submodules", + "args": [ + { + "name": "submodule", + "cType": "git_submodule *", + "cppClassName": "GitSubmodule", + "jsClassName": "Submodule", + "isSelf": true, + "comment": "The submodule to modify" + }, + { + "name": "fetch_recurse_submodules", + "cType": "int", + "cppClassName": "Int32", + "jsClassName": "Number", + "comment": "Boolean value" + } + ], + "ignore": true, + "isAsync": false, + "isConstructorMethod": false, + "isPrototypeMethod": true, + "jsFunctionName": "setFetchRecurseSubmodules", + "cppFunctionName": "SetFetchRecurseSubmodules", + "return": { + "cType": "int", + "cppClassName": "Int32", + "isErrorCode": true, + "comment": "old value for fetchRecurseSubmodules", + "jsClassName": "Number" + }, + "description": "

Set the fetchRecurseSubmodules rule for a submodule.

\n" + }, + { + "cFunctionName": "git_submodule_init", + "args": [ + { + "name": "submodule", + "cType": "git_submodule *", + "cppClassName": "GitSubmodule", + "jsClassName": "Submodule", + "isSelf": true, + "comment": "The submodule to write into the superproject config" + }, + { + "name": "overwrite", + "cType": "int", + "cppClassName": "Int32", + "jsClassName": "Number", + "comment": "By default, existing entries will not be overwritten, but setting this to true forces them to be updated." + } + ], + "isAsync": true, + "isConstructorMethod": false, + "isPrototypeMethod": true, + "jsFunctionName": "init", + "cppFunctionName": "Init", + "return": { + "cType": "int", + "cppClassName": "Int32", + "isErrorCode": true, + "comment": "0 on success, <0 on failure.", + "jsClassName": "Number" + }, + "description": "

Copy submodule info into ".git/config" file.

\n" + }, + { + "cFunctionName": "git_submodule_sync", + "args": [ + { + "name": "submodule", + "cType": "git_submodule *", + "cppClassName": "GitSubmodule", + "jsClassName": "Submodule", + "isSelf": true + } + ], + "isAsync": true, + "isConstructorMethod": false, + "isPrototypeMethod": true, + "jsFunctionName": "sync", + "cppFunctionName": "Sync", + "return": { + "cType": "int", + "cppClassName": "Int32", + "isErrorCode": true, + "jsClassName": "Number" + }, + "description": "

Copy submodule remote info into submodule repo.

\n" + }, + { + "cFunctionName": "git_submodule_open", + "args": [ + { + "name": "repo", + "cType": "git_repository **", + "cppClassName": "GitRepo", + "jsClassName": "Repository", + "isReturn": true, + "comment": "Pointer to the submodule repo which was opened" + }, + { + "name": "submodule", + "cType": "git_submodule *", + "cppClassName": "GitSubmodule", + "jsClassName": "Submodule", + "isSelf": true, + "comment": "Submodule to be opened" + } + ], + "isAsync": true, + "isConstructorMethod": false, + "isPrototypeMethod": true, + "jsFunctionName": "open", + "cppFunctionName": "Open", + "return": { + "cType": "int", + "cppClassName": "Int32", + "isErrorCode": true, + "comment": "0 on success, <0 if submodule repo could not be opened.", + "jsClassName": "Number" + }, + "description": "

Open the repository for a submodule.

\n" + }, + { + "cFunctionName": "git_submodule_reload", + "args": [ + { + "name": "submodule", + "cType": "git_submodule *", + "cppClassName": "GitSubmodule", + "jsClassName": "Submodule", + "isSelf": true + } + ], + "isAsync": true, + "isConstructorMethod": false, + "isPrototypeMethod": true, + "jsFunctionName": "reload", + "cppFunctionName": "Reload", + "return": { + "cType": "int", + "cppClassName": "Int32", + "isErrorCode": true, + "jsClassName": "Number" + }, + "description": "

Reread submodule info from config, index, and HEAD.

\n" + }, + { + "cFunctionName": "git_submodule_status", + "args": [ + { + "name": "status", + "cType": "unsigned int *", + "cppClassName": "Int32", + "jsClassName": "Number", + "comment": "Combination of `GIT_SUBMODULE_STATUS` flags" + }, + { + "name": "submodule", + "cType": "git_submodule *", + "cppClassName": "GitSubmodule", + "jsClassName": "Submodule", + "isSelf": true, + "comment": "Submodule for which to get status" + } + ], + "isAsync": true, + "isConstructorMethod": false, + "isPrototypeMethod": true, + "jsFunctionName": "status", + "cppFunctionName": "Status", + "return": { + "cType": "int", + "cppClassName": "Int32", + "isErrorCode": true, + "comment": "0 on success, <0 on error", + "jsClassName": "Number" + }, + "description": "

Get the status for a submodule.

\n" + }, + { + "cFunctionName": "git_submodule_location", + "args": [ + { + "name": "location_status", + "cType": "unsigned int *", + "cppClassName": "Int32", + "jsClassName": "Number", + "comment": "Combination of first four `GIT_SUBMODULE_STATUS` flags" + }, + { + "name": "submodule", + "cType": "git_submodule *", + "cppClassName": "GitSubmodule", + "jsClassName": "Submodule", + "comment": "Submodule for which to get status" + } + ], + "ignore": true, + "isAsync": false, + "isConstructorMethod": false, + "isPrototypeMethod": false, + "jsFunctionName": "location", + "cppFunctionName": "Location", + "return": { + "cType": "int", + "cppClassName": "Int32", + "isErrorCode": true, + "comment": "0 on success, <0 on error", + "jsClassName": "Number" + }, + "description": "

Get the locations of submodule information.

\n" + } + ] + }, + { + "filename": "tag.h", + "dependencies": [ + "../include/oid.h", + "../include/repo.h", + "../include/object.h", + "../include/signature.h" + ], + "jsClassName": "Tag", + "cppClassName": "GitTag", + "cType": "git_tag", + "freeFunctionName": "git_tag_free", + "functions": [ + { + "cFunctionName": "git_tag_free", + "args": [ + { + "name": "tag", + "cType": "git_tag *", + "cppClassName": "GitTag", + "jsClassName": "Tag", + "comment": "the tag to close" + } + ], + "ignore": true, + "isAsync": false, + "isConstructorMethod": false, + "isPrototypeMethod": false, + "isFree": true, + "jsFunctionName": "free", + "cppFunctionName": "Free", + "return": { + "cType": "void", + "cppClassName": "void", + "jsClassName": "void" + }, + "description": "

Close an open tag

\n" + }, + { + "cFunctionName": "git_tag_id", + "args": [ + { + "name": "tag", + "cType": "const git_tag *", + "cppClassName": "GitTag", + "jsClassName": "Tag", + "isSelf": true, + "comment": "a previously loaded tag." + } + ], + "isAsync": false, + "isConstructorMethod": false, + "isPrototypeMethod": true, + "jsFunctionName": "oid", + "cppFunctionName": "Oid", + "return": { + "cType": "const git_oid *", + "cppClassName": "GitOid", + "copy": "git_oid_dup", + "comment": "object identity for the tag.", + "jsClassName": "Oid" + }, + "description": "

Get the id of a tag.

\n" + }, + { + "cFunctionName": "git_tag_target", + "args": [ + { + "name": "target_out", + "cType": "git_object **", + "cppClassName": "GitObject", + "jsClassName": "Object", + "isReturn": true, + "comment": "pointer where to store the target" + }, + { + "name": "tag", + "cType": "const git_tag *", + "cppClassName": "GitTag", + "jsClassName": "Tag", + "isSelf": true, + "comment": "a previously loaded tag." + } + ], + "isAsync": true, + "isConstructorMethod": false, + "isPrototypeMethod": true, + "jsFunctionName": "getTarget", + "cppFunctionName": "GetTarget", + "return": { + "cType": "int", + "cppClassName": "Int32", + "isErrorCode": true, + "comment": "0 or an error code", + "jsClassName": "Number" + }, + "description": "

Get the tagged object of a tag

\n" + }, + { + "cFunctionName": "git_tag_target_id", + "args": [ + { + "name": "tag", + "cType": "const git_tag *", + "cppClassName": "GitTag", + "jsClassName": "Tag", + "isSelf": true, + "comment": "a previously loaded tag." + } + ], + "isAsync": false, + "isConstructorMethod": false, + "isPrototypeMethod": true, + "jsFunctionName": "targetId", + "cppFunctionName": "TargetId", + "return": { + "cType": "const git_oid *", + "cppClassName": "GitOid", + "copy": "git_oid_dup", + "comment": "pointer to the OID", + "jsClassName": "Oid" + }, + "description": "

Get the OID of the tagged object of a tag

\n" + }, + { + "cFunctionName": "git_tag_target_type", + "args": [ + { + "name": "tag", + "cType": "const git_tag *", + "cppClassName": "GitTag", + "jsClassName": "Tag", + "isSelf": true, + "comment": "a previously loaded tag." + } + ], + "isAsync": false, + "isConstructorMethod": false, + "isPrototypeMethod": true, + "jsFunctionName": "targetType", + "cppFunctionName": "TargetType", + "return": { + "cType": "git_otype", + "cppClassName": "Int32", + "comment": "type of the tagged object", + "jsClassName": "Number" + }, + "description": "

Get the type of a tag's tagged object

\n" + }, + { + "cFunctionName": "git_tag_name", + "args": [ + { + "name": "tag", + "cType": "const git_tag *", + "cppClassName": "GitTag", + "jsClassName": "Tag", + "isSelf": true, + "comment": "a previously loaded tag." + } + ], + "isAsync": false, + "isConstructorMethod": false, + "isPrototypeMethod": true, + "jsFunctionName": "name", + "cppFunctionName": "Name", + "return": { + "cType": "const char *", + "cppClassName": "String", + "comment": "name of the tag", + "jsClassName": "String" + }, + "description": "

Get the name of a tag

\n" + }, + { + "cFunctionName": "git_tag_tagger", + "args": [ + { + "name": "tag", + "cType": "const git_tag *", + "cppClassName": "GitTag", + "jsClassName": "Tag", + "isSelf": true, + "comment": "a previously loaded tag." + } + ], + "isAsync": false, + "isConstructorMethod": false, + "isPrototypeMethod": true, + "jsFunctionName": "tagger", + "cppFunctionName": "Tagger", + "return": { + "cType": "const git_signature *", + "cppClassName": "GitSignature", + "copy": "git_signature_dup", + "comment": "reference to the tag's author or NULL when unspecified", + "jsClassName": "Signature" + }, + "description": "

Get the tagger (author) of a tag

\n" + }, + { + "cFunctionName": "git_tag_message", + "args": [ + { + "name": "tag", + "cType": "const git_tag *", + "cppClassName": "GitTag", + "jsClassName": "Tag", + "isSelf": true, + "comment": "a previously loaded tag." + } + ], + "isAsync": false, + "isConstructorMethod": false, + "isPrototypeMethod": true, + "jsFunctionName": "message", + "cppFunctionName": "Message", + "return": { + "cType": "const char *", + "cppClassName": "String", + "comment": "message of the tag or NULL when unspecified", + "jsClassName": "String" + }, + "description": "

Get the message of a tag

\n" + }, + { + "cFunctionName": "git_tag_create_frombuffer", + "args": [ + { + "name": "oid", + "cType": "git_oid *", + "cppClassName": "GitOid", + "jsClassName": "Oid", + "comment": "Pointer where to store the OID of the newly created tag" + }, + { + "name": "repo", + "cType": "git_repository *", + "cppClassName": "GitRepo", + "jsClassName": "Repository", + "comment": "Repository where to store the tag" + }, + { + "name": "buffer", + "cType": "const char *", + "cppClassName": "String", + "jsClassName": "String", + "comment": "Raw tag data" + }, + { + "name": "force", + "cType": "int", + "cppClassName": "Int32", + "jsClassName": "Number", + "comment": "Overwrite existing tags" + } + ], + "ignore": true, + "isAsync": false, + "isConstructorMethod": false, + "isPrototypeMethod": false, + "jsFunctionName": "createFrombuffer", + "cppFunctionName": "CreateFrombuffer", + "return": { + "cType": "int", + "cppClassName": "Int32", + "isErrorCode": true, + "comment": "0 on success; error code otherwise", + "jsClassName": "Number" + }, + "description": "

Create a new tag in the repository from a buffer

\n" + }, + { + "cFunctionName": "git_tag_peel", + "args": [ + { + "name": "tag_target_out", + "cType": "git_object **", + "cppClassName": "GitObject", + "jsClassName": "Object", + "isReturn": true, + "comment": "Pointer to the peeled git_object" + }, + { + "name": "tag", + "cType": "const git_tag *", + "cppClassName": "GitTag", + "jsClassName": "Tag", + "comment": "_target_out Pointer to the peeled git_object" + } + ], + "isAsync": false, + "isConstructorMethod": false, + "isPrototypeMethod": true, + "jsFunctionName": "peel", + "cppFunctionName": "Peel", + "return": { + "cType": "int", + "cppClassName": "Int32", + "isErrorCode": true, + "comment": "0 or an error code", + "jsClassName": "Number" + }, + "description": "

Recursively peel a tag until a non tag git_object is found

\n" + } + ] + }, + { + "filename": "threads.h", + "dependencies": [], + "jsClassName": "Threads", + "cppClassName": "GitThreads", + "functions": [ + { + "cFunctionName": "git_threads_init", + "args": [], + "isAsync": false, + "isConstructorMethod": false, + "isPrototypeMethod": false, + "jsFunctionName": "init", + "cppFunctionName": "Init", + "return": { + "cType": "int", + "cppClassName": "Int32", + "isErrorCode": true, + "comment": "0 or an error code", + "jsClassName": "Number" + }, + "description": "

Init the threading system.

\n" + }, + { + "cFunctionName": "git_threads_shutdown", + "args": [], + "isAsync": false, + "isConstructorMethod": false, + "isPrototypeMethod": false, + "jsFunctionName": "shutdown", + "cppFunctionName": "Shutdown", + "return": { + "cType": "void", + "cppClassName": "void", + "jsClassName": "void" + }, + "description": "

Shutdown the threading system.

\n" + } + ] + }, + { + "filename": "trace.h", + "ignore": true, + "jsClassName": "Trace", + "cppClassName": "Trace", + "cType": "git_trace", + "freeFunctionName": "git_trace_free", + "functions": [ + { + "cFunctionName": "git_trace_set", + "args": [ + { + "name": "level", + "cType": "git_trace_level_t", + "cppClassName": "TraceLevelT", + "jsClassName": "TraceLevelT", + "comment": "Level to set tracing to" + }, + { + "name": "cb", + "cType": "git_trace_callback", + "cppClassName": "TraceCallback", + "jsClassName": "TraceCallback", + "comment": "Function to call with trace data" + } + ], + "isAsync": false, + "isConstructorMethod": false, + "isPrototypeMethod": false, + "jsFunctionName": "set", + "cppFunctionName": "Set", + "return": { + "cType": "int", + "cppClassName": "Int32", + "isErrorCode": true, + "comment": "0 or an error code", + "jsClassName": "Number" + }, + "description": "

Sets the system tracing configuration to the specified level with the\nspecified callback. When system events occur at a level equal to, or\nlower than, the given level they will be reported to the given callback.

\n" + } + ] + }, + { + "filename": "transport.h", + "ignore": true, + "jsClassName": "Transport", + "cppClassName": "Transport", + "cType": "git_transport", + "freeFunctionName": "git_transport_free", + "functions": [ + { + "cFunctionName": "git_cred_userpass_plaintext_new", + "args": [ + { + "name": "out", + "isReturn": true, + "cType": "git_cred **", + "cppClassName": "Cred", + "jsClassName": "Cred", + "comment": "The newly created credential object." + }, + { + "name": "username", + "cType": "const char *", + "cppClassName": "String", + "jsClassName": "String", + "comment": "The username of the credential." + }, + { + "name": "password", + "cType": "const char *", + "cppClassName": "String", + "jsClassName": "String", + "comment": "The password of the credential." + } + ], + "isAsync": false, + "isConstructorMethod": false, + "isPrototypeMethod": false, + "jsFunctionName": "gitCredUserpassPlaintextNew", + "cppFunctionName": "GitCredUserpassPlaintextNew", + "return": { + "cType": "int", + "cppClassName": "Int32", + "isErrorCode": true, + "comment": "0 for success or an error code for failure", + "jsClassName": "Number" + }, + "description": "

Creates a new plain-text username and password credential object.\nThe supplied credential parameter will be internally duplicated.

\n" + }, + { + "cFunctionName": "git_transport_new", + "args": [ + { + "name": "out", + "isReturn": true, + "cType": "git_transport **", + "cppClassName": "Transport", + "jsClassName": "Transport", + "comment": "The newly created transport (out)" + }, + { + "name": "owner", + "cType": "git_remote *", + "cppClassName": "GitRemote", + "jsClassName": "Remote", + "comment": "The git_remote which will own this transport" + }, + { + "name": "url", + "cType": "const char *", + "cppClassName": "String", + "jsClassName": "String", + "comment": "The URL to connect to" + } + ], + "isAsync": false, + "isConstructorMethod": true, + "isPrototypeMethod": false, + "jsFunctionName": "new", + "cppFunctionName": "New", + "return": { + "cType": "int", + "cppClassName": "Int32", + "isErrorCode": true, + "comment": "0 or an error code", + "jsClassName": "Number" + }, + "description": "

Function to use to create a transport from a URL. The transport database\nis scanned to find a transport that implements the scheme of the URI (i.e.\ngit:// or http://) and a transport object is returned to the caller.

\n" + }, + { + "cFunctionName": "git_transport_dummy", + "args": [ + { + "name": "out", + "isReturn": true, + "cType": "git_transport **", + "cppClassName": "Transport", + "jsClassName": "Transport", + "comment": "The newly created transport (out)" + }, + { + "name": "owner", + "cType": "git_remote *", + "cppClassName": "GitRemote", + "jsClassName": "Remote", + "comment": "The git_remote which will own this transport" + }, + { + "name": "payload", + "cType": "void *", + "cppClassName": "void", + "jsClassName": "void", + "comment": "You must pass NULL for this parameter." + } + ], + "isAsync": false, + "isConstructorMethod": true, + "isPrototypeMethod": false, + "jsFunctionName": "dummy", + "cppFunctionName": "Dummy", + "return": { + "cType": "int", + "cppClassName": "Int32", + "isErrorCode": true, + "comment": "0 or an error code", + "jsClassName": "Number" + }, + "description": "

Create an instance of the dummy transport.

\n" + }, + { + "cFunctionName": "git_transport_local", + "args": [ + { + "name": "out", + "isReturn": true, + "cType": "git_transport **", + "cppClassName": "Transport", + "jsClassName": "Transport", + "comment": "The newly created transport (out)" + }, + { + "name": "owner", + "cType": "git_remote *", + "cppClassName": "GitRemote", + "jsClassName": "Remote", + "comment": "The git_remote which will own this transport" + }, + { + "name": "payload", + "cType": "void *", + "cppClassName": "void", + "jsClassName": "void", + "comment": "You must pass NULL for this parameter." + } + ], + "isAsync": false, + "isConstructorMethod": true, + "isPrototypeMethod": false, + "jsFunctionName": "local", + "cppFunctionName": "Local", + "return": { + "cType": "int", + "cppClassName": "Int32", + "isErrorCode": true, + "comment": "0 or an error code", + "jsClassName": "Number" + }, + "description": "

Create an instance of the local transport.

\n" + }, + { + "cFunctionName": "git_transport_smart", + "args": [ + { + "name": "out", + "isReturn": true, + "cType": "git_transport **", + "cppClassName": "Transport", + "jsClassName": "Transport", + "comment": "The newly created transport (out)" + }, + { + "name": "owner", + "cType": "git_remote *", + "cppClassName": "GitRemote", + "jsClassName": "Remote", + "comment": "The git_remote which will own this transport" + }, + { + "name": "payload", + "cType": "void *", + "cppClassName": "void", + "jsClassName": "void", + "comment": "A pointer to a git_smart_subtransport_definition" + } + ], + "isAsync": false, + "isConstructorMethod": true, + "isPrototypeMethod": false, + "jsFunctionName": "smart", + "cppFunctionName": "Smart", + "return": { + "cType": "int", + "cppClassName": "Int32", + "isErrorCode": true, + "comment": "0 or an error code", + "jsClassName": "Number" + }, + "description": "

Create an instance of the smart transport.

\n" + }, + { + "cFunctionName": "git_smart_subtransport_http", + "args": [ + { + "name": "out", + "isReturn": true, + "cType": "git_smart_subtransport **", + "cppClassName": "SmartSubtransport", + "jsClassName": "SmartSubtransport", + "comment": "The newly created subtransport" + }, + { + "name": "owner", + "cType": "git_transport*", + "cppClassName": "Transport*", + "jsClassName": "Transport*", + "comment": "The smart transport to own this subtransport" + } + ], + "isAsync": false, + "isConstructorMethod": false, + "isPrototypeMethod": false, + "jsFunctionName": "gitSmartSubtransportHttp", + "cppFunctionName": "GitSmartSubtransportHttp", + "return": { + "cType": "int", + "cppClassName": "Int32", + "isErrorCode": true, + "comment": "0 or an error code", + "jsClassName": "Number" + }, + "description": "

Create an instance of the http subtransport. This subtransport\nalso supports https. On Win32, this subtransport may be implemented\nusing the WinHTTP library.

\n" + }, + { + "cFunctionName": "git_smart_subtransport_git", + "args": [ + { + "name": "out", + "isReturn": true, + "cType": "git_smart_subtransport **", + "cppClassName": "SmartSubtransport", + "jsClassName": "SmartSubtransport", + "comment": "The newly created subtransport" + }, + { + "name": "owner", + "cType": "git_transport*", + "cppClassName": "Transport*", + "jsClassName": "Transport*", + "comment": "The smart transport to own this subtransport" + } + ], + "isAsync": false, + "isConstructorMethod": false, + "isPrototypeMethod": false, + "jsFunctionName": "gitSmartSubtransportGit", + "cppFunctionName": "GitSmartSubtransportGit", + "return": { + "cType": "int", + "cppClassName": "Int32", + "isErrorCode": true, + "comment": "0 or an error code", + "jsClassName": "Number" + }, + "description": "

Create an instance of the git subtransport.

\n" + } + ] + }, + { + "filename": "tree_entry.h", + "dependencies": [ + "../include/oid.h", + "../include/repo.h", + "../include/object.h" + ], + "jsClassName": "TreeEntry", + "cppClassName": "GitTreeEntry", + "cType": "git_tree_entry", + "freeFunctionName": "git_tree_entry_free", + "functions": [ + { + "cFunctionName": "git_tree_entry_dup", + "args": [ + { + "name": "entry", + "cType": "const git_tree_entry *", + "cppClassName": "GitTreeEntry", + "jsClassName": "TreeEntry", + "isSelf": true, + "comment": "A tree entry to duplicate" + } + ], + "ignore": true, + "isAsync": false, + "isConstructorMethod": false, + "isPrototypeMethod": true, + "jsFunctionName": "dup", + "cppFunctionName": "Dup", + "return": { + "cType": "git_tree_entry *", + "cppClassName": "GitTreeEntry", + "comment": "a copy of the original entry or NULL on error (alloc failure)", + "jsClassName": "TreeEntry" + }, + "description": "

Duplicate a tree entry

\n" + }, + { + "cFunctionName": "git_tree_entry_free", + "args": [ + { + "name": "entry", + "cType": "git_tree_entry *", + "cppClassName": "GitTreeEntry", + "jsClassName": "TreeEntry", + "isSelf": true, + "comment": "The entry to free" + } + ], + "ignore": true, + "isAsync": false, + "isConstructorMethod": false, + "isPrototypeMethod": true, + "isFree": true, + "jsFunctionName": "free", + "cppFunctionName": "Free", + "return": { + "cType": "void", + "cppClassName": "void", + "jsClassName": "void" + }, + "description": "

Free a user-owned tree entry

\n" + }, + { + "cFunctionName": "git_tree_entry_name", + "args": [ + { + "name": "entry", + "cType": "const git_tree_entry *", + "cppClassName": "GitTreeEntry", + "jsClassName": "TreeEntry", + "isSelf": true, + "comment": "a tree entry" + } + ], + "isAsync": false, + "isConstructorMethod": false, + "isPrototypeMethod": true, + "jsFunctionName": "name", + "cppFunctionName": "Name", + "return": { + "cType": "const char *", + "cppClassName": "String", + "comment": "the name of the file", + "jsClassName": "String" + }, + "description": "

Get the filename of a tree entry

\n" + }, + { + "cFunctionName": "git_tree_entry_id", + "args": [ + { + "name": "entry", + "cType": "const git_tree_entry *", + "cppClassName": "GitTreeEntry", + "jsClassName": "TreeEntry", + "isSelf": true, + "comment": "a tree entry" + } + ], + "isAsync": false, + "isConstructorMethod": false, + "isPrototypeMethod": true, + "jsFunctionName": "oid", + "cppFunctionName": "Oid", + "return": { + "cType": "const git_oid *", + "cppClassName": "GitOid", + "copy": "git_oid_dup", + "comment": "the oid of the object", + "jsClassName": "Oid" + }, + "description": "

Get the id of the object pointed by the entry

\n" + }, + { + "cFunctionName": "git_tree_entry_type", + "args": [ + { + "name": "entry", + "cType": "const git_tree_entry *", + "cppClassName": "GitTreeEntry", + "jsClassName": "TreeEntry", + "isSelf": true, + "comment": "a tree entry" + } + ], + "isAsync": false, + "isConstructorMethod": false, + "isPrototypeMethod": true, + "jsFunctionName": "type", + "cppFunctionName": "Type", + "return": { + "cType": "git_otype", + "cppClassName": "Number", + "comment": "the type of the pointed object", + "jsClassName": "Number" + }, + "description": "

Get the type of the object pointed by the entry

\n" + }, + { + "cFunctionName": "git_tree_entry_filemode", + "args": [ + { + "name": "entry", + "cType": "const git_tree_entry *", + "cppClassName": "GitTreeEntry", + "jsClassName": "TreeEntry", + "isSelf": true, + "comment": "a tree entry" + } + ], + "isAsync": false, + "isConstructorMethod": false, + "isPrototypeMethod": true, + "jsFunctionName": "filemode", + "cppFunctionName": "filemode", + "return": { + "cType": "git_filemode_t", + "cppClassName": "Number", + "comment": "filemode as an integer", + "jsClassName": "Number" + }, + "description": "

Get the UNIX file attributes of a tree entry

\n" + }, + { + "cFunctionName": "git_tree_entry_cmp", + "args": [ + { + "name": "e1", + "cType": "const git_tree_entry *", + "cppClassName": "GitTreeEntry", + "jsClassName": "TreeEntry", + "isSelf": true, + "comment": "first tree entry" + }, + { + "name": "e2", + "cType": "const git_tree_entry *", + "cppClassName": "GitTreeEntry", + "jsClassName": "TreeEntry", + "comment": "second tree entry" + } + ], + "ignore": true, + "isAsync": false, + "isConstructorMethod": false, + "isPrototypeMethod": true, + "jsFunctionName": "compare", + "cppFunctionName": "Compare", + "return": { + "cType": "int", + "cppClassName": "Int32", + "isErrorCode": true, + "comment": "<0 if e1 is before e2, 0 if e1 == e2, >0 if e1 is after e2", + "jsClassName": "Number" + }, + "description": "

Compare two tree entries

\n" + }, + { + "cFunctionName": "git_tree_entry_to_object", + "args": [ + { + "name": "object_out", + "cType": "git_object **", + "cppClassName": "GitObject", + "jsClassName": "Object", + "isReturn": true, + "comment": "pointer to the converted object" + }, + { + "name": "repo", + "cType": "git_repository *", + "cppClassName": "GitRepo", + "jsClassName": "Repository", + "comment": "repository where to lookup the pointed object" + }, + { + "name": "entry", + "cType": "const git_tree_entry *", + "cppClassName": "GitTreeEntry", + "jsClassName": "TreeEntry", + "isSelf": true, + "comment": "a tree entry" + } + ], + "isAsync": true, + "isConstructorMethod": false, + "isPrototypeMethod": true, + "jsFunctionName": "getObject", + "cppFunctionName": "GetObject", + "return": { + "cType": "int", + "cppClassName": "Int32", + "isErrorCode": true, + "comment": "0 or an error code", + "jsClassName": "Number" + }, + "description": "

Convert a tree entry to the git_object it points too.

\n" + } + ] + }, + { + "filename": "tree.h", + "dependencies": [ + "../include/repo.h", + "../include/oid.h", + "../include/tree_entry.h", + "../include/diff_list.h", + "../include/diff_options.h", + "../include/tree_builder.h", + "../include/index.h" + ], + "jsClassName": "Tree", + "cppClassName": "GitTree", + "cType": "git_tree", + "freeFunctionName": "git_tree_free", + "functions": [ + { + "cFunctionName": "git_tree_free", + "args": [ + { + "name": "tree", + "cType": "git_tree *", + "cppClassName": "GitTree", + "jsClassName": "Tree", + "comment": "The tree to close" + } + ], + "ignore": true, + "isAsync": false, + "isConstructorMethod": false, + "isPrototypeMethod": false, + "isFree": true, + "jsFunctionName": "free", + "cppFunctionName": "Free", + "return": { + "cType": "void", + "cppClassName": "void", + "jsClassName": "void" + }, + "description": "

Close an open tree

\n" + }, + { + "cFunctionName": "git_tree_id", + "args": [ + { + "name": "tree", + "cType": "const git_tree *", + "cppClassName": "GitTree", + "jsClassName": "Tree", + "isSelf": true, + "comment": "a previously loaded tree." + } + ], + "isAsync": false, + "isConstructorMethod": false, + "isPrototypeMethod": true, + "jsFunctionName": "oid", + "cppFunctionName": "Oid", + "return": { + "cType": "const git_oid *", + "cppClassName": "GitOid", + "copy": "git_oid_dup", + "comment": "object identity for the tree.", + "jsClassName": "Oid" + }, + "description": "

Get the id of a tree.

\n" + }, + { + "cFunctionName": "git_tree_owner", + "args": [ + { + "name": "tree", + "cType": "const git_tree *", + "cppClassName": "GitTree", + "jsClassName": "Tree", + "isSelf": true, + "comment": "A previously loaded tree." + } + ], + "ignore": "Never make public for memory allocation reasons", + "isAsync": false, + "isConstructorMethod": false, + "isPrototypeMethod": true, + "jsFunctionName": "owner", + "cppFunctionName": "Owner", + "return": { + "cType": "git_repository *", + "cppClassName": "GitRepo", + "comment": "Repository that contains this tree.", + "jsClassName": "Repository" + }, + "description": "

Get the repository that contains the tree.

\n" + }, + { + "cFunctionName": "git_tree_entrycount", + "args": [ + { + "name": "tree", + "cType": "const git_tree *", + "cppClassName": "GitTree", + "jsClassName": "Tree", + "isSelf": true, + "comment": "a previously loaded tree." + } + ], + "isAsync": false, + "isConstructorMethod": false, + "isPrototypeMethod": true, + "jsFunctionName": "size", + "cppFunctionName": "Size", + "return": { + "cType": "size_t", + "cppClassName": "Uint32", + "comment": "the number of entries in the tree", + "jsClassName": "Number" + }, + "description": "

Get the number of entries listed in a tree

\n" + }, + { + "cFunctionName": "git_tree_entry_byname", + "args": [ + { + "name": "tree", + "cType": "git_tree *", + "cppClassName": "GitTree", + "jsClassName": "Tree", + "isSelf": true, + "comment": "a previously loaded tree." + }, + { + "name": "filename", + "cType": "const char *", + "cppClassName": "String", + "jsClassName": "String", + "comment": "the filename of the desired entry" + } + ], + "isAsync": false, + "isConstructorMethod": false, + "isPrototypeMethod": true, + "jsFunctionName": "entryByName", + "cppFunctionName": "EntryByName", + "return": { + "cType": "const git_tree_entry *", + "cppClassName": "GitTreeEntry", + "copy": "git_tree_entry_dup", + "comment": "the tree entry; NULL if not found", + "jsClassName": "TreeEntry" + }, + "description": "

Lookup a tree entry by its filename

\n" + }, + { + "cFunctionName": "git_tree_entry_byindex", + "args": [ + { + "name": "tree", + "cType": "git_tree *", + "cppClassName": "GitTree", + "jsClassName": "Tree", + "isSelf": true, + "comment": "a previously loaded tree." + }, + { + "name": "idx", + "cType": "size_t", + "cppClassName": "Uint32", + "jsClassName": "Number", + "comment": "the position in the entry list" + } + ], + "isAsync": false, + "isConstructorMethod": false, + "isPrototypeMethod": true, + "jsFunctionName": "entryByIndex", + "cppFunctionName": "EntryByIndex", + "return": { + "cType": "const git_tree_entry *", + "cppClassName": "GitTreeEntry", + "copy": "git_tree_entry_dup", + "comment": "the tree entry; NULL if not found", + "jsClassName": "TreeEntry" + }, + "description": "

Lookup a tree entry by its position in the tree

\n" + }, + { + "cFunctionName": "git_tree_entry_byoid", + "args": [ + { + "name": "tree", + "cType": "const git_tree *", + "cppClassName": "GitTree", + "jsClassName": "Tree", + "isSelf": true, + "comment": "a previously loaded tree." + }, + { + "name": "oid", + "cType": "const git_oid *", + "cppClassName": "GitOid", + "jsClassName": "Oid", + "comment": "the sha being looked for" + } + ], + "isAsync": false, + "isConstructorMethod": false, + "isPrototypeMethod": true, + "jsFunctionName": "entryByOid", + "cppFunctionName": "EntryByOid", + "return": { + "cType": "const git_tree_entry *", + "cppClassName": "GitTreeEntry", + "copy": "git_tree_entry_dup", + "comment": "the tree entry; NULL if not found", + "jsClassName": "TreeEntry" + }, + "description": "

Lookup a tree entry by SHA value.

\n" + }, + { + "cFunctionName": "git_tree_entry_bypath", + "args": [ + { + "name": "out", + "isReturn": true, + "cType": "git_tree_entry **", + "cppClassName": "GitTreeEntry", + "jsClassName": "TreeEntry", + "comment": "Pointer where to store the tree entry" + }, + { + "name": "root", + "cType": "git_tree *", + "cppClassName": "GitTree", + "jsClassName": "Tree", + "isSelf": true, + "comment": "Previously loaded tree which is the root of the relative path" + }, + { + "name": "path", + "cType": "const char *", + "cppClassName": "String", + "jsClassName": "String", + "comment": "Path to the contained entry" + } + ], + "isAsync": true, + "isConstructorMethod": false, + "isPrototypeMethod": true, + "jsFunctionName": "getEntry", + "cppFunctionName": "GetEntry", + "return": { + "cType": "int", + "cppClassName": "Int32", + "isErrorCode": true, + "comment": "0 on success; GIT_ENOTFOUND if the path does not exist", + "jsClassName": "Number" + }, + "description": "

Retrieve a tree entry contained in a tree or in any of its subtrees,\ngiven its relative path.

\n" + }, + { + "cFunctionName": "git_treebuilder_create", + "args": [ + { + "name": "out", + "isReturn": true, + "cType": "git_treebuilder **", + "cppClassName": "GitTreeBuilder", + "jsClassName": "TreeBuilder", + "comment": "Pointer where to store the tree builder" + }, + { + "name": "source", + "cType": "const git_tree *", + "cppClassName": "GitTree", + "jsClassName": "Tree", + "isSelf": true, + "comment": "Source tree to initialize the builder (optional)" + } + ], + "isAsync": false, + "isConstructorMethod": false, + "isPrototypeMethod": true, + "jsFunctionName": "builder", + "cppFunctionName": "Builder", + "return": { + "cType": "int", + "cppClassName": "Int32", + "isErrorCode": true, + "comment": "0 on success; error code otherwise", + "jsClassName": "Number" + }, + "description": "

Create a new tree builder.

\n" + }, + { + "cFunctionName": "git_tree_walk", + "args": [ + { + "name": "tree", + "cType": "const git_tree *", + "cppClassName": "GitTree", + "jsClassName": "Tree", + "isSelf": true, + "comment": "The tree to walk" + }, + { + "name": "mode", + "cType": "git_treewalk_mode", + "cppClassName": "TreewalkMode", + "jsClassName": "TreewalkMode", + "comment": "Traversal mode (pre or post-order)" + }, + { + "name": "callback", + "cType": "git_treewalk_cb", + "cppClassName": "TreewalkCb", + "jsClassName": "TreewalkCb", + "comment": "Function to call on each tree entry" + }, + { + "name": "payload", + "cType": "void *", + "cppClassName": "void", + "jsClassName": "void", + "comment": "Opaque pointer to be passed on each callback" + } + ], + "ignore": true, + "isAsync": true, + "isConstructorMethod": false, + "isPrototypeMethod": true, + "jsFunctionName": "walk", + "cppFunctionName": "Walk", + "return": { + "cType": "int", + "cppClassName": "Int32", + "isErrorCode": true, + "comment": "0 or an error code", + "jsClassName": "Number" + }, + "description": "

Traverse the entries in a tree and its subtrees in post or pre order.

\n" + }, + { + "cFunctionName": "git_diff_tree_to_tree", + "args": [ + { + "name": "diff", + "cType": "git_diff_list **", + "cppClassName": "GitDiffList", + "jsClassName": "DiffList", + "isReturn": true, + "comment": "Output pointer to a git_diff_list pointer to be allocated." + }, + { + "name": "repo", + "cType": "git_repository *", + "cppClassName": "GitRepo", + "jsClassName": "Repository", + "comment": "The repository containing the trees." + }, + { + "name": "old_tree", + "cType": "git_tree *", + "cppClassName": "GitTree", + "jsClassName": "Tree", + "isSelf": true, + "comment": "A git_tree object to diff from, or NULL for empty tree." + }, + { + "name": "new_tree", + "cType": "git_tree *", + "cppClassName": "GitTree", + "jsClassName": "Tree", + "comment": "A git_tree object to diff to, or NULL for empty tree." + }, + { + "name": "opts", + "cType": "const git_diff_options *", + "cppClassName": "GitDiffOptions", + "jsClassName": "DiffOptions", + "isOptional": true, + "comment": "Structure with options to influence diff or NULL for defaults." + } + ], + "isAsync": true, + "isConstructorMethod": false, + "isPrototypeMethod": true, + "jsFunctionName": "diffTree", + "cppFunctionName": "DiffTree", + "return": { + "cType": "int", + "cppClassName": "Int32", + "isErrorCode": true, + "jsClassName": "Number" + }, + "description": "

Create a diff list with the difference between two tree objects.

\n" + }, + { + "cFunctionName": "git_diff_tree_to_index", + "args": [ + { + "name": "diff", + "cType": "git_diff_list **", + "cppClassName": "GitDiffList", + "jsClassName": "DiffList", + "isReturn": true, + "comment": "Output pointer to a git_diff_list pointer to be allocated." + }, + { + "name": "repo", + "cType": "git_repository *", + "cppClassName": "GitRepo", + "jsClassName": "Repository", + "comment": "The repository containing the tree and index." + }, + { + "name": "old_tree", + "cType": "git_tree *", + "cppClassName": "GitTree", + "jsClassName": "Tree", + "isSelf": true, + "comment": "A git_tree object to diff from, or NULL for empty tree." + }, + { + "name": "index", + "cType": "git_index *", + "cppClassName": "GitIndex", + "jsClassName": "Index", + "comment": "The index to diff with; repo index used if NULL." + }, + { + "name": "opts", + "cType": "const git_diff_options *", + "cppClassName": "GitDiffOptions", + "jsClassName": "DiffOptions", + "comment": "Structure with options to influence diff or NULL for defaults." + } + ], + "isAsync": true, + "isConstructorMethod": false, + "isPrototypeMethod": true, + "jsFunctionName": "diffIndex", + "cppFunctionName": "DiffIndex", + "return": { + "cType": "int", + "cppClassName": "Int32", + "isErrorCode": true, + "jsClassName": "Number" + }, + "description": "

Create a diff list between a tree and repository index.

\n" + }, + { + "cFunctionName": "git_diff_tree_to_workdir", + "args": [ + { + "name": "diff", + "cType": "git_diff_list **", + "cppClassName": "GitDiffList", + "jsClassName": "DiffList", + "isReturn": true, + "comment": "A pointer to a git_diff_list pointer that will be allocated." + }, + { + "name": "repo", + "cType": "git_repository *", + "cppClassName": "GitRepo", + "jsClassName": "Repository", + "comment": "The repository containing the tree." + }, + { + "name": "old_tree", + "cType": "git_tree *", + "cppClassName": "GitTree", + "jsClassName": "Tree", + "isSelf": true, + "comment": "A git_tree object to diff from, or NULL for empty tree." + }, + { + "name": "opts", + "cType": "const git_diff_options *", + "cppClassName": "GitDiffOptions", + "jsClassName": "DiffOptions", + "comment": "Structure with options to influence diff or NULL for defaults." + } + ], + "isAsync": true, + "isConstructorMethod": false, + "isPrototypeMethod": true, + "jsFunctionName": "diffWorkDir", + "cppFunctionName": "DiffWorkDir", + "return": { + "cType": "int", + "cppClassName": "Int32", + "isErrorCode": true, + "jsClassName": "Number" + }, + "description": "

Create a diff list between a tree and the working directory.

\n" + } + ] + }, + { + "filename": "tree_builder.h", + "dependencies": [ + "../include/repo.h", + "../include/oid.h", + "../include/tree_entry.h", + "../include/tree.h", + "../include/diff_list.h", + "../include/diff_options.h", + "../include/index.h" + ], + "jsClassName": "TreeBuilder", + "cppClassName": "GitTreeBuilder", + "cType": "git_treebuilder", + "freeFunctionName": "git_treebuilder_free", + "functions": [ + { + "cFunctionName": "git_treebuilder_create", + "args": [ + { + "name": "out", + "isReturn": true, + "cType": "git_treebuilder **", + "cppClassName": "GitTreeBuilder", + "jsClassName": "TreeBuilder", + "comment": "Pointer where to store the tree builder" + }, + { + "name": "source", + "cType": "const git_tree *", + "cppClassName": "GitTree", + "jsClassName": "Tree", + "isOptional": true, + "comment": "Source tree to initialize the builder (optional)" + } + ], + "isAsync": false, + "isConstructorMethod": true, + "isPrototypeMethod": false, + "jsFunctionName": "create", + "cppFunctionName": "Create", + "return": { + "cType": "int", + "cppClassName": "Int32", + "isErrorCode": true, + "comment": "0 on success; error code otherwise", + "jsClassName": "Number" + }, + "description": "

Create a new tree builder.

\n" + }, + { + "cFunctionName": "git_treebuilder_clear", + "args": [ + { + "name": "bld", + "cType": "git_treebuilder *", + "cppClassName": "GitTreeBuilder", + "jsClassName": "TreeBuilder", + "comment": "Builder to clear" + } + ], + "isAsync": false, + "isConstructorMethod": false, + "isPrototypeMethod": true, + "jsFunctionName": "clear", + "cppFunctionName": "Clear", + "return": { + "cType": "void", + "cppClassName": "void", + "jsClassName": "void" + }, + "description": "

Clear all the entires in the builder

\n" + }, + { + "cFunctionName": "git_treebuilder_entrycount", + "args": [ + { + "name": "bld", + "cType": "git_treebuilder *", + "cppClassName": "GitTreeBuilder", + "jsClassName": "TreeBuilder", + "isSelf": true, + "comment": "a previously loaded treebuilder." + } + ], + "isAsync": false, + "isConstructorMethod": false, + "isPrototypeMethod": false, + "jsFunctionName": "size", + "cppFunctionName": "Size", + "return": { + "cType": "unsigned int", + "cppClassName": "Uint32", + "comment": "the number of entries in the treebuilder", + "jsClassName": "Number" + }, + "description": "

Get the number of entries listed in a treebuilder

\n" + }, + { + "cFunctionName": "git_treebuilder_free", + "args": [ + { + "name": "bld", + "cType": "git_treebuilder *", + "cppClassName": "GitTreeBuilder", + "jsClassName": "TreeBuilder", + "comment": "Builder to free" + } + ], + "ignore": true, + "isAsync": false, + "isConstructorMethod": false, + "isPrototypeMethod": false, + "isFree": true, + "jsFunctionName": "treebuilderFree", + "cppFunctionName": "GitTreebuilderFree", + "return": { + "cType": "void", + "cppClassName": "void", + "jsClassName": "void" + }, + "description": "

Free a tree builder

\n" + }, + { + "cFunctionName": "git_treebuilder_get", + "args": [ + { + "name": "bld", + "cType": "git_treebuilder *", + "cppClassName": "GitTreeBuilder", + "jsClassName": "TreeBuilder", + "isSelf": true, + "comment": "Tree builder" + }, + { + "name": "filename", + "cType": "const char *", + "cppClassName": "String", + "jsClassName": "String", + "comment": "Name of the entry" + } + ], + "isAsync": false, + "isConstructorMethod": false, + "isPrototypeMethod": true, + "jsFunctionName": "get", + "cppFunctionName": "Get", + "return": { + "cType": "const git_tree_entry *", + "cppClassName": "GitTreeEntry", + "copy": "git_tree_entry_dup", + "comment": "pointer to the entry; NULL if not found", + "jsClassName": "TreeEntry" + }, + "description": "

Get an entry from the builder from its filename

\n" + }, + { + "cFunctionName": "git_treebuilder_insert", + "args": [ + { + "name": "out", + "isReturn": true, + "cType": "const git_tree_entry **", + "cppClassName": "GitTreeEntry", + "jsClassName": "TreeEntry", + "copy": "git_tree_entry_dup", + "comment": "Pointer to store the entry (optional)" + }, + { + "name": "bld", + "cType": "git_treebuilder *", + "cppClassName": "GitTreeBuilder", + "jsClassName": "TreeBuilder", + "isSelf": true, + "comment": "Tree builder" + }, + { + "name": "filename", + "cType": "const char *", + "cppClassName": "String", + "jsClassName": "String", + "comment": "Filename of the entry" + }, + { + "name": "id", + "cType": "const git_oid *", + "cppClassName": "GitOid", + "jsClassName": "Oid", + "comment": "SHA1 oid of the entry" + }, + { + "name": "filemode", + "cType": "git_filemode_t", + "cppClassName": "Number", + "jsClassName": "Number", + "comment": "Folder attributes of the entry. This parameter must be valued with one of the following entries: 0040000, 0100644, 0100755, 0120000 or 0160000." + } + ], + "isAsync": false, + "isConstructorMethod": false, + "isPrototypeMethod": true, + "jsFunctionName": "insert", + "cppFunctionName": "Insert", + "return": { + "cType": "int", + "cppClassName": "Int32", + "isErrorCode": true, + "comment": "0 or an error code", + "jsClassName": "Number" + }, + "description": "

Add or update an entry to the builder

\n" + }, + { + "cFunctionName": "git_treebuilder_remove", + "args": [ + { + "name": "bld", + "cType": "git_treebuilder *", + "cppClassName": "GitTreeBuilder", + "jsClassName": "TreeBuilder", + "isSelf": true, + "comment": "Tree builder" + }, + { + "name": "filename", + "cType": "const char *", + "cppClassName": "String", + "jsClassName": "String", + "comment": "Filename of the entry to remove" + } + ], + "isAsync": false, + "isConstructorMethod": false, + "isPrototypeMethod": true, + "jsFunctionName": "gitTreebuilderRemove", + "cppFunctionName": "GitTreebuilderRemove", + "return": { + "cType": "int", + "cppClassName": "Int32", + "isErrorCode": true, + "jsClassName": "Number" + }, + "description": "

Remove an entry from the builder by its filename

\n" + }, + { + "cFunctionName": "git_treebuilder_filter", + "args": [ + { + "name": "bld", + "cType": "git_treebuilder *", + "cppClassName": "GitTreeBuilder", + "jsClassName": "TreeBuilder", + "isSelf": true, + "comment": "Tree builder" + }, + { + "name": "filter", + "cType": "git_treebuilder_filter_cb", + "cppClassName": "TreebuilderFilterCb", + "jsClassName": "TreebuilderFilterCb", + "comment": "Callback to filter entries" + }, + { + "name": "payload", + "cType": "void *", + "cppClassName": "void", + "jsClassName": "void", + "comment": "Extra data to pass to filter" + } + ], + "ignore": true, + "isAsync": false, + "isConstructorMethod": false, + "isPrototypeMethod": false, + "jsFunctionName": "filter", + "cppFunctionName": "Filter", + "return": { + "cType": "void", + "cppClassName": "void", + "jsClassName": "void" + }, + "description": "

Filter the entries in the tree

\n" + }, + { + "cFunctionName": "git_treebuilder_write", + "args": [ + { + "name": "id", + "cType": "git_oid *", + "cppClassName": "GitOid", + "jsClassName": "Oid", + "shouldAlloc": true, + "isReturn": true, + "comment": "Pointer to store the OID of the newly written tree" + }, + { + "name": "repo", + "cType": "git_repository *", + "cppClassName": "GitRepo", + "jsClassName": "Repository", + "comment": "Repository in which to store the object" + }, + { + "name": "bld", + "cType": "git_treebuilder *", + "cppClassName": "GitTreeBuilder", + "jsClassName": "TreeBuilder", + "isSelf": true, + "comment": "Tree builder to write" + } + ], + "isAsync": true, + "isConstructorMethod": false, + "isPrototypeMethod": true, + "jsFunctionName": "write", + "cppFunctionName": "Write", + "return": { + "cType": "int", + "cppClassName": "Int32", + "isErrorCode": true, + "jsClassName": "Number", + "comment": "0 or an error code" + }, + "description": "

Write the contents of the tree builder as a tree object

\n" + } + ] + } +]