Permalink
Browse files

Merge branch 'devel'

  • Loading branch information...
2 parents 1dae618 + dfac89e commit 9d81b3f13cff55961cfa021096abd41056be018b @samcday samcday committed Apr 3, 2011
Showing with 4,201 additions and 2,737 deletions.
  1. +10 −1 CHANGELOG.md
  2. +7 −4 TODO.md
  3. +0 −63 examples/create-commit.js
  4. +19 −12 examples/display-commit-tree.js
  5. +0 −32 examples/raw_obj.js
  6. +18 −8 examples/walk-revisions.js
  7. +674 −0 lib/bindings/bindings.js
  8. +1 −0 lib/gitteh.js
  9. +7 −5 package.json
  10. +253 −0 src/blob.cc
  11. +43 −0 src/blob.h
  12. +232 −417 src/commit.cc
  13. +11 −18 src/commit.h
  14. +24 −19 src/error.h
  15. +2 −2 src/{ts_objectwrap.h → gitobjectwrap.h}
  16. +129 −0 src/gitobjectwrap_new.h
  17. +4 −12 src/gitteh.cc
  18. +10 −2 src/gitteh.h
  19. +15 −9 src/index.cc
  20. +2 −2 src/index.h
  21. +8 −2 src/index_entry.cc
  22. +2 −2 src/index_entry.h
  23. +220 −0 src/object_cache.h
  24. +5 −1 src/object_factory.h
  25. +20 −0 src/object_store.h
  26. +0 −173 src/rawobj.cc
  27. +0 −37 src/rawobj.h
  28. +216 −82 src/ref.cc
  29. +15 −24 src/ref.h
  30. +674 −278 src/repository.cc
  31. +29 −15 src/repository.h
  32. +37 −20 src/rev_walker.cc
  33. +7 −2 src/signature.h
  34. +182 −125 src/tag.cc
  35. +11 −4 src/tag.h
  36. +65 −492 src/tree.cc
  37. +8 −31 src/tree.h
  38. +0 −136 src/tree_entry.cc
  39. +0 −35 src/tree_entry.h
  40. +141 −0 test/blob.test.js
  41. +52 −207 test/commit.test.js
  42. BIN test/fixtures/gitrepo/objects/04/43b5568baa18a00d636db219785f584d8fd28b
  43. BIN test/fixtures/gitrepo/objects/0a/5117ad03e5e1c5555be75ac56d487c83af3f64
  44. +0 −3 test/fixtures/gitrepo/objects/19/d361418f74421ab4b2baddb9619ea0449a8bdb
  45. BIN test/fixtures/gitrepo/objects/38/042ca303189a2e6955b92d53aab7d642cc82c2
  46. +0 −2 test/fixtures/gitrepo/objects/46/d47fb28223a7f29df5d2072eb05e380985a477
  47. BIN test/fixtures/gitrepo/objects/62/abb59382c54e3b5629c8d0e1b0b27ccb127f50
  48. BIN test/fixtures/gitrepo/objects/65/719ec56f58578c87eb842e945aacb6f9e97986
  49. BIN test/fixtures/gitrepo/objects/67/69dd60bdf536a83c9353272157893043e9f7d0
  50. BIN test/fixtures/gitrepo/objects/6a/670a961ede0d6965e5326797e074d26ecee235
  51. BIN test/fixtures/gitrepo/objects/6c/d2ee6530e7f104040569bd7bf516f90e86e747
  52. BIN test/fixtures/gitrepo/objects/78/e15d85683e4342009ffaec14e619ebf482e440
  53. BIN test/fixtures/gitrepo/objects/91/ef0fd7ea773461d4d57dc1e5675a9bc83d6081
  54. BIN test/fixtures/gitrepo/objects/98/695ebf529d456e0e2cbf16ff6e06b0bfe3e843
  55. +0 −3 test/fixtures/gitrepo/objects/a9/12c342ece537e69f60352eae2f717a7f72ab2d
  56. +0 −1 test/fixtures/gitrepo/objects/b0/72908b7dbf6bebf2a1ee825264fd25b1b8de0c
  57. BIN test/fixtures/gitrepo/objects/b3/184a04cf754d1934e974b9603b05687ee86b09
  58. BIN test/fixtures/gitrepo/objects/b3/d3b5f6620d05b24521ae8eeccbbaf478abca8b
  59. BIN test/fixtures/gitrepo/objects/b7/6986bf57110b466b2f77ef662ea37f9d5eab80
  60. BIN test/fixtures/gitrepo/objects/ba/e21d9853dc927b3784420144afd9082d768024
  61. +0 −2 test/fixtures/gitrepo/objects/ca/1f3314acd24c4551da8c26adaf562272db1d19
  62. BIN test/fixtures/gitrepo/objects/df/a48f906451815913215afb4ef58321c33824e7
  63. BIN test/fixtures/gitrepo/objects/df/ad82c5d5f5d4f589f449df594ad4321d8d8468
  64. BIN test/fixtures/gitrepo/objects/e5/1d4f52d0b38a9052c6cebaa1b49a0b75e8d82e
  65. BIN test/fixtures/gitrepo/objects/e6/9de29bb2d1d6434b8b29ae775ad8c2e48c5391
  66. BIN test/fixtures/gitrepo/objects/f0/5af273ba36fe5176e5eaab349661a56b3d27a0
  67. +0 −1 test/fixtures/gitrepo/refs/heads/asyncoidtest
  68. +0 −1 test/fixtures/gitrepo/refs/heads/asyncrenametest_renameme
  69. +0 −1 test/fixtures/gitrepo/refs/heads/asyncsymtest
  70. +0 −1 test/fixtures/gitrepo/refs/heads/master
  71. +0 −1 test/fixtures/gitrepo/refs/heads/new
  72. +0 −1 test/fixtures/gitrepo/refs/heads/oidchangetargettest
  73. +0 −1 test/fixtures/gitrepo/refs/heads/old
  74. +0 −1 test/fixtures/gitrepo/refs/heads/setoidasync
  75. +0 −1 test/fixtures/gitrepo/refs/heads/setoidsync
  76. +0 −1 test/fixtures/gitrepo/refs/heads/settargetasync
  77. +0 −1 test/fixtures/gitrepo/refs/heads/symtest
  78. +0 −1 test/fixtures/gitrepo/refs/heads/syncoidtest
  79. +0 −1 test/fixtures/gitrepo/refs/heads/syncsymtest
  80. +0 −1 test/fixtures/gitrepo/refs/heads/testbranch
  81. +0 −1 test/fixtures/gitrepo/refs/tags/test_tag
  82. +36 −2 test/fixtures/helpers.js
  83. 0 test/fixtures/{gitrepo → reference_bare_repo}/HEAD
  84. 0 test/fixtures/{gitrepo → reference_bare_repo}/config
  85. 0 test/fixtures/{gitrepo → reference_bare_repo}/description
  86. 0 test/fixtures/{gitrepo → reference_bare_repo}/hooks/applypatch-msg.sample
  87. 0 test/fixtures/{gitrepo → reference_bare_repo}/hooks/commit-msg.sample
  88. 0 test/fixtures/{gitrepo → reference_bare_repo}/hooks/post-commit.sample
  89. 0 test/fixtures/{gitrepo → reference_bare_repo}/hooks/post-receive.sample
  90. 0 test/fixtures/{gitrepo → reference_bare_repo}/hooks/post-update.sample
  91. 0 test/fixtures/{gitrepo → reference_bare_repo}/hooks/pre-applypatch.sample
  92. 0 test/fixtures/{gitrepo → reference_bare_repo}/hooks/pre-commit.sample
  93. 0 test/fixtures/{gitrepo → reference_bare_repo}/hooks/pre-rebase.sample
  94. 0 test/fixtures/{gitrepo → reference_bare_repo}/hooks/prepare-commit-msg.sample
  95. 0 test/fixtures/{gitrepo → reference_bare_repo}/hooks/update.sample
  96. 0 test/fixtures/{gitrepo → reference_bare_repo}/info/exclude
  97. +18 −0 test/fixtures/reference_bare_repo/info/refs
  98. +2 −0 test/fixtures/reference_bare_repo/objects/info/packs
  99. BIN test/fixtures/reference_bare_repo/objects/pack/pack-e2bdbf5cd059d7ea0a40412b927aed93e9095718.idx
  100. BIN test/fixtures/reference_bare_repo/objects/pack/pack-e2bdbf5cd059d7ea0a40412b927aed93e9095718.pack
  101. +2 −0 test/fixtures/reference_bare_repo/packed-refs
  102. 0 test/fixtures/{gitrepo → reference_bare_repo}/refs/heads/test
  103. 0 test/fixtures/{workingdir → reference_working_repo}/dotgit/COMMIT_EDITMSG
  104. 0 test/fixtures/{workingdir → reference_working_repo}/dotgit/HEAD
  105. 0 test/fixtures/{workingdir → reference_working_repo}/dotgit/config
  106. 0 test/fixtures/{workingdir → reference_working_repo}/dotgit/description
  107. 0 test/fixtures/{workingdir → reference_working_repo}/dotgit/hooks/applypatch-msg.sample
  108. 0 test/fixtures/{workingdir → reference_working_repo}/dotgit/hooks/commit-msg.sample
  109. 0 test/fixtures/{workingdir → reference_working_repo}/dotgit/hooks/post-commit.sample
  110. 0 test/fixtures/{workingdir → reference_working_repo}/dotgit/hooks/post-receive.sample
  111. 0 test/fixtures/{workingdir → reference_working_repo}/dotgit/hooks/post-update.sample
  112. 0 test/fixtures/{workingdir → reference_working_repo}/dotgit/hooks/pre-applypatch.sample
  113. 0 test/fixtures/{workingdir → reference_working_repo}/dotgit/hooks/pre-commit.sample
  114. 0 test/fixtures/{workingdir → reference_working_repo}/dotgit/hooks/pre-rebase.sample
  115. 0 test/fixtures/{workingdir → reference_working_repo}/dotgit/hooks/prepare-commit-msg.sample
  116. 0 test/fixtures/{workingdir → reference_working_repo}/dotgit/hooks/update.sample
  117. BIN test/fixtures/{workingdir → reference_working_repo}/dotgit/index
  118. 0 test/fixtures/{workingdir → reference_working_repo}/dotgit/info/exclude
  119. 0 test/fixtures/{workingdir → reference_working_repo}/dotgit/logs/HEAD
  120. 0 test/fixtures/{workingdir → reference_working_repo}/dotgit/logs/refs/heads/master
  121. BIN ...es/{workingdir → reference_working_repo}/dotgit/objects/29/8f1e4adbcb2616d6203eb1ace240452441059a
  122. BIN ...tures/{gitrepo → reference_working_repo/dotgit}/objects/30/20f22e8b22650f524523710f3c211f214f8e75
  123. BIN ...tures/{gitrepo → reference_working_repo/dotgit}/objects/47/ee7698c336ba5b163c193ae6309f0a7d7e9662
  124. 0 ...es/{workingdir → reference_working_repo}/dotgit/objects/ed/fbbcb6e98f0b80c710f68fbd603624756c174b
  125. 0 test/fixtures/{workingdir → reference_working_repo}/dotgit/refs/heads/master
  126. 0 test/fixtures/{workingdir → reference_working_repo}/file.txt
  127. 0 test/fixtures/{workingdir → reference_working_repo}/unstaged.txt
  128. +8 −0 test/fixtures/temp_repo_template/committed.txt
  129. +1 −0 test/fixtures/temp_repo_template/dotgit/COMMIT_EDITMSG
  130. 0 test/fixtures/{gitrepo/refs/heads/asyncrenametest → temp_repo_template/dotgit/HEAD}
  131. +5 −0 test/fixtures/temp_repo_template/dotgit/config
  132. +1 −0 test/fixtures/temp_repo_template/dotgit/description
  133. +15 −0 test/fixtures/temp_repo_template/dotgit/hooks/applypatch-msg.sample
  134. +24 −0 test/fixtures/temp_repo_template/dotgit/hooks/commit-msg.sample
  135. +8 −0 test/fixtures/temp_repo_template/dotgit/hooks/post-commit.sample
  136. +15 −0 test/fixtures/temp_repo_template/dotgit/hooks/post-receive.sample
  137. +8 −0 test/fixtures/temp_repo_template/dotgit/hooks/post-update.sample
  138. +14 −0 test/fixtures/temp_repo_template/dotgit/hooks/pre-applypatch.sample
  139. +46 −0 test/fixtures/temp_repo_template/dotgit/hooks/pre-commit.sample
  140. +169 −0 test/fixtures/temp_repo_template/dotgit/hooks/pre-rebase.sample
  141. +36 −0 test/fixtures/temp_repo_template/dotgit/hooks/prepare-commit-msg.sample
  142. +128 −0 test/fixtures/temp_repo_template/dotgit/hooks/update.sample
  143. BIN test/fixtures/temp_repo_template/dotgit/index
  144. +6 −0 test/fixtures/temp_repo_template/dotgit/info/exclude
  145. +2 −0 test/fixtures/temp_repo_template/dotgit/logs/HEAD
  146. +2 −0 test/fixtures/temp_repo_template/dotgit/logs/refs/heads/master
  147. +1 −0 test/fixtures/temp_repo_template/dotgit/logs/refs/heads/test
  148. +1 −0 test/fixtures/temp_repo_template/dotgit/objects/05/d2c9c26d23c6ad9f8dde127e2cab9256be6ab2
  149. BIN test/fixtures/temp_repo_template/dotgit/objects/16/c07c728e090cd7656e8058f2f1d4a4be85f62a
  150. BIN test/fixtures/temp_repo_template/dotgit/objects/39/da184ab61a20c80d1cafecd7d05352614cb837
  151. BIN test/fixtures/temp_repo_template/dotgit/objects/47/a2e1960c861b38e13124401d94c7a993ab51e2
  152. BIN test/fixtures/temp_repo_template/dotgit/objects/4a/1e4c8d3e2a8ea94a049768a8b558f247b5f105
  153. BIN test/fixtures/temp_repo_template/dotgit/objects/53/02e718dddce0c57533e4a2d6cce175aa37653c
  154. +3 −0 test/fixtures/temp_repo_template/dotgit/objects/6c/1321e4bf4371fced27f7172778d61e7a40d2bd
  155. BIN test/fixtures/temp_repo_template/dotgit/objects/85/b851a1a139400ecfe56cb3b656938d0eaff519
  156. +1 −0 test/fixtures/temp_repo_template/dotgit/refs/heads/master
  157. +1 −0 test/fixtures/temp_repo_template/dotgit/refs/heads/test
  158. +1 −0 test/fixtures/temp_repo_template/dotgit/refs/tags/test_tag
  159. +3 −0 test/fixtures/temp_repo_template/staged.txt
  160. +3 −0 test/fixtures/temp_repo_template/unstaged.txt
  161. +4 −3 test/fixtures/values.js
  162. BIN test/fixtures/workingdir/dotgit/objects/30/20f22e8b22650f524523710f3c211f214f8e75
  163. BIN test/fixtures/workingdir/dotgit/objects/47/ee7698c336ba5b163c193ae6309f0a7d7e9662
  164. +115 −0 test/fixtures/wrench.js
  165. +9 −8 test/index.test.js
  166. +0 −143 test/rawobj.test.js
  167. +212 −167 test/ref.test.js
  168. +2 −2 test/repository.test.js
  169. +7 −7 test/revwalker.test.js
  170. +80 −0 test/stability/ref_pack.js
  171. +47 −94 test/tag.test.js
  172. +5 −10 test/tree.test.js
  173. +0 −1 vendor/libgit2
  174. +7 −2 wscript
View
@@ -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.
View
11 TODO.md
@@ -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.
View
@@ -1,63 +0,0 @@
-var gitteh = require("gitteh"),
- path = require("path"),
- fs = require("fs");
-
-var repository = gitteh.openRepository(path.join(__dirname, "..", ".git"));
-
-var newCommit = repository.createCommit();
-
-// A commit starts off in something of in an "identity" state. Pretty much
-// everything is null. We have to populate the data before a save can happen.
-
-newCommit.author = newCommit.committer = {
- name: "Sam Day",
- email: "sam.c.day@gmail.com",
- time: new Date()
-};
-
-newCommit.message = "A demo commit.";
-
-// A commit needs to have a Tree associated with it. This contains the actual
-// files that make up the commit.
-var myTree = repository.createTree();
-
-// Each tree entry references another git object. Generally a tree entry will
-// either reference a "blob", which is an actual file, or it will reference
-// another tree, which is a subdirectory.
-
-// In this case, we'll just add a single blob to the tree.
-var myBlob = repository.createRawObject();
-myBlob.data = new Buffer("Hello world!");
-myBlob.type = "blob";
-myBlob.save();
-console.log("Created a test BLOB. ID = " + myBlob.id);
-
-// At this point, our blob now has an identity, we can add it to the tree now.
-// 33188 is the file attributes. It's the decimal equiv of 100644 in octal.
-myTree.addEntry(myBlob.id, "test", 33188);
-
-// We can now save the tree.
-myTree.save();
-
-console.log("Created a test TREE. ID = " + myTree.id);
-
-// At this point, our tree now exists in the Git object database, and it has
-// an identity. We can add it to the commit now.
-
-// You can set the tree of a commit either with a Tree object, or with a string
-// id of a pre-existing tree.
-newCommit.setTree(myTree);
-
-// We're ready to finally create our commit now. How exciting!
-newCommit.save();
-
-console.log("Created a test COMMIT. ID = " + newCommit.id);
-
-// Note that you won't see this commit in a git log. This is because it's not
-// part of the Directed Acyclic Graph (DAG). That is to say, there's no way to
-// follow references to this commit via any of the refs (HEAD/refs/heads/master,
-// etc).
-
-// You can view the commit directly using git by executing a command like this:
-// git log <commit id>
-// Ex: git log ed7c24a4f6909465eb478e9a969c4d65fc0afcd7
@@ -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;
@@ -30,4 +37,4 @@ var displayTreeContents = function(tree, tabs) {
}
};
-displayTreeContents(commit.getTree(), 1);
+displayTreeContents(commit.tree, 1);
View
@@ -1,32 +0,0 @@
-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 commit = repository.getCommit(headCommit);
-
-// We can open any object in Git in raw mode, which will give us access to the
-// entirety of an entity stored in Git.
-var tree = commit.getTree();
-
-var rawObj = repository.getRawObject(commit.id);
-console.log("COMMIT RAW DATA");
-console.log("===============");
-console.log(rawObj.data.toString());
-
-console.log("\n\n\nTREE RAW DATA");
-console.log("=============");
-rawObj = repository.getRawObject(tree.id);
-console.log(rawObj.data.toString());
-
-rawObj = repository.getRawObject(tree.getEntry(0).id);
-console.log("\n\n\nBLOB RAW DATA");
-console.log("=============");
-console.log(rawObj.data.toString());
-
-//You can write data in raw mode if you want (read: if you're a masochist).
-//But neither Gitteh nor libgit2 will hold your hand if you fuck something up.
View
@@ -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
@@ -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();
@@ -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;
Oops, something went wrong.

0 comments on commit 9d81b3f

Please sign in to comment.