Skip to content

Commit

Permalink
Merge branch 'devel'
Browse files Browse the repository at this point in the history
  • Loading branch information
Sam committed Apr 3, 2011
2 parents 1dae618 + dfac89e commit 9d81b3f
Show file tree
Hide file tree
Showing 174 changed files with 4,201 additions and 2,737 deletions.
11 changes: 10 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,15 @@
## v0.1.0 - 03/04/11
* Heavy refactors to bring gitteh up to date with libgit2 0.11.0.
* Commits no longer have methods to retrieve tree/parents. Instead, they are just sha1 string properties on the object.
* Trees no longer have getEntry() method, all tree entries are added to an array in the tree.entries property.
* Tree writing is currently unsupported (as it's been broken in libgit2), next version will allow writing an index as a tree.
* Ref deletion is now supported.
* Ref packing is supported. This is a fairly advanced feature and required more work than it was worth. Any issues reported on this will be followed up ASAP.
* Full documentation written for the bindings. Huzzah.

## v0.0.4 - 29/03/11
* Added support for working with git indexes.
* Fixed issues that could cause asynchronous retrieval of objects to fail miserably.
* Fixed issues that could cause asynchronous retrieval of objects to fail miserably.

## v0.0.3 - 20/03/11
* Fixed up some pretty serious memory leaks stemming from how git_oid and git_signatures were being handled.
Expand Down
11 changes: 7 additions & 4 deletions TODO.md
Original file line number Diff line number Diff line change
@@ -1,11 +1,14 @@
# TODO

* Delete support.
* Integrity tests, make sure bindings don't choke or segfault on really bad data.
* Revisit index support, expand and add tests.
* Possibly implement custom backend support, allowing JS callbacks to provide a custom git backend.
* Check for memory leaks
* Support for ref deletion.
* Implement ref packing method call, without breaking shit.
* Cache raw objects properly, so two requests for the same oid don't result in different objects.
* Maybe add convenience methods to all existing wrapped objects to get the raw object equivalent of them.
* Error handling in the EIO initialization stuff for objects. Not sure if something can go wrong there, but better safe than sorry.
* Tests for initializing a new repository, bare or workingdir.
* Stress test suite.
* Perf tests.
* See if we can remove the lock on repository for some serious speed.
* Make sure all create/get stuff in repo is returning local copies of handles.
* Update Index to not use getters/setters for index modification. Instead, work with an array like tree entries.
63 changes: 0 additions & 63 deletions examples/create-commit.js

This file was deleted.

31 changes: 19 additions & 12 deletions examples/display-commit-tree.js
Original file line number Diff line number Diff line change
@@ -1,27 +1,34 @@
/**
* This example will load the Git repository for gitteh, and display the commit
* tree of the latest revision. You have to have cloned the gitteh Git repo for
* this to work, of course.
*/

var gitteh = require("gitteh"),
path = require("path"),
fs = require("fs");

var repository = new gitteh.Repository(path.join(__dirname, "..", ".git"));

var headCommit = fs.readFileSync(path.join(
__dirname, "..", ".git", "refs", "heads", "master"), "utf8");
var repository = gitteh.openRepository(path.join(__dirname, "..", ".git"));
var headRef = repository.getReference("HEAD");
headRef = headRef.resolve();

var commit = repository.getCommit(headCommit);
var commit = repository.getCommit(headRef.target);

var displayTreeContents = function(tree, tabs) {
var tabStr = ""; for(var i = 0; i < tabs; i++) tabStr += " ";
var displayTreeContents = function(treeId, tabs) {
var tree = repository.getTree(treeId);

for(var i = 0, len = tree.entryCount; i < len; i++) {
var entry = tree.getEntry(i);
var tabStr = ""; for(var i = 0; i < tabs; i++) tabStr += " ";

for(var i = 0, len = tree.entries.length; i < len; i++) {
var entry = tree.entries[i];
var line = tabStr ;
line += entry.filename;
line += entry.name;

// 16384 == 40000 in octal (which is directory attribute in Git).
if(entry.attributes == 16384) {
line += "/";
console.log(line);
displayTreeContents(repository.getTree(entry.id), tabs + 1);
displayTreeContents(entry.id, tabs + 1);
}
else {
//line += " - " + entry.id;
Expand All @@ -30,4 +37,4 @@ var displayTreeContents = function(tree, tabs) {
}
};

displayTreeContents(commit.getTree(), 1);
displayTreeContents(commit.tree, 1);
32 changes: 0 additions & 32 deletions examples/raw_obj.js

This file was deleted.

26 changes: 18 additions & 8 deletions examples/walk-revisions.js
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
/**
* This example will open the Gitteh Git repo and walk the entire revision
* history, displaying a screen output fairly similar to what you'd get when you
* run `git log`.
*/
var gitteh = require("gitteh"),
path = require("path"),
fs = require("fs");

// Note that we're manually grabbing the master ref from the repo. Gitteh will
// eventually feature a ref-management api.
var headCommit = fs.readFileSync(path.join(
__dirname, "..", ".git", "refs", "heads", "master"), "utf8");

var startTime = Date.now();

// Load up the node-gitteh repository. This will only work if you cloned the
Expand All @@ -15,7 +15,17 @@ var startTime = Date.now();
// You have to point it to the GIT directory though, so if you're working with
// a repo that has a working copy checked out, you need to point it to the .git
// folder.
var repository = new gitteh.Repository(path.join(__dirname, "..", ".git"));
var repository = gitteh.openRepository(path.join(__dirname, "..", ".git"));

// First step is to grab the HEAD commit. We use the ref management features of
// gitteh to achieve this.
var headRef = repository.getReference("HEAD");

// Just in case the reference is pointing to another reference (symbolic link),
// we "resolve" the reference to a direct reference (one that points to an OID).
// If the ref being pointed to by HEAD is already direct, then resolve does
// nothing but return the same reference.
headRef = headRef.resolve();

// Let's create a revision walker and traverse the entire commit history.
var walker = repository.createWalker();
Expand All @@ -28,8 +38,8 @@ var walker = repository.createWalker();

// This will start from the most recent commit, and go back in time.
// Note that you have to set sorting BEFORE you push a commit to traverse from.
walker.sort(gitteh.SORT_TIME);
walker.push(repository.getCommit(headCommit));
walker.sort(gitteh.GIT_SORT_TIME);
walker.push(headRef.target);

// This output basically mimicks a basic `git log` command.
var commit;
Expand Down
Loading

0 comments on commit 9d81b3f

Please sign in to comment.