You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I'm trying to use nodegit to build a virtual fs module that fetches its data from a commit in a git repository: https://github.com/papandreou/node-gitfakefs -- it's going fine so far, I've implemented readFile, readdir, and stat.
Next up is adding support for the index. I found repo.openIndex and can get the entries out of it, but from the docs I can't find a way to get the contents of an index entry -- the actual staged contents. Is there a way to accomplish that? Otherwise consider this a feature request :)
Can you research the libgit2 functions which would provide this functionality, then find them in the v0.18.json file and copy/paste those entries here?
git_index_time ctime
git_index_time mtime
unsigned int dev
unsigned int ino
unsigned int mode
unsigned int uid
unsigned int gid
git_off_t file_size
git_oid oid
unsigned short flags
unsigned short flags_extended
char *path
whereas nodegit's equivalent has much fewer:
require('nodegit').Repo.open('test/testrepo.git',function(err,repo){repo.openIndex(function(err,index){vare=index.entry(0);for(varpine){console.warn(p,e[p]);}})});// ctime function ctime() { [native code] }// mtime function mtime() { [native code] }// path function path() { [native code] }
If the index entry object had the oid method, I believe I could use repo.getBlob to get the staged contents. Unfortunately that is missing from v0.18.0.json, which only has:
Thanks for the info! Here is a request. Since I'd like to encourage more people to make contributions to nodegit (so the code never rots), I'd like to walk you through how to make this change yourself. In theory it's fairly easy.
Take all the fields that are missing (i.e., everything minus ctime, mtime, and path) and add them to the fields section you pasted above. For each field, you'll need to populate the appropriate attributes. For example, for the field unsigned int dev, you would add
The trickiest bit is knowing the cppClassName given a cType. If you search around in the v0.18 json file, you should see things you can copy by analogy -- remember to check parameters and return types for functions as well as other fields. The jsFunctionName is the name it will be exposed as in javascript; by convention the cppFunctionName is just the titlecased version of that. You might, in the example above, want to call dev something more descriptive.
Once you've done that for everything, you should be able to build the project using
npm run-script gen && npm install && npm test
Double check that it works in your project (perhaps using the npm link command), and if everything goes smoothly, submit a pull request.
What an exemplary way to handle a request like this -- thanks a lot for walking me through the process. I got it working and added a pull request here: #95
Activity
nkallen commentedon Sep 23, 2013
Can you research the libgit2 functions which would provide this functionality, then find them in the v0.18.json file and copy/paste those entries here?
papandreou commentedon Sep 23, 2013
Thanks for your reply.
The libgit2 docs (http://libgit2.github.com/libgit2/#HEAD/type/git_index_entry) list a bunch of properties for the
git_index_entrytype:whereas nodegit's equivalent has much fewer:
If the index entry object had the
oidmethod, I believe I could userepo.getBlobto get the staged contents. Unfortunately that is missing fromv0.18.0.json, which only has:nkallen commentedon Sep 23, 2013
Thanks for the info! Here is a request. Since I'd like to encourage more people to make contributions to nodegit (so the code never rots), I'd like to walk you through how to make this change yourself. In theory it's fairly easy.
Take all the fields that are missing (i.e., everything minus
ctime,mtime, andpath) and add them to thefieldssection you pasted above. For each field, you'll need to populate the appropriate attributes. For example, for the fieldunsigned int dev, you would addThe trickiest bit is knowing the
cppClassNamegiven acType. If you search around in the v0.18 json file, you should see things you can copy by analogy -- remember to check parameters and return types forfunctionsas well as otherfields. ThejsFunctionNameis the name it will be exposed as in javascript; by convention thecppFunctionNameis just the titlecased version of that. You might, in the example above, want to calldevsomething more descriptive.Once you've done that for everything, you should be able to build the project using
npm run-script gen && npm install && npm test
Double check that it works in your project (perhaps using the
npm linkcommand), and if everything goes smoothly, submit a pull request.Thanks for your help!
index_entry: Added missing fields.
papandreou commentedon Sep 26, 2013
What an exemplary way to handle a request like this -- thanks a lot for walking me through the process. I got it working and added a pull request here: #95
nkallen commentedon Sep 26, 2013
Awesome! Thanks!